How to make 9V battery to last longer in my PIC Micro controller Circuit

Thread Starter

Faizan Zaheer

Joined Dec 20, 2017
8
Hello Everyone

I need some guideline in designing circuit powered by 9V battery so that it can last longer. I am using PIC Micro controller and four LEDs for indication. I have interfaced sensor, such that when user places object on it, the MCU powers the LED based on program written. The job of placement continues till the user wants to. My 9V battery has capacity of 400mAh and total current consumption of my circuit is 150mA when all of LEDs are in ON state.
In order to save energy I can go to sleep mode of micro controller after some time of inactivity. What are the other things are required just like Sleep Mode or Auto Power OFF to use for making it power saving as well?
Second, I am using Low Drop Out Voltage Regulator to power a circuit with regulated output of 5V, will this effect as the voltage regulator will also have power dissipation when regulating 5V from 9V?
 

danadak

Joined Mar 10, 2018
4,057
Is there power management on the chip to permit shutting off various
internal peripherals when not in use when not in sleep mode ? Modern
processors have this capability.

Regards, Dana.
 

ArakelTheDragon

Joined Nov 18, 2016
1,366
Is there power management on the chip to permit shutting off various
internal peripherals when not in use when not in sleep mode ? Modern
processors have this capability.

Regards, Dana.
There is. Its shutting down the analog modules in the initialization (NO_ANALOGS) so they don't drain energy.
 

ArakelTheDragon

Joined Nov 18, 2016
1,366
LEDs can probably come down to 5mA (or less) each and still do their job.
Even a normal LED will work at 0.3mA (0.0003A), but for us blind people now a days, it won't be so bright and it will be hard to see, unless you put the hand on it, an ultra bright LED will shine brighter, especially if you use sandpaper to whipe off the ultra bright LEDs ( I saw the sandpaper trick on youtube, I have not tested it).
 

AlbertHall

Joined Jun 4, 2014
12,653
Even a normal LED will work at 0.3mA (0.0003A), but for us blind people now a days, it won't be so bright and it will be hard to see, unless you put the hand on it, an ultra bright LED will shine brighter, especially if you use sandpaper to whipe off the ultra bright LEDs ( I saw the sandpaper trick on youtube, I have not tested it).
And flashing the LED will of itself reduce the power consumption and make a dimmer LED more noticeable.
 

ebp

Joined Feb 8, 2018
2,332
The first thing to do is to prepare a power consumption table so you can clearly determine where the power is going. A spreadsheet is useful for this, You need to do things like calculate the average current for each LED (e.g. if the LED requires 10 mA and is on for 5% of the time, then it's average current requirement is 500 µA)

People have mentioned the LEDs, but I am wondering about how much current the sensor requires. It may be the biggest overall power consumer if it is on continuously even if the processor is in sleep mode. It may be necessary to add control circuitry to turn off the sensor and just turn it on briefly often enough so as not to produce an unacceptable delay in the system response. That may be tricky, depending on the nature of the sensor. Some sensors can take a bit of time to stabilize after power is applied.

Once you know what the average power over time for the LEDs and the sensor is, then you can address whether trying to conserve as much power in the processor as possible will really be worthwhile.

There are many highly efficient integrated switch mode voltage regulars available. Some need only an inductor and two capacitors as external components. You should get at least 30% more operating time with the switch mode regulator. You need to choose one that is very efficient with a very light load to preserve overall efficiency if the system is in low power mode for much of the time.
 

MrSoftware

Joined Oct 29, 2013
2,273
If you want to know how much power each device in your system is actually taking, wire in some 1/4 or 1/2 ohm resistors and measure the voltage across them with a true RMS volt meter. Obviously remove these after debugging.

For the LED; By flashing he means PWM. You can often PWM an LED and it will look just as bright, or nearly as bright as an LED that is on continuously, however you will be saving power during the off time.

Also for your processor; you want to put the processor into low power mode as quickly and as often as possible. In a best case, connect your inputs to interrupts and put your processor to sleep until an interrupt wakes it. If the processor needs to actively check for inputs, then use a timer to wake it just long enough to check for inputs, then immediately go back to sleep. This way it actually spends most of its time sleeping and power drain becomes very small. Here's some code that fits with nordic processors, treat it as pseudo code and maybe you can apply the same general idea to your platform:

Code:
static volatile bool are_we_sleeping = false; /* This is set while we are sleeping, cleared by our wake up interrupt handler */
APP_TIMER_DEF(my_wakeup_timer); /* Declare our timer, your platform may use different syntax */

// This will be called when our wakeup timer expires
static void wake_up_interrupt_handler(void * p_context)
{
   are_we_sleeping = false;
}


// Create a timer that will wake us up from low energy state
void create_timer
{
    app_timer_create(&my_wakeup_timer, APP_TIMER_MODE_SINGLE_SHOT, wake_up_interrupt_handler);
}


/* Low power delay - set the wakeup timer for ms_delay milisec, then go to sleep for that amount of time */
uint8_t low_power_delay_ms(int ms_delay)
{
    // Start a timer that will wake up the processor via interrupt when the timer expires
    app_timer_start(my_wakeup_timer, APP_TIMER_TICKS(ms_delay, APP_TIMER_PRESCALER), NULL);
    /* Set the flag to indicate we're sleeping.  This will be cleared in the interrupt handler when we wake up */
    are_we_sleeping = true;

    /* Loop until our flag is cleared.  Note this loop will happen only once, see below */
    while(are_we_sleeping)
    {
        /* Put the processor to sleep.  Execution will stop here until we are woken up by the timer */
        power_manage();
    }
    return 0;
}

main()
{
    // Read our sensor 4x per second, entering low power state (sleeping) in-between
    while(1)
    {
        read_my_sensor();
        // Enter low power mode until we're ready to read again
        low_power_delay_ms(250);

    }
}
 

danadak

Joined Mar 10, 2018
4,057
There is. Its shutting down the analog modules in the initialization (NO_ANALOGS) so they don't drain energy.
How about the digital peripherals, UART, PWM, Counter/Timers.......?


Regards, Dana.
 

ebp

Joined Feb 8, 2018
2,332
A typical small PIC will require 4 or 5 mA with everything going with a clock of a few megahertz, not counting current from I/O pins. This is a small part of the maximum current in the application at hand. It isn't worth fussing about microamps here and there until a clear picture of where the rest of that 150 mA is going. 150 mA at 0.1% duty cycle is 150 µA. Scraping another 15 µA off of that is probably worthwhile. If the duty cycle is 1%, 15 µA is getting down into the "rounding error" realm.

Some PICs can be put into very low power mode. None of the digital peripherals require anything more than CMOS idle current if they aren't being clocked. Analog blocks like the comparators that use resistive dividers to set references and the brownout detector are bigger consumers.

===
"... measure the voltage across them with a true RMS volt meter. ..."
No, you want an averaging meter to measure average current. A LED operating with PWM at 50% duty cycle and 10 mA when ON requires an average current of 5 mA. The RMS current would be about 7.1 mA (I on x √d). The battery cares about the average, not the RMS (not 100% true because there will be some loss due to battery internal resistance that will be RMS dependent). The resistor in series with the LED cares about the RMS current in terms of heating, but that isn't the matter under consideration.
 

ebp

Joined Feb 8, 2018
2,332
Good point about average current. Probably most good RMS meters will also have an average function.
RMS is normally applied only to the AC functions. DC functions are "always" averaging. Some RMS meters will correctly read DC on the AC ranges (1 volt DC is 1 volt RMS, regardless of what Fluke says!) but others put blocking capacitors in the AC path so to get the true RMS value of a signal with "AC" riding on DC, you have to measure with both the AC range and the DC range and do the RMS summation (square each & take square root of the mean) the hard way - sometimes convenient, sometimes damned annoying.
 

MrSoftware

Joined Oct 29, 2013
2,273
I'm using a Fluke 87V and it has an actual "Average" function under the max/min feature that averages the readings over up to 36 hours. I'm not sure of the implementation details such as sample rate, etc.. But I believe this is what you want to use if calculating the average power draw over some period of time.

That aside; am I mistaken in thinking that you actually need an RMS voltage reading, because the current will be varying all over the place (such as with the processor changing power states multiple times per second, LEDs pulsing, etc..), and graphing the voltage across the resistor would give you a random looking curve varying between 0 and peak, not a nice solid line or square wave. Have I outsmarted myself here?
 

Thread Starter

Faizan Zaheer

Joined Dec 20, 2017
8
Use a buck regulator for the 9V to 5V conversion.
Reduce the LED current to the minimum acceptable.
Make the LEDs flash - while they are off they draw no current! - and this will also make dimmer LEDs more noticeable.
I have searched some buck regulator and I find the TI TPS6205x 800-mA Synchronous Step-Down Converter. I am using 9V 6F22 Zinc-Carbon battery.Does the battery composition effects the device operation and this TI buck converter is for Li-ion, Ni-Cd, Ni-Mh and for alkaline battery?
 

Ian Rogers

Joined Dec 12, 2012
1,136
Can I ask why you want to use a 9V battery... Far better results would be achieved using 2 or 4 AA batteries. Zinc has puny current compared to alkaline..

I use 2 x 1.5v batteries AA can give nearly 3Ah.. No rectifier... Using a new low power pic the system will work from 3 ~ 1.8 volts..
I use a small radio that works down to 1.8v... In sleep mode ( more than 99% of the time ) current consumption can be as little as 100nA..
 

Thread Starter

Faizan Zaheer

Joined Dec 20, 2017
8
Can I ask why you want to use a 9V battery... Far better results would be achieved using 2 or 4 AA batteries. Zinc has puny current compared to alkaline..

I use 2 x 1.5v batteries AA can give nearly 3Ah.. No rectifier... Using a new low power pic the system will work from 3 ~ 1.8 volts..
I use a small radio that works down to 1.8v... In sleep mode ( more than 99% of the time ) current consumption can be as little as 100nA..
My requirement is to power it from 9V so any battery composition will effect switching regulator operation or not?
 

Thread Starter

Faizan Zaheer

Joined Dec 20, 2017
8
Can I ask why you want to use a 9V battery... Far better results would be achieved using 2 or 4 AA batteries. Zinc has puny current compared to alkaline..

I use 2 x 1.5v batteries AA can give nearly 3Ah.. No rectifier... Using a new low power pic the system will work from 3 ~ 1.8 volts..
I use a small radio that works down to 1.8v... In sleep mode ( more than 99% of the time ) current consumption can be as little as 100nA..
Does changing the supply voltage will have effect on external crystal oscillator. I am using 16MHz Crystal Oscillator and I want it to run at 3.3 V instead of 5V?
 
Top