Tips on minimizing power

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As my first AVR project, I am building a nightlight. The schematic is simple: the MCU (I use an ATTiny85) consults a DS3231 (real-time clock on I²C bus), and depending on the answer, lights up either zero or one of two LEDs on the board (a white one or a yellow one). (I already have a working prototype for this). Ideally, the transition from one LED to the other should be doone smoothly (via PWM).

 

However I intend to build this as a battery-powered project (Li-Po battery; 3.7 V) and so I would want to minimize power as much as possible.

 

For minimizing the power consumption of the MCU itself, in addition to the standard tricks (e.g. those listed on www.gammon.au/power) I understand that I could put it in POWER_DOWN sleep mode and rely on the DS3231's alarm to wake it up, via the RESET pin, the next time it has to do anything.

 

For the LEDs, instead of limiting the current with a resistor I plan to use some variant of a buck converter to step the voltage down to about 1.8-2V. I see three possibilities for this:

 

(a) I could try plugging directly the LED to an output pin set to PWM (say, in series with an inductor to smooth the current). This uses the fewest parts (and is therefore probably quite efficient power-wise), is slightly risky (but not too much, and LEDs are cheap enough that I can test for the right PWM setting). This prevents me from using POWER_DOWN on the MCU, however.

 

(b) A “cleaner” variant would use the PWM output to do a proper synchronous buck converter. This uses more parts than (a), and is safer, but could end up more inefficient as well.

(c) Finally, I could also use an independent (asynchronous) buck converter (I hear that there exists some chips that do it), and simply use the output pin to drive the LED via a MOSFET. I would have more losses in the converter, but the MCU would not need to be active and could use a sleep mode.

 

As a final point, white and yellow LEDs don't have the same V-I characteristic: I probably need to drive the yellow one at about 1.8V and the white one at about 2.4V.

 

Is there anything obvious I missed?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Circonflexe wrote:
lights up either zero or one of two LEDs
Circonflexe wrote:
want to minimize power as much as possible.
Those two statements seem to be at odds with one another. While I guess you can do what you can to reduce a mA to a few uA for the micro itself that is going to pale into insignificance compared to the consumption of the LEDs so the best effort is probably expended in finding the most efficient LEDs you can.

 

What physical size is planned - IOW how many mAh can you squeeze into the LiPo ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why would you need an RTC chip? at all   If it is dark(er) turn on(increase) the nightlight, if not turn it off.

Running a PWM, switching losses, etc....maybe just a variable linear regulator would be better for you.

May be with a few opamps, no AVR is needed at all.   This is a nightlight, not a dishwasher.

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

While I guess you can do what you can to reduce a mA to a few uA for the micro itself that is going to pale into insignificance compared to the consumption of the LEDs so the best effort is probably expended in finding the most efficient LEDs you can.

 

What physical size is planned - IOW how many mAh can you squeeze into the LiPo ?

 

1. Of course I'm not going to scrape the last few μA when I'm dropping about 20mA on the LED. On the other hand some of these measures will have a noticeable effect: according to the site I linked to, they will save on the order of tens of mA, which is about as much as one full LED. Moreover, the LEDs will not be switched on all the time, but only during the night and the nap time: in all, only about 12 to 16h a day (depending on the precise schedule I program). This means that efficient handling of the MCU should about double battery life.

 

2. And my main point in my original post was indeed not about saving power on the MCU, but on using the MCU to save power on the LEDs themselves. Using current-limiting resistors wastes about 50% of the power (from a 3.7V battery). Surely with PWM we can do better than that.

 

avrcandies wrote:

Why would you need an RTC chip? at all   If it is dark(er) turn on(increase) the nightlight, if not turn it off.

Running a PWM, switching losses, etc....maybe just a variable linear regulator would be better for you.

May be with a few opamps, no AVR is needed at all.   This is a nightlight, not a dishwasher.

 

 

I need an RTC chip because this is not a brightness-controlled clock, this is a time-controlled clock. (If you really want to know, this is for indicating to the younger ones when to wake up and when to sleep).

 

Last Edited: Fri. Nov 29, 2019 - 05:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

this is for indicating to the younger ones when to wake up and when to sleep).

How is an led going to wake you up?  Maybe a buzzer would be more noticeable.

 

If the led is running 20ma nearly all day, you'll be changing batteries very often...why not plug it in & avoid the annoyance? 

You can buy a 2 watt wall-wart for next to nothing.

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Circonflexe wrote:
Using current-limiting resistors wastes about 50% of the power (from a 3.7V battery).

Yes, a current-limiting resistor can waste a lot of power.

 

Circonflexe wrote:
Surely with PWM we can do better than that

With the AVR's PWM, you'd still need something to limit the current during the 'on' phase.

 

What you need is a proper controlled current source.

 

There are LED-driver chips which do exactly this

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What you need is a proper controlled current source.

If it is linear, it will be about as wasteful (or maybe a little more), than a resistor.

An inductor circuit might save some power (but the switcher takes a little power itself to run).  It needs to be a micropower switcher, since the load itself is only milliamps.

 

http://www.ti.com/lit/ds/symlink/tps62736.pdf

 

The battery should be completely drained, to avoid wasting it (unless it is rechargeable).

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
If it is linear, it will be about as wasteful

Yes, that's true.

 

But most are switchers - and are pretty efficient.

 

Many are designed specifically for this kind of application - (LEDs on batteries).

 

You don't want the ones designed for "off-line" (ie, mains) applications!

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Surely with PWM we can do better than that.

Yes and no.

 

The PWM signal is either fully on, or fully off.

So it is useful for dimming an LED, as one can change the duty cycle from 0 % to 100 % and the LED will be on 0 % up to 100 %.

 

But when the PWM signal is high, (on), one still needs to control the current into the LED.

 

As mentioned, a constant current LED driver chip is likely the way to go.

 

Designing a constant current source is a good project by itself...  (Current sense resistor, op-amp, pass transistor, etc.).

Using a linear voltage regulator configured as a low current, constant current source is certainly possible, also, but by then one might just as well use a chip that was purpose built for this.

 

I suspect you need to look more into your LED selection, also, (as already mentioned above).

Running a LED at 20 mA is 20 year old technology.

These days there are very bright LEDs that run on 1/10th that!

(Talking about small indicator LEDs, not power LEDs for room or vehicle lighting!)

 

Sounds like an interesting project.

 

What is the location of the night light such that Mains power isn't available?

 

After you design and build version 1 and version 2, I suspect you might end up with version 3 being Mains powered!

 

JC

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

 

Designing a constant current source is a good project by itself...  (Current sense resistor, op-amp, pass transistor, etc.).

 

 

 

I was thinking on the lines of “feed PWM through a low-pass filter”. This has the advantage of requiring only a few passive components.

Of course this depends on the load, and a LED is highly non-linear, which complicates modelization.

 

Edit: I wrote a short SPICE simulation (using a LED model “found on the Internet”), which says that this should be fine:

.TITLE Filtering PWM through low-pass LC filter + LED
.model LED D (IS=1a RS=3.3 N=1.8)
L1  1 2 100u
C1 2 0 10u
D1 2 0 LED
.OPTION OUT=80
* Make a frequency-domain plot to show cut-off frequency:
Vin 1 0 AC 3.7
.PLOT AC  VDB(2)(-30,0)
.AC 1k 100k decade 3
.DELETE Vin
*PWM signal at ~ 16 kHz with 33% duty cycle:
Vin 1 0 PULSE(IV=0 PV=3.7 PERIOD=60u WIDTH=20u)
.PRINT TRAN V(1) V(2) I(D1)
.TRANSIENT 0 .001 .0000001 > a.dat

 

 

 

 

Quote:

Running a LED at 20 mA is 20 year old technology.

These days there are very bright LEDs that run on 1/10th that!

 

I admit that I did not plot the V-I characteristic of my LEDs! The order of magnitude comes from a quick Internet look-up (I use cheap 3mm LEDs bought on Aliexpress; these don't come with a datasheet) and might be outdated. I will measure their current load tomorrow.

 

Quote:

What is the location of the night light such that Mains power isn't available?

 

 

After you design and build version 1 and version 2, I suspect you might end up with version 3 being Mains powered!

 

The night light will be mains-powered most of the time, but I want it to have as much autonomy as possible in case I need to set it up in a temporary location. Also while writing the code, I realized that there are several ways of achieving the result, and one good way to decide is to select an efficient one (instead of my current prototype, which busy-waits for 1s between each poll of the DS3231 — this works for test purposes, but is about the most inefficient design possible!).

Last Edited: Sun. Dec 1, 2019 - 12:12 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Actually white LEDs are usually blue ones coated with a rare-earth phosphor. So, they drop about 3V, meaning you don't waste much energy if you use a resistor for current limiting.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have a clear idea about this project?  A nightlight that wakes someone up?  How? Maybe batt powered, but maybe not.  

It is best to get a firm idea of what you want the thing to do first & carefully weight th choices.

 

nd a LED is highly non-linear, which complicates modelization.

A led optical output power is very linear with respect to current.   Increasing from 3 mA to 6 mA  will give almost exactly double the output (until reaching the illuminating limit of the led). There may be a slight temperature effect, but it will still be close to 2x.

What is not linear is that your eyes have a "log" response, which depends upon color, contrast, alcohol, time, etc. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, I tried a few more simulations of this, and the answer seems to be “it's doable, but this needs some good values for the LC circuit”.

 

A back-of-the-envelope computation first: this is a resonant oscillator with time constant √LC, so the LED will flicker at the corresponding frequency. On the other hand, this oscillator must average several periods of the PWM signal, so √LC must be greater than the PWM period, which can be about 60μs. A f=1kHz oscillator seems fine.

To compute appropriate values of L and C, we need another equation, and that is given by the maximal current through the system. The maximal energy of the system is 1/2 Limax2 = 1/2 C umax2. Solving for umax ≈ 3.4V, imax ≈ 20mA and √LC =1/f ≈ 1ms gives L=umax/(f· imax) ≈ 170 mH and C=imax/(f ·umax) ≈ 6 μF. Such an inductor is quite unreasonable hower; a more realistic circuit could use e.g. L=10mH and C=L(imax/umax)2 ≈ 350 nF, for a resonating frequency of 16kHz.

 

I tried simulating this with SPICE models for a typical Si-C blue LED (Vf=3.4 V) and found that L=10mH and C=1μF give a quite steady output of a few milliamperes through the voltage source. This is not too far from what I computed (the difference probably being due to the fact that I did not really include the LED in my model!). Here is the SPICE code (actually gnucap):

.TITLE Filtering PWM through low-pass RLC
*Typ RED GaAs LED: Vf=1.7V Vr=4V If=40mA trr=3uS
.MODEL RedLED D (IS=93.2P RS=42M N=3.73 BV=4 IBV=10U
+ CJO=2.97P VJ=.75 M=.333 TT=4.32U)

*Typ RED,GREEN,YELLOW,AMBER GaAs LED: Vf=2.1V Vr=4V If=40mA trr=3uS
.MODEL YellowLED D (IS=93.1P RS=42M N=4.61 BV=4 IBV=10U
+ CJO=2.97P VJ=.75 M=.333 TT=4.32U)

*Typ BLUE SiC LED: Vf=3.4V Vr=5V If=40mA trr=3uS
.MODEL BlueLED D (IS=93.1P RS=42M N=7.47 BV=5 IBV=30U
+ CJO=2.97P VJ=.75 M=.333 TT=4.32U)

D1 2 0 BlueLED
L1 1 2 10m
C1 2 0 1u

*Crude plot of transfer function:
.OPTION OUT=80
Vin 1 0 AC 3.7
.PLOT AC  VDB(2)(-30,0)
.AC .5k 50k decade 5
.DELETE Vin

*PWM signal at ~ 16 kHz with 33% duty cycle:
Vin 1 0 PULSE(IV=0 PV=3.8 PERIOD=60u WIDTH=50u)
.PRINT TRAN V(1) V(2) I(D1) I(Vin)
.TRANSIENT 9m 10m 1u > a.dat

And here is the plot of voltage and current as functions of time. The average current is quite sensitive to PWM duty cycle; this is reasonable, because we are trying to average the voltage to the Vf of the diode.

 

The total cost for the two passive components is about 10 cents, and since they are purely reactive this should dissipate almost no power (zero with ideal components).

On the other hand, for a yellow LED I needed to manually ad a damping resistor (about 2Ω were enough) in series with the inductor.

 

Before I fry a few ATTinys and LEDs: did anybody try this already?

Last Edited: Sun. Dec 1, 2019 - 07:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Circonflexe wrote:
Before I fry a few ATTinys and LEDs: did anybody try this already?

 

Can you post a schematic of your planed circuit? The chances of frying a pin are particularly large if it is connected directly to an inductor.

 

But I suppose as long as the pin doesn't go high impedance while the inductor has current, it should be more or less fine.

Last Edited: Mon. Dec 2, 2019 - 12:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Put a couple leds in series, so you run at a high voltage (say 6 or 7 V).  The build a cheap boost circuit

 

 

Now you can run the battery really really low  (as low as the AVR can take), just keep boosting...no expensive inductor needed.

 

Here is an odd idea (prob not for you):   http://blog.davidegrayson.com/2017/03/one-part-avr-controller-boost-converter.html

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Dec 2, 2019 - 12:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Inductors are not that expensive for such low currents, a small SMD inductor will do. And charge pumps are less efficient than inductors.

Here is an example of a small 10uH / 40mA inductor: https://www.findchips.com/search...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is an example of a small 10uH / 40mA inductor

I had a similar thought, but at low freq & low currents, the L increases rapidly to several millihenries!  Plus, the boost lets you run the batt as empty as possible (such as a C cell getting down to 0.8V), whereas the buck forces you to stop. Of course, once the voltage starts to really fall, the batt is 95% empty anyhow.  However, I hate throwing away 4 AA cells because they are at 1.15 V and my product no longer works!

 

Someone was actually selling AA cells (or some ultra thin adapter) with a built in booster!

....found it:

https://www.batteroo.com//

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Dec 2, 2019 - 04:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The circuit is described by these lines of code:

D1 2 0 BlueLED
L1 1 2 10m
C1 2 0 1u

Vin 1 0 PULSE(IV=0 PV=3.8 PERIOD=60u WIDTH=50u)

and should look like this (the code above does not have a damping resistor, so that R1=0 in this case):

 

LC low-pass filter

The voltage source V1 is the PWM output.

(Don't look at the type of the LED, I drew this in Circuitlab and don't know anything about their LED models).

 

Oh, and 10 mH inductors can be quite cheap.

Last Edited: Mon. Dec 2, 2019 - 09:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not sure the circuit will work exactly as shown.

The inductor must always draw & maintain current (flowing left to right) from the pin. 

When the PIN is set low , it can certainly sink current (into the pin), but internally, it may not be able to source current (from the pin).  Generically it should (a fet switched to gnd), but there can be other stuff inside we don't see (such as any internal diode that prevents outflow when the bottom fet is on).

The specs for one chip spec sourcing 20 ma when high & sinking 20 ma when low, but do not include the opposite cases (sourcing when low).

 

Best bet is to try it out.

You can avoid this dilemma by connecting a schottky diode from the pin to gnd (non-shorting direction)

Then either apply a high output (ON time), or set the pin as an input (OFF time) & let the diode maintain the recirculating current. 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Dec 2, 2019 - 09:41 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Circonflexe wrote:

 

LC low-pass filter

 

 

Ok, so in the real world the V1 source will be a MCU pin. At first glance, it seems fine, as long as you wait for the inductor/capacitor/resistor system to fully discharge in any situation where the V1 pin might go high impedance.

Maybe you could simulate the situation when the circuit goes from V1=PWM to V1=GND to see how long it takes to relax and how much current is involved?

 

Also, keep in mind that MCU pins are not perfect voltage sources, on the AVR they have an internal resistance of 20 ohm or so (there are V-I curves on the datasheets from which you can infer this resistance, see "Pin Driver Strength" section). You should take that into consideration in the simulation.

In fact is the damping resistor really needed, considering that real world inductors and capacitors have parasitic resistance?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

  With careful timing and under some conditions you do not need the resistor nor the capacitor.

 

  It depends on how much current you want to pump on the LED and how much current the pin can handle. When you go to higher currents on the pin a voltage drop over the pin circuitry occur with due losses. When you add an inductor, it means that the maximum current is higher than the average one. So take these aspects in consideration.

 

  The higher the PWM frequency, the cheaper the inductor. I would look at few kHz. To get a high PWM frequency with a good resolution you need a higher CPU frequency which means power.

 

  If ADC pin available, I would measure battery power, and use a look-up table for the PWM duty cycle. I would build the look-up table based on measurements at various voltages, and keep the switching in discontinuous mode.

 

  If you need more current than the pin can handle, options are like use more than one pin in parallel, use an external gates IC, and the ultimate solution using an external mosfet which complicates the circuitry.