# How to vary the voltage of a battery

Essentially, what I need to do is vary the output voltage of a battery between say 2V - 5V. This is to mimic the voltage output properties of a solar panel under different sunlight intensities.

The battery being used is a solar charger power bank; http://www.amazon.co.uk/MAOZUA-15000mAh-Charger-Portable-Flashlight/dp/B011R3Q0AC

So far I have tried to use a potentiometer to do this, but the resulting output went up in smoke. The measured resistance of the circuit that will be driven by the battery is 1.3kOhms.

Is there a better way of varying the batteries voltage manually? Or the most ideal solution would be to have the output voltage slowly cycle between 2V and 5V automatically. Is this feasible?

• I am not quite fully understanding what you want to accomplish - the battery pack you have linked to already outputs a constant 5v (or should) - if you want to convert this to a varying amount between 2 and 5v, an adjustable DC-DC converter should be able to do the trick - and then in order to slowly cycle the voltage, your going to have to be more specific, but the pot you mentioned before should be able to adjust it. Also, are you sure that the resistance of the circuit that will be driven is a resistive load? Feb 29 '16 at 16:24
• You need something like this: en.wikipedia.org/wiki/Buck%E2%80%93boost_converter Feb 29 '16 at 16:28

## 2 Answers

5V/1300Ω is 3.8 milliamps, if your characterization of the load is correct. At 5 volts that would be 19 mW

If the load is not a simple resistor, and you "measured it with a meter set to Ohms" that number is meaningless, and you need to measure actual load current at 5V with an ammeter (or use a voltmeter and measure the voltage across a 1 ohm or 0.1 ohm or 0.01 ohm resistor - which is pretty much what an ammeter does.)

Many potentiometers should have been fine feeding a load at 4 milliamps/2 hundreths of a watt, if the potentiometer was hooked up appropriately - lacking detail of how you did that and what your now smoked potentiometer was, I'm suspecting the load draws quite a bit more current, or you hooked the potentiometer up in a way (and it was of a value) that might lead to smoke release regardless.

Depending on your constraints and use, a simple linear regulator may be the easiest and cheapest approach - it's not efficient, but if this is just for testing that may not matter much. AN LM317 or TLV431 might work, depending on actual load current required.

Finally, a varying voltage with full current supply ability (as from a regulated battery) is a poor model for a solar cell and varying light intensity. If you really want to test how a circuit works with a solar cell and varying light intensity, attach a solar cell, and depending on time and budget constraints, either take it out on a sunny day and shade it variably, or shine some bright lights on it and vary the distance from the lights.

• How can he get 5V out of a 5V battery with an LM317? Feb 29 '16 at 17:20
• Test lead will do it. Feb 29 '16 at 18:30

Don't use a battery, they have variable power supplies for this, just buy a cheap one on ebay and set it to the voltage you want. Secondly if you are trying to simulate a solar cell, this approach will not work. A solar panel has an IV curve that is very much different from a battery. The best (and probably only way) is to use a light source with the actual cell. There are ways you could simulate the load of a solar cell with a computer and a digital voltage source, but you (or the manufacturer) would have to characterize the cell with calibrated light source. You could potentially build your own source and calibrate it yourself. Or your could just use an rack of ordinary light bulbs if you didn't really care about coming up with numbers for your solar cell and matching it up with the suns output.