Exact match. Not showing close matches.
PICList
Thread
'[PIC]: Very Long timing delays'
2001\07\17@205140
by
Michael A. Powers
|
Hello,
I have been experimenting with TMR0 and the prescaler to provide timing delays in my application. It seems pretty easy to do if you want short delays. However, when you are using a 4MHz clock, it seems to get difficult to get long delays, say like 1s. I can set the prescaler to 1:128 and start TMR0 at 0, and have the timer overflow every 32,768 cycles. At 4MHz, that's orders of magnitude away from a 1s delay, and I would like to have delays of 24 hrs or more! The only way I can think of getting around this is having the interrupt routine increment another register, and be able to count the cycles to a second that way. But again, that's a very inconvenient way if you want a routine to function every 24 hrs, you would need quite a lot of bits! I guess I have two other options, slowing the instruction clock down to the kilohertz range, or putting a secondary oscillator on T0CKI. If anyone has any advice to share, I'd be grateful to hear it.
Thank You,
-Mike
--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
2001\07\17@213449
by
Tony Nixon
|
"Michael A. Powers" wrote:
>
> Hello,
>
> I have been experimenting with TMR0 and the prescaler to provide timing delays in my application. It seems pretty easy to do if you want short delays. However, when you are using a 4MHz clock, it seems to get difficult to get long delays, say like 1s. I can set the prescaler to 1:128 and start TMR0 at 0, and have the timer overflow every 32,768 cycles. At 4MHz, that's orders of magnitude away from a 1s delay, and I would like to have delays of 24 hrs or more! The only way I can think of getting around this is having the interrupt routine increment another register, and be able to count the cycles to a second that way. But again, that's a very inconvenient way if you want a routine to function every 24 hrs, you would need quite a lot of bits! I guess I have two other options, slowing the instruction clock down to the kilohertz range, or putting a secondary oscillator on T0CKI. If anyone has any advice to share, I'd be grateful to hear it.
>
> Thank You,
> -Mike
TMR0 can cycle every 65mS with the PS at 1:256 @4MHz
That is roughly 15 counts per second and would need some trimming. There
was some info about error free timing not long back.
86400 seconds in a day
15 X 86400 = 1296000 counts.
129600 = 13 C6 80 in HEX so you would need 3 registers.
You could also 5 registers for these...
15 loop counter
1 second count - increments every 15 cycles
1 minute count - increments every 60 sec
1 hour count - increments every 60 min
1 day count - increments every 24 hour
--
Best regards
Tony
mICros
http://www.bubblesoftonline.com
spam_OUTsalesTakeThisOuT
bubblesoftonline.com
--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
2001\07\17@214117
by
Drew Vassallo
|
>At 4MHz, that's orders of magnitude away from a 1s delay, and I would like
>to have delays of 24 hrs or more! The only way I can think of getting
>around this is having the interrupt routine increment another
I guess you don't actually mean "delays," but "timers" of 24 hours or so.
If you're really talking about delays, then you don't need interrupts - just
set a loop for a given time and create the "delay." What you're describing
is more of a "let-me-know-when-I've-reached-a-certain-time" timer.
If you want something very long like this and need an accurate reference,
why not just add a real-time clock chip and periodically read the current
time off of it? If you want 24 hours, just check to see if the time values
are equal. This would only require two I/O lines, clock and data.
--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
2001\07\18@003847
by
Andrew E. Kalman
Re:
>I have been experimenting with TMR0 and the prescaler to provide
>timing delays in my application. It seems pretty easy to do if you
>want short delays. However, when you are using a 4MHz clock, it
>seems to get difficult to get long delays, say like 1s.
...
App Note AN-7 "Ninety-Day Countdown Timer" on our website may give
you some ideas ...
--
______________________________________
Andrew E. Kalman, Ph.D.
Salvo(TM), The RTOS that runs in tiny places(TM)
Pumpkin, Inc.
750 Naples Street
San Francisco, CA 94112
tel: (415) 584-6360
fax: (415) 585-7948
web: http://www.pumpkininc.com
email: .....aekKILLspam
@spam@pumpkininc.com
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2001\07\18@010534
by
Roman Black
Michael A. Powers wrote:
>
> Hello,
>
> I have been experimenting with TMR0 and the prescaler to provide timing delays in my
> application. It seems pretty easy to do if you want short delays. However, when
> you are using a 4MHz clock, it seems to get difficult to get long delays, say like > 1s.
> At 4MHz, that's orders of magnitude away from a 1s delay, and I would like to have
> delays of 24 hrs or more!
Hi Michael, I have some sample code on my web page:
http://centauri.ezy.net.au/~fastvid/one_sec.htm
For giving easy, zero-error timing of 1 second
with a 4MHz PIC or even much longer periods. The
code uses very little ram, operates quick
and can easily be inserted into whatever timer
interrupts you may already be using with any
frequency crystal. :o)
-Roman
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2001\07\18@024852
by
Dale Botkin
|
On Wed, 18 Jul 2001, Roman Black wrote:
> Michael A. Powers wrote:
> >
> > Hello,
> >
> > I have been experimenting with TMR0 and the prescaler to provide timing delays in my
> > application. It seems pretty easy to do if you want short delays. However, when
> > you are using a 4MHz clock, it seems to get difficult to get long delays, say like > 1s.
>
> > At 4MHz, that's orders of magnitude away from a 1s delay, and I would like to have
> > delays of 24 hrs or more!
>
>
> Hi Michael, I have some sample code on my web page:
> http://centauri.ezy.net.au/~fastvid/one_sec.htm
I can vouch for this approach. I used a C implementation in a job I am
just finishing up, and it's perfect. Bob Ammerman and Roman Black, I owe
you each a beer or three. My clock now has NO drift other than whatever
the crystal introduces -- I think we can live with 50PPM! 8-)
Dale
--
A train stops at a train station. A bus stops at a bus station.
On my desk I have a workstation...
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2001\07\18@090630
by
Olin Lathrop
>>
At 4MHz, that's orders of magnitude away from a 1s delay, and I would like
to have delays of 24 hrs or more! The only way I can think of getting
around this is having the interrupt routine increment another register, and
be able to count the cycles to a second that way. But again, that's a very
inconvenient way if you want a routine to function every 24 hrs, you would
need quite a lot of bits!
<<
Gimme a break! This is quite simple and is done all the time. The maximum
timer 0 overflow rate is once every 65,536 instructions, or every 65.536mS
at 4MHz oscillator. That is 15.26 times per second, so it only takes a 4
bit counter to get to a second. For 24 hours you need to count to 60 * 60 *
24 / 0.065536 = 1,318,359, which requires 21 bits, which requires only 3
bytes.
********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, olin
KILLspamembedinc.com, http://www.embedinc.com
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
More... (looser matching)
- Last day of these posts
- In 2001
, 2002 only
- Today
- New search...