Silicon ChipMulti-purpose Battery Manager - August 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Publisher's Letter: The power of batteries
  6. Feature: Time for a total rethink? by Mark Nelson
  7. Feature: Net Work by Alan Winstanley
  8. Project: Multi-purpose Battery Manager by Tim Blythman
  9. Project: Simple MIDI Music Keyboard by Tim Blythman
  10. Project: NANO PONG ON YOUR TV by TIM BLYTHMAN
  11. Project: USB Power Delivery Chargers by Jim Rowe
  12. Feature: Make it with Micromite by Phil Boyce
  13. Feature: KickStart by Mike Tooley
  14. Feature: Max’s Cool Beans by Max the Magnifi cent
  15. Feature: Flowcode Graphical Programming by Martin Whitlock
  16. Feature: Circuit Surgery by Ian Bell
  17. PCB Order Form
  18. Advertising Index

This is only a preview of the August 2022 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Multi-purpose Battery Manager thman By Tim Bly Our recent Battery Multi Logger is a great tool for monitoring and diagnosing battery problems. But sometimes, you need something which will not just monitor what’s going on but also take action, such as connecting and disconnecting loads based on battery charge state. That’s just part of what this Battery Manager does. O ur Battery Multi Logger (PE, February-March 2022) is a Micromite-based device that monitors the condition and usage of a battery system. It can handle battery systems between 6V and 100V, and it is a convenient tool to keep track of how batteries are being used, ensuring that they are kept healthy. Being heavily discharged or overcharged can greatly reduce a battery’s working life, possibly leading to the need to buy an expensive replacement prematurely. So you want to be sure that you’re treating them well. Both of these conditions are relatively easy to rectify, as long as you are aware of them happening, by simply 14 disconnecting the load(s) or charger causing the problem. Our recent Battery Multi Logger unit can monitor this but did not have any means to take corrective action – until now. The Battery Manager adds switching modules to the Battery Multi Logger, which can connect or disconnect loads and chargers to keep the batteries healthy. Part of the design is a new I/O Expander board that provides control signals to allow up to four Switch Modules to independently and automatically connect and disconnect loads as needed. The Battery Manager can also interface with the High Current Four Battery Balancer (PE, April-May 2022) to provide even more detailed information about the state of a multi-cell battery or multi-battery system. The Battery Manager can even be used to program, control and monitor the Battery Balancer. While the Battery Multi Logger hardware remains mostly unchanged from the published design, a new control program adds the interface to configure, control and monitor the Switch Modules and Battery Balancer. The Switch Module and I/O Expander hardware also have uses outside the Battery Manager. While designed for 3.3V operation, the I/O Expander board will happily work at 5V, so it could be hooked up to an Arduino board or just about any other microcontroller. Practical Electronics | August | 2022 Features ● ● ● ● ● m a t, e i le a m e ta is e t atte ai a i te a e it t e i a a le s it i ell la a t iti t t e atte l a s/s es t e t e 20 ( Similarly, the Switch Module will work with just about anything that can supply a control signal of 3.3-15V. So it can also be driven directly by just about any microcontroller. M lti e te t atte ies atte ala e ssi l e 30 ) at 10 -60 Switch Module One of the goals of the Battery Multi Logger is to use as little power as possible. So we have designed the new Switch Module to have very low quiescent and operating currents. We are using high-current MOSFETs as switches because these can be controlled with minimal power. The MOSFETs are driven by a latching circuit that ‘remembers’ the state of the switch and drives the MOSFET gates on or off as needed. This latch can be toggled in several different ways. A pair of switch contacts connected to the latch circuit can set its state, providing simple pushbutton control. The Switch Module PCB also incorporates a pair of opto-isolators. Their output transistors are in parallel with the switch contacts. Thus, there is also the option to set the latch state and control the MOSFETs via an electrically isolated interface. pins that provide the COM1: serial port are not used, though, and are brought out to the Battery Multi Logger PCB edge. But we have earmarked these to interface with other serial devices. A better way to control Switch Module(s) is to use the I2C interface, which is brought out to pins at CON4 of the Battery Multi Logger PCB. We are using a PCF8574 IC, which we described in our article on I/O Expander Modules (PE, November 2021). This lets us easily add eight I/O ports. In fact, with multiple ICs, we could add up to 128 I/O ports, although that would exceed our requirements. So we have designed a small I/O Expander PCB, which can be controlled using the available I2C bus. It provides eight I/O pins connected to transistors to drive the opto-isolated inputs of th Switch Module(s). As noted above, a low quiescent current is important. The PCF8574 draws around 10μA when there is no activity on the I2C bus. Its primary current consumption is the current it supplies to drive the opto-isolators, and they are only active very briefly during switching. I/O Expander board You might recall from the Battery Multi Logger article that it doesn’t have many free I/O pins left. The two Battery Balancer support As we just noted, the COM1: serial port on the Battery Multi Logger is free for us to use. Since the Battery Balancer already has a serial interface, we can simply connect these to allow communication and control between the two. We can also use the Mini Isolated Serial Link (PE, March 2022) to isolate the different parts of the system. Fig.1 shows an overview of the additions to the Battery Multi Logger to turn it into a Battery Manager. Note the connection from the Battery Balancer to CON6 on the Battery Multi Logger. Updated software Naturally, these extra features need to be controlled and configured. This is done via extra buttons and pages on the Battery Multi Logger’s Micromite LCD interface, shown in screengrabs later in this article. There is also a more detailed description indicating how to use these new screens along with those images. The first new page controls the Switch Modules; up to eight triggers can be set. These are voltage or current thresholds that result in an action occurring, such as one or more of the Switch Modules being activated. A latch is also set to prevent repeated activation; a trigger can also reset a latch to provide alternate operation. For example, Trigger 1 can be set to activate when the battery voltage falls below 11V. This sets Trigger 1’s latch and, via a Switch Module, also disconnects some non-essential load from the battery, reducing the chance of damage to the battery from deep discharge. Trigger 2 is set to activate when the battery rises to 12.5V and also to reset Trigger 1. Similarly, Trigger 1 can reset Trigger 2. As you might expect, Trigger 2 would be configured to reconnect the load that is disconnected by Trigger 1. Fig.1: the Battery Manager consists of the Battery Multi Logger plus the peripherals shown here. Up to four Switch Modules can be added with one I/O Expander – we imagine most constructors will need one or two. It can also interface with the High Current Battery Balancer, allowing cell status and balancing activity to be monitored. Practical Electronics | August | 2022 15 Thus these two triggers work to detach a load from the battery except when it has sufficient charge. A similar arrangement in reverse can also work as a crude charge regulator, preventing overcharging. The external switches can also be manually manipulated, either for testing or to override the programming; plus you can also manually reset the triggers. Another page shows the current operating state of the Battery Balancer (as reported by the Balancer over its serial port), including which cells are being bala nced, in which direction and to what extent. Buttons are also provided to issue commands to the Battery Balancer. Two graph pages are available to show recent data from the Battery Balancer. One page shows the cell and stack balancing activity, while a second page plots the individual cell voltages. I/O Expander operation The circuit diagram of the I/O Expander module is shown in Fig.2. Its CON1 header connects to the Battery Multi Logger’s CON2 for 3.3V power and ground. The I2C bus is present at the Battery Multi Logger’s CON4, which connects to CON2 here. These are situated to align directly, allowing the I/O Expander module to stack onto the existing hardware, using either stackable headers or being directly soldered. Since it is only four wires, it can be run remotely too, although a direct connection is preferable. The Battery Multi Logger hosts the pull-up resistors required for the I2C bus, so these are not present on the I/O Expander board. It’s generally better for pull-ups to be on the master, since only one pair is needed per bus. On the I/O Expander PCB, the 3.3V, ground, SDA and SCL lines from CON1 and CON2 go to IC1’s pins 16, 8, 15 and 14, respectively. A 100nF capacitor bypasses IC1’s supply. There are two more 100nF capacitors to help source current into downstream connectors CON3-CON6. IC1, the PCF8574, has three address pins (1, 2 and 3) that need to be pulled up or down to set its address. We avoid the use of pull-up or pull-down resistors as this could increase current consumption. So a group of three jumper pads, JP1-JP3, is provided for this purpose. All pins are pulled low by default, giving a 7-bit address of 0x20 hexadecimal (32 decimal). These jumpers are actually solder pads on the PCB and can be changed by cutting the thin traces and soldering between pads. Since eight I/O pins are ample, we have written the software to simply work with a single I/O Expander board with the default address. The PCF8574 could be replaced by the mostly identical PCF8574A. The only difference is that the PCF8574A uses a different range of addresses; in this case, the default address will be 0x38 (56 decimal), and the software would need to be modified to suit that value. Pin 13 of IC1 provides an active-low input change interrupt signal, which is not used in this application. We are using all of the pins as outputs, so we do not need the interrupt function. The remaining pins labelled P0-P7 (pins 4, 5, 6, 7, 9, 10, 11 and 12, respectively) are the I/O pins. They are either weakly pulled up (the default state) or pulled low by a sink capable of around 10mA. Since the opto-isolators on the Soft Switch are active-high devices, we use P-channel MOSFETs controlled from these I/O pins to source current from the 3.3V rail. These MOSFETs also invert the signals. For example, Q1’s gate is connected to pin 4 of IC1 (P0). The gate is also pulled high by a 10kΩ resistor. While probably not strictly necessary, we have fitted these so that false triggering does not occur while the Battery Multi Logger is powering up. Q1’s source is connected to the 3.3V rail and is effectively connected to its I/O Expander Module Fig.2: the I/O Expander adds to the modular nature of the Battery Manager, providing extra I/O ports to drive devices like Switch Modules. Each I/O Expander adds eight signals, enough to control four Switch Modules. It uses the PCF8574 addressable I/O Expander IC, which can be configured to respond to eight different addresses, allowing further expansion. 16 Practical Electronics | August | 2022 drain when the gate goes low, delivering 3.3V to pin 2 of CON3. A similar arrangement exists for the other seven I/O pins of IC1. The outputs are arranged in pairs, to provide the complementary on/off functions needed for the Switch Module to operate. Each of CON3-CON6 can connect to the input of a Switch Module, and so we can control up to four Switch Modules with one I/O Expander board. In operation, the I2C host (in this case, the Battery Multi Logger) writes a default value of 0xFF (all bits set high) to IC1, which then sits in this idle state, drawing virtually no current. Its output transistors are off, and all pins on CON3-CON6 are not connected to the 3.3V rail. When an output needs to be activated, the Battery Multi Logger sends a data byte with at least one bit set low. This causes the corresponding pin from P0-P7 to go low, turning on its MOSFET and sending its corresponding output high. For the brief period that the I2C bus is active, IC1 draws a modest 100μA, while any of P0-P7 that are active will cause less than 1mA to be sunk through its pull-up resistor. The transistor will also source whatever current is needed to control the connected Switch Module. Switch Module operation Fig.3 shows the circuit diagram of the Switch Module. As mentioned, up to four Switch Modules can be connected to a single I/O Expander board. CON1 and CON2 are large, highcurrent connections to the positive end of a battery and its load or source (eg, a charger). Thus, we perform highside switching, leaving the ground connections uninterrupted. The connections are not polarised, so current can flow in either direction when the switch is on. Across CON1 and CON2 are connected pairs of back-to-back P-channel MOSFETs, Q4-Q11. Their sources are connected together, with the drains going to either CON1 or CON2. The Battery Balancer can be connected to the Battery Manager to provide greater information about the state of the batteries. It connects via our Mini Isolated Serial Link. With the gates held near the source potential, the transistors do not conduct, and the switch is off. If the gates are taken low relative to their sources, then a low-resistance path exists between CON1 and CON2. The MOSFET body diodes pass a positive voltage from either CON1 or CON2 to the remainder of the circuit. CON3 is used to provide a ground connection for the circuit and is wired to the battery system’s common negative terminal. The 10kΩ resistor in series with the GND connection and the 100nF capacitor across ZD2 provide a filtered logic supply (between LOGIC+ and LOGIC_ GND). Typically, around 90% of the battery voltage is present across the 100nF capacitor and ZD2. Zener diode ZD2 does not conduct under normal conditions; it is not even strictly needed for 12V systems, but will clamp any spikes that might be present. It also allows the switch module to be used with battery voltages over 60V. Q1 and Q2 are configured as a bistable latch, with the 100kΩ and 220kΩ resistors connected to their gates – these provide a mutually exclusive interlock. The gate of Q1 is connected to the drain of Q2 and vice versa. If Q1 is on, then Q2’s gate is pulled to near its source voltage, and it is off. Similarly, if Q2 is on, then Q1 must be off. This latch is what retains the state of the Switch Module. Q1’s gate is also connected to Q3’s gate, so that Q3’s state is generally the same as Q1’s. Q3’s drain is also connected to Q4-Q11’s gates. When Q3 is on, its drain network (consisting of the 100kΩ and 220kΩ resistors and 15V zener diode ZD1) drives the gates of Q4-Q11 to 4-15V below their sources. In this state, Q4-Q11 turn on, closing the Switch Module’s connection between CON1 and CON2. Otherwise, their gates are pulled up to their sources by the 220kΩ resistor and they switch off, opening the Switch Module’s connection between CON1 and CON2. Toggling the Switch Module state involves pulling either of Q1 or Q2’s gates to LOGIC_GND. This can be The I/O Expander (also labelled as an I2C Interface) adds another PCB to the Battery Manager stack. If you need multiple I/O Expanders, you could fit them with stackable headers (as used on Arduino Shields). Just be sure to set different I2C addresses on the stacked PCBs. Practical Electronics | August | 2022 17 Switch Module Fig.3: the Switch Module has two opto-isolated inputs which drive a pair of complementary latching MOSFETs. These, in turn, drive a bank of highcurrent MOSFETs for switching loads up to at least 20A. This is useful in its own right, as it can be driven by just about any microcontroller, or even a simple set of contacts such as a pushbutton. done by the phototransistor outputs of OPTO1 or OPTO2, respectively. When a voltage is applied at CON4’s pin 2 that is positive with respect to its pin 1, current flows through OPTO1’s LED via the 470Ω resistor, turning on its phototransistor. Similarly, a positive voltage at pin 3 of CON4 triggers OPTO2, pulling Q2’s gate low. A connection between the pins of CON5 or CON6 will have the same effect. This allows control by something like a pushbutton, in addition to control by the Battery Manager. If both Q1 and Q2 have their gates pulled low, then naturally, Q3’s gate is low too, and the Switch Module is off. Thus the safe ‘off’ state dominates if conflicting signals occur. This is similar to the state that occurs when power is first applied. In this case, capacitor C1 (which will have been discharged by its parallel 100kΩ resistor) holds Q1’s gate low for a brief period, allowing Q2 to turn on before Q1, and the Switch Module is forced into the off state. The time constant of this RC network is less than 1ms, so as long as external pulses are at least this long, then incoming pulses are latched correctly. If the reverse behaviour is required, then the capacitor is fitted adjacent to Q2, to the pads marked C3 instead of C1. The Switch Module will then power up in the on state. 18 Current consumption When sitting in the latched off state, the current consumption is around 500μA at 60V and proportionally less at lower voltages; around 100μA at 12V. When switched on, extra current flows through Q3, adding around 200μA at 60V, down to 40μA at 12V. The current level during switching will be higher than this, with Q1, Q2 and Q3 sinking current, but that occurs only very briefly, because the complementary transistors turn off almost instantaneously. Switch ratings P-channel MOSFETs Q4-Q11 are SUP53P06 types with a nominal maximum gate voltage of –20V (with respect to the source) and a maximum drain voltage of –60V. These parameters set the practical working limits of the Switch Module. These MOSFETs are specified at around 9A continuous current each (at 25°C), but the PCB track width limits this to about 20A across the four pairs; perhaps up to 30A with ample cooling. This can be increased by supplementing the PCB with extra wires soldered directly to the MOSFETs. Alternatively, for very light loads, some MOSFETs could be left off. The dividers around Q1, Q2 and Q3 have been set to allow operation up to 60V (respecting their 20V gate limit with the 220kΩ/100kΩ divider). Since they have gate thresholds down around 3V, they require a battery voltage of at least 10V to work correctly. ZD1 is provided to clamp the gate voltage to 15V for safety. This is generally not a problem for switching loads, as the maximum voltage seen will be the battery voltage. However, for charging sources the voltage can be much higher. For example, a 12V solar panel can have a 22V open-circuit voltage. Wind turbines can be even higher; they typically need a shunt regulator to prevent their unloaded voltage from reaching dangerous levels. So care should be taken when using this module with a charging source to ensure that the open-circuit voltage does not exceed the Switch Module’s limits. The MOSFET types can be changed to allow operation at higher voltages, but other parts of the circuit might have to be modified too. For example, the SPP15P10-type MOSFET used in the Burp Charger for NiMH and NiCad Batteries (PE, June 2015) can handle up to 100V, and is a direct substitute for the SUP53P06. The other change we recommend for higher voltage builds is increasing the value of the 10kΩ resistor to reduce the quiescent current through it and possibly ZD2. Consider the section in parallel with ZD2 as having a resistance of around 100kΩ. So for 100V switching, replacing the 10kΩ resistor with a 220kΩ resistor will put around 30V across ZD2, thereby allowing the circuit to operate correctly. We have not specified the SPP15P10 MOSFET in our parts list because it Practical Electronics | August | 2022 has a much higher drain-source resistance. So it will produce more heat at the same current level, and we expect most readers will be using the Switch Module below 60V. Handling more current If you find that your current requirements are beyond that of the Switch Module, you can use the Switch Module to operate the coil of a heavy-duty relay. The current when energised will be much higher, but this option allows the Battery Manager to work with just about any load. In this case, just a single pair of MOSFETs is sufficient to operate the relay coil (eg, Q4 and Q5). A snubbing diode across the coil is highly recommended, to protect the MOSFETs from spikes that the coil might generate when it de-energises. Software updates This is a good point to upgrade the software on the Battery Multi Logger to give it the Battery Manager features, if for no other reason than to get it out of the way before we connect the I/O Expander to the ICSP header (which would make programming trickier). If you have blank chips, follow the original instructions for programming the Battery Multi Logger, including putting the Microbridge firmware on the PIC16F1455. But instead of the Battery Multi Logger firmware file (1110620A.HEX), load the newer Battery Manager (1110620B.HEX) file. Don’t forget to set JP2 to the PROG position before using the ICSP interface – and then set it back to RUN after programming. For an already-working Battery Multi Logger, you can simply update the MMBasic file. The same library file and LCD OPTIONS are used, so no other changes are needed. The act of loading a program will delete any logged data, so you should export that first, if necessary. The newer software has less space for logged data due to needing more space to store configuration variables for the Soft Switches. Thus, the longterm data is reduced to 10 days, and this allows two Soft Switches (controlled by four triggers) to be fitted. These limits are set by CONST values in the program. We’ve listed some options below regarding how these two values can be changed and still fit within the existing Flash memory. But generally, as long as the sum of the number of days stored and the number of triggers is no more than 14, it should work. These are the D_COUNT and TRIG_ COUNT values. Due to the way they are Practical Electronics | August | 2022 The Battery Soft Switch (or Switch Module) uses highcurrent MOSFETs as switches so that the total operating power consumption is low. Four of these Switch Modules can be independently controlled per I/O Expander board. displayed on the page, TRIG_COUNT should be no higher than eight, as otherwise, the control buttons cannot be seen. You will need to load the ‘crunched’ (with comments and whitespace removed) program, as it does not fit in memory otherwise. The uncrunched version is also available so that you can inspect the fully-commented code and make changes if you like. In general, you should follow the instructions for the Battery Multi Logger but replace the respective HEX and MMBasic files with their Battery Manager equivalents. Run the newly installed program to set the AUTORUN flag. Now it should automatically start when powered up. We’ll go into the software detail later, but you should see the new main page as seen in Screen 1. Construction options An important first step before building the board is to determine what parts are needed. Given the low cost of the parts for the I/O Expander board, we recommend that you build the full version, which can handle four Switch Modules. However, you could leave off some of the parts if you are sure that you will only be connecting one or two Switch Modules. The specifics of your battery installation might also affect how you build it. We’ve designed the Switch Module PCB with holes to suit 8mm screws and thus eyelets suiting up to 8G (3.25mm diameter copper) cable, which should be sufficient for anything that the Switch Module can handle. You will need to consider how many Switch Modules you need. Most people will need one or perhaps two to disable non-critical loads when the battery charge state gets low. There’s always a critical load that can’t be disconnected, and that won’t need a Switch Module; you’d much rather have a flat battery than a submerged boat because the bilge pump wasn’t running! And assuming you have a reputable charge controller, there will be little need to add a Switch Module inline with any connected solar panels. Similarly, you might or might not need to build and connect a Battery Balancer. If you have a 24V, 36V or 48V system composed of 12V batteries wired in series, you can make good use of the Battery Balancer. If the Battery Balancer and Battery Multi Logger can’t share the same ground, you will also need to build the Mini Isolated Serial Link. Regardless, we recommend using the Mini Isolated Serial Link to avoid any potential problems; it’s cheap and easy to build, and safer to isolate the two devices. Building the I/O Expander Let’s start by building the I/O Expander and connecting it to the Battery Multi Logger; you can add switch Modules after that. If you’re just interested in the Battery-Balancer-related upgrades, 19 Screen 1: the Battery Multi Logger’s Main screen has been updated to add two new buttons for the Trigger and Balancer functions. At bottom right, the trigger state is shown, and the title has also been changed to reflect the unit’s new capabilities. you can skip most of the construction (assuming you’ve already built the Battery Multi Logger and Battery Balancer). The I/O Expander is built on a double-sided PCB coded 11104212, which measures 37.5 x 35.5mm and is available from the PE PCB Service. Fig.4 is the PCB overlay diagram; all the components are on one side, but there are some solder pad ‘jumpers’ on the underside, so both sides are shown. Since the I/O Expander will essentially become part of the Battery Multi Logger PCB, we have used surface-mounted parts. We recommend having on hand a fine-tipped soldering iron, flux paste, solder wicking braid, a set of tweezers and a magnifier. Flux paste releases a fair bit of smoke, so good fume extraction or ventilation is important too. Start by fitting IC1, noting that its pin 1 is closest to the mounting hole. We found the marking on this chip difficult to discern; there should be a small circle on the top of the part, and a bevel along the nearest edge. On the chips we used, pin 1 is at lower left when the chip markings are the right way up (with the bevel along the bottom edge). Put some flux on the PCB pads for IC1, rest the chip roughly in place and apply a bit more flux to the top of the pins. It doesn’t hurt to be generous. Load the tip of the iron with a bit of solder and tack one pin in place. Adjust the chip if necessary by melting the solder and nudging the chip with tweezers. Once all the pins are correctly aligned, solder them to the PCB. If there are any bridges between pins, remove them with the braid. Add flux to the bridge and press the braid against it with the iron, carefully pulling it away when the braid has drawn up the solder. Solder the transistors next. They are all the same type and are polarised, but should only fit one way due to their shape. Put some flux on the pads and tack one lead in place, then solder the remaining leads. Despite their small size, the leads are well spread around the part, so they are quite easy to solder. Place the three capacitors next; they are near the top of the PCB. Use a similar technique of soldering one lead at a time. The remaining parts are much easier to solder and have larger pads. Follow with the resistors, then clean up any excess flux with the solution recommended by the flux manufacturer (or your favourite one). Attaching it to the main board Since the I/O Expander is designed to mount directly to the Battery Multi Logger PCB, shut down the Logger and disassemble it. If you have a header fitted to CON2, remove it and clean up the pads to allow the I/O Expander to be fitted. Take the pairs of header pins and sockets and plug them together. Install them in their respective holes between the two PCBs, with the female headers on the Logger PCB and the male headers on the I/O Expander PCB. This will reduce the chance of exposed connectors if the I/O Expander PCB is removed. You can then clamp the two PCBs together temporarily with a machine screw and nut (or tapped spacer). This will make them easier to solder. Refer to the photos as a guide. Solder the headers in place, remove the temporary screw and reassemble the stack, including the LCD. Instead of fitting the machine screw in the corner where the I/O Expander sits, use the extra spacer and the longer machine screw to secure everything against the tapped spacer fitted to the back of the LCD. Switch Module assembly The Switch Module is built on a PCB coded 11104211, which measures 81.5 x 82.5mm and is available from the PE PCB Service. Its overlay diagram is shown in Fig.5 – note that it uses all through-hole parts. Start by fitting the resistors according to the markings on the PCB. It’s best to check their values with a multimeter to ensure you have the correct components. Follow with the two zener diodes. Neither of these are necessary for systems that operate up to around 25V, as there are unlikely to be voltages high enough to cause damage to MOSFETs, although it’s a good idea to fit ZD1 to protect the MOSFETs. ZD2 is only needed for systems that go over 60V. Keep in mind what we mentioned before about solar panels and wind turbines producing much higher voltages than their nominal ratings. Next, fit the two 1N4148 diodes near CON4, noting their polarity. Follow with the two adjacent opto-isolators. Take care that their pin 1 markings align as shown in our photos. They both face the same way. Now install the two capacitors. As mentioned earlier, C3 does not need to be fitted unless the default behaviour needs to be changed, so it is not shown in Fig.5. After this, mount the three smaller transistors, Q1-Q3. Ensure that they align to their footprints, and push them down as close to the PCB as possible before soldering. Follow with the larger transistors. If you are not fitting all of them, fit those closest to CON1 and CON2 in Fig.4: assembly of the I/O Expander is straightforward – it uses mostly SMD components, but they are easy to handle. Fit IC1 first, ensuring its pin 1 marking is oriented as shown. All capacitors and resistors are non-polarised and of a single value. You don’t have to use vertical headers, as shown here; you could use right-angle headers, sockets or just solder wires to the pads. 20 Practical Electronics | August | 2022 matching pairs. For example, if you only need four MOSFETs to handle your load current, put them in the spots marked Q4-Q7. For each transistor, bend its leads back 90° around 7mm from where they meet the body. Insert the leads through the PCB and fi x the tab in place with the machine screw, washer and nut. Take care not to twist the transistors, which might bend the leads. Once aligned with its footprint, solder and trim the leads. The large copper pour will draw heat from your iron, so use a higher temperature if necessary. We’ve added some thermal relief on the PCB to help with this. Basic testing You might like to test the I/O Expander and Switch Module at this point. Connect CON3 on the I/O Expander to CON4 on the Switch Module. Connect G to COM, P0 to OFF and P1 to ON. Now attach a 12V power source between CON1 and CON3 on the Switch Module, with the negative terminal to CON3. Connect a multimeter across the empty C3 pads; it should read about 1/3 of the supply voltage. Shorting the CON6 pads on the Switch Module should cause this to drop to 0V and stay there when released. Similarly, shorting CON5’s pads will cause the voltage to revert to 1/3 supply. Using the SOFT SWITCH page on the Battery Manager, you can press the green button next to TR0 and TR1 to toggle the state via the I/O Expander. Keep in mind that the software has been configured with some defaults to suit a 12V battery, and these will be active when the Battery Manager is first powered up. If all this is correct, then the I/O Expander and Switch Module are working correctly. Your wiring from here will depend on your application, but consider that CON1 and CON2 are the switch terminals. Ideally, you should have a fuse and separate switch to the battery circuit feeding the Switch Module to protect it in the event of a fault. So, do ensure that you don’t connect something that can cause damage or be affected by unplanned switching. You might like to leave this until later, after you have configured the Battery Manager. Note the holes in the corner of the PCB, which are designed to take M3 machine screws, allowing the Soft Switch modules to be mounted in an enclosure. For example, you could fit them to the interior of the same panel as the Battery Manager. Practical Electronics | August | 2022 Parts List – Battery Manager 1 assembled Battery Multi Logger module (PE, February-March 2022, with IC1 programmed with 1110620B.hex instead of 1110620A.hex 1 assembled Battery Balancer module (optional) (PE, April-May 2022) 1 or more assembled I/O Expander modules (see below) 1 or more assembled Switch Modules (see below) 1 assembled Mini Isolated Serial Link (optional) (PE, March 2022) various lengths of heavy-duty wire, eyelet lugs etc to suit battery and application various lengths of medium-duty hookup wire (see text) various jumper leads (optional; to connect I/O Expander module[s] to the Battery Manager and Switch Module[s]) I/O Expander module parts (per module) 1 double-sided PCB coded 11104212, 38 x 36mm 1 PCF8574 I2C expander IC, SOIC-16 (IC1) [Digi-Key, Mouser] 8 IRLML2244 P-channel MOSFETs (Q1-Q8) [Digi-Key, Mouser] 3 100nF X7R SMD 3216/M1206-size ceramic capacitors 8 10kΩ 1% SMD 3216/M1206-size resistors 1 5-way header (CON1) 1 2-way header (CON2) 1-4 3-way headers or subminiature screw terminals� (CON3-CON6) 1 untapped 12mm-long spacer, ~3.125mm inner diameter 1 M3 x 20mm panhead machine screw Switch Module (per module) 1 double-sided PCB coded 11104211, 82 x 83mm 1 3-way pin header or subminiature screw terminal� (CON4) 16 M3 x 6mm panhead machine screws 4 M3 x 12mm tapped spacers 8 M3 nuts 8 M3 washers � eg, Digi-Key part number ED10562 Semiconductors 2 4N25 opto-isolators, DIP-6 (OPTO1,OPTO2) 3 2N7000 N-channel small-signal MOSFETs, TO-92 (Q1-Q3) 2-8 SUP53P06 P-channel high-current logic-level MOSFETs, TO-220 (Q4-Q11) 1 15V zener diode (ZD1) 1 39-60V zener diode (ZD2) (optional; see text) 2 1N4148 small signal diodes (D1,D2) Capacitors 1 100nF 100V MKT 1 1nF 100V MKT Resistors (all 1/4W 1% axial metal film) 3 220kΩ 3 100kΩ 1 10kΩ 2 470Ω A header can be added to the top of the Logger PCB, as shown, to allow in-circuit programming. This header can also provide power to a Mini Isolated Serial Link for connection to a Battery Balancer (singular red wire). Battery Balancer interface You need four wires to connect the Battery Balancer to the Battery Manager if using the Mini Isolated Serial Link, or three if you are not. The fourth wire is to power the isolator. 21 Fig.5: the Switch Module uses all through-hole components and is easy to assemble. Watch the orientation of OPTO1, OPTO2 and the diodes. You can install fewer than eight MOSFETs if your load draws less than 20A; just make sure to fit them in pairs (Q4 and Q5; Q6 and Q7...). The load can be connected either via the twoway screw terminal, or eye lugs bolted to CON1 and CON2. Revision E and later of the Battery Multi Logger PCB has pads breaking out the three connections at CON6. For power, you will need to tap into the 3.3V supply, and the best place for this will be at the Battery Manager’s CON2 (which also connects to the I/O Expander’s CON1). If you have an earlier PCB (unlikely, but see note on caption to Fig.6), then the only way to tap into the serial data pins (Micromite pins 21 and 22) is to solder directly to the pins at the IC. It’s not easy, but it is not much harder than soldering the SOIC parts in the first place. Fig.6 and 7 show the wiring required. Fig.6 depicts how a direct connection would be made, while Fig.7 shows the wiring via a Mini Isolated Serial Link. Note how in both cases, the wires appear to go to two points on the Battery Logger PCB at left. They only need to go to one. If CON6 is present (on Revision E boards or later), then use those connections. Otherwise, use the dashed alternatives. These go to pin 22 of the IC for RX and pin 21 for TX. If CON6 is missing, the ground connection can be taken from pin 2 of the LCD header or the middle pin (pin 3) of CON2, the ICSP header. The preferred arrangement, using the Mini Isolated Serial Link, is shown Fig.6: only one of each colour of wire is needed, but we’ve shown two options for each, so you can choose a suitable way to connect the two boards. The dashed wires are only needed if you have an early revision of the PCB that lacks CON6 (bottom right). While the boards are notionally at the same ground potential, it wouldn’t hurt to add series resistors, but Fig.7 shows an even better option. (Note – all boards sold by PE will be of the later variety with CON6.) Fig.7: the preferred method of joining the Battery Multi Logger to our Battery Balancer is via a Mini Isolated Serial Link module. The module needs to be supplied with 3.3V on each side; ensure that the jumper links on the Serial Link are set to the 5V positions, as shown (which actually corresponds to 3.3V in this case). 22 Practical Electronics | August | 2022 Screen 2: the SOFT SWITCH page shows the trigger states and thresholds. Pressing the buttons allows the triggers’ operation to be tested and triggers to be manually reset, if this form of operation is preferred. in Fig.7. Jumpers JP1 and JP2 on the Isolator board are set to the 5V position, which means it takes power from the pin adjacent to ground. Since the Battery Balancer has been designed to have the Mini Isolated Serial Link directly attached, it makes sense to do this, as it matches that configuration. Then run the four wires back to the Battery Multi Logger PCB. If the Mini Isolated Serial Link is fitted upside-down to the Battery Balancer PCB (as in Fig.7), it will not hide the LEDs, although it will slightly overhang the PCB edge. The photo on page 71 shows the Link fitted to the Balancer in this fashion. Due to space constraints, there is no 3.3V connection on CON6, so the best option is to take this from pin 2 of the ICSP header. If you lack CON6, then taking the ground connection from the adjacent pin 3 is a good choice. Similarly, the TX and RX signals are taken from CON6 or the microcontroller pins directly, as shown. While setting up these connections, you might also like to solder a five-way header to either CON2 of the Battery Logger or CON1 of the I/O Expander to regain the in-circuit programming (ICSP) capability. All the things we have hanging from these pins only take power and ground connections – therefore, they should not affect programming. But you may have to power the board from USB instead of the programmer during ICSP programming, as the programmer might not be able to provide sufficient current. Reassemble anything you have taken apart during this construction. Then power up the Battery Logger and its connected peripherals. Using it Now that everything has been configured, we can explore the new screens. Screen 1 is the updated Main screen, with two new buttons and a display for the status of the triggers. If your battery is above 12.5V, you should see Trigger 1 in red. Or if your battery is below 11V, then Trigger 0 might have tripped. Press the Trigger button to see Screen 2. This is an overview of the triggers, with one displayed on each line. Each trigger has a parameter and threshold that it monitors; these are displayed as in Screen 2. When a parameter reaches its threshold, the trigger is tripped and will show a red TRIP button instead of a green OK button. The trigger cannot trip again until it is reset. On each trip event, any combination Practical Electronics | August | 2022 Screen 3: each trigger is configured on its EDIT TRIGGER page, including its thresholds. The page displays the switches it drives and the other triggers it will reset. Screen 4: pressing the SWITCHES button on the EDIT TRIGGER page allows the SWITCH OUTPUTs to be set. You can get an idea of the unit’s operation from the example configuration we have provided. Screen 5: the RESET TRIGGERs are set similarly. All the changes made to these (and other triggerrelated) settings are saved on exit from the SOFT SWITCH page. of switches can be activated. These switches correspond to Soft Switch inputs, and the software delivers a pulse via the I/O Expander to the corresponding switches. Each trip event can also reset any other trigger, allowing alternate action as two triggers track a variable between the two hysteresis points, as shown by the default settings for TR0 and TR1. 23 Screen 6: the BALANCER CONTROL page is accessed from the MAIN screen, and shows the current cell voltages and Balancer operating mode. Buttons are provided to issue control commands to the Balancer, assuming it is connected and communicating. Screen 7: the BALANCER HISTORY page shows the recent operation of the Balancer, including which cells are being balanced and in which direction. Screen 8: similarly, the CELL V HISTORY page shows the relative cell voltages (to Cell 1). The button at bottom left allows easy toggling between these last two pages. This is only one way it can be used. Each trigger could be set to require a manual reset or could even reset multiple triggers. The page shown in Screen 2 lets you manually trip and reset each trigger for testing. Each press toggles between the tripped and reset states. Pressing the button (such as TR0 for Trigger 0) takes you to Screen 3, which has more settings. The TRIP and RESET buttons work as you would expect. The various buttons labelled V and I allow the threshold variable and condition to be set. CLEAR removes any threshold, meaning the trigger will not activate automatically. The THRESHOLD+ button sets a positive value, while the THRESHOLD– button is used to set a 24 negative value. This is useful for current thresholds; the Battery Manager cannot measure negative voltages. Finally, the SWITCHES and RESETS buttons allow setting of the actions that result from each trigger. Screen 4 shows the switch controls; these correspond to the P0-P7 outputs on the I/O Expander, while Screen 5 shows the reset controls, which correspond to the triggers. All parameters are saved to Flash memory when you press BACK from the Trigger overview page seen in Screen 2. This provides a good compromise between usability and Flash wear. Balancer menu From the Main page, pressing the Balancer button goes to the BALANCER CONTROL page, as seen in Screen 6. The two columns of buttons at left will send commands to the Battery Balancer to move charge between specific cells and the entire stack. The rate at which this happens is set by the third column, with options of 25%, 50%, 75% and 100%; the currently selected value is highlighted. Similarly, the PAUSE and RESUME buttons send commands to the Battery Balancer to pause or resume balancing. The data displayed at the top of the screen is taken from the Balancer in real time. The GRAPH button goes to the page shown in SCREEN7, which shows the relative flow in and out of each cell. Around 100 data points are stored, and these are updated in time with the logging software’s 10-second cycle. Thus, around 15 minutes of balancing data is available. It is only stored in RAM, so it is erased if power loss occurs. The screen does not automatically refresh; you need to press the Refresh button. Pressing the ‘Cell V’ button changes the graph to display the individual cell voltages measured by the Balancer. The chart is centred on the current bottom cell voltage, as this will always be present. The graph spans 1V from top to bottom, allowing cell voltage variations to be easily seen. Battery Manager Thus we have updated the Battery Multi Logger to the Battery Manager. We expect many people will have different requirements regarding what they will control and how they will connect things to the Battery Manager. Indeed, we expect many people will add the Battery Manager to an existing battery installation, perhaps in a car, caravan or boat. And it becomes a relatively simple addition to such a system. In fact, there are so many features in the improved Battery Manager that readers may not even wish to add all of them. But this is easy, as it is entirely modular in construction. We wouldn’t be surprised if some people use the I/O Expander or Switch Module in unrelated projects. Some people may not need the Battery Balancer add-on, especially those with 12V batteries that don't require balancing. Both the I/O Expander and the Switch Module will work fine with 3.3V and 5V logic levels, so they could be used on their own (or together) with other microcontrollers such as the Arduino or Micromite. Reproduced by arrangement with SILICON CHIP magazine 2022. www.siliconchip.com.au Practical Electronics | August | 2022