Raspberry Pi HATS compatible UPS – part IIa – trickle charger

Following on from part I and a little discussion on the Raspberry Pi forums here is part IIa, in which I’ll go through and explain and calculate the values and also the reasoning behind each part for the trickle charger. This was going to be for the whole board, but ended up being very long so bitesize chunks for both me and anyone reading!

I made this design with a bit of a nod toward it being produced, and this constraint I hope will become clear during the text.

55 mA trickle charger

Trickle charger

Trickle charger

As previously discussed, sealed lead acid batteries were intended to be the first choice of backup power due to their ready availability, high capacity, and low cost. To keep the battery topped up, a small current is applied – a trickle charger. The charging current is much lower than the battery capacity, and also much lower than the highest charging current the battery could withstand. The current needs to be limited in case a deeply discharged battery is connected; an SLA can take several amps when discharged so could do some damage to the power supply.

Initially, I considered using the SLA charging circuit from the LM317 datasheet. This had a few issues for this design: 1) the dropout voltage for the LM317 is quite high, at least 1.25 V, and it would be prudent to have some voltage headroom headroom as well, 2) the current limiting is on the ground side so there would be different ground potentials connected, which is equivalent to a short circuit. I could have implemented a high-side current limiter, but that doesn’t make any difference to the dropout voltage, and in fact makes the problem worse with a shunt resistor. From a manufacturing point of view, as well, this introduces a lot of new parts, and the LM317 required would have to be in an expensive and large TO220 (or SMD equivalent) package to dissipate the power.

To address these issues, the trickle charger is implemented using a constant current source (CCS) (LED1, R2, R3, Q1) driving a shunt regulator (R15, R16, R21, R27, IC3, Q2, C4). Since the biggest factor we need to address is the charging voltage, I’ll discuss the regulator first and then the CCS. For a lead acid battery at ambient temperature (25 °C), the voltage required to keep one cell topped up is 2.25-2.30 V. So for the intended 3 cell 6 V SLA battery this was nominally designed for, this means a charging voltage of 6.75-6.90 V is required so around 2% accuracy is required. This is actually quite a tight tolerance, and I’ll come back to this is a later post for those with different requirements.

As mentioned, the regulator is based around IC3, which is a TL431 shunt regulator. This is an incredibly cheap and accurate part, and very widely available. It’s used in a lot of things, and you’ve probably got dozens in your house. In brief, it will shunt away excess current to keep a constant voltage at it’s output, hence the name. The TL431 has a nominal 2.495 V internal reference, and an opamp driving a transistor. Here’s how the values were calculated:

  1. The voltage out for the shunt regulator, as shown in the datasheet, is given by V_O = (1 + \frac{R15}{R21})V_{ref}. We know what V_{ref} is, and I’ve defined a value for R21 as 3k6 \Omega. Why 3k6 \Omega? Further down you’ll see this value used a lot, and when manufacturing, you always want to have the fewest number of individual values as that will drive down your inventory costs, and allow you to access bulk buy discounts. Also, having R15 + R21 \approx 10\ \textrm{k}\Omega is a sensible choice, giving around 0.5 mA through the resistor divider. With that information in hand, we can determine R15. Rearrangement of the first equation gives: R15 = (\frac{V_O}{V_{ref}} - 1)R21 \rightarrow R15 = (\frac{6.81}{2.495} - 1) \times 3600 = 6226 \Omega.
  2. Now, we want to use readily available, and thus cheap, resistor values. The Electronic Industries Association specifies a list of preferred values. You can choose from the lowest series which meets your requirements. We need to be quite precise here, so I’ve chosen from the E24 series. So, the 6226 \Omega becomes 6k2 k\Omega with little impact on the function of the circuit.
  3. Calculate the worst case power dissipation in the TL431. The worst case is if the battery voltage is greater than the 6.8 V we set as V_O. In that case all the current is passing through the TL431. Using P = IV, we can work out the dissipation. As shown below, I’ve specified I to be 55 mA, and V is V_O. So, P = IV \rightarrow P = 0.055 \times 6.8 = 374 mW. Now, checking the TL431 datasheet, this is more power than the chip can handle so we need to include a pass transistor, which is Q2. This is in a bigger package designed for heat dissipation, and will handle all the excess shunt current easily.
  4. As we now have the pass transistor, we need to feed the TL431 a little current to generate the desired voltage. As per the datasheet, this current is in the range 1 mA < I_\mathrm{TL431} < 100 mA, so let’s give it 2 mA. The voltage at the junction of R16, IC3, and the base of Q2 is V_O - V_{be}. To conduct current, Q2 requires current applied to it’s base. This I_B is then multiplied by the transistor’s h_{FE}. You can find the values of V_{be} and typical h_{FE} value in the datasheet for the BCP52-16, which are 1 V and 100 respectively. This means the current through the TL431 is equal to the current through R16 plus the current into the transistor’s base. Putting this together gives: I_\mathrm{TL431} = \frac{V_{be}}{R16} + \frac{I_C}{h_{FE}}. Rearranging to find R16 yields: R16 = \frac{V_{be}}{I_\mathrm{TL431} -\frac{I_C}{h_{FE}}} \rightarrow R16 = \frac{1}{0.002}-\frac{0.055}{100} =\ 500 \Omega.
  5. You’ll notice there is another resistor in parallel with R16, that is resistor R27. Why two resistors and not one? Again, this comes down to manufacturing ease: two 910 \Omega resistors in parallel is equivalent to a single 455 \Omega resistor, which is standing in for the value we calculated in step (4). It’s a bit smaller, but that just means there’s a little extra current going through the TL431, which is not a problem.
  6. Finally, C4 is there to provide some bypassing. It’s value isn’t (usually) too critical, and may be anywhere from 100-470 \muF.

Well, that was a rather in depth look into something which on the surface may appear quite straightforward! I suggest taking a piece of paper and checking everything’s as calculated and makes sense. We’re half way there for the trickle charger, next up is the constant current source: The values for the CCS are derived as follows:

  1. LED1 has a roughly known value (~2.2 V for a green LED), specified in it’s datasheet
  2. Q1 is a general purpose PNP bipolar transistor. It is in a SOT223 for heat dissipation (we’ll calculate this later). The values of interest in it’s datasheet are: hfe and Vbe.
  3. Emitter resistor R3 sets the current. The transistor will try to maintain the same voltage drop across R3 as (VLED + Vbe). This gives us the equation we need to solve: R_3 = \frac{V_{LED} + V_{be}}{I_C}. Since we know all these values, we can then calculate R3 as: R_3 = \frac{2.2 - 1}{0.055} = 21.1 \Omega. As for the regulator, we need to pick a “real” value; in this case, 22 \Omega is ideal.
  4. Next, we need to check the power dissipation of R3. Using P = I^2R, we get 66.6 mW. It’s prudent to specify at least double the wattage, so I’ll specify a 250 mW part for this position.
  5. Finally, the power dissipation in Q1 should be determined. I’d intended for a 15 V power supply to be used as the maximum for the power source, which will give us the worst case dissipation in Q1. The voltage across Q1, V_{CE} will be: V_{CE} = V_\mathrm{supply} - V_\mathrm{R3} - V_\mathrm{regulated} \rightarrow V_{CE} = 15 - 0.055 \times 22 - 6.8 = 6.99 V. Now, P = I_CV_{CE} \rightarrow P = 0.055 x 6.99 = 384 mW.

So, we’ve successfully designed a trickle charger for our lead acid backup battery! As I hope was clear through that was that the values you see on schematics take quite a lot of calculation, and there are little tricks like holding values constant and working from those constraints. As ever, any questions, feel free to comment here or on the forum page.



2 thoughts on “Raspberry Pi HATS compatible UPS – part IIa – trickle charger

  1. Pingback: Raspberry Pi HATS compatible UPS – part IIb – status indication | AWJ Logan

  2. Pingback: Raspberry Pi HATS compatible UPS – part IIc – power and miscellaneous parts | AWJ Logan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s