View previous topic :: View next topic |
Author |
Message |
info@ckmintech.com
Joined: 16 May 2006 Posts: 39
|
Sleep mode and wake up |
Posted: Thu Jul 27, 2006 2:59 am |
|
|
In order to save power, I need to set the cpu to sleep for 30 seconds and self wake up (not by external interrupt). Ex_wakeup is using external interrupt which is not suitable for my application.
Is there any advise.
Thanks |
|
|
Ttelmah Guest
|
|
Posted: Thu Jul 27, 2006 4:52 am |
|
|
Basically, you can't do this, with any accuracy. The only 'wakeup' available to you, without using an external source of some sort, is the watchdog, and the timing accuracy of this is very poor (up to about 3:1 variation between chips, over the full temperature/voltage range). The possible times, also exclude 30 seconds. You can build a clock, based on an external 32768Hz crystal on a timer, but obviously, this will need to use the pins for this timer.
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Jul 27, 2006 6:35 am |
|
|
The problem with going to sleep is that the main oscillator is stopped and all internal timers become non-functional. Waking up from sleep based on a certain elapse then leaves only a few options open:
1) An external wake-up signal, for example the alarm output of a real time clock chip.
2) An additional hardware oscillator circuit connected to the timer1 pins. Make this low frequency, for example 32kHz for low current consumption.
3) Abuse the watchdog circuit. As Ttelmah already mentioned this has a very wide accuracy spread. To create longer time-out periods you can add a software based counter.
Most of the newer nanoWatt PIC processors have additional sleep modes allowing you to go into a half-sleep mode where the CPU-core is stopped but the peripherals and main oscillator continue to run. This way you can create an accurate sleep interval but at the cost of consuming more power than deep-sleep. |
|
|
info@ckmintech.com
Joined: 16 May 2006 Posts: 39
|
Sleep mode and wake up |
Posted: Thu Jul 27, 2006 7:53 am |
|
|
Thanks. We are using PIC18F1220 that provides nanoWatt. Can you give me a source code example how to turn on the half sleep mode. |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Thu Jul 27, 2006 10:38 am |
|
|
Code: | #byte OSCCON = 0xFD3
#define OSCCON_IDLEN_BIT 7
bit_clear(OSCCON, OSCCON_IDLEN_BIT);
sleep(); |
This puts the chip into 'IDLE' mode (CPU stopped, timers running) Consult the datasheet about the 'power managed modes'.
Though I would suggest to use the low power Timer1 oscillator with an external 32768Hz crystal, this would need no IDLE mode, it can be turned on-off independently. |
|
|
Guest
|
|
Posted: Thu Jul 27, 2006 10:59 pm |
|
|
CCS already provides for this (although it isn't very well explained)
setup_oscillator(OSC_IDLE);
sleep(); |
|
|
lorenzomercatali
Joined: 16 May 2006 Posts: 1
|
POWER MODE |
Posted: Thu Aug 03, 2006 3:30 am |
|
|
I all, i am working with power mode too and i have this problem.
I put my pic in sleep and idle modecorrectly but i observe a great consumption of current:
sleep 19 mA
idle 23 mA
run mode 32 ma.
I suppose i forget some instruction before putting the micro in sleep......
Do you know the exact procedure to reduce the current consumption?
Thanks in andvance.
Lorenzo. |
|
|
Ttelmah Guest
|
|
Posted: Thu Aug 03, 2006 3:55 am |
|
|
If full 'sleep', is drawing 19mA, then the problem is the other circuitry round the chip. There are a whole series of things to remember for low power consumption:
1) Voltage regulators wll often have significant quiescent consumption. You need to select types for these, and all other 'support' parts that are low power.
2) Any ouput that is driving a signal, will still draw power when the chip is stopped. You need to ensure that each line is taken to the state that turns off external components, and draws the least power, before sleeping.
3) A _floating_ input, can draw noticeable power (at the 'transition' point, where the gate changes state, this can be significant). Either have inputs biased with a high value resistor, or ensure that external circuits are driving them, before sleeping.
4) There is a 'balancing act', with external oscillators. These give fast wake up (the internal crystal oscillator takes a _long_ time to wake up properly), but these typically draw significant current.
Best Wishes |
|
|
s.jaglowski
Joined: 14 Nov 2005 Posts: 14
|
|
Posted: Thu Dec 07, 2006 1:44 pm |
|
|
An alternative is to use a nanowatt with ULPWU (16F688); this uses an RC load under controlled discharge of ~200nA.
Again, the accuracy can be good for any particular machine and RC combination, but tuning software may be required for anything using significant production runs, because of the tolerances available on low cost, low leakage capacitors.
Regards,
Steve Jaglowski |
|
|
Carlos Junior
Joined: 08 Dec 2006 Posts: 2
|
|
Posted: Fri Dec 08, 2006 5:36 am |
|
|
To wake only after 30 seconds and NOT with the external interrupts (or the buttons) you could configure the WATCHDOG to wake up the PIC ... And, to NOT wake up with the external interrupts, you could put an external circuit between the PIC and the buttons, like a 2 inputs AND gate which has one input at the button and the other at a pin of the pic with the 0 (zero level) signal, and the output at the external interrupt pin of the PIC, then any push at the button will not have effect at the pin of the PIC... After, when the PIC has already woken up you can put the 1 signal (level one) to the AND pin and make the external interrupt work again ! _________________ Carlos Junior
(carlosjunior@gmail.com)
Electrical Engineer
Location: Brasil |
|
|
|