PICAXE Timer

Groutie

New Member
I am multitasking a 28x1 and would like to use the internal timer for 1 minute time interrupts

Can any body suggest anything


Thanks
 

slimplynth

Senior Member
Hi Groutie... I guess it depends how accurate the timing needs to be, what are using it for? For my pir sensor I set a wait time of 40 seconds using...

Code:
for b1 = 1 to 10
pause 4000
next b1

main: blah blah blah
replacing 4000 with 6000 would give you the 60 seconds(ish) you may require.
 

Groutie

New Member
PIC AXE Timer

HI Simplynth

Thanks

I am mutlitasking 4 7seg displays as a clock so can't afford to use pauses etc as this affects the displays. I would to use the internal timers to generate the interrupt so that displays can be updated accurately

At present I am using nested loops to create the 1min delays but I think it's not that acuurate and I think using the internal clock etc would be better

Wot do you think?


Groutie
 

Jeremy Leach

Senior Member
Hi there

Yes, you need to use the SetTimer command, with an appropriate preload value, and the SetFlags command to set the interrupt. Look at SetTimer and SetFlags in the manual because it describes the detail. If you are using an external crystal then this will be very accurate.

Basically the internal timer has minor ticks and major ticks and the preload value sets the tick rate of the major ticks and how the Timer variable is incremented. When the timer variable overflows it can cause an interrupt (if you've setflags appropriately) and you can then update you 7seg displays in your interrupt routine.

Hope this gives you the general idea.
 

ArnieW

Senior Member
HI Simplynth

Thanks

I am mutlitasking 4 7seg displays as a clock so can't afford to use pauses etc as this affects the displays. I would to use the internal timers to generate the interrupt so that displays can be updated accurately

At present I am using nested loops to create the 1min delays but I think it's not that acuurate and I think using the internal clock etc would be better

Wot do you think?


Groutie
Groutie, check out this code snippet. It uses interrupts every second and should do what you are after with a bit of modification.

cheers, Arnie
 

womai

Senior Member
For a clock, I would not recommend using the 28X1's internal timing (interrupt or other). It's only as accurate as the oscillator the 28X1 is running off, i.e. about 0.5 - 1%. A 1% error corresponds to about 15min per day! Better to use a dedicated real time clock chip (Dallas Semi / Maxim) running of a precise 32 kHz clock cystal. The Picaxe can then query the time from this chip a few times per second. Look at Rev-Ed's interfacing manual for details.

Wolfgang
 

womai

Senior Member
True,a crystal is more accurate than a ceramic resonator. Although afaik those 32kHz crystals tend to be more accurate than generic multi-MHz crystals, because they are manufactured dedicated for precise timekeeping.

And the external RTC chip has the advantage that the Picaxe can go off and do other things without having to worry about keeping time - i.e. it frees up your interrupt for other things - and it takes care about leap years etc. in case you also want a date display.
 
Top