Shop OBEX P1 Docs P2 Docs Learn Events
Is it possible to interface BS2 with BS2sx? — Parallax Forums

Is it possible to interface BS2 with BS2sx?

holelyholely Posts: 9
edited 2005-03-11 04:06 in BASIC Stamp
I have a BS2(client) and a BS2sx(server) and wanted to make them communicate with each other. I got some problems though:


' {$STAMP BS2} client test·program
DIRS=%0000000000000000
SERIN 1\0, 16468, [noparse][[/noparse]WAIT(250)]
a:
PAUSE 100
OUTPUT 1
SEROUT 1\0, 16468, [noparse][[/noparse]"HELLO!"]

==================================================================================

' {$STAMP BS2sx} server test program
DIRS=%0000000000000000
LETTA VAR Byte
a:
IF IN7=1 THEN haha
GOTO a
haha:
OUTPUT 1
SEROUT 1\0, 16624, [noparse][[/noparse]250]
AGAIN:
INPUT 1
SERIN 1\0,16624,[noparse][[/noparse]LETTA]
DEBUG LETTA
PAUSE 1000
GOTO again


These are the respective codes. The server program worked if I used a BS2 and changed the baudrate to 16468. For BS2sx, it only·debugs garbage. Why is this so?

Thanks in advance for any help!
·

Comments

  • kb2hapkb2hap Posts: 218
    edited 2005-03-10 00:08
    I understand this maynot be the issue but have you tried a slower baud rate?
    also it would be easier to make the serin and serout pin different its ok it works but start from the basics and work your way up until you see a problem.

    * The BASIC Stamp 2 and BASIC Stamp 2e may have trouble synchronizing with the incoming serial stream at this rate and higher due to the lack of a hardware input buffer. Use only simple variables and no formatters to try to solve this problem.
    * The BASIC Stamp 2sx and BASIC Stamp 2p may have trouble synchronizing with the incoming serial stream at this rate and higher due to the lack of a hardware input buffer. Use only simple variables and no formatters to try to solve this problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    DTQ
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-10 04:53
    As long as both BASIC Stamps are using the SAME baud rate you will have no problems.

    The problem with using "magic numbers" for constants (e.g. with your baudmode parameter) is that they're easy to get wrong. My standard programming template includes a conditional compilation block for SERIN/SEROUT parameters that ensures I always get those things correct, and I don't have to change my code when I change BASIC Stamp modules.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • holelyholely Posts: 9
    edited 2005-03-11 04:06
    I changed the baud rate to 2400 and with the appropriate baud mode values, I managed to get the thing going now. It seems that 9600 doesn't work.
Sign In or Register to comment.