i used a PIC12F675 at 4 Mhz, and i have a problem to put him sleep and wake after 2 or 3 minuts, because the timers cant go so far. what i need to know is how to put the litle guy sleeping because he use a small batery, and after a (long time), 3 minutes or more, he wake and says "im a live" and back to sleep without increment a variable, verifing the variable and back to sleep again until the variable reach a specific value. this procedure empty the battery very fast. so.. if someone can give me some code example, i apreciate. Pleas help.
Sorry my bad, bad, bad english, im improved every day (i hope)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What is the sleep current value? Turning off pullups, timers, comparators, other outputs, and not having floating inputs etc. prior to sleep can save a lot. Check out the power down values in the electrical specs in the data sheet. You should be <10ua or so in sleep. For instance using the wdt is half the current of a timer during power down.
A 12f683 and the newer chips have an extended wdt period of 268 sec.
Good luck. Kent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thank you Kent, but that not solve my problem, i have no problem to put the pic sleeping and obtain lower current. The problem is wakup after a certain period, 3 or more minutes. But thank´s any way, i apreciate your replay.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you let the watchdog run while the PIC is sleeping, it can wake up the processor when it times out, say in 2 seconds if you use the watchdog clock prescaler. So every 2 seconds you'd wake up, increment a counter variable and go back to sleep. If the counter ever gets to a value corresponding to a 3 minutes (90 wakeups), then you can do what has to be done before going to sleep again. It seems to me that waking up, incrementing a counter variable and checking its value should only take a few tens of microseconds, so the additional current would only be (awaketime/watchdog interval) * operating current, probably only a few uA on average.
Joe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thank´s Joe, but that is what i try not to do. I want the batery stil in the circuit for about 3 years, it is possible, but if i try to incremet a variable, in a couple of weks the batery is drain. But is the second time i read something about the watchdog associated with timers,(interesting), and i have no ideia how can i use it. if you post a small code of using watchdog i apreciate. After all if i dont have more solutions, maibe this is a good ideia. 99% of the time the pic is sleeping. maibe 2 seconds work. thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
God, that´s what im loking for… thank you all for trying to helpme. some time the solution is near to us and we cant see. i understimated the search function on this forum. thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The steps would be:
1) Set up the watchdog pre-scaler and enable the watchdog
2) Execute a Sleep instruction
3) When the watchdog times out (2.3 secs later), it will wake up the PIC. Your wakeup code should increment a variable and check whether the value has exceeded a value of approx 78 (2.3 * 78 = 180 secs). If not, execute the Sleep instruction again.
4) If the timer variable has exceeded 78, then take whatever action is desired, clear the variable and execute Sleep again.
Assuming that your wakeup code only takes about 10usec, then the average current consumption will be about 1/230,000 of the power the processor draws when it is awake ( 2.3sec / 10e-6 sec). You should be be able to get it under 10ua total.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi folks,
i used a PIC12F675 at 4 Mhz, and i have a problem to put him sleep and wake after 2 or 3 minuts, because the timers cant go so far. what i need to know is how to put the litle guy sleeping because he use a small batery, and after a (long time), 3 minutes or more, he wake and says "im a live" and back to sleep without increment a variable, verifing the variable and back to sleep again until the variable reach a specific value. this procedure empty the battery very fast. so.. if someone can give me some code example, i apreciate. Pleas help.
Sorry my bad, bad, bad english, im improved every day (i hope)
What is the sleep current value? Turning off pullups, timers, comparators, other outputs, and not having floating inputs etc. prior to sleep can save a lot. Check out the power down values in the electrical specs in the data sheet. You should be <10ua or so in sleep. For instance using the wdt is half the current of a timer during power down.
A 12f683 and the newer chips have an extended wdt period of 268 sec.
Good luck. Kent
thank you Kent, but that not solve my problem, i have no problem to put the pic sleeping and obtain lower current. The problem is wakup after a certain period, 3 or more minutes. But thank´s any way, i apreciate your replay.
If you let the watchdog run while the PIC is sleeping, it can wake up the processor when it times out, say in 2 seconds if you use the watchdog clock prescaler. So every 2 seconds you'd wake up, increment a counter variable and go back to sleep. If the counter ever gets to a value corresponding to a 3 minutes (90 wakeups), then you can do what has to be done before going to sleep again. It seems to me that waking up, incrementing a counter variable and checking its value should only take a few tens of microseconds, so the additional current would only be (awaketime/watchdog interval) * operating current, probably only a few uA on average.
Joe
thank´s Joe, but that is what i try not to do. I want the batery stil in the circuit for about 3 years, it is possible, but if i try to incremet a variable, in a couple of weks the batery is drain. But is the second time i read something about the watchdog associated with timers,(interesting), and i have no ideia how can i use it. if you post a small code of using watchdog i apreciate. After all if i dont have more solutions, maibe this is a good ideia. 99% of the time the pic is sleeping. maibe 2 seconds work. thank you.
If your battery can run the circuit for 3 years (or whatever you desire) with a few ua load, then this method should work.
what metod????
@paulofgf16f877
Check out the search function, you will find a 12f675 wdt example code.
God, that´s what im loking for… thank you all for trying to helpme. some time the solution is near to us and we cant see. i understimated the search function on this forum. thank you.
Section 9.6 of the datasheet describes the watchdog timer (http://ww1.microchip.com/downloads/en/devicedoc/41190c.pdf). If you set the watchdog pre-scaler to 128 per the datasheet, then the watchdog will time out in 2.3 secs.
The steps would be:
1) Set up the watchdog pre-scaler and enable the watchdog
2) Execute a Sleep instruction
3) When the watchdog times out (2.3 secs later), it will wake up the PIC. Your wakeup code should increment a variable and check whether the value has exceeded a value of approx 78 (2.3 * 78 = 180 secs). If not, execute the Sleep instruction again.
4) If the timer variable has exceeded 78, then take whatever action is desired, clear the variable and execute Sleep again.
Assuming that your wakeup code only takes about 10usec, then the average current consumption will be about 1/230,000 of the power the processor draws when it is awake ( 2.3sec / 10e-6 sec). You should be be able to get it under 10ua total.