Searching \ for '[PIC]: Multitasking and timing' 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/microchip/ints.htm?key=multitasking
Search entire site for: 'Multitasking and timing'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Multitasking and timing'
2002\06\11@152835 by adam

flavicon
face
Hello,

I am trying to make a PIC16LF872 do multiple things at variable
intervals.

Let's suppose that I have eventA and eventB.  I want eventA to occur (it
could be making an output pin high, calling a procedure, whatever...)
every 26 seconds and eventB to occur every 35 seconds.  How do you guys
suggest I do this?

I want the PIC to be asleep when the events are not being fired.  Also,
the times given above (26 and 35 seconds) are just for illustration,
these will be variable from 1-300 seconds.

I was thinking of using the WDT with the prescaler and use some
computations to add a postscaler in accordance to the requirements, but
given the inaccuracy of the WDT (7-33 ms) it isn't very feasible.

Given the incredibly fast advancement of the timers (even with a
prescaler), this option doesn't sound very appealing either.  (The chip
will be running on a 4MHz clock.)

The only reasonable option I've come up with is a 555 timer giving me a
1Hz pulse to count off of.  The big downfall here is the power
consumption.  Not only will this be running off of 4 AA batteries, these
periodic events will be occurring 24 hours a day.

Any suggestions?

Thanks,
Adam Smith

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\06\12@015652 by Andreas Nyholm

flavicon
face
Hello!!

> I am trying to make a PIC16LF872 do multiple things at variable
> intervals.
>
> Let's suppose that I have eventA and eventB.  I want eventA to occur (it
> could be making an output pin high, calling a procedure, whatever...)
> every 26 seconds and eventB to occur every 35 seconds.  How do you guys
> suggest I do this?
>
I had this same problem some days ago and I did it with timer1 and all
prescaler possible. (When I used 20MHz I got ~0.1 sec.) Then I used
interrupts and increased an extra timer every interrupt. When that timer
was FF I got ~26 sec. If you need more than 26 sec you can have another
timer increasing every 26 sec.
I don't think you can use sleep with this, and I don't know how good this
idea is, but atleast it's one idea :)
Hope this helps!
Regards
Andreas
>
> Given the incredibly fast advancement of the timers (even with a
> prescaler), this option doesn't sound very appealing either.  (The chip
> will be running on a 4MHz clock.)
>

--
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


2002\06\12@021113 by Brendan Moran

picon face
You want really slow time delays, using sleep, correct?

My best suggestion on this one is to use an external clock generation
circuit.  Feed that into the CLOCKIN input, and feed it through several
hardware dividers.  You'll be able to drop the frequency by a few orders of
magnitude, then feed it into one of the counter inputs, which have
associated interrupts that operate in sleep mode.

Not all htat elegant as PIC based projects go, but it sure is effective,
and reduces coding difficulties. ;)

--Brendan Moian

--
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


2002\06\12@021314 by Pic Dude

flavicon
face
If variable from 1-300, and assuming that that means integers,
I'd say use TMR0 and divide accordingly in the ISR to get 1-sec
pulses.  Then maintain 2 counters -- one set to 26 and the
other to 35.  On every 1-sec pulse, decrement counter A and
perform whatever action when it hits 0.  Also reset it to 26.
ALSO, on the same 1-sec pulses, do the same for counter B and
reset to 35 when it hits 0 and you perform the necessary
actions.

Can't say how this would work using the WDT, but I don't feel
that it was designed for this purpose, where as TMR0 etc was.

Cheers,
-Neil.



{Original Message removed}

2002\06\12@022353 by Vasile Surducan

flavicon
face
Adam, your problem is easy because is dealing with wery slow events
Use your tmr0 to generate one second event as Roman show in:
http://www.ezy.net.au/~fastvid/one_sec.htm
if you need precisely events ( exactly at 26 and 36 seconds )
Let the second counter from isr routine to work as free counter.
In the main loop reset the second counter then increment it untill
the 26'th second. Compare your counter with a constant ( 26 ) and run your
event, then compare your counter with 35 and run the other event, then
reset the counter.
It's a less then 100 lines JAL program. And work very precisely.

regards,
Vasile
http://www.geocities.com/vsurducan


On Tue, 11 Jun 2002, Adam Smith wrote:

{Quote hidden}

--
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


2002\06\12@041037 by Andy Jancura

picon face
Adam,

may be Salvo (http://www.pumpkininc.com) can solve this.

A.

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

--
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


2002\06\12@103201 by Tim McDonough

flavicon
face
On Tue, 11 Jun 2002 14:15:51 -0500, Adam Smith wrote:
>
>I want the PIC to be asleep when the events are not being fired.
>Also, the times given above (26 and 35 seconds) are just for
>illustration, these will be variable from 1-300 seconds.

>I was thinking of using the WDT with the prescaler and use some
>computations to add a postscaler in accordance to the requirements,
>but given the inaccuracy of the WDT (7-33 ms) it isn't very
>feasible.

>The only reasonable option I've come up with is a 555 timer giving
>me a 1Hz pulse to count off of.  The big downfall here is the power
>consumption.  Not only will this be running off of 4 AA batteries,
>these periodic events will be occurring 24 hours a day.

An LMC555, the CMOS version of the venerable 555 timer, has a typical
current requirement of 0.1 mA @ 5VDC according to National's data
sheet. It's about 0.05 mA @ 1.5VDC. Also run the PIC as slowly as
possible for your application.

I've been looking at this for a current project too. In my case I would
like the system to wake up once every 15 minutes, check on things, and
go back to sleep.

Tim

--
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


2002\06\12@173059 by Jinx

face picon face
>The only reasonable option I've come up with is a 555 timer giving
>me a 1Hz pulse to count off of.  The big downfall here is the power
>consumption.  Not only will this be running off of 4 AA batteries,
>these periodic events will be occurring 24 hours a day.

Extremely low power with long-term accuracy. Only a little
more expensive than a 555, and you get a clock mech to
play around with after the surgery

http://home.clear.net.nz/pages/joecolquitt/lowpower.html

--
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


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