4
\$\begingroup\$

I want to simulate a battery whose behaviour can be controlled by a microcontroller. If the battery is at low charge and there is a high current, the voltage should decrease. Any solution for this issue is good.

My idea was to use a voltage regulator and to change the voltage when required. To simulate the battery, the current would need to be measured constantly. I could simply add a resistor in series and measure the voltage across it. Then, I would have to use a large resistor so that the output voltage still matches the output voltage of the voltage regulator. But then, the maximum voltage at the resistor would be very low and I would have to amplify it.

So my question is whether there is any voltage regulator with integraded current measurement, or you see any alternative solution.

\$\endgroup\$
  • 1
    \$\begingroup\$ A series resistor like you suggest is the standard way to do this. The resistor can be very small, like 0.01 Ohms. Search for other questions about "high-side" or "low-side" current sensing for some example circuits. \$\endgroup\$ – The Photon May 4 '12 at 18:15
5
\$\begingroup\$

First, a voltage regulator whose voltage can be changed by a microcontroller is more typically called an digital to analog converter, or DAC. You can send the output of a DAC to a buffer to increase the current, but there will probably† need to be a DAC somewhere in your system.

Second, before trying to simulate something, you need to come up with a model. The simplest model for a battery is a voltage source. You've recognized that a perfectly stiff voltage source is inadequate, because battery output dips with increased current. A little research will indicate that the cause of this drop with increased current is internal series resistance; put a resistor into your model and you're good to go! More can always be done, of course - Take a look at this article for more detailed models:

enter image description here

The primary modifier in this example is a series resistor, so, rather than algorithmically sensing the current and decreasing the output voltage, you could simply add a resistor. A resistor will instantly respond to changes in voltage and current, without any complicated code on a microcontroller. If you find that you need to model transient behaviors, add a transient resistance and capacitance.

If you need to occasionally change the resistance, then use a potentiometer. If you need to do it while the system is running, use an in-line MOSFET to build a variable resistor or buy a digital potentiometer IC.

If you still need to measure the current, the customary way to do this is to add a small (insignificant) series resistance and amplify the voltage across this resistor. If you use only linear regulators with minimal quiescent current, you can put this sense resistor at the supply of your voltage regulator, alleviating the problems you mentioned in your question. The voltage will still be small, and it won't be referenced to 0V, so you'll need to amplify and condition it. The easiest way to do this is with a high-side current sense monitor IC.


You can also do this with filtered PWM or by directly driving a switching regulator from your microcontroller, but those are both trickier than simply using a DAC to output a voltage.

\$\endgroup\$
  • \$\begingroup\$ Thank you for this detailed answer! This helped me a lot. \$\endgroup\$ – Yogu May 4 '12 at 18:51
  • \$\begingroup\$ Naturally, things get more complex if you also need to model charging a battery, or its behavior when nearly discharged. But for simulating behavior in the normal useful life case, this analog model approach has to be the right approach. \$\endgroup\$ – RBerteig Dec 9 '14 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.