Javelin COM port parameters
WaldoDTD
Posts: 142
Hey,
Anybody know the protocol to communicate with the Javelin Stamp through a COM port? I saw in the manual the baud is 9600, there is no parity, and stop bits is set to 1, but what about Flow Control I/O and databits? The manual only says to set it to hardware with the hyperterminal thing so I am guessing that the hardware selection covers these three parameters. Thanks!-Hacker
Post Edited (Hacker) : 10/25/2005 3:05:38 AM GMT
Anybody know the protocol to communicate with the Javelin Stamp through a COM port? I saw in the manual the baud is 9600, there is no parity, and stop bits is set to 1, but what about Flow Control I/O and databits? The manual only says to set it to hardware with the hyperterminal thing so I am guessing that the hardware selection covers these three parameters. Thanks!-Hacker
Post Edited (Hacker) : 10/25/2005 3:05:38 AM GMT
Comments
http://groups.yahoo.com/group/JavelinCode/files/documents/
For communication with other devices I recommend the use of Uart VP's.
A great number of (standard) baudrates from 600 to 57600 are available.
Hardware handshake (RTS/CTS) is an option with the Uart VP.
Parity is available when you use my adapted Uart class.
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/core/
The Jide port uses no handshake, but DTR is used to reset the javelin.
regards peter
They are for pc java programs.
If you write a java program for the javelin you can use
import stamp.core.*;
public class uartTest {
static final int txPin = CPU.pin0; //transmit pin
static final int rxPin = CPU.pin1; //receive pin
static final int rtsPin = CPU.pin2; //rts pin (optional)
static final int ctsPin = CPU.pin3; //cts pin (optional)
//tx and rx uart without handshake, 9600 baud, no parity, 1 stopbit
static Uart txUart = new Uart(Uart.dirTransmit,txPin,Uart.dontInvert,Uart.speed9600,Uart.stop1);
static Uart rxUart = new Uart(Uart.dirReceive,rxPin,Uart.dontInvert,Uart.speed9600,Uart.stop1);
//tx and rx uart with handshake, 9600 baud, no parity, 1 stopbit
static Uart txhsUart = new Uart(Uart.dirTransmit,txPin,Uart.dontInvert,ctsPin,Uart.dontInvert,Uart.speed9600,Uart.stop1);
static Uart rxhsUart = new Uart(Uart.dirReceive,rxPin,Uart.dontInvert,rtsPin,Uart.dontInvert,Uart.speed9600,Uart.stop1);
· static void main() {
··· while (true) {
····· txUart.sendByte('A');
····· //wait for reply
···· ·while (!rxUart.byteAvailable()) ;
····· char c = (char)rxUart.receiveByte();
····· //echo received byte
····· txUart.sendByte(c);
··· }
· }
}
You need a rs232 level shifter like max232 to connect the pins 0 to 3 to the pc com port.
The javelin sends out an 'A', your pc program must reply with a character that is echoed
back to the pc.
Baudrates available are 600,1200,2400,4800,7200,9600,14400,19200,28800,38400,57600.
For receive 38400 and 57600 are not reliable.
regards peter
Post Edited (Peter Verkaik) : 10/26/2005 4:34:06 PM GMT
DTR is used to reset the javelin. For normal operation turn DTR off or
disconnect DTR.
regards peter
Post Edited (Hacker) : 10/28/2005 2:39:17 AM GMT
which goes to the ATN pin (pin 3) of the stamp. That is the only way
to reset the stamp from the pc. It is required for downloading programs
to the stamp, but not for runtime communication.
The baudrate for the javelin program port is fixed to 28800 baud, 8 databits, 1 stopbit.
regards peter
that you can create on I/O pins using Uart objects. That is not the
javelin program port, and therefore there·are no echoes and there
is no fixed protocol or baudrate.
regards peter
Post Edited (Hacker) : 11/4/2005 3:24:51 AM GMT
http://www.parallax.com/javelin/downloads.asp
That shows on page 85 how to wire the COM port connector to Javelin I/O pins.
The BOE-bot rev.C probably only has one·DB9 connector (the program port)
which is fine to use for basic stamps. The baudrate for basic stamps is indeed 9600
baud for the program port. However if you put in a javelin, the baudrate is
28800 baud.
Please specify (by url)·what example program you refer to.
You can connect a MAX232 level shifter to javelin I/O pins to
achieve a serial pc connection. Unfortunately the Javelin Demo Board
is not seperate obtainable, only as part of the javelin starterkit.
regards peter
·
Post Edited (Hacker) : 11/4/2005 5:04:30 AM GMT
http://www.electronelec.co.uk/max232cpe.htm
I/O pins are 0 to 5V. The chip converts that to -10/+10V that is
required for the pc com port. The chip SP237 on the javelin·demo board does
the same as the max232.
regards peter
pc does not have to wait for the javelin to request data. Your
pc may transmit·data when it has some available. The javelin Uart
is capable of receiving data in the background ·while doing some
other task.
regards peter
They do offer this
http://www.parallax.com/detail.asp?product_id=29120
If your board has an appmod header, you can connect it directly
to your board, offering the same functionality as the SP237
on the javelin board.
These may even be stacked to offer more serial ports.
regards peter
http://groups.yahoo.com/group/JavelinCode/files/JavelinDirect/
allows you to create a .jem file that holds the binary bytecodes
that are to be downloaded into the javelin.
The zipfile has an executable in it.
regards peter
is this all in one string or is it all in bytes and would I have to write a Uart.sendByte() command for each component of the command? Thanks!-Adam
You would write
tx.sendByte('!');
tx.sendByte('S');
tx.sendByte('C');
etc.
Or you could define or assemble a char array
and then loop the array (null terminated)
int index=0;
while (buf[noparse][[/noparse]index]!=0) tx.sendByte(buf[noparse][[/noparse]index++]);
where buf holds the '!', 'S', 'C' and following chars.
regards peter
static void bufferMessage(){
int cmd = 0;
c = 0xff;
while (c != '\r'){
if(rxUart.byteAvailable()){
c = (char)rxUart.receiveByte();
buffer[noparse][[/noparse]cmd] = c;
cmd++;
}
}
}// end bufferMessage
public static void main(){
int index = 0;
while (forever = true){
bufferMessage();
if (buffer[noparse][[/noparse]0] != 0){
while (buffer[noparse][[/noparse]index] != 0){
mrUart.sendByte(buffer[noparse][[/noparse]index++]);
buffer = null;
}//end while loop
}//end if statement
}//end forever loop
}//end main()
}//end Wintermute_Mrk_III
Post Edited (Hacker) : 11/5/2005 2:17:09 AM GMT
static void bufferMessage(){
· int index = 0;
· char c = (char)0xff;
· while (c != '\r'){
··· if (rxUart.byteAvailable()) {
····· c = (char)rxUart.receiveByte();
····· buffer[noparse][[/noparse]index++] = c;
·· }
· }
· buffer[noparse][[/noparse]index]=0; //make asciiz string, assuming no binary 0 is ever received
}// end bufferMessage
public static void main(){
· int index;
· while (true) { //you don't need variable forever
··· bufferMessage();
····index = 0;
··· while (buffer[noparse][[/noparse]index] != 0)·mrUart.sendByte(buffer[noparse][[/noparse]index++]);
· }//end forever loop
}//end main()
}//end Wintermute_Mrk_III<!-- Edit -->
Note·that the received '\r' is also sent.
If you don't want that, or you want to change the '\r' into
either '\n' (newline) or a '\r' followed by a '\n' (CR,LF) you need
to adapt bufferMessage().
regards peter
Post Edited (Peter Verkaik) : 11/5/2005 3:43:04 AM GMT
and not unicode characters which are 16bits.
But you must limit the inputlength in your pc program, and buffer in the javelin
must have size inputlength + 1 (for the closing 0). Otherwise you may
receive too many chars on the javelin, resulting in an outOfBound error
while filling buffer.
regards peter
·
setup a char array with
'!','S','C',(char)(60290&0xFF),(char)(2304>>>8)
To get the lowbyte of an int use
value&0xFF
To get the highbyte of an int use
value>>>8
regards peter
·