Measuring elapsed time

fmr300

New Member
I'd like to use the Picaxe to periodically run certain tasks, while also doing other things in the background. With other processors, quite easy, just do the background tasks and occasionally check an elapsed timer to see if it's time to run the periodic tasks.

TIME is only good for full seconds-counting..... any ideas on how to check periodically to see if it's time to run the "500ms tasks" ?
Again, I don't want to 'wait' or 'pause' since there are low-priority things to also do, but be on-time for running the 500ms-tasks.

tnx,

-mark
 

erco

Senior Member
Typically you will execute your other low-priority tasks in an empirically time-calibrated loop then do whatever needs doing before restarting the loop.

Otherwise you could use an interrupt. A simple external 555 timer oscillating at 120 hz would give you a pulse every 500 ms.
 

Goeytex

Senior Member
Which Picaxe Chip? (Not all Picaxe chips are created equal).

With either a 20x2 or 28x2 you should be able to use 'settimer' and 'setintflags' to generate an interrupt every 500ms
 

AllyCat

Senior Member
Hi,

An M2 PICaxe at SETFREQ m32 (only) will increment the time variable every 500 ms. ;)

Otherwise, a SERVO (or PWM) pulse could be arranged to generate an (external) interrupt every 20 ms, which could quickly increment a counting variable (e.g. S_W6) and then RETURN. Hardware-generated PWM frequencies are "accurate" but cannot be lower than 61 Hz, whilst a hazard of the firmware-generated "time" variable and Servo pulses is that they can be "stretched" by certain commands such a SERIN/OUT.

Cheers, Alan.
 

fmr300

New Member
Thanks for the ideas!, and really appreciate the quick responses. Nice to know that the board is active with experienced people.
 

oracacle

Senior Member
Don't know if it be any help, but I wrote this a while back, don't know if there is a compatible operation on M2 variants.

 
Top