Power Down Modes PIC Help Needed

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Power Down Modes PIC Help Needed

Post 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
Attachments
Aquatronics_Sensor_Module.fcf
(40.32 KiB) Downloaded 256 times
the will to learn, should not be stopped by any price

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Power Down Modes PIC Help Needed

Post 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

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Power Down Modes PIC Help Needed

Post 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
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Power Down Modes PIC Help Needed

Post 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" :wink: 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
the will to learn, should not be stopped by any price

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Power Down Modes PIC Help Needed

Post 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" :wink: 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
Last edited by Mikat on Sun Dec 30, 2012 7:23 pm, edited 1 time in total.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Power Down Modes PIC Help Needed

Post 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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Power Down Modes PIC Help Needed

Post 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
the will to learn, should not be stopped by any price

Post Reply