Shop OBEX P1 Docs P2 Docs Learn Events
PSC Question — Parallax Forums

PSC Question

Kevin HarrisKevin Harris Posts: 15
edited 2005-07-01 20:31 in BASIC Stamp
I have recently bought a serial PSC. I am need to change the baud rate from the defaul 2400 to 38k4. I can successfully do this using the included code in the documentation, but the documentation never says how to send commands to the PSC in 38k4 mode, it only shows how to do it in 2400 mode. For example, to send a message to move a servo you would send SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SC" etc..., (baud = 396) from what I gather the Baud+$8000 is the part that says it is 2400 baud, how would I change a statement like that to indicate that I am sending at the higher baud rate? Any information would be helpful, thanks. -Kevin

Comments

  • Kevin HarrisKevin Harris Posts: 15
    edited 2005-07-01 20:17
    Thanks for the quick reply, the problem is, I have no idea what that constant would be. I'm using a regular BS2 on a Homework board. Any ideas?
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-07-01 20:18
    The "baudmode" constants are in the manual under SERIN or SEROUT.

    I don't think you CAN send 38,000 Baud from a BS2. Maybe the BS2sx can do it.
    What are you trying to accomplish by doing this?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-01 20:19
    Kevin,

    ·· You simply change the value for the Baud rate that you're using after you send the change command.· For example, the baud rate value for 2400 is 396 (For BS2).· The + $8000 is added to that.· You would start using: "6 + $8000" after that.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Kevin HarrisKevin Harris Posts: 15
    edited 2005-07-01 20:20
    I've written a program in Java that tracks colors from a camera and outputs via serial to the Basic Stamp, then the stamp processes the command and sends it to the PSC, but for some reason I'm getting some delay, I thought it might be because of the baudrate.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-01 20:20
    allanlane5 said...
    The "baudmode" constants are in the manual under SERIN or SEROUT.
    I don't think you CAN send 38,000 Baud from a BS2. Maybe the BS2sx can do it.
    What are you trying to accomplish by doing this?
    Allan,

    ·· The BS2 can do 38.4K.· The baud mode parameter is 6 for that baud rate.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-01 20:30
    If one adds this conditional compilation block to the top of their program it will simplify serial programming -- I've worked out all the values for popular baud rates (including MIDI).

    #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
    · #CASE BS2PX
    ··· T1200······ CON···· 3313
    ··· T2400······ CON···· 1646
    ··· T4800······ CON···· 813
    ··· T9600······ CON···· 396
    ··· T19K2······ CON···· 188
    ··· TMidi······ CON···· 108
    ··· T38K4······ CON···· 84
    #ENDSELECT


    SevenBit······· CON···· $2000
    Inverted······· CON···· $4000
    Open··········· CON···· $8000


    Baud··········· CON···· T9600

    For the PSC, you might use these definitions:

    BaudSlow······· CON··· ·T2400 + Open
    BaudFast······ ·CON···· T38K4 + Open


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-07-01 20:31
    Oh, Chris, I didn't know that. Thanks.

    Kevin: You should know that the BS2 MUST be waiting in a SERIN statement if it is going to recieve data and act on it immediately. That could have been your delay.
Sign In or Register to comment.