Andrew Parsons
10-26-2009, 10:39 AM
Hello all,
I am trying to get my stamps·talking through a rs-485 for my project ( please go to this post read about it if intrested http://forums.parallax.com/showthread.php?p=850046) in order to control a hb-25 montor contoller from my master via a pot. I have the two stamps comunicating but i am only able to recive/send one byte· of info and thus cannot transfer the proper RCtime from the pot to contol the variable pulsout from the slave stamp to the hb-25. here are my test prjoects that i am having problems with.
Master stamp
' {$STAMP BS2sx}
' {$PBASIC 2.5}
'
'========== Variables =============
reply VAR Byte ' Response from node.
xm_rcv CON 0 ' Pin 0 sets transmit (1) or receive (0).
serIO CON 1
time VAR Word ' rctime min value 1 max·value is 680 with currect setup
'========== Initialize ============
OUTPUT 0 'Make pin 0 an output
'========== Main Loop =============
loop1:
HIGH 7 'sets pin 7 high for cap charge
PAUSE 5 ' charge time
RCTIME 7, 1, time 'place decharge time in time var
HIGH 0 'Put the SN75176 into transmit mode
PAUSE 1 ' beathing room
SEROUT serIO,16468,[DEC time,"."]
LOW 0 'Put the SN75176 into rec mode
SERIN serIO,16468,100,error,[reply]
DEBUG HOME, "RC time = ", DEC5 time, " slave response =· ", reply
GOTO loop1
error:
DEBUG HOME, "communication error"
GOTO loop1
Now the slave project
' {$STAMP BS2sx}
' {$PBASIC 2.5}
time VAR Byte ' rc time from master
myid VAR Byte ' ID number to show communication is working
xm_rcv CON 0 ' Pin 0 sets transmit (1) or receive (0).
serIO CON 1 ' Pin 1 is used for serial input/output.
myId = "A" ' ID letter of this node.
again:
LOW xm_rcv ' Set 485 transceiver to receive mode.
SERIN serIO,16468,again, [time]
DEBUG HOME, "time = ", time
HIGH xm_rcv: PAUSE 10 ' Set 485 transceiver for transmit.
SEROUT serIO,16468, [myId] ' Send back my ID letter.
GOTO again ' Do it all over.
Thank you all in advance, the goal is to show the same value on the slaves time var as the master min 0001 max 00680 with current capacitor.
I am trying to get my stamps·talking through a rs-485 for my project ( please go to this post read about it if intrested http://forums.parallax.com/showthread.php?p=850046) in order to control a hb-25 montor contoller from my master via a pot. I have the two stamps comunicating but i am only able to recive/send one byte· of info and thus cannot transfer the proper RCtime from the pot to contol the variable pulsout from the slave stamp to the hb-25. here are my test prjoects that i am having problems with.
Master stamp
' {$STAMP BS2sx}
' {$PBASIC 2.5}
'
'========== Variables =============
reply VAR Byte ' Response from node.
xm_rcv CON 0 ' Pin 0 sets transmit (1) or receive (0).
serIO CON 1
time VAR Word ' rctime min value 1 max·value is 680 with currect setup
'========== Initialize ============
OUTPUT 0 'Make pin 0 an output
'========== Main Loop =============
loop1:
HIGH 7 'sets pin 7 high for cap charge
PAUSE 5 ' charge time
RCTIME 7, 1, time 'place decharge time in time var
HIGH 0 'Put the SN75176 into transmit mode
PAUSE 1 ' beathing room
SEROUT serIO,16468,[DEC time,"."]
LOW 0 'Put the SN75176 into rec mode
SERIN serIO,16468,100,error,[reply]
DEBUG HOME, "RC time = ", DEC5 time, " slave response =· ", reply
GOTO loop1
error:
DEBUG HOME, "communication error"
GOTO loop1
Now the slave project
' {$STAMP BS2sx}
' {$PBASIC 2.5}
time VAR Byte ' rc time from master
myid VAR Byte ' ID number to show communication is working
xm_rcv CON 0 ' Pin 0 sets transmit (1) or receive (0).
serIO CON 1 ' Pin 1 is used for serial input/output.
myId = "A" ' ID letter of this node.
again:
LOW xm_rcv ' Set 485 transceiver to receive mode.
SERIN serIO,16468,again, [time]
DEBUG HOME, "time = ", time
HIGH xm_rcv: PAUSE 10 ' Set 485 transceiver for transmit.
SEROUT serIO,16468, [myId] ' Send back my ID letter.
GOTO again ' Do it all over.
Thank you all in advance, the goal is to show the same value on the slaves time var as the master min 0001 max 00680 with current capacitor.