Timer control
Archiver
Posts: 46,084
A PAK-VII can do this easily: http://www.al-williams.com/awce/pak7.htm
Regards,
Al Williams
AWC
*Floating point math for the Stamp, PIC, SX, or any microcontroller.
http://www.al-williams.com/awce/pak1.htm
>
Original Message
> From: Jennifer Loiacono [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=-RO6WHjjqbW4Bx-QKA7tDPPULJSd8ybhNMnrRe6ACaB32tRHN6j6ByNcbNBWEZguZhgnTqknX303zYI]jenl@a...[/url
> Sent: Thursday, June 01, 2000 2:08 PM
> To: basicstamps@egroups.com
> Subject: [noparse][[/noparse]basicstamps] Timer control
>
>
> I need to implement a timer to run *in the background*, while the
> rest of the code continues to execute. Has anyone had success doing
> this, or does an external timer need to be used?
>
> Thanks,
> JL
>
>
>
Regards,
Al Williams
AWC
*Floating point math for the Stamp, PIC, SX, or any microcontroller.
http://www.al-williams.com/awce/pak1.htm
>
Original Message
> From: Jennifer Loiacono [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=-RO6WHjjqbW4Bx-QKA7tDPPULJSd8ybhNMnrRe6ACaB32tRHN6j6ByNcbNBWEZguZhgnTqknX303zYI]jenl@a...[/url
> Sent: Thursday, June 01, 2000 2:08 PM
> To: basicstamps@egroups.com
> Subject: [noparse][[/noparse]basicstamps] Timer control
>
>
> I need to implement a timer to run *in the background*, while the
> rest of the code continues to execute. Has anyone had success doing
> this, or does an external timer need to be used?
>
> Thanks,
> JL
>
>
>
Comments
Stamps don't allow foreground/background processing, so you need an
external timer. That can be done with a crystal and a chip to divide
its frequency down to the interval you need.
One exception is a cumbersome method of adding the cycle times of
instructions in a loop, and counting the number of loops to reach the
desired interval. This is not recommended for preserving either
accuracy or sanity.
Note that other PIC families, not used for Stamps, include built-in
timers. I use a 16C622 for this purpose, and a C compiler to program
it.
Dennis
Jennifer Loiacono wrote:
> I need to implement a timer to run *in the background*, while the
> rest of the code continues to execute. Has anyone had success doing
> this, or does an external timer need to be used?
>
> Thanks,
> JL
jenl@a... writes:
> I need to implement a timer to run *in the background*, while the
> rest of the code continues to execute. Has anyone had success doing
> this, or does an external timer need to be used?
If your resolution requirement isn't tremendous, you can pull it off in
software. Using a task-switcher design in your software, you can create a
"background" timer while your mainline code is run as a bunch of small tasks.
I designed a commercial product (an auto-dialer) that can monitor up to four
inputs and call a pager service if any of them stays active too long. I did
this with a BS2 and the timing resolution for each channel is about 10 ms --
not bad and the product works really well.
You need to analyze your specific requirement. If it can't be done in
software, Al Williams (no relation) has some neat hardware goodies that
should be helpful.
You might also find my April and May "Stamp Applications" articles in Nuts &
Volts magazine helpful if you think a software-approach is doable.
-- Jon Williams
-- Dallas, TX
> software, Al Williams (no relation) has some neat hardware goodies that
> should be helpful.
We aren't related? Rats.
One other thing. If your looking for a timeout or something similar that
isn't very critical, you can use a capacitor charging to provide an external
time for a few pennies. I have a combo lock in my book
(www.al-williams.com/awce/sbook.htm) that uses this technique. When it wants
to start the time, it sets a pin to an output at 0 to discharge a capacitor
and then returns the pin to input state. The cap charges through a resistor.
You can sample the input to find when the cap's voltage exceeds the input
threshold.
Regards,
Al Williams
AWC
*8 channels of pulse output for servos, PWM, etc.:
http://www.al-williams.com/awce/pak8.htm
rest of the code continues to execute. Has anyone had success doing
this, or does an external timer need to be used?
Thanks,
JL