Page 1 of 1
Power Down Modes PIC Help Needed
Posted: Sat Dec 29, 2012 12:45 am
by Jordy101091
Hi all,
I have been working on my Aquarium controller project for quite some time now, one of the last things I need to do is,
to make my wireless color sensor controller to go into some sort of power down mode where it consumes the least amount of current.
The microcontroller im using is the PIC16F76. But I dont have any idea on how to get this done.
The idea is as follow:
The sensor module needs to send every 15 minutes for 2 minutes long color information to the main controller. (so sleep for 15 minutes then wake up send for 2 minutes and back to sleep ect.)
But first I need to un init. the RF module and power down my color sensor.
Is this possible to do.
Let me know what you're thinking.
Regards Jordy
Re: Power Down Modes PIC Help Needed
Posted: Sat Dec 29, 2012 12:10 pm
by Jan Lichtenbelt
Dear Jordy,
Did you look in the datasheet of PIC16F76 to the SLEEP possibilities in e.g. chapter 12 and special chapter 12.14 Power-down Mode.
http://www.microchip.com/wwwproducts/De ... e=en010222
I hope this helps you.
Kind regrads
Jan Lichtenbelt
Re: Power Down Modes PIC Help Needed
Posted: Sat Dec 29, 2012 12:41 pm
by Jordy101091
Oké,
I hvae read the datasheet an a power-down mode is possible when executing a sleep command.
I think I need to put this into a c-code block
"Sleep();"
But the watchdog timer how does that work how can I set this in flow code.
Can you help me with this thanks.
Regards Jordy
Re: Power Down Modes PIC Help Needed
Posted: Sun Dec 30, 2012 6:22 pm
by Jordy101091
Oke I have figured out on how to execute a sleep command.
I need to fill this "asm Sleep" into a C-Code block.
The sleep function works verry well my aaplication now consumes 0.56mA which is great.
But I want to wake-up the device very 14 minutes where it send information for about a minute and goes back to sleep. This will create a cycle of 15 minutes.
For the interrupt I want to use the Watchdog timer in the datasheet of the PIC16F76 I have found that the Watchdog rollsover every 18ms.
To prevent this from happening I need what some other call it "Patting the dog"

I think I can do this with the following command:
clear_wdt();
Or
MX_CLEAR_WATCHDOG
But when I want a delay of 14 minutes which is 840000 milliseconds
840000 / 18 = 46667
Does this mean that I need to execute the clear watchdog command 46667 times.
What is the best way to accomplish this.
Regards Jordy
Re: Power Down Modes PIC Help Needed
Posted: Sun Dec 30, 2012 7:21 pm
by Mikat
Jordy101091 wrote:
But I want to wake-up the device very 14 minutes where it send information for about a minute and goes back to sleep. This will create a cycle of 15 minutes.
For the interrupt I want to use the Watchdog timer in the datasheet of the PIC16F76 I have found that the Watchdog rollsover every 18ms.
To prevent this from happening I need what some other call it "Patting the dog"

I think I can do this with the following command:
clear_wdt();
Or
MX_CLEAR_WATCHDOG
But when I want a delay of 14 minutes which is 840000 milliseconds
840000 / 18 = 46667
Does this mean that I need to execute the clear watchdog command 46667 times.
What is the best way to accomplish this.
Regards Jordy
Nope, you can't do anything when the device is in sleep, if you wtd wakes device every 18mS I think you need to do this, sleep -> wtd wakes device ->check counter, if below 46667 add counter by 1 -> sleep....-> wtd wakes device-> counter = 46667, exec the code, clear counter-> sleep.
But there is postscaler at the watchdog at the OPTION_REG register, where the wtd timer can be configured 1/128 at wtd clock (is it 31KHz ?), I don't know is the wtd timer 8 or 16 bit, but even in the 8 bit you should have something like second to wtd overflow... But I am not sure, the 16F devices are not so familiar to me..
But you can use timer 1 overflow too ,to wake device up at sleep...
T:Mika
Re: Power Down Modes PIC Help Needed
Posted: Sun Dec 30, 2012 7:22 pm
by kersing
Why don't you use timer1 in async mode to wake from sleep? (See page 49 of
the data sheet for more information.
Watchdog does not seem the appropriate mechanism for your application.
Re: Power Down Modes PIC Help Needed
Posted: Mon Dec 31, 2012 1:00 pm
by Jordy101091
I have read the datasheet,
And if im wright i need to have a external clock source other then the main clock because this is disabled in sleep mode.
I dont fully understand what I need to do here, what type of crystal do I need to connect, how do I enable timer1 in ASYNC mode and so on.
Regards Jordy