Counter or timer with 'serin'

Tyro

Member
I am looking for ideas on a timer or counter that will run while using ‘serin’.

I am running some code and hardware with a 08M2 that is working perfectly. Part of it uses a wireless link and most of the time the program sits waiting for a signal using the ‘serin’ command. When a signal is received, some code determines what action is to be taken.

Normally, there is no incoming signal but when it is generated, the signal repeats every eight seconds.

I have successfully written the code that requires two identical signals to be received before action is taken. I want to add some code that will start a timer after the first signal is detected and only take action if the second signal is detected within about twelve seconds.

I have tried three ways to do this, the first was using the ‘time’ command but ‘time’ appears to stop during ‘serin’.

The second way was to use a second ‘task’ running a simple 1-second clock but I cannot restart it after the very first cycle. I can only find ‘suspend’, ‘resume’ and ‘restart’ in manual 2.

The third way was to use the timeout on ‘serin’ but that goes to the same address whether it times out or not.

Any ideas?
 

hippy

Ex-Staff (retired)
The third way was to use the timeout on ‘serin’ but that goes to the same address whether it times out or not.
I'm not sure how you mean there; if there's no timeout the SERIN should continue on the next line, if there is a timeout it can go to the timeout label specified.

I'd probably add an external 08M2, trigger it when I got my first packet of data, check to see if the 08M has set an 8 seconds expired / time period valid signal back when I got my second packet.
 
Top