Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

One Hour Delay during Sleep-Wake-Up (PIC)

Status
Not open for further replies.

Electrix

Member
How do I wake up my PIC (16F7x) from sleep after 1 hour. I know that the interrupts can wake it up and that the watchdog timer overflow can also wake it up, but no interrupts are used in my design, also the max limit on the WDT is less than 1min. Do I have to use Timer1 module, please explain ...

Thanks.
 
The only way how to wake the PIC up, is to use Interrupt! (or MCLR reset)
WDT is producing interrupt as well (or Reset if the PIC is not in sleep). Maybe you can use one 16bit timer and go to sleep/wake up multiple times, until 60 minutes will pass.
 
Jay.slovak said:
The only way how to wake the PIC up, is to use Interrupt! (or MCLR reset)
WDT is producing interrupt as well (or Reset if the PIC is not in sleep). Maybe you can use one 16bit timer and go to sleep/wake up multiple times, until 60 minutes will pass.

Can I not do a 60 minutes sleep continously ?? Can a Timer1 and CCP work together in a sleep with the oscillator clock stopped ?? I understand that the Timer1 has a max timing of 16 seconds of sleep-wakeup intervals, so timer1 is out of the question for continous 1 hr sleep
 
Is there a particular reason not to use Timer1 (and do 225 Wake-up cycles)? Or look for some sort of External wake-up source (such as 555 or other PIC), the PIC will sleep forever unless you wake it up. All you need is an interrupt.
 
Jay.slovak said:
Is there a particular reason not to use Timer1 (and do 225 Wake-up cycles)? Or look for some sort of External wake-up source (such as 555 or other PIC), the PIC will sleep forever unless you wake it up. All you need is an interrupt.

Well yes..I wanted the PIC to handle all the operations ..sort of a one man show..I am actually building an environment monitor that takes readings once in an hour, so thats why..
The guys at the Univ of Southampton managed this with a PIC 16F876, they actually had a 4 hour sleep time.
Ref: Environmental Sensor Networks by Kirk Matinez..et al.
 
Electrix said:
Jay.slovak said:
Is there a particular reason not to use Timer1 (and do 225 Wake-up cycles)? Or look for some sort of External wake-up source (such as 555 or other PIC), the PIC will sleep forever unless you wake it up. All you need is an interrupt.

Well yes..I wanted the PIC to handle all the operations ..sort of a one man show..I am actually building an environment monitor that takes readings once in an hour, so thats why..
The guys at the Univ of Southampton managed this with a PIC 16F876, they actually had a 4 hour sleep time.
Ref: Environmental Sensor Networks by Kirk Matinez..et al.

Are you sure they put it in sleep?, and if they did it's unlikely they had a four hour sleep time (unless they used an external signal to wake it). As already suggested, it's more likely the used TMR1 to wake it up MUCH more often, and counted the number of wakeups until four hours had passed. You can do the same with the WDT, but the WDT is very inaccurate.

I presume you're looking at sleep mode for power savings?, so I also presume everything else is absolutely zero power (or extremely low)?, or you're wasting your time putting it to sleep - a PIC when running is pretty low consumption anyway!.
 
Nigel Goodwin said:
Electrix said:
Jay.slovak said:
Is there a particular reason not to use Timer1 (and do 225 Wake-up cycles)? Or look for some sort of External wake-up source (such as 555 or other PIC), the PIC will sleep forever unless you wake it up. All you need is an interrupt.

Well yes..I wanted the PIC to handle all the operations ..sort of a one man show..I am actually building an environment monitor that takes readings once in an hour, so thats why..
The guys at the Univ of Southampton managed this with a PIC 16F876, they actually had a 4 hour sleep time.
Ref: Environmental Sensor Networks by Kirk Matinez..et al.

Are you sure they put it in sleep?, and if they did it's unlikely they had a four hour sleep time (unless they used an external signal to wake it). As already suggested, it's more likely the used TMR1 to wake it up MUCH more often, and counted the number of wakeups until four hours had passed. You can do the same with the WDT, but the WDT is very inaccurate.

I presume you're looking at sleep mode for power savings?, so I also presume everything else is absolutely zero power (or extremely low)?, or you're wasting your time putting it to sleep - a PIC when running is pretty low consumption anyway!.

Hi Nigel
Yes, my aim is to put the PIC and the rest of my circuit in low power mode so that I can leave it unattended for days (or months). I have read that when the PIC is running with A/D on, oscillator running at high freq and with UART doing some exchanges the power level of the battery would deteriorate more quickly, as you can guess I have all these features on, so thats why sleep mode is good.

Suppose I do use the mutiple sleep-wakeup method to extend the delay, how can I count the number of wakeups? Would it be like..Sleep-ISR(cnt 1)..Sleep-ISR(cnt 2)..and so on, that is to say an ISR within an ISR and so on till the Count reaches a threshold..?
 
Electrix said:
Yes, my aim is to put the PIC and the rest of my circuit in low power mode so that I can leave it unattended for days (or months). I have read that when the PIC is running with A/D on, oscillator running at high freq and with UART doing some exchanges the power level of the battery would deteriorate more quickly, as you can guess I have all these features on, so thats why sleep mode is good.

Yes, sleep mode will significantly reduce the PIC's consumption, but my point was that the rest of the design needs designing on the same basis - for instance there's no point putting a PIC in sleep mode if you have a 7805 regulator powering it, the power used by the 7805 is so much greater then the PIC's requirements.

Suppose I do use the mutiple sleep-wakeup method to extend the delay, how can I count the number of wakeups? Would it be like..Sleep-ISR(cnt 1)..Sleep-ISR(cnt 2)..and so on, that is to say an ISR within an ISR and so on till the Count reaches a threshold..?

You don't use sleep in an ISR, that would be asking for trouble, particularly with the very small stack size in a PIC!. The sleep command is in the main program, so your program initially starts and sets everything up, plus a value in a counter (it could be zero and count up, or it could be a specific value and count down, you might also need to use more than a single 8 bit GPR). Once it's setup the main program then executes a sleep instruction, and the PIC goes to sleep. When the timer times out an interrupt is called, and the PIC wakes - the interrupt routine either increments or decrements the previously mentioned counter, then exits (RETFI). The main program is then running, which simply checks the counter value, if it's time? then do your readings, if not then sleep again. When it does timeout, you should first disable the tmr1 interrupt (to prevent any further ones while you do your readings), and reset the counter, ready for sleep again after the readings.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top