Shop OBEX P1 Docs P2 Docs Learn Events
Baud rate 38k4?? — Parallax Forums

Baud rate 38k4??

AJIAJI Posts: 22
edited 2004-12-11 15:57 in Robotics
Ok just jot a psc for my robot and need help

when i chnge the baude rate to 38k4. What do i put in the serout for that baud rate????


Serout 15, ????, [noparse][[/noparse]coman dstring]

what does 38k4 mean??··· 3840???

And why do i have to make the baud rate befor any change

serout 15, 396+$8000,[noparse][[/noparse]comand string]

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2004-12-03 15:59
    I believe baud rate "38K4" is equivalent to 38,000 baud, or 3.8 times 10 to the 4.

    On the BS2, the equation is: INT(1,000,000 / baud rate) - 20

    So 1e6 / 38e3 == 26, -20 == 6.

    1e6 / 26 == 38,461 baud (exactly). So you can't get exactly 38,000. But 38,461 is only 1% off, so it should still work.

    Final answer:· "6 + $8000" is the number you would put in.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-03 16:21
    38K4 is a Euro-type abbreviation for 38,400; a "standard" baud rate.

    One of the things that makes my life easier is conditional compilataion -- especially for things like SERIN/SEROUT that have different parameters based on the module used.· In my standard template I have this section that handles serial parameters; I use it all the time and my serial life is a breeze.

    #SELECT $STAMP
      #CASE BS2, BS2E, BS2PE
        T1200       CON     813
        T2400       CON     396
        T4800       CON     188
        T9600       CON     84
        T19K2       CON     32
        TMidi       CON     12
        T38K4       CON     6
      #CASE BS2SX, BS2P
        T1200       CON     2063
        T2400       CON     1021
        T4800       CON     500
        T9600       CON     240
        T19K2       CON     110
        TMidi       CON     60
        T38K4       CON     45
    #ENDSELECT
     
    SevenBit        CON     $2000
    Inverted        CON     $4000
    Open            CON     $8000
     
    Baud            CON     T9600
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • AJIAJI Posts: 22
    edited 2004-12-03 21:33
    Thanks I will try that when I get home



    The help file for SEROUT does not show 38400 in the chart. That's why I could not figure that out. I did get it needed to be "6" but didnot realise i still needed the "$8000" with it.



    now I know what is is for too. hop.gif

    Maybe the PSC·documents could use more exaples or even that chart.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-06 00:34
    When one actually reads the help file, you will see that the BS2 family can easily handle 38.4 kBaud -- it's right at the top. The charts are a convenient set of values for "standard" baud rates, but are not by any means limits to what the BASIC Stamp can do. There is also detailed instructions -- in that file -- for calculating any baud rate and mode.

    Serial stuff can be tricky, but I assure you that the details are there.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • achilles03achilles03 Posts: 247
    edited 2004-12-10 20:44
    I thought the BS2 could start encountering trouble when you go up to 9600 or so? I remember reading that somewhere in the PBASIC manual... is that only for recieving or something?

    Dave
  • AJIAJI Posts: 22
    edited 2004-12-10 21:04
    well it is working and servos movment is much better and smoother

    much better than the default.

    The only thing I find is that if I turn off the power switch on the BOE I· have to push the rest button. For it to start working again

    This might be because I have the baud change statment before the Main loop.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-10 22:17
    The when using formatters with SERIN -- like DEC and HEX, etc. -- the baud rate is limited to 9600 baud because the BASIC Stamp has to work in between received bytes. When doing straight (no formatting or flow control) SERIN or SEROUT you can get up to about 50 kBaud.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • achilles03achilles03 Posts: 247
    edited 2004-12-11 15:52
    So could the following command could be transmitted/recieved reliably at 36.4 kbps with the BS2?

    SERIN DATAPIN,N36400,[noparse][[/noparse]WAIT("@"),SKIP 3, STR GPSD\4, SKIP 5, STR GPSA\4]

    Thanks for the info,
    Dave
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-11 15:57
    No. WAIT, SKIP, STR -- all those take work in between received bytes, and as I pointed out above there is just no time for the BASIC Stamp to do this work at rates above 9600.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.