How to look for state change on pin
Archiver
Posts: 46,084
Jim-
First thing I'd do is liberally sprinkle some DEBUG instructions in
your program to get a better handle on what's going on. Display your
variables' values and some info messages such as "at Remote" to let
you know where the program is getting stuck and why. The values of
your variables are crucial since you're using them to control program
flow. DEBUG is your friend.
Also, note that in the following routine:
Remote:
Branch PinState, [noparse][[/noparse]RemLow,RemHigh]
RemLow:
LOW PinNumber 'Deactivate current channel
goto Remote
If you ever reach the RemLow label, you begin an endless loop since
PinState retains the value that got you to RemLow in the first
place, so you go back to Remote, then Branch again to RemLow, then
back to Remote...
Regards,
Steve
First thing I'd do is liberally sprinkle some DEBUG instructions in
your program to get a better handle on what's going on. Display your
variables' values and some info messages such as "at Remote" to let
you know where the program is getting stuck and why. The values of
your variables are crucial since you're using them to control program
flow. DEBUG is your friend.
Also, note that in the following routine:
Remote:
Branch PinState, [noparse][[/noparse]RemLow,RemHigh]
RemLow:
LOW PinNumber 'Deactivate current channel
goto Remote
If you ever reach the RemLow label, you begin an endless loop since
PinState retains the value that got you to RemLow in the first
place, so you go back to Remote, then Branch again to RemLow, then
back to Remote...
Regards,
Steve
Comments
of the pins changes state (Low to High). Specifically, I am looking
for Pin 5 to be pulled to ground under certain conditions. I
currently have Pin 5 tied to Vdd via a 10k pullup resistor. I also
have a wire tied to the point in the circuit which will go low when a
certain condition exists.
I am having trouble getting the stamp to recognize when Pin 5 goes
low, so my Stamp program is caught in a loop, just sitting in a hold
loop and waiting.
Here's a sample of the BS2-IC program. Please offer any
suggestions, as I am VERY new to this and obviously need some help.
'{$STAMP BS2}
PinNumber var byte
PinState var byte
Mode var byte
Main:
'Manual Mode = 0 and Remote Mode = 1
Serin 16,16780,[noparse][[/noparse]WAIT(255),Mode,PinNumber,PinState]
Branch Mode, [noparse][[/noparse]Manual,Remote]
Manual:
Branch PinState, [noparse][[/noparse]ManLow,ManHigh]
ManLow:
LOW PinNumber 'Deactivate current channel
goto Main
ManHigh:
HIGH PinNumber 'Activate current channel
Goto Main
Remote:
Branch PinState, [noparse][[/noparse]RemLow,RemHigh]
RemLow:
LOW PinNumber 'Deactivate current channel
goto Remote
RemHigh:
HIGH PinNumber 'Activate current channel
INPUT 5
Hold:
If In5=1 then Hold 'Wait for Pin 5 to be pulled LOW)
Serout 16,16780,[noparse][[/noparse]"Signal"]
STOP
Thanks for any help you may offer....
Jim D. Martin