Master/Slave aka Serin/Serout Issues
Archiver
Posts: 46,084
I have seen so many samples of the master/slave stampnet please
forgive me if I havent properly credited the folks that have helped
me out so much. The problem I am having and can't seem to clear up
is that while running the master/ slave with the following code, they
loose each other after about 6 or 7 times around the Master loop
(most likely because its being flooded with data). The nice part is
that they re-synch and continue on for another 6 or 7 'rounds before
loosing touch again. I have tried increasing the pause at the slave
serout, but that hasnt seemed to help. The requirement is to get the
24 values back to the master as fast as possible for continious
monitoring. To make matters worse, after the master gets the data
from the slave, it has to send it to VB. Any ideas on how to
eliminate the dropoff between Master/Slave before I move forward to
the VB side.. Id like the stamp side to be as solid as possible..
Thanks in advance.
RT
MASTER
commands var byte
datas var byte
pad VAR byte
sensor VAR byte
result VAR word
main:
commands=0
debug 2,0,0
loop:
if commands > 23 then theend
high 1 ' set data line to high level
serout 0\1,16468,5000,noslave,[noparse][[/noparse]commands]
serin 2\3,16468,5000,noslave,[noparse][[/noparse]pad,sensor,result.lowbyte,
result.highbyte]
debug dec pad, dec2 sensor ,dec result, cr
commands=commands+1
goto loop:
theend:
goto main
noslave:
debug "noSlave", cr
goto loop
SLAVE
'{$STAMP BS2}
commands var byte
outnum VAR Byte
initstr VAR Byte
Din CON 13
Dout CON 14
CS CON 12
SCLK CON 15
pad VAR Byte
sensor VAR Byte
result VAR Word
pad = 2
main:
'DEBUG "Slave", CR
HIGH 3 ' to inhibit transmissions from the master
loop:
'DEBUG "Waiting", CR
SERIN 2\3,16468,5000,loop,[noparse][[/noparse]commands]
'DEBUG ? commands
sensor = commands
if sensor >=0 and sensor <=7 then mux1
if sensor >=8 and sensor <=15 then mux2
if sensor >=16 and sensor <=23 then mux3
if sensor >23 then main
goto senddata
senddata:
SEROUT 0\1,16468,5000,notalk,[noparse][[/noparse]pad,sensor,result.LOWBYTE,
result.HIGHBYTE]
pause 70 ' change to see if I can prevent a problem
GOTO loop
mux1:
outnum=sensor
initstr=%10000000 + (sensor<<4) + %00001100
LOW CS
SHIFTOUT 10,SCLK,1,[noparse][[/noparse]initstr]
SHIFTIN 11,SCLK,2,[noparse][[/noparse]result\12]
HIGH CS
goto senddata
mux2:
outnum=sensor-8
initstr=%10000000 + (outnum<<4) + %00001100
LOW CS
SHIFTOUT Din,SCLK,1,[noparse][[/noparse]initstr]
SHIFTIN Dout,SCLK,2,[noparse][[/noparse]result\12]
HIGH CS
goto senddata
mux3:
outnum=sensor-16
initstr=%10000000 + (outnum<<4) + %00001100
LOW CS
SHIFTOUT 8,SCLK,1,[noparse][[/noparse]initstr]
SHIFTIN 9,SCLK,2,[noparse][[/noparse]result\12]
HIGH CS
goto senddata
notalk:
DEBUG "noTalk", CR
GOTO loop
forgive me if I havent properly credited the folks that have helped
me out so much. The problem I am having and can't seem to clear up
is that while running the master/ slave with the following code, they
loose each other after about 6 or 7 times around the Master loop
(most likely because its being flooded with data). The nice part is
that they re-synch and continue on for another 6 or 7 'rounds before
loosing touch again. I have tried increasing the pause at the slave
serout, but that hasnt seemed to help. The requirement is to get the
24 values back to the master as fast as possible for continious
monitoring. To make matters worse, after the master gets the data
from the slave, it has to send it to VB. Any ideas on how to
eliminate the dropoff between Master/Slave before I move forward to
the VB side.. Id like the stamp side to be as solid as possible..
Thanks in advance.
RT
MASTER
commands var byte
datas var byte
pad VAR byte
sensor VAR byte
result VAR word
main:
commands=0
debug 2,0,0
loop:
if commands > 23 then theend
high 1 ' set data line to high level
serout 0\1,16468,5000,noslave,[noparse][[/noparse]commands]
serin 2\3,16468,5000,noslave,[noparse][[/noparse]pad,sensor,result.lowbyte,
result.highbyte]
debug dec pad, dec2 sensor ,dec result, cr
commands=commands+1
goto loop:
theend:
goto main
noslave:
debug "noSlave", cr
goto loop
SLAVE
'{$STAMP BS2}
commands var byte
outnum VAR Byte
initstr VAR Byte
Din CON 13
Dout CON 14
CS CON 12
SCLK CON 15
pad VAR Byte
sensor VAR Byte
result VAR Word
pad = 2
main:
'DEBUG "Slave", CR
HIGH 3 ' to inhibit transmissions from the master
loop:
'DEBUG "Waiting", CR
SERIN 2\3,16468,5000,loop,[noparse][[/noparse]commands]
'DEBUG ? commands
sensor = commands
if sensor >=0 and sensor <=7 then mux1
if sensor >=8 and sensor <=15 then mux2
if sensor >=16 and sensor <=23 then mux3
if sensor >23 then main
goto senddata
senddata:
SEROUT 0\1,16468,5000,notalk,[noparse][[/noparse]pad,sensor,result.LOWBYTE,
result.HIGHBYTE]
pause 70 ' change to see if I can prevent a problem
GOTO loop
mux1:
outnum=sensor
initstr=%10000000 + (sensor<<4) + %00001100
LOW CS
SHIFTOUT 10,SCLK,1,[noparse][[/noparse]initstr]
SHIFTIN 11,SCLK,2,[noparse][[/noparse]result\12]
HIGH CS
goto senddata
mux2:
outnum=sensor-8
initstr=%10000000 + (outnum<<4) + %00001100
LOW CS
SHIFTOUT Din,SCLK,1,[noparse][[/noparse]initstr]
SHIFTIN Dout,SCLK,2,[noparse][[/noparse]result\12]
HIGH CS
goto senddata
mux3:
outnum=sensor-16
initstr=%10000000 + (outnum<<4) + %00001100
LOW CS
SHIFTOUT 8,SCLK,1,[noparse][[/noparse]initstr]
SHIFTIN 9,SCLK,2,[noparse][[/noparse]result\12]
HIGH CS
goto senddata
notalk:
DEBUG "noTalk", CR
GOTO loop
Comments
I am very much doing the something with Master/Slaves
BStamps and the master BS talk to PC using VB6. I am
very much interested in what you are doing, and will
appreciate with whatever experience that you can share
with me. Thank You.
George
--- rltaylor001 <rltaylor001@h...> wrote:
> I have seen so many samples of the master/slave
> stampnet please
> forgive me if I havent properly credited the folks
> that have helped
> me out so much. The problem I am having and can't
> seem to clear up
> is that while running the master/ slave with the
> following code, they
> loose each other after about 6 or 7 times around the
> Master loop
> (most likely because its being flooded with data).
> The nice part is
> that they re-synch and continue on for another 6 or
> 7 'rounds before
> loosing touch again. I have tried increasing the
> pause at the slave
> serout, but that hasnt seemed to help. The
> requirement is to get the
> 24 values back to the master as fast as possible for
> continious
> monitoring. To make matters worse, after the master
> gets the data
> from the slave, it has to send it to VB. Any ideas
> on how to
> eliminate the dropoff between Master/Slave before I
> move forward to
> the VB side.. Id like the stamp side to be as solid
> as possible..
>
> Thanks in advance.
> RT
>
>
MASTER
> commands var byte
> datas var byte
> pad VAR byte
> sensor VAR byte
> result VAR word
>
> main:
> commands=0
> debug 2,0,0
>
> loop:
> if commands > 23 then theend
> high 1 ' set data line to high level
> serout 0\1,16468,5000,noslave,[noparse][[/noparse]commands]
> serin
> 2\3,16468,5000,noslave,[noparse][[/noparse]pad,sensor,result.lowbyte,
> result.highbyte]
>
> debug dec pad, dec2 sensor ,dec result, cr
> commands=commands+1
> goto loop:
>
> theend:
> goto main
>
> noslave:
> debug "noSlave", cr
> goto loop
>
>
SLAVE
> '{$STAMP BS2}
> commands var byte
> outnum VAR Byte
> initstr VAR Byte
> Din CON 13
> Dout CON 14
> CS CON 12
> SCLK CON 15
> pad VAR Byte
> sensor VAR Byte
> result VAR Word
>
> pad = 2
>
> main:
> 'DEBUG "Slave", CR
> HIGH 3 ' to inhibit transmissions from the master
>
> loop:
> 'DEBUG "Waiting", CR
> SERIN 2\3,16468,5000,loop,[noparse][[/noparse]commands]
> 'DEBUG ? commands
> sensor = commands
>
> if sensor >=0 and sensor <=7 then mux1
> if sensor >=8 and sensor <=15 then mux2
> if sensor >=16 and sensor <=23 then mux3
> if sensor >23 then main
>
> goto senddata
>
> senddata:
> SEROUT
> 0\1,16468,5000,notalk,[noparse][[/noparse]pad,sensor,result.LOWBYTE,
> result.HIGHBYTE]
> pause 70 ' change to see if I can prevent a problem
> GOTO loop
>
> mux1:
> outnum=sensor
> initstr=%10000000 + (sensor<<4) + %00001100
> LOW CS
> SHIFTOUT 10,SCLK,1,[noparse][[/noparse]initstr]
> SHIFTIN 11,SCLK,2,[noparse][[/noparse]result\12]
> HIGH CS
> goto senddata
> mux2:
> outnum=sensor-8
> initstr=%10000000 + (outnum<<4) + %00001100
> LOW CS
> SHIFTOUT Din,SCLK,1,[noparse][[/noparse]initstr]
> SHIFTIN Dout,SCLK,2,[noparse][[/noparse]result\12]
> HIGH CS
> goto senddata
> mux3:
> outnum=sensor-16
> initstr=%10000000 + (outnum<<4) + %00001100
> LOW CS
> SHIFTOUT 8,SCLK,1,[noparse][[/noparse]initstr]
> SHIFTIN 9,SCLK,2,[noparse][[/noparse]result\12]
> HIGH CS
> goto senddata
>
> notalk:
> DEBUG "noTalk", CR
> GOTO loop
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
The behavior I have seen is the time-out will
wait until either it receives all the bytes
the SERIN is looking for, or the time-out
occurs.
If you have received SOME bytes when the
timeout occurs, you'll get a partial in
what SERIN is reading.
Also, you should probably put some delay
in the 'Master' after sending the 'command',
to give the 'Slave' time to decide what
to do.
I hope you have a 220 ohm resistor in the
'flag' pins, to prevent damage should both
try to drive them.
The 'Master' should not drive '1' high before
it talks -- the Slave is supposed to drive
the 'flag' pin 1 TO the Master, to indicate
it is ready to receive. The Master SHOULD
drive pin 3 high, so the Slave SEROUT will
wait till the Master is ready.
You are using 'Inverted' mode sending. In
this mode, the 'FPIN' should be set LOW to
indicate the Reciever is not yet ready to
take data, and it should be set by the
SERIN side. Note once a successful SERIN
has occurred, it will properly maintain the
FPIN state. (BS2 manual 2.0c pg 289)
--- In basicstamps@yahoogroups.com, "rltaylor001" <rltaylor001@h...>
wrote:
> I have seen so many samples of the master/slave stampnet please
> forgive me if I havent properly credited the folks that have helped
> me out so much. The problem I am having and can't seem to clear up
> is that while running the master/ slave with the following code,
they
> loose each other after about 6 or 7 times around the Master loop
> (most likely because its being flooded with data). The nice part is
> that they re-synch and continue on for another 6 or 7 'rounds
before
> loosing touch again. I have tried increasing the pause at the
slave
> serout, but that hasnt seemed to help. The requirement is to get
the
> 24 values back to the master as fast as possible for continious
> monitoring. To make matters worse, after the master gets the data
> from the slave, it has to send it to VB. Any ideas on how to
> eliminate the dropoff between Master/Slave before I move forward to
> the VB side.. Id like the stamp side to be as solid as possible..
>
> Thanks in advance.
> RT
>
>
MASTER
> commands var byte
> datas var byte
> pad VAR byte
> sensor VAR byte
> result VAR word
>
> main:
> commands=0
> debug 2,0,0
>
> loop:
> if commands > 23 then theend
> high 1 ' set data line to high level
> serout 0\1,16468,5000,noslave,[noparse][[/noparse]commands]
> serin 2\3,16468,5000,noslave,[noparse][[/noparse]pad,sensor,result.lowbyte,
> result.highbyte]
>
> debug dec pad, dec2 sensor ,dec result, cr
> commands=commands+1
> goto loop:
>
> theend:
> goto main
>
> noslave:
> debug "noSlave", cr
> goto loop
>
>
SLAVE
> '{$STAMP BS2}
> commands var byte
> outnum VAR Byte
> initstr VAR Byte
> Din CON 13
> Dout CON 14
> CS CON 12
> SCLK CON 15
> pad VAR Byte
> sensor VAR Byte
> result VAR Word
>
> pad = 2
>
> main:
> 'DEBUG "Slave", CR
> HIGH 3 ' to inhibit transmissions from the master
>
> loop:
> 'DEBUG "Waiting", CR
> SERIN 2\3,16468,5000,loop,[noparse][[/noparse]commands]
> 'DEBUG ? commands
> sensor = commands
>
> if sensor >=0 and sensor <=7 then mux1
> if sensor >=8 and sensor <=15 then mux2
> if sensor >=16 and sensor <=23 then mux3
> if sensor >23 then main
>
> goto senddata
>
> senddata:
> SEROUT 0\1,16468,5000,notalk,[noparse][[/noparse]pad,sensor,result.LOWBYTE,
> result.HIGHBYTE]
> pause 70 ' change to see if I can prevent a problem
> GOTO loop
>
> mux1:
> outnum=sensor
> initstr=%10000000 + (sensor<<4) + %00001100
> LOW CS
> SHIFTOUT 10,SCLK,1,[noparse][[/noparse]initstr]
> SHIFTIN 11,SCLK,2,[noparse][[/noparse]result\12]
> HIGH CS
> goto senddata
> mux2:
> outnum=sensor-8
> initstr=%10000000 + (outnum<<4) + %00001100
> LOW CS
> SHIFTOUT Din,SCLK,1,[noparse][[/noparse]initstr]
> SHIFTIN Dout,SCLK,2,[noparse][[/noparse]result\12]
> HIGH CS
> goto senddata
> mux3:
> outnum=sensor-16
> initstr=%10000000 + (outnum<<4) + %00001100
> LOW CS
> SHIFTOUT 8,SCLK,1,[noparse][[/noparse]initstr]
> SHIFTIN 9,SCLK,2,[noparse][[/noparse]result\12]
> HIGH CS
> goto senddata
>
> notalk:
> DEBUG "noTalk", CR
> GOTO loop