Javelin RS232 simple example
I have a Basic stamp activity board, a Bs2p40 demo board, and the DCE 232 app mod.· I have searched and tried to make existing code work for some rs232 operations.· I want to go back and just try something simple.
I just want to send something to from the stamp to a pc, and from a pc back to the stamp.
Advice, sample code etc....· need help
I just want to send something to from the stamp to a pc, and from a pc back to the stamp.
Advice, sample code etc....· need help
Comments
regards peter
I am using a usb converter from parallax, and it works fine.· However i have another one for the App mod.· (this did not work to well with the ide port though).· Nothing is happening.· The code is executing and breaks into both while loops however I get no display of any kind to let me know that it has tx and rx'd?
and what you typed is echoed back. You should try this with hyperterminal.
Setup hyperterminal for direct connection to a com port. Settings 9600 baud, 8 databits, no parity,
1 stopbit. Select no handshake. Local echo off.
If all is well, any character you type in hyperterminal gets displayed in hyperterminal, proceeded
by the 'A' character. So if you type PQRST you would see APAQARASAT
Use a straight 9pin DB9male-DB9female cable to connect the DCE appmod connector with the PC.
If you only have one comport, program the javelin, then close the JIDE program, then disconnect
the javelin program cable from both board and pc, then connect the DCE appmod connector to your
pc com port (you can use the program cable as this is a straight 9pin male-female cable).·Then
start hyperterminal.
regards peter
Post Edited (Peter Verkaik) : 11/18/2005 7:25:25 AM GMT
I also have seperate question on your window jide terminal etc. files. What exactly is that for?
This program sends out continuesly the last received character and it starts
with sending 'A' characters. So as long as you don't type anything, you should see
'A' characters in hyperterminal. If you don't see those, your hyperterminal setup is incorrect.
Could be the wrong comport or baudrate, parity, handshake settings.
The moment you get the 'A' characters in hyperterminal, then your hyperterminal setup
is correct. If you then type another key, say 'P', you will see all 'P' characters.
Try this and let me know.
regards peter
regards peter
What are your JIDE_TERMINAL files on the yahoo post? In searching for rs232 i kept reading about that?
it has a picture of the DCE appmod·printed circuit board.
You can send anything you want.·What do you want to send and how would you like
to see that in hyperterminal?
I will explain about JIDE terminal later.
regards peter
Thanks, I am actually using the DCE mod already. That is what is connecting to the HyperTerminal, I am actually using two usb to serial converters as well. New laptop does not have a serial port. Eventually I want to send stuff from the stamp to a VB.net program. I have been aquiring functions to do RS232 communication.
I want the stamp to read some sensors, when the stamp gets the signal, lets say a high(5) I want to send that sensor name in a (string or integer#) to the VB.net program and then do some User interface junk.
the sample VB program that comes with the APPmod does not work with VB.net cause they got rid of MScomm. I have found a rs232 class that someone wrote. I just have to figure out on how to use the methods. It works to check the com ports correctly, however I need to run it again and see if the 'A' will print to the text window now.
The easiest way is using the Format class.
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/util/text/
I have attached a test program that shows how you send text and values in
readable form (eg.·a binary number 12 is send as '1','2')
you need my adapted Uart class:
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/core/
First rename your current Uart.java to Uart.org, then copy my Uart.java to the javelin core folder
(default c:\program files\parallax inc\javelin stamp ide\lib\stamp\core)
regards peter
http://www.codeworks.it/net/VBNetRs232.htm
regards peter
The javelin program port operates at 28800 baud, 8 databits, no parity, 1 stopbit, no handshake.
To send data out of the javelin SOUT pin, you use System.out.print() or System.out.println(),
or you can use my Format class using Format.printf().
To receive data from the javelin SIN pin, you use Terminal.byteAvailable() and Terminal.getChar(),
my adapted Terminal class also has a method getString().
To use the program port to communicate with other devices, those other devices need to know
about and must implement the javelin protocol. Anything these devices send to the javelin SIN pin,
is automatically echoed back to those devices. That is how the port hardware works and this echo
cannot be turned of.
Data·messages sent from the Javelin conform to the following pattern:
(each message corresponds to a single CPU.message call)
0x05 0x03 <messagedata> 0x7E
<messagedata> is the sequence of bytes being sent by the CPU.message() native method. It is byte-stuffed. This means that if <messagedata> contains a byte <b> that has the value 0x7F or 0x7E then that byte is replaced with 0x7F <b>^0x20. i.e. 0x7F followed by the orginal byte xored with 0x20.
Terminal characters are sent to the Javelin using the following algorithm:
After the Javelin is reset it send 0x0F followed a pause followed by 0x50 (the version of the Javelin firmware).
Running the following simple program:
public class HelloWorld { public static void main() { System.out.println("Hello World"); } }
will generate the following on Sout:
0F 50 05 03 48 65 6C 6C 6F 20 57 6F 72 6C 64 7E 05 03 0D 0A 7E 05 05 7E
Note that the sequence 0x05 0x05 0x7E indicates that the Java program has ended.
For existing devices the program port is unusable because of the used protocol.
For the pc I have written several programs that allow you the catch the javelin output data
so you can view it and log it to a file. Also these programs allow you to send a file to the
javelin. Because of the javelin protocol, it is best suited to send text files only, but binary
files are possible.
Here are my Jide Terminal programs:
only·view and log output (command line version only)
http://groups.yahoo.com/group/JavelinCode/files/JideDebug/
view and log output and send lines and files (command line and windows version)
http://groups.yahoo.com/group/JavelinCode/files/JideTerm/
Regarding receiving data from the SIN pin:
Make sure you use Terminal.byteAvailable() to test for any data. Terminal.getChar() will wait
forever until data is received. To operate in slave mode (javelin responds to user input) use
static void main() {
· //place initialization code here
· while (true) { //mainloop
··· if (Terminal.byteAvailable()) {
····· c = Terminal.getChar();
····· //assemble received chars into an array
····· //or use·Terminal.getString() but this does not return until·CR,LF is received or a number of chars
··· }
··· //other mainloop code here
· }
}
The reason to use Terminal.byteAvailable() is that you can disconnect the cable from the
program port, but this is tricky. If the javelin appears to be stopped running after disconnecting the cable,
it probably is waiting·for a byte at Terminal.getChar(). ·Then reconnect the cable and send an empty
string (or a 'no data available' reply) from the terminal program, then disconnect again. The moment of disconnecting determines wether Terminal.byteAvailable() returns true or false. I have found that it
usually takes 3 or 4 attempts before success. But then the javelin runs with the cable disconnected.
To gain access to the javelin again, simply connect the cable and send a command (which of course
you need to program in your javelin code). If you use a Uart you don't have these little problems.
regards peter
Post Edited (Peter Verkaik) : 11/18/2005 12:37:46 PM GMT
I don't think that I need the Jide files, because I am using a seperate cable for my serial connection and not using the Jide port.
That is just if you only had the program port and wanted to capture and send data via that port correct??
Thanks..
Scott
for other purposes than programming.
In your opinion, as you have researched several rs232 packages, is the
vb.net package I mentioned a good one, or have you found a better one ?
regards peter
It is easy to use and works great going back and forth with Javelin stamp uarttest.java file you sent.· I have been modifying the uarttest file to see about sending other data type information, and have been reading your uart class to see about the parameters.·
I would definately recommend that VB.net program to anyone, it is easy to use and works great.·· Easy to incorporate into my VB.net project.
Thanks Again!
Scott
I attached the other VB.net Rs232 file.· Someone just needs to add it to thier project.· Then just declare a new rs232 object.· And use the methods desired.·
Thanks in advance.
the·exact source anymore for the binary that I released.
I attached the source as it is now. I am not sure
if this will run. I believe I added a 'LCD' text area
below the normal display window. The idea was
to easily test LCD output via the JIDE port.
The source is for visual c#.
Good luck.
regards peter