Hi all,
The below code is simply monitoring for several bursts of data and flash some LEDs (at a slower rate) to indicate the presence (or lack of) data arriving.
In this case, the data is active only when activated by the external gear. it is not a constant data stream.
(i was previously using this code to monitor the picaxe programming data, to flash some leds).
I now need to add a latched relay signal out of the 08M2 (i'll use C.0, jumpered between programming mode and running mode)
I'm having trouble trying to generate a latched signal to hold a relay in place DURING the data arriving..
At the moment all my attempts are using some shady maths which obviously monitors the data becoming 0 or 1 and makes the relay chatter alot.
I'm not sure if a clever do..while/until loop will help or not, but i think maybe i need to use a timer that will timout (release the relay) after the data arriving stops interrupting the timer.
I'm not entirely sure, i haven't really used timers before
Can somebody point me in the right direction? i think it's too easy for me to see the problem lol ;-)
Thanks in advance.
The below code is simply monitoring for several bursts of data and flash some LEDs (at a slower rate) to indicate the presence (or lack of) data arriving.
In this case, the data is active only when activated by the external gear. it is not a constant data stream.
(i was previously using this code to monitor the picaxe programming data, to flash some leds).
I now need to add a latched relay signal out of the 08M2 (i'll use C.0, jumpered between programming mode and running mode)
I'm having trouble trying to generate a latched signal to hold a relay in place DURING the data arriving..
At the moment all my attempts are using some shady maths which obviously monitors the data becoming 0 or 1 and makes the relay chatter alot.
I'm not sure if a clever do..while/until loop will help or not, but i think maybe i need to use a timer that will timout (release the relay) after the data arriving stops interrupting the timer.
I'm not entirely sure, i haven't really used timers before
Can somebody point me in the right direction? i think it's too easy for me to see the problem lol ;-)
Thanks in advance.
Code:
#Picaxe 08M2
; set FREQ to highest speed?
; obviously ports/bits configured as INs and OUTs as needed.
Do
IF pinC.3 <> 0 THEN 'If pin is NOT 0, then there must be activity (data/voltage present)
High PinC.2 'Turn Bi-Colour GREEN LED ON, on pinC.2
Low PinC.1 'Turn Bi-Colour RED LED OFF, on pinC.1
pause 100 'Keep LED ON at least 100mSecs so it's visible.
Else 'otherwise.....
Low PinC.2 'Turn Bi-Colour GREEN LED OFF, on pinC.2
High PinC.1 'Turn Bi-Colour RED LED ON, on pinC.1
Pause 100 'Keep LED OFF at least 100mSecs so it's visible.
End if
Loop 'Keep monitoring for activity on PinC.3 and repeat.
Last edited: