two BS2s communicating.
ilya
Posts: 13
I am attempting to have one BS2 send a variable to another. As a test, i created two programs for two BS2s, one to send a variable and one to receive. I have both BS2s wired to a gnd and a 5 volt source. There is also one wire running from the I/O of one BS2 to an I/O of the other. The program for the sending BS2 is:
' {$STAMP BS2}
' {$PBASIC 2.5}
ActualAngleDegr VAR Word
ActualAngleDegr = 56
SEROUT 5,396,[noparse][[/noparse]"!", DEC ActualAngleDegr, ";"]
The program for the reciever BS2 is:
' {$STAMP BS2}
' {$PBASIC 2.5}
ActualAngleDegr VAR Word
MoveTo CON 2
SERIN 0,396,[noparse][[/noparse]WAIT("!"), DEC ActualAngleDegr]
DEBUG MoveTo, 0, 3, "ActualAngleDegr is: ", ActualAngleDegr, " "
The debugger opens but no text is written and the variable is not displayed. Any thoughts/suggestions? Thanks.
-Ilya
' {$STAMP BS2}
' {$PBASIC 2.5}
ActualAngleDegr VAR Word
ActualAngleDegr = 56
SEROUT 5,396,[noparse][[/noparse]"!", DEC ActualAngleDegr, ";"]
The program for the reciever BS2 is:
' {$STAMP BS2}
' {$PBASIC 2.5}
ActualAngleDegr VAR Word
MoveTo CON 2
SERIN 0,396,[noparse][[/noparse]WAIT("!"), DEC ActualAngleDegr]
DEBUG MoveTo, 0, 3, "ActualAngleDegr is: ", ActualAngleDegr, " "
The debugger opens but no text is written and the variable is not displayed. Any thoughts/suggestions? Thanks.
-Ilya
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
One BS2 code:
' {$STAMP BS2}
' {$PBASIC 2.5}
reps VAR Nib
ActualAngleDegr VAR Word
FOR reps = 1 TO 100
ActualAngleDegr = 95
SEROUT 5,396,[noparse][[/noparse]"!", DEC2 ActualAngleDegr]
PAUSE 1000
NEXT
Second BS2 Code:
' {$STAMP BS2}
' {$PBASIC 2.5}
ActualAngleDegr VAR Word
MoveTo CON 2
DO
SERIN 0,396,[noparse][[/noparse]WAIT("!"), DEC2 ActualAngleDegr]
DEBUG "ActualAngleDegr is: ", ActualAngleDegr, " "
LOOP
Any thoughts as to why the variable does not come out as 95 as the result?
Are you using this set up
See the [url=mk:@MSITStore:C:\Program%20Files\Parallax%20Inc\Stamp%20Editor%20v2.2.6\PBASIC.chm::/serin_ex.htm]example program[/url] for a flow control example using two BS2s. In the demo program example, without flow control, the sender would transmit the whole word "HELLO!" in about 6 ms. The receiver would catch the first byte at most; by the time it got back from the first 1-second PAUSE, the rest of the data would be long gone. With flow control, communication is flawless since the sender waits for the receiver to catch up.
In the figure below, I/O pin 0, FPin, is pulled to ground through a 10 kΩ resistor. This is to ensure that the sender sees a stop signal (0 for inverted communications) when the receiver is being programmed.
[img]mk:@MSITStore:C:\Program%20Files\Parallax%20Inc\Stamp%20Editor%20v2.2.6\PBASIC.chm::/graphics/flow_ctrl_sch.gif[/img]
- When using a BS2-family module, you can simplify Baudmode parameter selection by using conditional compilation. The example below can be included in the standard programming template and will handle most serial IO requirements. Remember that defining constants does not affect compiled program space, and yet does make program debugging easier.
- [img]mk:@MSITStore:C:\Program%20Files\Parallax%20Inc\Stamp%20Editor%20v2.2.6\PBASIC.chm::/graphics/bs2all_inline.gif[/img]
' {$PBASIC 2.5} #SELECT $STAMP #CASE BS2, BS2E, BS2PE T1200 CON 813 T2400 CON 396 T4800 CON 188 T9600 CON 84 T19K2 CON 32 T38K4 CON 6 #CASE BS2SX, BS2P T1200 CON 2063 T2400 CON 1021 T4800 CON 500 T9600 CON 240 T19K2 CON 110 T38K4 CON 45 #CASE BS2PX T1200 CON 3313 T2400 CON 1646 T4800 CON 813 T9600 CON 396 T19K2 CON 188 T38K4 CON 84#ENDSELECTSevenBit CON $2000Inverted CON $4000Open CON $8000Baud CON T9600 + Inverted ' match DEBUG▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support