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.

Sleep Function

Status
Not open for further replies.

parimi

New Member
Hi,

I am new to programming stuff. Can anybody help me out with this problem. I need to transmit the data once in 15 sec. In order to save battery life i am sending the controller into Sleep mode.
As of now the sleep function i am using is like this :

SETUP_WDT(WDT_288MS);
RESTART_WDT();
SLEEP();

My question is can we setup the WDT to 14 sec or is their any maximum limit to the WDT??

Or any other solution to this problem?

I am using PIC16F627.

Waiting for ur update....
thanks,
parimi. :)
 
Keep the WDT at 288mS and use a counter to work out when 15 seconds is up. If you want it accurate then add 288 to a variable until it reaches 15000.

The cost in terms of battery usage will be minimal.

Mike.
 
Thanks for the update Mike.
After completing the 288ms the WDT will generate a WDT wake up (read from the datasheet). So the program comes out of sleep. Is there any use in providing a counter?
 
The counter is so you know to either go back into sleep mode or send the data. Did I misunderstand your question?

Mike.
 
no. Last time i couldn't get what u r staying. I got u this time.
I will use a counter and see.
Thanks for the update Mike.
 
any idea how to convert the time into a counter??
how to find equivalent counter number for 1 sec..
time Vs number..

i thought for some time and couldnt find any answers..
so help needed again
 
First off, the WDT isn't at all accurate - far, far from it - it's not intended to be.

But assuming you're getting regular wakeups from it every 288mS, then if you count ten of them you get 2.88 seconds.

What EXACTLY are you trying to do, and why?.
 
I thought about that but i should check the WDT flag every time. This will increase futher more steps. Did u hear about crontab? Is it what i am looking for..??

i don't know what it is...
if this links the time and numbers then i will google it and see..
 
sorry goodwin

i didn't see ur questions..

i have mentioned it in the first post.
i will elobarate it here..

the program has to send data to the reader circuit for every 15sec. As the transmission ends battery cannot be changed regularly. We want it to be minimum.
 
parimi said:
sorry goodwin

i didn't see ur questions..

i have mentioned it in the first post.
i will elobarate it here..

the program has to send data to the reader circuit for every 15sec. As the transmission ends battery cannot be changed regularly. We want it to be minimum.

Yes, but how accurate does the 15 seconds need to be?, by using the WDT it can vary from roughly 7.5 seconds to 30 seconds - that's all the accuracy it gives, varying a LOT with temperature.

What current is the rest of your circuit taking?, if you run the PIC at a low clock speed it's got very low consumption anyway - if the rest of your circuit takes any appreciable current, using sleep mode probably isn't going to save you anything worthwhile?.

Perhaps you could post your circuit?.
 
Nigel Goodwin said:
Yes, but how accurate does the 15 seconds need to be?, by using the WDT it can vary from roughly 7.5 seconds to 30 seconds - that's all the accuracy it gives, varying a LOT with temperature.

I have never heard that the WDT will vary. Where can i get more information about it?

I calculated the current consumptions. If we can send the controller to sleep our battery life increases by one month.
 
parimi said:
I have never heard that the WDT will vary. Where can i get more information about it?

Read the datasheet, there are usually graphs towards the end showing frequency drift with temperature and supply voltage.

I calculated the current consumptions. If we can send the controller to sleep our battery life increases by one month.

So I take it the rest of the circuit takes next to no power then?.
 
i will read from the datasheet

other circuits will be off during the sleep
still i have to do some research on some issues..

:(

thanks goodwin..
 
Last edited:
i have seen the graphs. What u said is true.
The difference may be 5 to 15ms for every loop.

Is their anyway that i can use sleep without oscillator?
Now i am not using any external oscillator.

what is the maximum limit to the WDT??
The datasheet says 2.3 seconds.
 
The WDT is temperature sensitive and makes for a horrible clock timebase. The WDT was designed to get your PIC out of a program lockup.
The right way to do it is add a 32768Hz crystal on Timer1's oscillator pins. This will interrupt / wakeup the PIC every 2 seconds (programmable see my Dragonfly documentation for an example)
Also make sure to turn off internal peripherals as they draw power.
Some PICs like the 16F88 have an enhanced WDT which can be programmed for up to 4 minutes.
 
Last edited:
Before any efforts or the "addition" of parts to aid in a problem, first measure the Full main line power consumption without sleeping to get a baseline. Then measure Full main line power consumption with the PIC in sleep mode as a comparison. Repeat for each existing devices. Once whatever device is found to be the biggest contributor of power consumption then target it, be it PIC or da..da.. da...
 
thanks bill.. :)

This is a stupid question to ask but i have to ask..

Can i use the timer1 without external clock? The datasheet says timer1 should have a oscillator . But as i have made my PCB already in bulk with no external clock, is there any change of using Timer1 without osc?
 
donniedj said:
Before any efforts or the "addition" of parts to aid in a problem, first measure the Full main line power consumption without sleeping to get a baseline. Then measure Full main line power consumption with the PIC in sleep mode as a comparison. Repeat for each existing devices. Once whatever device is found to be the biggest contributor of power consumption then target it, be it PIC or da..da.. da...

As i said before in my post i have done calculations for the power consumptions part. First i am targeting the PIC and then DC to DC convertor IC.
:)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top