internal Timing

airton65

Member
Hi All.
I'm at a bit of a loss, I'm building a Nixie Indoor/outdoor thermometer using a 20M2 and a HV5812. I'm using three of the PWM's to fade the RGB LEDs in and out, and another PWM to run the mosfet for the voltage booster. with all that going on I'm having trouble timing the display to read Indoor temps for ,say, 5 seconds then outdoor temps for 5 seconds. I was hoping to be able to use some sort of internal timer or count clock cycles and trigger an interrupt at the appropriate times. Does anyone know if this is possible?
Thanks in advance
Tony
 

westaust55

Moderator
You do not indicate what you have tried that did not work.

Have you looked into the TIME system variable ? That increments on seconds when clock speed is 4 MHz or 16 MHz.
See page 18 in PICAXE Manual2: http://www.picaxe.com/docs/picaxe_manual2.pdf

More information about the TIME variable at the on-line website here: http://www.picaxe.com/BASIC-Commands/Time-Delays/time/

The Time variable does not have an interupt capability (to my knowledge) so you need to check to value (eg IF time >= 5 THEN) at intervals
 

AllyCat

Senior Member
Hi,

The PWM outputs are background (hardware) tasks so shouldn't affect timing. Instructions which can affect the "time" (variable) are long PULSIN/OUT, IRIN, SERIN, etc..

So, as WA55 says, (for M2s) the easiest method is to test either for time >4, followed by a time = 0 , or (time // 5) >= 4 .

Cheers, Alan.
 

airton65

Member
Hi Westaust55,
Thankyou, I haven't come across that before. Thats exactly what I am looking for I think, I'll just do a bit of experimentation with it now. I have built a Nixie indoor/outdoor thermometers in the past but only with a single colored LED so there wasn't a lot for the 20M2 to do, so getting the display timing was easy.
Tony
 

airton65

Member
Hi AlleyCat,

My PWM's for the LEDs and Voltage Boost circuit are always changing as I want to maintain 180V and have the LEDs constantly fading through the color spectrum, so this part of my code is constantly running. My problem is that I want to branch out at a constant time interval to send data to the HV5812. I think Westaust55 has the solution with a bit of a work around
 

inglewoodpete

Senior Member
I have used the 08M2's and 14M2's internal Time variable as the basis for a crude clock. It has proven to be accurate to about +/- 3 minutes per day or 0.2% - good enough for my purpose. As AllyCat mentions, there are some 'rules' your code must abide by.
 
Top