Digitally controlling charge voltage with some regulator like Lm317 is a matter of using some resistor and transistor as stated in lm317 datasheet to select from multiple pre defined voltage.

But what about choosing output current ? How it can be adjust with digital signals from microcontroller ?

Normally what i found on the web and lm317 datasheet is using a fixed high wattage resistor to limit charge current.

I am trying to build a smart charger as a part of smart ups and i want to use a range of battery with different voltage and current and it must be selectable from software.

So what is your suggestion for digitally selecting charge current ?

  • \$\begingroup\$ I would say to use the same technic. Have several selectable resistors to give you several current values. \$\endgroup\$
    – vini_i
    Jan 23 at 0:57
  • \$\begingroup\$ it seems using multiple high wattage resistor with some relay or transistor would work but is this efficient way of doing it ? i mean does commercial charger work this way ? \$\endgroup\$
    – A.M.S
    Jan 23 at 1:04
  • 1
    \$\begingroup\$ The cheap commercial units i’ve seen use a microcontroller and a buck/boost converter. By using pwm you can vary the voltage/current easily. \$\endgroup\$
    – Kartman
    Jan 23 at 1:21
  • \$\begingroup\$ Unless the charge current is very low, limiting it with a linear regulator will not work very well. Power dissipation will be excessive so that the design effort becomes focused almost entirely on cooling. Using switch-mode DC-DC conversion techniques will be much more suitable and easier to manage from a micro-controller. DC-DC conversion techniques involve using transistors (and sometimes diodes) for switches along with inductors and capacitors for filtering. \$\endgroup\$
    – mkeith
    Jan 23 at 1:30
  • 1
    \$\begingroup\$ Lead acid battery uses constant current constant voltage (CCCV) charging. A regulated current raises the terminal voltage until the charge voltage limit is reached, then the current drops due to saturation. 12–16 hours and up to 36–48 hours for large stationary batteries. Lead acid batteries are charged in three stages, constant-current charge, topping charge and float charge. The constant-current charge applies the bulk of the charge and uses ~50% of the charge time; the topping charge continues at a lower charge current providing saturation, the float charge compensates self-discharge loses \$\endgroup\$
    – Gil
    Jan 23 at 3:11

You could have less trouble and better control if you charge with a dedicated analog circuit, as I answered in another post (see ahead).

However, trying to answer strictly what and how you asked, you could achieve by several methods: From an accurate and more complicated way, or the simpler and discrete ones. The simpler could be to use some current-limited sets as {LM317 + NPN + R.sense} to drive down the current at different set values. Let’s say two assemblies adjusted at 1A, a third one at 0.5A. Selecting them in parallel could enable currents from 0.5 to 2.5A. See also the second diagram I posted in the following link here Q1 and R.cl, and the explanation preceding that circuit about how it works.

My preference is to use this 3-stage charger, that is a good and safe way to charge a SLA battery. I already built several of these chargers, based in the first picture of that post, with the modifications/upgrades I detailed there.

An intermediate way could be to add a resistance in the output terminal as 0.2Ω to 0.5Ω and benefit from the voltage and impedance multiplication at the output of the LM317, as I illustrated in this picture (source already marked inside): enter image description here So, for a 12V Charger the equivalent R.out impedance of the charger would be around 2Ω to 5Ω, respectively.

Some brainstorm on a not so complicated way, using simplified control setup with a microcontroller,as you intend: if you combine an adjustable V.ref (for instance generated by a PWM +RC) to shift the “reference-ground” of the LM317s (in parallel and with R.out), you could either adjust the voltage or the current. This control would be at digital level, with algorithms in the microcontroller (as an Attiny85 or Arduino). The R.out would just enable a smoother current variation when you vary the voltage, and vice-versa. Your algorithm is the one who will determine if this crude “microcontrolled power supply” would prioritize Constant Voltage (CV) or Constant Current (CC), to your set points and charging profile. If not properly designed, the control will be slow or could overshoot, but in a worst case voltages and currents would be contained by the “hardware” circuitry around the LM317; and a SLA battery will forgive transitory hunts for the set-points, so at least it could be a fun experience.

Voltage dividers before and after the power resistor could sample the voltages and calculate the differential (proportional to current) in a voltage range that AD channels of a microcontroller could read, for instance.

Just be attentive of minimum and maximum common-mode voltages, unexpected voltage swings, also if battery is connected reversed, or when the power source still powered off. Current limiting resistors and shunting diodes might be helpful to protect the AD ports and other circuitry.


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.