Charge pump to maintain 3V supply for mini pro

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

I guess CrossRoad's original suggestion of the regulator is worth it then (and cheaper AU location suggested by Leo).

Would it be possible to use 1 only of these regulators to supply the 2 LEDs? Maybe 1 pin feeds the supply to the regulator that then delivers 3.3V to both the green and red LED. To then turn on the voltage, I could have one pin to ground going low and one pin to the other led going high. Given the high would be say 1.8V at low voltage, the difference (3.3V - 1.8V) would be lower than the forward voltage of the LED so only 1 would correctly turn on. Would that work?

cjcj:
I guess CrossRoad’s original suggestion of the regulator is worth it then (and cheaper AU location suggested by Leo).

Would it be possible to use 1 only of these regulators to supply the 2 LEDs? Maybe 1 pin feeds the supply to the regulator that then delivers 3.3V to both the green and red LED. To then turn on the voltage, I could have one pin to ground going low and one pin to the other led going high. Given the high would be say 1.8V at low voltage, the difference (3.3V - 1.8V) would be lower than the forward voltage of the LED so only 1 would correctly turn on. Would that work?

If you use a common-anode LED, it’ll be easy. Regulator output to the anode, and a pair of transistors to switch in whatever cathode you want to activate (through a limiting resistor of course). Common cathode would be harder, and require more difficult high-side switching.
IMG_20161212_130530407_compressed.jpg

Don’t use a digital pin to feed the input of the regulator. You don’t need to, and it’s generally a bad idea anyway. The regulator module has it’s own shutdown pin. Hook the input directly to the battery and connect the microcontroller to SHDN.

Thanks Ninja. I'll wait for the regulator to arrive, then give it a go. Ta.

Whilst waiting for a regulator, I thought I give the inverting charge pump one final go. I’ve been testing it all day. I’ve now been able to deliver 1mA for voltages between 3V and 1.85V in one of my options. I couldn’t however get it to work as low as 1.8V. But I now have some questions I’m not sure of.

  1. Does anyone know why (with the circuit below), once I lower the supply voltage lower than 1.85V, (and I measure the Vout at as -2.59V on the negative side of C2), the voltage then suddenly takes a dive towards 0V and LED starts blinking. Lowering the input slightly more, then stops the LED lighting up at all?

2 stage inverting charge pump with C3.jpg

  1. Also, when I removed C3 from the junction of diodes 2 and 3 above, I found the inverter was more linear for some reason. Why? I found at low voltage (1.85) I could attain a 1mA current, whereas I couldn’t with C3. Also, the frequency to supply voltage has a more linear inverse proportion (as shown in the 3rd table as compared to the 2nd table below). Why?

2 stage inverting charge pump less C3.jpg

  1. Is the third option below therefore the best to use?

1.jpg

  1. Lastly, in running both a green (voltage ok) and red (voltage low) RG led, could I power each of the anode pins via a separate digital pin (say D4 and D5), and in the sketch turn on both D9 + D4 for say green or D9 + D5 for red (based on reference voltage measurement)?
  1. Does anyone know why (with the circuit below), once I lower the supply voltage lower than 1.85V, (and I measure the Vout at as -2.59V on the negative side of C2), the voltage then suddenly takes a dive towards 0V and LED starts blinking. Lowering the input slightly more, then stops the LED lighting up at all?

I don' think that configuration is a true 2-stage pump, the capacitors would need to be driven by complementary signals, not in-phase ones. The pump probably isn't able to generate enough voltage to overcome the forward voltage of the LED and 3 diodes.

I'm not sure how your simulator works, but it looks like the other end of the square wave generator isn't connected to anything. Is that how it's supposed to be? I would have expected it to be connected to 0V.

  1. Also, when I removed C3 from the junction of diodes 2 and 3 above, I found the inverter was more linear for some reason. Why? I found at low voltage (1.85) I could attain a 1mA current, whereas I couldn't with C3. Also, the frequency to supply voltage has a more linear inverse proportion (as shown in the 3rd table as compared to the 2nd table below). Why?

I don't know, I would have expected it to work worse than before. The middle capacitor is meant to be a reservoir that the first (right) stage can pump charge into on the upstroke, and the second (left) stage can pump charge out of on the downstroke. Without it I don't think it can be a true two-stage pump. Though that really won't matter for the way you've wired it since it's still a doubler even with 1 stage.

I don't like this setup very much though. If you look at my circuits you'll see that both ends of the diode chain are connected to 0V. I did this for a very specific reason, which you can see if you take a closer look at your circuits. With both ends connected to the same voltage (0), there is absolutely no chance for current to flow when the pumping signal is not engaged.

It is an entirely different story when the anode end is connected to a positive voltage. With a 18.V LED and 3 x 0.4V Schottkies being all that's in the way between the +V and GND, that adds up to about 3V worth of forward voltage. That is dangerously close to the fresh battery voltage. Any more than that and you risk overcurrenting because you only have diodes to provide resistance. If you hook up 3.3V or (heaven help you) 5V for testing or programming you're going to get very large, uncontrolled currents even if the pumping signal is disengaged.

From the beginning, I wasn't expecting a linear relationship between input voltage and frequency. I was expecting it to be more like a reciprocal function. The frequency should increase sharply as the input voltage is lowered. I don't think you can linearize it without making it much more complicated. Instead of worrying about deriving a formula to calculate the frequency as a function of voltage, make a static lookup table as an array of voltage-frequency pairs. Read the voltage, find the nearest voltage in the table, and pump that frequency. You'll need separate tables for green and red, but that's an easy thing to deal with.

  1. Lastly, in running both a green (voltage ok) and red (voltage low) RG led, could I power each of the anode pins via a separate digital pin (say D4 and D5), and in the sketch turn on both D9 + D4 for say green or D9 + D5 for red (based on reference voltage measurement)?

I've got a better idea, a bit similar to that but just a tiny bit different. I hadn't thought of it before until just now.

Swap the LED and the leftmost Schottky so that the LED is now on the left end of the string. Connect the anode end to 0V, and put back in the middle intermediate reservoir capacitor, but make it much bigger than the pump capacitors, like 10uF. I'd go for at least 10x bigger. Have the two LEDs in parallel on the left side output, and connect their cathodes to different Arduino pins. Now it's a booster instead of an inverter, but it's still much the same really. The current is still being pumped from right to left through the diode chain, the only different is which end the LED is on.

With the pump signal off, it doesn't really matter what level the Arduino pins are at. If they're LOW, the LED will have no voltage across it, and if they're HIGH then they're LED will be reverse-biased (and also have no current). Most LEDs should be able to handle up to 5V reverse bias voltage like this LiteOn one (though usually not much more), so there's no danger of anything bad happening. You will need to engage the pump for there to be any current flow.

When you want to light one of the LEDs, make HIGH the LED you want off and LOW the one you want on, then start the pump signal. With the two LEDs in parallel like that, the current will all flow into the one that needs less voltage to turn on. For the LOW LED, that voltage is just the forward voltage of the LED itself. But for the HIGH one, that voltage is the forward voltage + the pin voltage. Because the HIGH LED will require much more voltage to turn on, all the current will get dumped into the LOW one.

Jiggy-Ninja:
I’m not sure how your simulator works, but it looks like the other end of the square wave generator isn’t connected to anything. Is that how it’s supposed to be? I would have expected it to be connected to 0V.

I’m not sure if I’ve drawn up the sketch above correctly. The symbol I placed at the bottom represents the “tone” signal from pin 9 of the arduino. I “assume” the tone signal goes from high to low at the formula driven frequency.

I’m not really why, but the setup now seems to work except for one point (I’ll note below). I ended up doing the following:

  • Measuring and tabulating Voltage vs Frequency to maintain 1mA - measured at 0.1V intervals
  • As the newer measurements ended up parabolic, I used on online calculator to derive the formula (yes I cheated!)
  • To alleviate the “over 3V” issued you mentioned, my sketch now measures the supply voltage, then turns on the LED via the appropriate frequency to achieve 1mA max.
  • To also make sure that the parabolic function doesn’t foul up with over 3V readings, the sketch sets variable “result” to 3V if the measurement is over 3V
  • I now find as start with a 3V supply and press the keypad, the LED lights up with 1mA
  • As I ramp the supply voltage down to 1.9V, it only deviates from the 1mA by about 0.3mA (due to the approximation of the parabolic calculation). The LED intensity works well at all voltages between 3 & 1.9.
  • I did connect the legs of the LED to pins 7 and 8, applying a high or low and it too seems to work well
  • On a button press, the setup runs at around 3.6mA when 3V supply or 3.1mA when 1.9V supply (around 1 second duration
  • When it sleeps, it consumes 0.9uA

The one issue I’m now facing as mentioned above is the effect of the function I have in “setup”:

power_all_disable ();

Something in this inhibits the frequency to vary as per my formula. It’s as if frequency doesn’t work at all. When I comment it out, it seems to work, but probably lowers the power savings. I’ve read Nick’s website and he notes that this setting does the following:

Bit 7 - PRTWI: Power Reduction TWI
Bit 6 - PRTIM2: Power Reduction Timer/Counter2
Bit 5 - PRTIM0: Power Reduction Timer/Counter0
Bit 4 - Res: Reserved bit
Bit 3 - PRTIM1: Power Reduction Timer/Counter1
Bit 2 - PRSPI: Power Reduction Serial Peripheral Interface
Bit 1 - PRUSART0: Power Reduction USART0
Bit 0 - PRADC: Power Reduction ADC

Can I power_all_disable in my sleep function, then power_all_enable when waking? Or can I somehow turn on the “Bit” above that is the problem

_06L_keypad_remote.ino (30.5 KB)

power_tim2_enable() or power_timer2_enable(), I'm not sure which is the correct function name. You need to turn Timer2 back on along with the other stuff for tone() to work.

That is not a parabolic function, it will be a reciprocal. As the input voltage increases, the necessary frequency will monotonically fall, it will not reverse direction and increase. Just eyeballing it, it looks like something like y=1000/(x-1.5) is a close fit to it.

I don't think you understood what I was saying about the 3V issue at all. Ignore the capacitors and everything below them. Remove them from your mind, and just look at the diode chain. The forward voltage of those 4 diodes adds up to about 3V. Fully charged alkaline batteries add up to about 3V. Neither of them will be exact, so I don't know which will be less or more than the other. If you connect the anode to to fresh batteries and cathode to GND, it's possible have current flowing even when the pump signal is off. And if you use something like an FTDI board for testing that can give 3.3V or 5V, you will definitely be higher than the forward voltage of that diode chain. If you are controlling the anode with a digital pin, you risk overstressing it from too much current draw.

Furthermore, if the diode chain does get forward biased, you have no way to limit the current. The pump circuit can only force additional current to flow from anode to cathode, it cannot inhibit any current that would be flowing from some other voltage applied to the chain.

That is why I recommend having both ends of the diode chain connected to 0V (and reverse-biasing the one you want off). There is no possible way for current to flow under any circumstance without the pump signal. And the current that flows because of the pumping action is completely under your control, and can be kept to a safe, power-efficient limit.

Hi Ninja.

Thanks for the heads up on power_tim2_enable() - or tim1. I’ll have a fiddle with these functions.

Parabolic - yes, it’s not really as it’s really only half of a parabola. The approximation however seems to work, but I’ll do some more testing with your formula.

With your original sketch, I think I my problem is that I can’t really see how the inversion of power physically works. I can see the left is at ground. On the right you have V4 which you said to ignore. On the right of that do I connect it to ground (as I didn’t originally). That would mean that when V1 and V2 are off, there is no potential difference across the diode chain - correct? I therefore don’t really understand what “Ouput” is. If I knew what values each point should be during the cycle it would be easier for me to understand. Sorry.

What I have drawn however in my altered setups was incorrect. I’m not connecting the LED common directly to 3V supply as I’ve drawn. Instead I ended up connecting it to the negative side of C2 (this is the negative generated voltage). The voltage only goes negative, when I pass the tone “frequency” from pin 9 to C1 and C3.

So to get the green LED to flash, I have pin 9 tone frequency turned on, pin 7 HIGH to the other green LED leg and pin 8 LOW to the third LED leg (red). After the blink, I change pin 9 to the same frequency but duration “1” and also change pin 7 to LOW.

So it’s the tone frequency that limits the current to each of these LEDs (via my formula). Does that all makes sense?

Parabolic - yes, it's not really as it's really only half of a parabola. The approximation however seems to work, but I'll do some more testing with your formula.

My point is it's not any kind of parabolic segment, even if it looks superficially like one. It is a reciprocal function, and this is how I derived that relationship:

The average current is going to be proportional to the voltage that gets pumped each cycle (the battery voltage minus half the forward voltage of all the diodes) and proportional to the frequency. A larger voltage means more charge gets moved per pump cycle, and a higher frequency means more pumps per second. The forward voltage of the diodes is halved because it acts like a 2 stage configuration. That gives the relationship:

kI = f(V-1.5)

f = pump frequency V = battery voltage I = average current k = unknown proportionality constant

Solving for f gives the formula:

f = kI / (V-1.5)

Your empirical observations suggest that k is about 1,000,000, which means that kI (I = 1mA) is 1,000.

f = 1000 / (V-1.5)

With your original sketch, I think I my problem is that I can't really see how the inversion of power physically works. I can see the left is at ground. On the right you have V4 which you said to ignore. On the right of that do I connect it to ground (as I didn't originally). That would mean that when V1 and V2 are off, there is no potential difference across the diode chain - correct? I therefore don't really understand what "Ouput" is. If I knew what values each point should be during the cycle it would be easier for me to understand. Sorry.

Don't think of it as an inverter than. The pumping action forces current to flow from the anode of the diode chain to the cathode. In my drawing that's right to left. Whether you consider is a "boosting" circuit pushing power through the load or an "inverting" circuit pulling power through the load depends entirely on which end you consider to be the load.

The same average current is flowing through every diode in the chain, so any one of them can be considered the load. In my initial schematics I drew the LED at the anode end, so that side was considered the load. However, I laid out a case for why it's better to put the LED at the cathode end of the string, which means we would call the other side the load.

The D4+V4 combo was my stand-in for a 2.0V LED in the simulation (0.7V + 1.3V). If you use that original circuit from Rely #2 but move the LED to the left end (and have a normal Schottky on the right), the voltage at C1 averages about 1.23V in my simulation. If that seems odd, remember that this is a modification of a normal charge pump circuit. We aren't using it to pump high voltage into a capacitor, but to pump current through diodes. The current is the output variable of interest, not any particular voltage reading.

What I have drawn however in my altered setups was incorrect. I'm not connecting the LED common directly to 3V supply as I've drawn. Instead I ended up connecting it to the negative side of C2 (this is the negative generated voltage). The voltage only goes negative, when I pass the tone "frequency" from pin 9 to C1 and C3.

So to get the green LED to flash, I have pin 9 tone frequency turned on, pin 7 HIGH to the other green LED leg and pin 8 LOW to the third LED leg (red). After the blink, I change pin 9 to the same frequency but duration "1" and also change pin 7 to LOW.

You have the LEDs on the anode end, right? That's not the best side to put them on. Have them on the cathode end. Both of their anodes connected to C1, and their cathodes connected to different Arduino pins.

I’ve now gone through quite a few videos about charge pumps and inverters to work out how they work. I’ve also re-read this post quite a few time and I now finally get it. Your sketch in post #2 has the diode chain as 0V on both ends. The pump signal is the only way to open up the current to the LEDs, which makes it much better than my setup as it’s controlled, regardless of voltage.

Jiggy-Ninja:
If you use that original circuit from Rely #2 but move the LED to the left end (and have a normal Schottky on the right), the voltage at C1 averages about 1.23V in my simulation.

I’ve now trialed that setup again. At 3V, I’ve adjusted the frequency to deliver 1mA to both LEDs as per post #24 above and that works well. I also now understand why you were suggesting to use “duration” in the frequency function. My mistake was I was using it in a loop for testing, so it never turned off. I now used the delay function along with the noTone function to fix my issue.

Now, where I’m still unstuck. I’ve lowered the voltage supply to 2.5V and can only get the current up to 0.75mA (even with a frequency of 56k). I’m not sure what I’m doing something wrong? Just to check, here’s my setup:

layout_3.jpg

However, this is the option that is currently working for me and I think it sort of works on the same principle of a zero voltage diode chain. Is it ok?

Working option.jpg

I’ve now gone through quite a few videos about charge pumps and inverters to work out how they work. I’ve also re-read this post quite a few time and I now finally get it. Your sketch in post #2 has the diode chain as 0V on both ends. The pump signal is the only way to open up the current to the LEDs, which makes it much better than my setup as it’s controlled, regardless of voltage.

YES! Finally it has sunk in.

Now, where I’m still unstuck. I’ve lowered the voltage supply to 2.5V and can only get the current up to 0.75mA (even with a frequency of 56k). I’m not sure what I’m doing something wrong? Just to check, here’s my setup:

Likely, you’re doing nothing wrong. Arduino pins are only so strong, and have about 30-50 ohms of resistance. When the voltage is that low and the frequency is that high they probably aren’t able to supply enough current to fully run the pump. I wasn’t sure from the beginning if that was going to be an issue, but it looks like it is.

Ain’t electronics fun?

However, this is the option that is currently working for me and I think it sort of works on the same principle of a zero voltage diode chain. Is it ok?

It’ll be fine if you’re careful to keep the supply voltage below 3.4V so that the chain isn’t forward biased when you turn pin 7 or 8 on.

Jiggy-Ninja:
f = 1000 / (V-1.5)

This formula works much better (closer) for the green LED. However for the red I had to create another formula between 1.9 and 2.2 V - I just used a straight line graph.

I also tried your suggestion of timer2. It worked. I “think” the function is

PRR = ~(1<<PRTIM2)

But instead I used:

power_timer2_enable(); (as this is part of the power library)

Jiggy-Ninja:
It’ll be fine if you’re careful to keep the supply voltage below 3.4V so that the chain isn’t forward biased when you turn pin 7 or 8 on.

At the moment, since my setup is using a 3.3V mini pro, I’m using a USB-to-TTL serial converter that is switchable between 5V and 3.3V. I use the 3.3V setting.

To lower power consumption on this unit, I’ve removed the on-board LED as well as the voltage regulator. I’m now wondering whether infact it’s safer to use keep the regulator, as the nRF24L01 won’t be a happy chappie if down the track someone other than me re-programmes this unit using a 5V converter? I’m also not sure if the atmega chip is happy with 5v, but my guess is that it is. But from memory, even during deep sleep, the regulator was consuming a couple of mA’s (above the current 0.7uA’s). Your thoughts?

Also, in regards to the reverse bias issue you mentioned, unless I’m wrong (which wouldn’t be surprising), I don’t think this would be an issue because in the code I’m reading Vref. From that, if it’s found to be above 3.0V, the code sets the “result” variable used in the frequency calculation to 3V maximum. This means the current will never be over approx. 1mA going through the LEDs. But would the higher negative voltage still be a problem?

In this hand held remote I’m planning on installing a 6 pin connector in the battery compartment, so that if in future the unit need re-programming, it’ll be possible. Hence the possibility that someone could program unknowingly with a 5V convertor.

Is it worth adding a 2 resistor voltage divider on this USB Vcc pin on my board just in case someone uses 5V? This would then be an issue in re-programming with 3.3V supply (as it would be divided) unless I put a note on the unit to use 2xAA batteries installed whilst programming. Is this worth doing?

At the moment, since my setup is using a 3.3V mini pro, I'm using a USB-to-TTL serial converter that is switchable between 5V and 3.3V. I use the 3.3V setting.

Most of the FTDI boards have that switch, the danger is if you plug it in with the switch in the wrong position. A 3.3V LDO, 10k series resistors on all the data lines (except maybe DTR, haven't checked how reset is connected on the boards) will probably be good enough to protect against accidentally plugging it when the switch is at 5V.

But you also have to be sure to not plug the programmer in while batteries are in there, unless they're rechargeables. Primary cells don't like being charged much. It's good that you're putting the connector in the battery compartment, since that'll help you remember to remove them.