Shop OBEX P1 Docs P2 Docs Learn Events
Javelin COM port parameters — Parallax Forums

Javelin COM port parameters

WaldoDTDWaldoDTD Posts: 142
edited 2005-11-05 21:55 in General Discussion
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

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-25 17:54
    The baudrate for the Jide port (eg. programming port) is fixed to 28800. There is also a defined protocol.

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-10-26 14:12
    Umm... when i run this program (only the main programs are included not the actual bin files which I will when I get access to them), the thing returns that 28800 is undefined parameter for the comm port, however when I run it at 9600 it comes up with undefined symbols. I am not using the JIDE port but the only serial port on the BOE Rev. C. Also is there any way to set up this board so that I can supply power to 6 servos instead of the 4 allowed such as an appmod? Thanks!-Adam
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-26 16:31
    The programs you attached are NOT suitable for download to the javelin.

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-10-27 15:13
    This program I wrote to test out the connection to the stamp. I am still on the project to link the PC java program to the Javelin stamp program. The Java program works fine, I just need to know if I should put any flow control on the stamp. Thanks!-Hacker
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-27 16:41
    No flow control on the javelin IDE port. Just TX,·RX, GND and DTR.

    DTR is used to reset the javelin. For normal operation turn DTR off or

    disconnect DTR.

    regards peter
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-10-28 02:32
    DTR? The parameters that I am working with in the flow control is the Xon/Xoff and RTS/CTS. Also, I am assuming that the thing goes on 9600 baud for communication.

    Post Edited (Hacker) : 10/28/2005 2:39:17 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-28 05:11
    The javelin stamp (as basic stamps) uses the pc com port DTR signal

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-03 16:15
    in the hyperterminal port example the thing says to set the parameters in the computer to connect as 9600 Databits = 8 and no parity. I am using the BOE rev. C and a Javelin stamp not the Javelin Stamp development board. I think that you are assuming that I am trying to connect two Javelins together, I am trying to connect a javelin to a program on a computer. The program connects to the stamp and then sends chars (in byte form from the .getbytes() method in the JDK). Everything is Java and I have the protocol transfered over for transmission from C++ to Java. Also is there a way to use 6 servos on one BOE? Is there a possible appmod that I could use to accomplish this? Thanks!-Adam
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-03 17:15
    I think that Hyperterminal example uses a serial port on the Javelin

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-04 03:19
    So wait, to use the uart class, I would have to connect the pins to the COM port in some way much like in the example. However I see that the BOE Rev. C does not allow for this and doesn't have a spot for COM wire overrides, (figure 4.8 of the manual pg 85 in the pdf on your site). The code I have been using uses the Terminal.getbyteavailable() method to find the bytes. Should this work just as well? If not is it possible to obtain just a Javelin Demo board minus the actual stamp? Also is it possible to have a parallax servo controller work as a slave to the Javelin stamp to handle the extra servos? Thanks!-Adam

    Post Edited (Hacker) : 11/4/2005 3:24:51 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-04 04:25
    Do you mean the Javelin Users manual v1.0a on this page?
    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
    ·
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-04 04:41
    MAX232 Level Shifter? I am unfamiliar with this device could you explain more/where can I find it? Is this the serial to ethernet device?

    Post Edited (Hacker) : 11/4/2005 5:04:30 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-04 07:43
    It is a rs232 tranceiver chip.

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-04 16:12
    So in order for my project to work I have to wire in this chip as well and configure the uart vps correct?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-04 16:26
    Yes, then you can use 9600 baud, there are no echoes and your

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-04 16:38
    Sweet! Thanks, can i buy this chip through parallax?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-04 16:50
    I am not sure.

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-04 17:26
    yeah i have one I am going to order the stuff I need tonight. Thanks!-hacker
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-04 22:33
    Does the Javelin IDE support tokenizers?-Hacker
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-04 23:49
    My adapted version of JavelinDirect, version 1.2

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-05 01:09
    The way that the Javelin would communicate with a PSC, the syntax says "!SC" C R pw.LOWBYTE, pw.HIGHBYTE
    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
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-05 01:16
    These are bytes.

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-05 01:52
    So would this be an acceptible method to send a string recieved by a program? (Buffer is a char array and bufferMessage is the same method in the HyperterminalCOM example it is also setup in a forever loop with the boolean value forever set to true).

    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
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-05 03:36
    Almost. Few changes.

    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
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-05 03:47
    Would it make a difference if my program on the computer sent down a string converted into bytes through the getBytes() method or should i convert the strings to char arrays and send each character one by one? Thanks!-Hacker
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-05 04:26
    You can let your pc program send a string if the string is made up with ascii characters (8bit)

    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
    ·
  • WaldoDTDWaldoDTD Posts: 142
    edited 2005-11-05 21:40
    would this be an appropriate command string to send to the PSC? !SC60290.LOWBYTE2304.HIGHBYTE
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-05 21:55
    I do not know the PSC but I think you would need to

    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
    ·
Sign In or Register to comment.