Help needed in programming a timer feature

johnmobley

New Member
I am working on a project and most of my code is now complete. I am stuck on just one part of it. At the press of a button (Start) I want to be able to start some sort of timer (most likey two seperate timers). There will be two more inputs, which each in turn needs to stop the associatied timer and then take that value and send it to an LCD in the format of seconds. Can this be done with just code or is there some other hardware needed and how would it be done? I am not a complete beginner in programming but i would not concider myself great at it yet ether.:confused:
 

hippy

Technical Support
Staff member
It should be entirely possible in software. Which PICAXE are you using ? That may affect the best way to do it.
 

BeanieBots

Moderator
Also depends on what accuracy you need and if anything else needs to be processed during the time delay.
As mentioned by Hippy, which PICAXE will play a large part in what's possible or not.
 

moxhamj

New Member
This would be a great project for an 18X. Smaller chips would not have enough code space nor enough pins to drive displays etc, but an 18X could do this easily.

If you can live with inaccuracy of a few percent you could do all this with software in the chip. If you really want perfect accuracy, you could pair the 18X with a real time clock chip and read off the seconds from that clock. Have a look through the help manuals looking for display code and interface to the real time clock. The code may look a bit complex but you just plug it in and usually it works, and if not you can post it here on the forum.

Addit: Congrats to Hippy for his 7,777th post!
 
Last edited:

hippy

Technical Support
Staff member
7,777 - Well spotted, but now I've broken the magic. Back again in 1,110 more :)
 

johnmobley

New Member
I was looking at (and debating) between using the PICAXE 20M or the 28X for this project. I am trying to make a "stopwatch" feature that is acurate to the 10-thousanths place (eg. 3.9825 Seconds). At the current time, I want to be able to track two different events at the same time to compare their times but i need it to be expandable to 4-6 events at a time at a later date. How can this be done?
 
Last edited:

BeanieBots

Moderator
So, you want timing down to +/- 100uS.
That is going to difficult with just a PICAXE. At 4Mhz, a 'typical' command takes around 250uS to execute. However, timer specific commands such as pulsin can resolve down to 10uS. The other issue you will probably encounter is 'overflow'. Your example "3.9825", is larger than a 16-bit binary number can hold. (max=65535). At 10uS resolution the longest you could time would be 0.65S. With commands taking 250uS, it would be impossible to handle the overflow in software.

If I were doing this, I would look to a hardware solution with a PICAXE only used to control/display the results.
 
Top