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**

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:

- The voltage out for the shunt regulator, as shown in the datasheet, is given by . We know what is, and I’ve defined a value for R21 as 3k6 . Why 3k6 ? 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 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: . - 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 becomes 6k2 with little impact on the function of the circuit. - 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 . In that case*all*the current is passing through the TL431. Using , we can work out the dissipation. As shown below, I’ve specified to be 55 mA, and V is . So, 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. - 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 , so let’s give it 2 mA. The voltage at the junction of R16, IC3, and the base of Q2 is . To conduct current, Q2 requires current applied to it’s base. This is then multiplied by the transistor’s . You can find the values of and typical 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: . Rearranging to find R16 yields: .
- 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 resistors in parallel is equivalent to a single 455 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.
- Finally, C4 is there to provide some bypassing. It’s value isn’t (usually) too critical, and may be anywhere from 100-470 F.

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:

- LED1 has a roughly known value (~2.2 V for a green LED), specified in it’s datasheet
- 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:
*h*_{fe}and*V*._{be} *Emitter resistor*R3 sets the current. The transistor will try to maintain the same voltage drop across R3 as (*V*LED +*Vbe*). This gives us the equation we need to solve: . Since we know all these values, we can then calculate R3 as: . As for the regulator, we need to pick a “real” value; in this case, 22 is ideal.- Next, we need to check the
*power dissipation*of R3. Using , 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. - 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, will be: V. Now, 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.

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

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