Searching \ for '5 second delay' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/timers.htm?key=delay
Search entire site for: '5 second delay'.

Truncated match.
PICList Thread
'5 second delay'
1999\10\20@232139 by spamdogg

flavicon
face
What would be the best way to create a 5 second delay with a 16c56?

Scott

P.S.    Thanks for all the help on PORTA.  About five minutes after I
sent the message I had about 500 people telling me what to do.  Thank
god none of you said to give up on PICs.   I am making the transition
from 68xx and 68xxx to the PICs and the road looks long and far.

1999\10\20@235932 by Juimiin Hong

flavicon
face
> What would be the best way to create a 5 second delay with a 16c56?

The easiest way would be to have a loop or nested loops and start
decrementing a counter until you reach 0.

juimiin

1999\10\21@002531 by John C. Frenzel

picon face
Scott,

Two ways are commonly used:
1)    delay loops.  Figure out how many instruction cycles are executed in 5
seconds.  This is dependant on the clock speed of the chip.   Then create a
set of loops to generate these many instructions.   A 16f84 at 10 Mhz
executes one instruction in 400x10e-9.   That is 2.5 million per second.
Execute 12.5 M instructions and it has been about 5 sec.   Nested loops of
NOP is a usual way
2)    Timer.   In many of the chips exists a timer with prescaler.  I am not
familiar with the 16c56.  Those with TMR0 functions, you set the prescaler
up for a divide by 256, and load the appropriate count in the timer register
and wait for the interrupt.   If you have other things for the PIC to do
during the delay, then interrupt driven delay is useful.  This is, of
course, more complicated than the delay loop.

> What would be the best way to create a 5 second delay with a 16c56?
>
> Scott
>
> P.S.    Thanks for all the help on PORTA.  About five minutes after I
> sent the message I had about 500 people telling me what to do.  Thank
> god none of you said to give up on PICs.   I am making the transition
> from 68xx and 68xxx to the PICs and the road looks long and far.


__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

1999\10\21@004723 by Sean H. Breheny

face picon face
Hi Scott,

Take a look at:

http://www.people.cornell.edu/pages/shb7/lop.html

Sean

At 11:15 PM 10/20/99 -0400, Scott wrote:
>What would be the best way to create a 5 second delay with a 16c56?
>
>Scott
>
>P.S.    Thanks for all the help on PORTA.  About five minutes after I
>sent the message I had about 500 people telling me what to do.  Thank
>god none of you said to give up on PICs.   I am making the transition
>from 68xx and 68xxx to the PICs and the road looks long and far.
>
|
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
spam_OUTshb7TakeThisOuTspamcornell.edu ICQ #: 3329174

1999\10\21@004916 by Lea

picon face
At 11:15 PM 10/20/99 -0400, you wrote:
>What would be the best way to create a 5 second delay with a 16c56?
>
>Scott

Hi Scott.
Some time ago I was working in a program that activate a routine once every
10 seconds, I used a "watch xtal" as oscilator for the PIC (32.768 Khz Xtal),
and using the prescaler dividing by 256 the pic clock, So TMR0 interrupts
me (overflow) 8 times x second, a simple do-loop will do the rest and it's
quite precise and easy to do but I don't know if 8.1khz of pic speed will be
enough processing power for you.

leo.
  Leandro J. Laporta (LU2AOQ)
  mail: .....lu2aoqKILLspamspam@spam@yahoo.com
  wrk: Arg. Assoc. for Space Technology.
  ham: TCP/IP high speed group HSG

1999\10\21@032146 by Byron A Jeff

face picon face
>
> What would be the best way to create a 5 second delay with a 16c56?

It really depends if you need to do anything else during that delay time.
If not then Sean's delay looping looks really good. PICS are quite helpful
because every instruction's execution time is completely deterministic.

If you need to do somthing else, then using the timer is your best bet.
Be aware that the PIC's timer will have jitter if you write to the
timer register. The upshot is that if you really want anything close to
precise timing, it's best to simply let the timer overflow and count the
overflows.

Here's an example. A 10 Mhz 16F84 timer register will count 2.5 million ticks
per second. We can use the prescaler to reduce this down to exactly 9765.625
tics per second be setting the prescaler to 256. Then if we watch just the
overflow then we'll get 38.14 tics per second. Then all you need to do is
count 190 overflows. This will give you a delay of 4.98073 seconds.

There are two ways to count the overflows. You can use interrupts and
update the count in the interrupt service routine. Or you can keep interrupts
off and watch the overflow bit yourself, updating the count and clearing the
overflow bit. In this case you must be sure that your routine checks the
bit within two overflows (52 ms in this example) or you'll miss a tick.

Lastly to get truly precise timing and keep the no write rule in place you
need to change crystal speeds so that they evenly divide by powers of 2.
For example by switching the crystal to 9.8304 Mhz you can divide evenly
all the way up to 2^17 power. This means that you can use the natural
clock divide by 4, overflow the counter, and prescale by 32, and get precisely
75 overflows per second. Count 375 of these (unfortunately requiring 9 bits)
and get a 5.00000 second delay.

Hope this helps,

>
> Scott
>
> P.S.    Thanks for all the help on PORTA.  About five minutes after I
> sent the message I had about 500 people telling me what to do.  Thank
> god none of you said to give up on PICs.   I am making the transition
> from 68xx and 68xxx to the PICs and the road looks long and far.

It really isn't. PICS work very well because they are simple. However that
simplicity sometimes requires rethinking how you do things, just like in
the PORTA example and the timer stuff here. One learns from experience
things like writing to the timer register messes up the count...

BAJ
>

1999\10\21@034011 by Don McKenzie

flavicon
face
> > What would be the best way to create a 5 second delay with a 16c56?
> >
> > Scott

If it's simple timed delays, then have a go at the code used for the
basic Stamp command "Pause".

; PAUSE time
; A general-purpose delay routine that puts the PIC into a do-nothing
; loop for a 16-bit number of milliseconds (1 to 65535) at 4 MHz.
Requires
; 16 cycles of overhead for call, return and other processing.

found at:
http://www.dontronics.com/convert2.html#pause

Don McKenzie  donspamKILLspamdontronics.com http://www.dontronics.com

Don's Download Dungeon:   http://www.dontronics.com/download.html
Australian Electronics Ring http://www.dontronics.com/aering.html
Win $500USD Cash. Micro design contest:  http://www.simmstick.com

1999\10\21@104906 by Lea

picon face
At 11:15 PM 10/20/99 -0400, you wrote:
>What would be the best way to create a 5 second delay with a 16c56?
>
>Scott

Hi Scott.
Some time ago I was working in a program that activate a routine once every
10 seconds, I used a "watch xtal" as oscilator for the PIC (32.768 Khz Xtal),
and using the prescaler dividing by 256 the pic clock, So TMR0 interrupts
me (overflow) 8 times x second, a simple do-loop will do the rest and it's
quite precise and easy to do but I don't know if 8.1khz of pic speed will be
enough processing power for you.>
leo.
  Leandro J. Laporta (LU2AOQ)
  mail: .....lu2aoqKILLspamspam.....yahoo.com
  wrk: Arg. Assoc. for Space Technology.
  ham: TCP/IP high speed group HSG

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...