# Charge pump to maintain 3V supply for mini pro

Hi. Can someone please give me some guidance here.

In another post, with help, I've created a remote from an NRF24L01, a 12 button keypad, an arduino mini pro and 2 x AA 1.5V batteries. This unit wakes with a button press, sends the signal, then goes back to sleep.

I'm now trying to work out how to maintain sufficient voltage to run an LED for each button press (green if voltage above 1.9V and red if under 1.9V). I've been trying to use a charge pump similar to the diagram shown below.

I'm suppling 3V from the right ofdiode D1, the neg side of C1 goes to pin 9, and the neg side of C2 goes to ground. Doubling the voltage works well. I haven't connected the LED nor resistor - just measuring the voltage there at the moment. The code I've tried is:

``````void setup() {
Serial.begin(9600);
pinMode(9, OUTPUT);
}

void loop() {
analogWrite(9, 127);
}
``````

So I can easily get around 5.4V, but I can't work out how to pulse this to get 3V instead. I've also tried to pulse pin 9 as well as pin 10 as shown but I still can't work out how to drop the voltage from around 5.4V.

``````void loop() {
digitalWrite(9, HIGH);
delayMicroseconds(25);
digitalWrite(9, LOW);
delayMicroseconds(75);
digitalWrite(10, HIGH);
delayMicroseconds(25);
digitalWrite(10, LOW);
delayMicroseconds(75);
}
``````

Can someone please give me a hint of what I'm doing wrong or how to achieve this?

A voltage double doubles the voltage - in general all switch-capacitor circuits produce multiples of the base voltage (less diode drops and losses).

Anyway what is your problem? You have a 3V supply, you need 1.9V

Also you want to use a charge pump to convert 3V to 3V rather than 5.4V??

There's something you haven't explained I think!

I see that I need to explain myself better. Instead of using the charge pump circuit to boost the voltage into an LED/resistor combo, I was envisioning feeding the charge pump circuit straight into the LED with no current limiting resistor. A switched capacitor circuit is inherently current-limited due to the fact that the capacitors can only pump a certain maximum about of charge each time they are cycled.

The reason I've taken a while to respond is that I've been trying to simulate in LTSpice various scenarios to try and come up with a formula to help designing this situation, basically trying to convert it into a Thevanin equivalent circuit (voltage source in series with a resistor). It's a bit harder than I expected though with the limitations LTSpice has, so I've abandoned that for now. I did tease out some relationships that are important, and you should be able to work with those. I'll post some graphs of the simulation.

Here is the schematic I was simulating:

This is a two-stage inverting charge pump. V1 and V2 have the same pulse profile, so their capacitors can both be driven by one pin instead of two. I made them separate components just for the simulation. Ignore L1, it is only there to smooth out the current waveform so it isn't just a series of huge spikes.

The reason I recommend a 2 stage inverter like this instead of a single-stage doubler is because, with the output fed just into the LED, the input voltage would just have the LED and a Schottky diode between it and GND, not a good situation when you're batteries are fresh. With the invertor, both sides of the input and output are at GND potential, so no current will flow at all until the pumping signal is applied to the capacitors.

1st thing: Duty cycle doesn't matter on the "pumping" signal, as long as there's enough time after each transition for the voltages to equalize. That is why analogWrite isn't doing anything.

2nd thing: output current depends linearly on input voltage, although it is not directly proportional due to the constant voltage drop of the diodes. This graph shows the output current levels when the input varies from 2.0 to 5.0V in 0.5V increments. Notice the even spacing between the levels.

3rd thing: Adding more stages to the output did not significantly increase the LED current. Further experimentation revealed that while the open-circuit voltage was increasing propotionally with each new stage, the short circuit current was not, indicating that the equivalent resistance of the charge pump is also proportional to the number of stages.

4th thing: The LED current is proportional to pumping frequency.

All of these things put together means that, with the two-stage inverter design here, you can use the tone() function to change the pumping frequency, increasing it as the battery voltage drops, to feed a roughly constant amount of current into the LED no matter what stage of discharge the battery is at. All you need for hardware is 3 Schottky diodes and 3 capacitors.

MarkT:
Anyway what is your problem? You have a 3V supply, you need 1.9V

Also you want to use a charge pump to convert 3V to 3V rather than 5.4V??

There's something you haven't explained I think!

Light an LED with consistent brightness from a 2-cell battery (1.8V -3V)

Originally I did create an inverter charge pump - I didn't realize that an LED could run from a neg to positive voltage - now I know. If I'm correct, I assume it's the potential difference between the values that drives the LED (current)??

I did originally experiment with formulas (using the analogWrite) function. I came up with a formula based on the input voltage, diode voltage drop, 0 to 255 range and output voltage. But the circuit wasn't working for me. I'm assuming I'll be doing the same here now with this new setup?

I did however work out that I could still see the LED blink quite clearly (even in sunlight) at as low at 1mA. So that's the value I'm aiming for.

Again sorry for my ignorance here, but I am a little uncertain however in reading the schematic:

• I assume V1, V2 and V4 are voltmeters taking measurements?
• You've listed diodes D1 to D4, yet you mentioned I only need 3
• Capacitors C1, C2 and C3 - are they 10uF electrolytic (say 16V rated)?
• Is the triangle symbol on the left of diode D1 and at the base of C2 a ground symbol?
• As I'm using an RGB LED, where do I connect the red and the green leg - I can only see one output on the circuit
• Instead of schottky diodes, can I instead use switching diodes (say IN4148)?
I'm also not very conversant with the tone function. Reading up there are two options:

tone(pin, frequency), and
tone(pin, frequency, duration)

Which should I be using? I assume this is what you were showing in your schematic, but I didn't understand the terms such as "PULSED(0 {VIN} 0 1n 1n 5u {Period}). I think I need a little bit of a push start here too.

cjcj:
I didn't realize that an LED could run from a neg to positive voltage - now I know.

Of course it can, just turn it around.

If I'm correct, I assume it's the potential difference between the values that drives the LED (current)??

Diodes have no concept of "negative" or "positive" in some absolute sense, all that matters in the voltage on their pins. If the anode is more positive than the cathode (and the difference is large enough to overcome the forward voltage), current will flow. If the cathode is more positive than the anode, current will be blocked.

The normal way LEDs are used here is to tie the cathode to GND and put a positive voltage on the anode, basically "pushing" current into the anode. With the inverting charge pump circuit I posted, the anode is tied to GND and a negative voltage is generated to "pull" from the cathode. The diode can't tell the difference.

I did originally experiment with formulas (using the analogWrite) function. I came up with a formula based on the input voltage, diode voltage drop, 0 to 255 range and output voltage. But the circuit wasn't working for me. I'm assuming I'll be doing the same here now with this new setup?

I addressed this as the 1st point in my findings. Duty cycle does nothing. In fact, most of those waveforms that I generated with the simulator had a 0.5% duty cycle (1 ms period, 5 us on). It is frequency that you need to change, not duty cycle. That's why I said to use the tone() function, not analogWrite().

I did however work out that I could still see the LED blink quite clearly (even in sunlight) at as low at 1mA. So that's the value I'm aiming for.

That's what I was expecting to be a good value too.

• I assume V1, V2 and V4 are voltmeters taking measurements?
They are voltage sources. V1 and V2 are standing in for the pumping waveform that would be generated by the tone() function from the Arduino. Just imagine that one pin from the microcontroller is connected to both capacitors.
• You've listed diodes D1 to D4, yet you mentioned I only need 3
D4 is standing in for the LED, and V4 is used to simulate the higher forward voltage needed (2V instead of 0.7V). I did it this way so I could simulate how different forward voltages affected the output current.
• Capacitors C1, C2 and C3 - are they 10uF electrolytic (say 16V rated)?
The two pump capacitors (C1 and C3) should be identical so that it's predictable. C2 is less important, though I'd recommend it be at least as large as the other two. I used 1uF for the pup capacitors in the simulation, but they can be adjusted: higher capacitance will result in more current for the same frequency. They probably don't need to be as high as 10 uF though, I'd start with 1uF, 4.7 uF at the most. The pump circuit will produce pulses of current, and you want that frequency to be high enough so that it's not visible.
• Is the triangle symbol on the left of diode D1 and at the base of C2 a ground symbol?
Yes, that is the symbol LTSpice (the simulation program) uses for ground.
• As I'm using an RGB LED, where do I connect the red and the green leg - I can only see one output on the circuit
I forgot about that little wrinkle. I thought I come up with something before but I've forgotten. Is it common cathode or common anode?
• Instead of schottky diodes, can I instead use switching diodes (say IN4148)?
You can, but Schottkys have lower forward voltage and will cause less problems as the batteries discharge.

I'm also not very conversant with the tone function. Reading up there are two options:

tone(pin, frequency), and
tone(pin, frequency, duration)

Which should I be using?

The one with duration, then it will stop automatically after a certain amount of time.

I assume this is what you were showing in your schematic, but I didn't understand the terms such as "PULSED(0 {VIN} 0 1n 1n 5u {Period}). I think I need a little bit of a push start here too.

Those are just the properties of the pulse voltage source I used to simulate the square wave output of the microcontroller. It sets the voltage levels, rise and fall times, period, etc. Don't worry too much about it.

My my simulations, using Schottky diodes, C1 and C3 = 1uF, and C2 = 10uF, you would need a tone() frequency of about 800Hz to put about 1.15 mA into a 2V diode when the battery's at 3V, and 2500 Hz when it's at 1.8V. This is a very doable frequency range if the simulation is accurate to how the actual circuit will behave.

If you do build this circuit with electrolytics or some other kind of polarized capacitor, remember that the negative lead needs to be connected to the diode line. The positive leads of C1 and C3 get connected to the microcontroller pin, and the positive lead gets connected to GND.

Thanks for that reply / explanation. The LED I'm using is an RGB 3mm diffused common cathode. The foward voltage on the red is around 2.4V and the green is 1.8V.

``````void setup() {
}
void loop() {
tone(9, 800, 10);
}
``````

When I measure the voltage between C3 / D3 junction and gnd, I get 6.75V. Changing the frequency to 2500, I get the same measurement. I also don't understand the idea of the "duration". From what I've read, this means the frequency will be on for 10ms, but then loop so it simply stays on the whole time. I've also tried adding "noTone(9);" after it so it pulses, but it gives me around 8.80V on all frequencies

``````void setup() {
}
void loop() {
tone(9, 800, 10);
delay(20);
}
``````

Not sure what I'm doing wrong

cjcj:
Not sure what I'm doing wrong

The first thing you're doing wrong is not being comprehensive about specifying your test conditions. When you measured 6.75V in the first test, was the LED hooked up or was it the open circuit output? 5V or 3V supply voltage? 6.75V sounds like what I would expect for the open circuit voltage with a 5V supply.

The other stuff is just a misunderstanding of charge pump theory.

What I've found in my simulations is that a charge pump circuit can be roughly approximated by a voltage source in series with a resistor, assuming you're just looking at averages. A charge pump will have significant ripple on the output due to it's switching nature, but that's not important for driving an LED.

The interesting part is which parts are affected by the different aspects of the circuit.

The equivalent voltage is only affected by the input voltage (VCC) and the number of stages (N). It will always be N*VCC - VDiodes, no matter what the the applied frequency is or the size of the pump capacitors. That is why even when you tone() at different frequencies (as long as it's not too low), you will always measure about the same voltage with a multimeter.

What the frequency and capacitance do change is the equivalent series resistance. The resistance is inversely proportional to both the pump frequency and pump capacitance. This gives you a very easy way to control the average current applied to the LED; as the batteries discharge and voltage drops, increase the pump frequency to reduce the equivalent resistance.

Does that make sense? The charge pump isn't a method of controlling the LED's driving voltage, it controls the current limiting "resistor" with just a small assembly of discrete components, no special ICs necessary. this is why I recommended running the LEDs straight off the output, because the circuit already has a virtual resistor built into the way it works.

The LED I'm using is an RGB 3mm diffused common cathode.

Crap. Common anode would have been a lot easier to work with. Then you could flip all the diodes around an use it as a booster. Apply the output to the anode and use a couple small transistors to switch which cathode you want on. I don't know how to make that work for common cathode. I think you'll be able to get away with a using a couple PNPs to high-side switch which anode you want.

Jiggy-Ninja:
The first thing you're doing wrong is not being comprehensive about specifying your test conditions.

Sorry. Yes, it was open circuit and 5V supply. I didn't have the LED hooked up - at the time I was wondering if the circuit needed to be under load. You've now answered that question. Ta.

I simply measured the voltage between the output and ground (= 6.75V). At one point I did place an LED with a 2.2K resistor (just in case). But the current was around 0.2'sh mA. So I didn't really understand. From "memory" as I changed the 800 to 2500, I didn't see much of a difference in current so I abandoned that method of measurement.

When I get home tonight, I'll do some more testing with an LED (given what you've noted above). Also, to make it easier, I'll buy an RGB common anode LED as I'd like to keep the part down in this unit. In the short term I'll test the circuit with 2 single color LEDs, but ultimately with a single. Can you let me know how you suggest I can connect the 2nd LED.

Jiggy-Ninja:
The charge pump isn't a method of controlling the LED's driving voltage, it controls the current limiting "resistor" with just a small assembly of discrete components

Yes, that fact that current not voltage is affecting the LED is clear now.

In regards to theory however, there's something I'm still missing. I've gone over your previous links to EEVblog video links you posted earlier quite a few times and can see "how" this works. The square wave input charging the capacitors in sequence which ends up "adding" to the output voltage line does make sense. Your note about number of stages affecting output voltage also does make sense.

However, in your 4th note above, you mentioned that the LED current is proportional to pumping frequency. Even though I accept that and it makes sense, I still cant see the difference between "frequency" and "duration" in the tone command. Is the "frequency" value affecting the pulsing or is it the "duration" along with a "delay"? What's the effect of these 2 variables in the operation?

I was envisioning feeding the charge pump circuit straight into the LED with no current limiting resistor. A switched capacitor circuit is inherently current-limited due to the fact that the capacitors can only pump a certain maximum about of charge each time they are cycled.

Non-sequitor - in fact switched capacitor circuits have very high current spikes due to the very low
resistances involved in typical capacitors.

Charge is not current, limiting charge doesn't limit current. 10A for 1us is the same charge as 1mA
for 10ms, and I know your LED would prefer the latter!

Ninja, could you please first read my post above (#8) with the questions, then this...

I've tried some measurements with the 5V supply and this is what I'm getting:

Is this correct?

What is the capacitance of the capacitors you used? Are the diodes Schottky or silicon?

Take a look at www.pololu.com they have a boost regulator that will make 3.3V or 5V from a single AA or similar until the battery is down to something like 0.5V. I think it can also limit the output if the battery is higher than 3.3V or 5V. Nice compact little board too.

Jiggy-Ninja:
What is the capacitance of the capacitors you used? Are the diodes Schottky or silicon?

I'm testing the circuit with C1 & C3 = 1uF electrolytic and C2 = 10uF electrolytic (similar to your simulation). Instead of the 3 schottky diodes however, I'm using testing with switching diodes that I have on hand (IN4148). I'll try get a few schottky's and see how much that improves the voltage.

Take a look at www.pololu.com they have a boost regulator that will make 3.3V or 5V from a single AA or similar until the battery is down to something like 0.5V

Thanks CorssRoads for that suggestion. I did consider it some time back, but I'm trying to create my own circuit here. I could even use a voltage doubler feeding a 3V regulator, but again - cheating. That would be my plan b.

Thanks CrossRoads. That items even though relatively cheap, ends up costing about \$5 + \$19 delivery to Aus. That's close to \$25 AU. The 2 caps and 3 schottky diodes are a much cheaper option.

Ninja, I bought a few schotty's and you're right - lower voltage drop. I now have the following figures:

I'll do some testing now with a 3V supply and try work out a formula to maintain the 1mA output. But I'm still keen on know how to connect up an RG common anode LED. Also the question I mentioned earlier about the affect of frequency vs duration in the tone command....

4 hours later..
Just tried to use 3V supply reducing to 1.8V. Couldn't get this to work, so I'm not sure what's happening here. Results below:

Get rid of the 670 ohm resistor, and replace it with something much smaller like 47 or 22 ohm. 3.6V minus the 3 Schottky diode losses (somewhere between 1.2 and 1.5) gives an equivalent voltage output of about 2.1V to 2.4V. That's pretty close to the voltage of LED so it's close to the borderline of if it will drive it properly. You will probably need to add a 3rd stage to be able to drive the red LED. Instead of adding another pair of diodes+capacitors, you can use the one in the middle as another pump capacitor instead of just connecting it to ground. The catch though is that it needs to be driven with the inverse signal of the other two. The ATmega328P does not have a peripheral to natively generate complementary waveforms, but you can cheat it by fiddling with the registers for Timer1. You set it to the Fast PWM mode that uses ICR1 as the TOP, set the OCR1A and OCR1B registers to about half ICR1, and the outputs of the two OCR pins to opposite polarities (one set on compare match, the other clear on compare match). This is not as hard as it sounds, you just need to read the datasheet to figure out what bits to set, and do some math to convert frequencies into the right TOP and prescaler values.

cjcj:
Thanks CrossRoads. That items even though relatively cheap, ends up costing about \$5 + \$19 delivery to Aus. That's close to \$25 AU.

Not if you order it on OZ.

Leo..

Jiggy-Ninja:
Get rid of the 670 ohm resistor, and replace it with something much smaller like 47 or 22 ohm

I did do this already with my 2nd lot of measurements above, because I found I couldn't get 1mA once the supply dropped to 2V. So the figures are with no resistor.

Jiggy-Ninja:
3.6V minus the 3 Schottky diode losses (somewhere between 1.2 and 1.5) gives an equivalent voltage output of about 2.1V to 2.4V

I re-did the measurements this morning just to make sure I wasn't doing anything wrong. At a supply of 2V, C1, C2 & C3 being 10uF, a frequency of 15,000 and duration of 10, the max current I could get was 0.96mA and output voltage from the inverter of 2.838V. So this figure would come from 2V x 2 - (1.2V for the diodes). PS. I'm still not sure what the mS does in the tone command.

However, when I drop the voltage supply to 1.8V, I find from pin 9, the maximum voltage I get (with a frequency of 56000) is about 0.9V from that pin. But then, no matter what configuration of capacitors I use, I end up with falling voltages - with the final output voltage under the minimum required to drive the green led.

Wawa:
Not if you order it on OZ. http://core-electronics.com.au/pololu-3-3v-step-up-voltage-regulator-u1v11f3.html

Yes, \$10 is not as bad. Considering the issues I'm having above, this option is starting to look better and better. But there must be a way to get it to work! I'm sure I'm doing something wrong.

That is an awesome little regulator that Pololu's using there. The best part about it compared to most boost regulators is that it has "True shutdown option that turns off power to the load", unlike most boost regulators that just shut off the switching circuitry and still leave a direct path from input to the load (through the inductor and diode). By the datasheet figure datasheet it's got a shutdown current of less than 1 uA.

If you don't want to screw around with the charge pump circuit anymore, the Pololu regulator is perfect.

PS. I'm still not sure what the mS does in the tone command.

It sets how long the tone goes on for. If you put a number there it will stop on it's own, but if you omit that argument it will tone forever until you stop it with noTone().

However, when I drop the voltage supply to 1.8V, I find from pin 9, the maximum voltage I get (with a frequency of 56000) is about 0.9V from that pin. But then, no matter what configuration of capacitors I use, I end up with falling voltages - with the final output voltage under the minimum required to drive the green led.

That's expected, since the theoretical open circuit voltage of the charge pump is right at the same voltage as the LED's forward voltage. There's no way to forward bias it like that, so you'd need to add a 3rd stage if you wanted to run the LED when the voltage is that low.