CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Reducing current drawn from battery?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

Reducing current drawn from battery?
PostPosted: Wed Jul 20, 2005 5:03 am     Reply with quote

Hi

I would like to reduce the power drawn by the PIC16LF873 from a battery. I am doing A/D on two channels, and flashing an LED (to show that the circuit is active).
I am drawing approximately 2.2mA of current.

Are there standard (and not standard) things to do to limit this current draw?

Thank you in advance
Regards
arrow

PS I found that timing the pulse width with interrupts, instead of A/D, draws approximately 1.45mA.
Douglas Richard



Joined: 08 Sep 2003
Posts: 49
Location: Concord NH

View user's profile Send private message Send e-mail Visit poster's website

lower power
PostPosted: Wed Jul 20, 2005 6:08 am     Reply with quote

Slow down your oscillator. When you are not doing anything place micro in sleep mode. Don't use internal pull ups on IO ports. Use a micro that takes advantage of nanowatt technology. Shut everything down you are not using (timers). FLash the LED less often if it is just for power indication.

Hope some of this helps.
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Wed Jul 20, 2005 6:14 am     Reply with quote

Hi Douglas

Thank you for your suggestions. I am not sure what you mean by "dont use internal pull ups"?

Do I have to set all the pins to L upon startup- will that help?
What do I do with the unused pins? (right now they are unconnected)

Also, is there any way to go into sleep mode, and still flash the LED?
Is there any way to go into sleep mode for say 5ms exactly?

Once again thank you
Regards
arrow
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Wed Jul 20, 2005 6:26 am     Reply with quote

Hi

If I were to go from a 4MHz Xstal, to say a 3MHz Xstal, how much less power will be consumed?
Is there a way to work this out?

Thank you
Regards
arrow
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Jul 20, 2005 6:56 am     Reply with quote

arrow wrote:
Hi Douglas

Thank you for your suggestions. I am not sure what you mean by "dont use internal pull ups"?

Do I have to set all the pins to L upon startup- will that help?
What do I do with the unused pins? (right now they are unconnected)

Also, is there any way to go into sleep mode, and still flash the LED?
Is there any way to go into sleep mode for say 5ms exactly?

Once again thank you
Regards
arrow


If you read the manual, i think PORTB has internal pullups. I think the compiler disables them by default, but you might want to add the extra instruction to do so as well to be sure they are off.

Unconnected pins can be driven as outputs (either high or low, who cares, i dont think it makes a difference in current draw).

How often do you want to flash the LED? If it is every, say 1 second, you can scale your wdog timer to time out and wake you up, toggle your LED, and go back to sleep again. Remember, a wdog timeout while your PIC is awake will cause your PIC to reset, while a timeout while your PIC is sleeping will merely wake up your PIC and continue executing from the instruction after SLEEP.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Jul 20, 2005 6:58 am     Reply with quote

Quote:
I am not sure what you mean by "dont use internal pull ups"?
Port B has internal pull up resistors and some chips also on port A. On most chips these are enabled on startup. Disbale the resistors by calling port_b_pullups(FALSE).

Quote:
Do I have to set all the pins to L upon startup- will that help?
What do I do with the unused pins? (right now they are unconnected)
Many discussions can be found on the internet about what is the best thing to do with unused ports. General concensus is that unconnected inputs are a very bad thing in CMOS circuits as this will cause a high current consumption.
Explanation: CMOS only dissipates energy when switching. The Open input voltage will float to about half the Vcc voltage and by induced noise will switch very fast between H/L, causing the high current consumption. Sometimes you will hear people say 'my circuit uses xxx mA but when I touch the pins of my microprocessor the current drops'. Now you know why.

Easiest thing to do is to program the pin as a logic low output. Low or high is not important for current consumption, except in cases of accidental short-cuts where a high output level is more likely to cause damage to the chip.

What I do in my circuits is to connect a 100k pull-down resistor to the unconnected pins and then program the pin as an input. Programming the pin as an input has the advantage of not using any current, even in the case of an accidental short cut. The pull-down resistor gives the input a defined value and has the advantage that in the future I can change this pin to an output without even having to remove the resistor (always a nice feature for after production bugfixes).

Quote:
Also, is there any way to go into sleep mode, and still flash the LED?
Is there any way to go into sleep mode for say 5ms exactly?
You can use the watchdog timer to recover from sleep. The watchdog timer is not very accurate and differs a lot between different chips. Search this forum for more threads on this issue.

In case the 5ms timing is critical you might consider to use Timer1 as an oscillator by connecting a 32kHz crystal to the Timer1 inputs. I never seriously looked into this but it is supposed to make it possible to switch between two clock frequencies.

Quote:
If I were to go from a 4MHz Xstal, to say a 3MHz Xstal, how much less power will be consumed?
Is there a way to work this out?
As a rule of thumb the power consumption scales lineair with the clock frequency, half the clock frequency means half the current. Check figures 16-1 to 16-10 in the datasheet. In these figures you see that the voltage supply has also a major impact on the current consumption, the lower the voltage the better. Up to 4MHz you can run the LF processor from as low as 2,0V.
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Jul 20, 2005 6:59 am     Reply with quote

arrow wrote:
Hi

If I were to go from a 4MHz Xstal, to say a 3MHz Xstal, how much less power will be consumed?
Is there a way to work this out?

Thank you
Regards
arrow


A 3Mhz crystal will cause you to draw less current, but i don't think the datasheet gets into all that detail. You'll have to solder one in and measure current with a Fluke DMM to get an exact number to compare with.

One thing to note is that using an external clock (such as a crystal or oscillator) draws significantly less current than using the internal oscillator. I tried that on two occasions and have noticed several uA difference in current draw.
Guest








PostPosted: Wed Jul 20, 2005 7:19 am     Reply with quote

I believe you can also sleep right after giving the ADC command. After the conversion is done the micro will wake back up. Enableing an ADC interrupt may be needed to do this (I have not tried this myself).
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Jul 20, 2005 8:21 am     Reply with quote

One more note on clock frequency. If you can design your program so that the processor goes to sleep when it has nothing to do, then the clock frequency is not very important. With a fast clock the work is finished more quickly and the processor sleeps longer, this gives about the same current consumption as when using a slower clock which requires more time to do the same job before going to sleep again.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group