Lithium Battery Tester v2
This device tests up to seven lithium cells. It measures cells in two modes:
PLEASE NOTE: THIS DESIGN IS PROVIDED WITHOUT WARRANTY AND FOR PERSONAL NON-COMMERCIAL USE ONLY.
* Mode 1: 'Dynamic' - This mode displays cell voltages together with a bar chart to make any imbalance easy to spot. It would typically be used when the pack is at rest but could be used to show changing voltages because the refresh rate is rapid.
* Mode 2: 'Recording' - The voltages of each cell are measured and logged 103 times over a 4+ second period. You would typically use this while applying a load (eg: your plane's motor). It then graphs these voltages, all together or one cell at a time. This allows you to identify weak cells after the test and whether your motor's load is pulling the pack's voltage too low.
This is v2 which is an evolution of the LED-based v1. v2 uses Microchip's 28 pin PIC18F2523 chip with its 12bit ADC. It uses the KS0108/KS0107-based JE-AN 128x64 graphical LCD. I have designed but not built 'v3' which will look identical but include FETs and plug-in resistors to also function as a balancer.
The source code may be available on request for non-commercial use. I will require you to commit clearly to personal use only and to not share, distribute or post the source code elsewhere. It comprises over 1,700 lines and compiles to over 9,000 words with font/image libraries. It is written in C for the BoostC compiler; a licenced version is required due to the program's size.
The exact workings of the program are described in the C program files, but here is an overview of the program and some details on the circuit itself.
* The circuit is powered by the higher of the 2nd and 3rd cells through a dual diode D1. The circuit measures all cells but requires at least 2 to function. Schottky diodes are recommended for D1 to minimise voltage drop (particularly with 2 cells under load tests). The 5v regulator is used as a voltage reference and it requires a minimum voltage for accuracy. Almost any low current 5v LDO reg will do and its data sheet will specific the values for C8 and C9.
* The LCD's backlight will draw around 100mA off the cells powering the circuit. This will pull thoses voltages down slightly while the light is on. If more diodes were used (similar to D1), you could automatically power the device from any number of cells. This would spread the backlight load over more cells and therefore reduce the effect. However, you need to ensure that your voltage regulator can handle the full input voltage if you do this and be aware of the heat generated by large voltage drops. The most accurate approach will simply to not use the backlight when exact voltages matter.
* A PIC's input can never exceed 5v so the cell voltages have to be reduced to below this level. On the higher cells (5, 6 and 7), reference diodes D2,3,4 reduce the voltage by an initial amount - see PIC Balancer for details of these devices (eg: LM4040, LM4050, ZRAxxx, ZRBxxx, ZRCxxx). I used 4.1v, 5v and 10v respectively in the prototype but larger values would improve accuracy. In addition to their reference voltage, temperature drift and voltage precision are characteristics which also differentiate between these devices. Temperature is not an issue on this circuit and whether you go for high voltage accuracy depends on the quality of your measuring equipment to calibrate it.
* The voltage of each cell is further reduced by resistor dividers to not exceed 5v. On this PIC the lower resistor should not exceed 2k5. Together with the reference diodes, this yields ADC conversion steps between 0.0022v and 0.0051v on various cells, ie: extremely accurate. The device displays voltages to 0.01v which means it has the luxury of being able to round up for accurate results. This easily exceeds the accuracy of most DVMs.
* For accurate results the program does need to be calibrated to match your components. The exact 5v reference voltage (regulator), resistor dividor and reference diode voltage drop morph into conversion factors using this spreadsheet. The better you can measure these items the more accurate will be the results.
* The chosen PIC has a 12bit ADC. Voltage conversions have a 'distribution' so a single measurement would probably appear eratic. However, from a sample of around 16 measurements, results become very stable. A stable source battery will typically reveal no jitter using this smoothing technique. I actually measure up to 4 cell packs 112 times to average results and to 'pad' mode 2 to my target 4sec recording period. Packs with 5 or more cells are measured 32 times, a smaller number to prevent mode 2 from taking too long. Every 'measurement' therefore comprises the average of that number of iterations. So for a 4 cell pack in Mode2, 46144 measurements are taken during the brief measurement period! (4 cells * 112 iterations * 103 cycles).
* R17 is a pullup for the MCLR pin to prevent it floating, without which random resets are possible. The backlight is ~4v on this LCD so the current from the 5v supply is limited with the 10 ohm R16. J3 is the 20pin connector to the LCD; its numbers do not match the LCD's numbers.
* Here are the Eagle files. Thanks to James Hopper for helping to create a well grounded design. This is important for voltage stability/reduced noise. The bottom comprises two grounds, essentially analogue and digital, joined together at the Pic's gound pins. The bottom planes are not filled in the Eagle files to save toner. Paint between the outlines before etching.
* The PCB is mainly intended for surface mounting (less holes to drill and a smoother under-side). Most components are intended to be SMD but some are 'through hole' but soldered on the top surface. All but the 2 gound pins on the PIC were cut short. The ground pins need to go through the board and must be soldered top and bottom to create via's. Other vias are made with hookup wire. Squeeze with pliers to flatten to make them a tight fit in the holes you drill. Then cut them just 0.5mm proud and solder top and bottom.
* I used two 10pin connectors for the LCD. I soldered pins at both end's through the PCB to secure it, with the rest folded over and soldered on the top. Again I used the two ground pins for this purpose + two at the other ends. My LCD actually came with a ribbon cable which I replaced with PCB headers. It would have been easier to simply solder the cable direct to the PCB.
* The device uses a JE-AN 64x128 dot matrix graphical LCD. These are available new on ebay for £4.50/$11 with postage. The program relies on 'safe' timings rather than reading the staus flag. Code to read the status is provided. I only used this for testing.
* Font libraries have been generated for the program. Characters are 5x7 and dots to create the graphs are 1x8 in size. Characters or dots are 'printed' to the screen individually rather than using strings.
* The 64 vertical dots comprises 8 rows each with 8 bits. The program therefore tends to be structured around formating data to present in those eight rows. I have not developed code to split characters over two rows yet so the labels on the vertical axis appear at different positions to best match the graduations on the axis which are always in multiples of '10'.
* Two buttons are used to select options. Both recognise short presses (<0.5s), medium (~1s) and long (~3s). The bottom row on the screen is used to display some sensible prompts.
* The circuit starts in Mode 1. This mode measures each cell 112 or 32 times, averages the results and displays cell voltages. It continues to do this until interrupted by the push-button. A small 'heartbeat' dot appears ocassionally in the middle of the bottom row.
* The display also reveals a 'bar graph' to the right of each cell. Each 'column' of 1x7 dots represents 0.01v. This helps you identify cells that are not in balance.
* The device will automatically detect the number of cells. However, short and medium presses of the right button allows you to increase or decrease the 'pack size' which over-rides the automatic selection. The chosen number of cells are used for Mode2. A long press of the left button initiates Mode 2.
* Mode 2 is intended for load tests (but can be used at any time). The easiest and most realistic way of applying a load is to measure the pack in a plane (on the ground). All you need to do this is to restrain the plane safely and connect the device to the battery's balancing lead. A 'long left' activates Mode 2.
* The display will clear and say 'Working...' while cells are being measured 103 times (x32 or x112 each as described above). 103 measurements fill the graph once measurements are complete. Data logged is stored in program memory (ROM). It is measured once only, the first time Mode 2 is entered. Only one set of measurements is retained, being over-written when the device is powered up and Mode2 entered again. A future enhancement may be to store multiple pack measurements. Functions exist in the program to also write to EEPROM; these are only used for testing.
* The graph will reveal changes in individual cell voltages over the 4+ second load test. By default, all cells are shown together initially. Short and medium presses of the right button allow individual (or all) cells to be selected.
* The graph has four zoom levels which keep halving/doubling the precision (1, 2, 4 and 8):
- Level '1' is 0.01v/dot and 0.1v/division
- Level '2' is 0.02v/dot and 0.2v/division
- Level '4' is 0.04v/dot and 0.5v/division
- Level '8' is 0.08v/dot and 1.0v/division
* The vertical axis has graduations. Large graduations represent 'whole volts' (3.0, 4.0, etc) and smaller ones are fractions. The value of each 'fraction' depends on the zoom level above. Their value (eg: 4.1, 4.2, etc in zoom '1') appears in brackets to the left of the vertical axis. These bracketed fraction indicators will appear either at the top, near the bottom (7th row) or both depending on where axis labels appear.
* The program will always select a zoom level which makes the whole graph appear on the screen. It will also always put the highest voltage near the top of the screen. With zoom level '8' the screen can show a 4.48v spread (7 rows = 56 dots x 0.08v). Zoom level '1' will show a 0.56v spread (56 dots x 0.01v). A long Right press scrolls through the zoom factors. Short and medium presses of the left button allows scrolling up and down the screen should this be required. Short and medium Rights scrolls through individual cells or displays all together.
* The middle of the last row shows you which cell(s) are currently graphed. A 3 cell pack would show '1-3' and this means all 3 currently appear on the graph. If you are looking at a single cell it will display the cell number (eg: #1, #2, etc). After the colon, the voltage spread of the chosen cell(s) appears. The decimal is suppressed due to space constraints. So '273-409' means the lowest voltage for cells currently on the screen was 2.73v and the highest 4.09v.
* A long Left press changes to mode 3 (mode '0' in the program code). This mode simply displays a bitmap image, currently 'Don Camilo'. Multiple images are feasible. Another Long Left scrolls back to Mode1.
Click on the links below for other pages.
Art of the Possible ¦
Absence of Matter ¦