When trip1 goes low it initiates the flashers and sets output B.3 high as it should.
When trip2 goes low the flashers continue as they should.
However when trip1 goes high again (simulates a train has passed) the program jumps back to main, even though the conditional statement says that ALL three conditions must be satisfied in order to exit the loop.
Any thoughts on why this is happening and suggested work arounds?
When trip2 goes low the flashers continue as they should.
However when trip1 goes high again (simulates a train has passed) the program jumps back to main, even though the conditional statement says that ALL three conditions must be satisfied in order to exit the loop.
Any thoughts on why this is happening and suggested work arounds?
Code:
'===== Inputs =====
symbol trip1 = pinC.0 'initiates crossing gate sequence
symbol trip2 = pinC.1 'sensor before the crossing
symbol trip3 = pinC.2 'sensor after the crossing
'trip1 = 0 when a train is present
'trip1 = 1 when sensor is uncovered.
'same for trip2 and trip3
'Distance between trip2 and trip3 must be
'less than one train length.
'===== Outputs =====
symbol red1 = B.1 'one crossing gate LED
symbol red2 = B.2 'the other crossing LED
symbol gate = B.3 'output to the slave processor
'===Directives===
#com 3 'specify serial port
#picaxe 14M2 'specify processor
dirsB = %11111111
dirsC = %00000000
main:
do
if trip1 = 0 and trip2 = 1 and trip3 = 1 then 'train detected
exit
end if
loop 'loops while waiting for train
high gate 'activates slave processor
flash:
do while trip2 = 1 or trip3 = 1
high red1 'flash red lights
low red2
pause 100
low red1
high red2
pause 100
low red2
if trip3 = 1 and trip2 = 1 and trip1 = 1 then 'no train
exit
end if
loop
low gate
goto main