Is it possible to interface BS2 with BS2sx?
holely
Posts: 9
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!
·
' {$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
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
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