Silicon ChipHigh-Current, High-Voltage Battery Capacity Meter, Pt.2 - July 2009 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Natural gas means geosequestration is unnecessary
  4. Feature: The Magic Of Water Desalination by Geoff Graham
  5. Review: Two Low-Cost DVD Recorders by Barrie Smith
  6. Project: Lead-Acid Battery Zapper & Desulphator Mk.3 by Jim Rowe
  7. Project: Hand-Held Metal Locator by John Clarke
  8. Project: Multi-Function Active Filter Module by John Clarke
  9. Feature: CeBIT: What’s New At Australia’s Largest IT Show? by Ross Tester
  10. Project: High-Current, High-Voltage Battery Capacity Meter, Pt.2 by Mauro Grassi
  11. Vintage Radio: The Lyric 8-Valve Console From The 1920s by Rodney Champness
  12. Book Store
  13. Advertising Index
  14. Outer Back Cover

This is only a preview of the July 2009 issue of Silicon Chip.

You can view 33 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "Lead-Acid Battery Zapper & Desulphator Mk.3":
  • Lead-Acid Battery Zapper and Desulphator Mk.3 PCB [04107091] (AUD $20.00)
  • Lead-Acid Battery Zapper & Desulphator Mk.3 PCB pattern (PDF download) [04107091] (Free)
  • Lead-Acid Battery Zapper & Desulphator Mk.3 front panel artwork (PDF download) (Free)
Items relevant to "Hand-Held Metal Locator":
  • Hand-Held Metal Locator PCB [04207091] (AUD $5.00)
  • Hand-Held Metal Locator PCB pattern (PDF download) [04207091] (Free)
  • Hand-Held Metal Locator front panel artwork (PDF download) (Free)
Items relevant to "Multi-Function Active Filter Module":
  • Multi-Function Active Filter PCB [01107091] (AUD $15.00)
  • Multi-Function Active Filter Module PCB pattern (PDF download) [01107091] (Free)
Items relevant to "High-Current, High-Voltage Battery Capacity Meter, Pt.2":
  • PIC18F2550-I/SP programmed for the Battery Capacity Meter [0420609A.HEX] (Programmed Microcontroller, AUD $20.00)
  • PIC18F2550 firmware and source code for the High-Current, High-Voltage Battery Capacity Meter (Software, Free)
  • High-Current, High-Voltage Battery Capacity Meter PCB pattern (PDF download) [04206091] (Free)
  • High-Current, High-Voltage Battery Capacity Meter front panel artwork (PDF download) to suit Altronics LCD (Free)
  • High-Current, High-Voltage Battery Capacity Meter front panel artwork (PDF download) to suit Jaycar LCD (Free)
Articles in this series:
  • High-Current, High-Voltage Battery Capacity Meter, Pt.1 (June 2009)
  • High-Current, High-Voltage Battery Capacity Meter, Pt.1 (June 2009)
  • High-Current, High-Voltage Battery Capacity Meter, Pt.2 (July 2009)
  • High-Current, High-Voltage Battery Capacity Meter, Pt.2 (July 2009)

Purchase a printed copy of this issue for $10.00.

Calibrating, Setting the Battery Capacit Last month we presented the full description, operation and construction details of our new Battery Capacity Meter. This month we guide you through the once-only setup and calibration. We also explain in detail how to use it! Part 2 – by Mauro Grassi A SSUMING YOU have completed the Battery Capacity Meter and installed it in its case, now it’s time to calibrate it and set it up, ready for use. We’ve also shown the various LCD readouts and what they mean – sorry the type is so tiny but we had to get a lot of information in! After use, most of these screen messages and sub-menus will become very much self-explanatory and common sense. And you can always refer back to this article if you need to! One Time Calibration To calibrate the meter, you will need to follow these steps: (1) Measure the voltage between pin 2 (GND) and pin 1 (+5V Rail) of CON4 using a DMM. Note this voltage and enter it in the CALIBRATION>Set +5V Rail SubMenu; (2) Measure the voltage between pin 2 (GND) and pin 5 (Low Battery Voltage) of CON4 using a DMM. Note this voltage and enter it in the CALIBRATION>Calibrate Lo. Divider SubMenu; (3) Measure the voltage between pin 2 (GND) and pin 6 (High Battery Voltage) of CON4 using a DMM. Note this voltage and enter it in the CALIBRATION>Calibrate Hi. Divider SubMenu; (4) Enter the value of your shunt resistance (in mΩ) in the 80  Silicon Chip STANDBY Mode: This flashes periodically when the meter is in standby mode. It goes into Standby mode when the load & charge currents are below the set threshold. USB must be disconnected for this to occur. In Standby mode, the meter consumes minimal power, turning the LCD backlight off. Use S1to bring the meter out of standby. SHUTDOWN Mode: This message appears briefly before the meter shuts down due to the battery voltage being lower than the shutdown voltage. This is a fail-safe way of protecting the battery. For example, a 12V SLA battery, should not be discharged below 11V. TURN METER OFF SubMenu Message: This message appears briefly if you've requested to turn off the meter manually by going to the 'Turn Meter Off' submenu and confirmed the action but the USB is connected. Since power is delivered through the USB, the meter cannot perform the requested action. This shows the typical view of a menu. A Submenu is enclosed in '<' and '>' brackets. Here the top two entries of the Main Menu are shown. You can press 'A' and 'B' to go up and down the menu and the corresponding number to enter the SubMenu. For example, pressing 1 here takes you to the Battery SubMenu. The strings scroll from right to left to show the entire name of the SubMenu. The typical view of a SubMenu as a sequence of snapshots from top to bottom. A submenu item that has no other SubMenus is enclosed in '[' and ']' brackets. Top two entries of the System SubMenu are shown. Press 'A' and 'B' to go up and down the SubMenu and the corresponding number to enter the SubMenu – eg, pressing 1 takes you to the Beeper Status SubMenu to enable or disable the beep. The strings scroll from right to left to show the entire name of the SubMenu, as well as any values of the relevant settings. This sequence shows how the SubMenu items scroll from right to left and how the value of the setting is shown in the scrolling string. The top line contains the string 'Beeper Status: On' indicating that the beeper system is enabled. You can change it by pressing 1. The bottom line contains the string 'Average Samples: 30.0' indicating that presently, 30 readings are averaged at a time. You can change the number of readings that are averaged by pressing 2. If you changed the number of average samples to 120, then on returning to this SubMenu, the bottom string would read 'Average Samples: 120.0' instead. For numerical settings, enter the new value by using the number keys, the key '*' is for a decimal point & the key 'D' is used as backspace if you make a mistake in typing ('D' is for Delete). When you are satisfied with the entered value, press the '#' key to enter the value. If no input is entered but you then press the '#' key to exit, the current value of the setting is retained. For values which are not numerical, you use the 'A' and 'B' keys to vary the value up and down, respectively, and use the '#' key to exit the SubMenu. Most settings are numerical, where the range is also shown and you must enter a number in the valid range for the new value to be accepted. Here are the various system messages and their meanings. Also shown is a sequence of screens depicting how the SubMenus appear on the LCD readout. siliconchip.com.au Up & Using ty Meter PERCENT CHARGE PRESS '1' BATTERY CAPACITY AMP HOURS PRESS '2' BATTERY VOLTAGE VOLTS PRESS '3' LOAD CURRENT AMPS PRESS '4' CHARGE CURRENT AMPS PRESS '5' NET CURRENT AMPS PRESS '6' TIME REMAINING IF DISCHARGING PRESS '7' TIME CHARGING IF CHARGING PERCENT CHARGE PRESS '8' BATTERY VOLTAGE CIRCUIT CURRENT MILLIAMPS PRESS '9' RELAY CURRENT MILLIAMPS (5) (6) (7) (8) (9) CALIBRATION>Shunt Resistance SubMenu; Enter the CALIBRATION> Calibrate Current SubMenu. Apply a small load of say a few amps to the LOAD terminal through a DMM. Note the current registered on the DMM and enter it; Enter the value of the gain of the load amplifier (usually 60.0 for the MAX4080SASA) in the CALIBRATION>Load Amp. Gain SubMenu; Enter the value of the gain of the charge amplifier (usually 60.0 for the MAX4080SASA) in the CALIBRATION>Charge Amp. Gain SubMenu; Enter the value of your sense resistance (usually 10Ω) in the CALIBRATION>Sense Resistance SubMenu; Enter the CALIBRATION>Detect Sense Resistance SubMenu. Connect the DMM in series between the GND terminal of the meter and the negative battery terminal. Note the instantaneous circuit siliconchip.com.au current and enter it (in mA). That completes the calibration. One-time user setup After the calibration is performed, you should run through the following checklist to set up your preferences: (1) Go to the BATTERY SubMenu; (2) Enter the full capacity of your battery in the Battery Capacity SubMenu; (3) Enter Peukert’s constant in the Peukert’s Constant SubMenu if you are using a Lead Acid battery; (4) Enter the cell chemistry in the Cell Chemistry SubMenu; (5) Enter the charging efficiency in the Charging Efficiency SubMenu; (6) Enter the cycle threshold in the Cycle Threshold SubMenu; (7) Exit the BATTERY SubMenu; (8) Go to the DISPLAY SubMenu and set up the display backlight preferences like brightness and time out period; CHARGE CURRENT AMPS PRESS 'A' LOAD CURRENT AMPS PERCENT CHARGE PRESS 'B' CHARGE/DISCHARGE CYCLES BATTERY VOLTAGE VOLTS PRESS 'C' BATTERY CURRENT AMPS BATTERY CAPACITY AMP-HOURS PRESS 'D' LOAD CURRENT AMPS BATTERY CAPACITY WATT-HOURS PRESS '*' LOAD POWER WATTS PRESS '0' TO SEE ALL READINGS, IN SCROLLING MODE. PRESS '#' TO ENTER THE MENU SYSTEM AND CHANGE SETTINGS. This shows all the available readings. Each is chosen by a single digit press on the alphanumeric keypad. For example, if you wish to display the battery voltage, type ‘3’. Or if you wish to see the battery capacity in Watt Hours and the load in Watts, press ‘*’. Notice that from here, you may press ‘#’ to enter the extensive menu system. The remaining panels illustrate in detail the various submenus. July 2009  81 (9) Go to the DETECTION SubMenu; (10) Enter the voltage below which to shut down in the ShutDown Voltage SubMenu; (11) Enter the low capacity alarm threshold in the Capacity Alarm SubMenu; (12) Enter the standby current threshold in the Standby Threshold SubMenu; (13) Enter the trickle current threshold in the Trickle Current SubMenu; (14) Enter the minimum voltage of your battery in the Min. Voltage SubMenu; (15)   Enter the maximum voltage of your battery in the Max. Voltage SubMenu; (16) Enter the Detection Period and number of detection points in the Detection Period and Detection Points SubMenus; (17) Exit the Detection SubMenu; (18) Enter the SYSTEM SubMenu; (19) Choose whether to enable or disable the audible alarm in the Beeper Status SubMenu; (20)   Choose the number of samples to average in the Average Samples SubMenu; (21)   Exit the SYSTEM SubMenu; (22) Enter the RELAY SubMenu; (23)   Choose whether you will use an external relay in the Relay System SubMenu; (24) If you are not using a relay, go to step 29; otherwise continue. (25)   Enter the relay coil resistance in the Relay Coil Resistance SubMenu; (26)   Enter the overload current and its duration in the Max. Load Current and Max. Current Duration SubMenus; (27)   Enter the relay off voltage in the Relay Off Voltage SubMenu; (28)   Enter the relay hysteresis value in the Relay Hysteresis SubMenu; (29)   Exit the RELAY SubMenu; (30)   If required, set up the logging options in the LOGGING SubMenu. Full Speed (12Mbps) USB 2.0 The firmware implements a USB 2.0 full speed bulk Fig.8: this Window appears when the meter is connected to a PC for the first time, using the USB interface. 82  Silicon Chip transfer bidirectional endpoint (EP1) with packet size set to 112 Bytes. This is used to communicate with the host program on the PC (battcap.exe) through the custom Microchip driver (MCHPUSB). We explain how to install the driver on Windows OSs below. Endpoint 0 is implemented as well, as that is mandatory for any USB device. A transaction between the host program on the PC and the battery meter consists in sending a 112-Byte packet to the meter. The firmware will decode the packet, according to the sent command, and update itself accordingly. The meter can also send logging data to the PC. Remember that the USB driver must be installed correctly for this to work. Instructions are given below. Software setup and driver installation for Windows The meter’s USB device interface uses the generic Microchip driver for Windows. Before communicating with the display using the PC host program, you will need to install this driver. This section explains how to install the driver in Windows XP, although other versions of Windows will be similar. You should have first downloaded the Microchip installer (MCHPFSUSB_Setup_v1.3.exe) from the SILICON CHIP website and ran it. Note that you must use version 1.3. Older or Newer Versions may not be compatible. This will (normally) install the driver in the C:\MCHPFUSB\ Pc\MCHPUSB Driver\Release directory. When you first connect the meter to your computer using a USB cable, Windows will recognize the device as a “Meter” and a “Microchip Custom USB device”. The ‘Found New Hardware’ Window appears as shown in Fig.8 and you should select the “No, not this time” option and click “Next”. You will be presented with the next screen as shown in Fig.9. Select “Install from a list or specific location” and click “Next” again. The final screen is as shown in Fig.10. Select “Search for the best driver in these locations” and enable the “Include this location in the search” box as shown. Now click the Fig.9: use the “install from a list or specific location” option to select the correct driver to install. siliconchip.com.au “Browse” button. In the “Locate File” window that appears, navigate to where the MCHPUSB files were installed. Normally it will be C:\MCHPFUSB\Pc\MCHPUSB Driver\ Release. Choose the file “mchpusb.inf”. Select that file, and then click “Next”. Windows should install the driver. If the driver is installed correctly you should be able to see the meter in device manager (under Control Panel>System (Hardware Tab)), as shown in Fig.11. Using the PC host software To install the PC host program, first download the compressed file battcap.zip from the SILICON CHIP website www.siliconchip.com.au (go to the downloads section under July 2009). Extract the files in the zipped file to a directory on your hard drive. There should be these files: (1) battcap.exe: this is the executable command line program. (2) battcap.map: this is an internal file, needed for the host program to work properly. As long as it is copied to the same directory as battcap.exe the program will recognise it. This file is produced by the C compiler of the firmware. It contains memory mapping information for the firmware produced by the linker. When and if the firmware is updated, the map file will change. Using the software Battcap.exe is a command line program () with three options. The -i option is used to get system settings (‘i’ stands for information). A screen grab is shown in Fig.12. So you would type at the command prompt: battcap -i. The -x option is used to get the current readings which will update continuously every second or so (a screen grab is shown in Fig.13). Finally, the -l option is used for data logging. You will be asked to confirm whether you wish to transfer the data to your PC (as this will empty the local buffer). If you choose ‘Yes’, you will be prompted for a file name (it should have a .csv extension). The default file name will contain the local time and date. The data dumped to that file will be in Comma Separated Fig.10: selecting the path to the driver previously downloaded from the SILICON CHIP website. siliconchip.com.au Fig.11: a view of Device Manager when the driver has been correctly installed and the meter is connected via the USB. Values format and can be imported into a spreadsheet. Once the data is in your spreadsheet you can use its graphing functions to produce a graph, as shown in Fig.14. Changing the hardware to suit your application (advanced) There are several hardware values which can modified to suit your application. The sense resistor can be changed from the default of 10Ω (you should enter the correct value for your application in the CALIBRATION>Sense Resistance SubMenu). You can choose to use a different version of the MAX4080 chip for the load or charge sensing if your charging currents are always much smaller than your load currents (to increase the resolution). You can then change the value of the gain in the corresponding submenu (hint: they are in the CALIBRATION SubMenu). Moreover, you can choose different resistors for the two voltage dividers as long as you then calibrate them by going to the CALIBRATION SubMenu. You can change the current shunt to get a different maximum current range. In this case, you should both enter the new value of the shunt resistance in the CALIBRATION>Shunt Resistance SubMenu and then go to the CALIBRATION>Calibrate Current SubMenu and follow the prompts. To turn power on, press S1. To see a particular reading, press the corresponding key on the keypad, according to the readings panel shown on p81. For example, to see the July 2009  83 CALIBRATION SUBMENUS BATTERY SUBMENUS DECLARE FULL NOW SubMenu: Use this menu to declare that the battery is now full. Press '*' to confirm the action and '#' to cancel it. BATTERY CAPACITY SubMenu: enter the capacity of the battery in AmpHours from 0 to 999999 AH. CALIBRATE LO DIVIDER SubMenu: calibrates the low voltage divider. Enter the voltage at the Low Battery terminal, pin 5 of the calibration connector. PEUKERT'S CONSTANT SubMenu: enter the value of Peukert's constant for your battery. Allowed input is from 1.0 to 2.0. Typically 1.1. This only applies to Lead-Acid batteries. CALIBRATE HI DIVIDER SubMenu: calibrates the high voltage divider. Enter the voltage at the High Battery terminal, pin 6 of the calibration connector. CHEMISTRY SubMenu: sets the Chemistry. Use 'A' and 'B' to change the value and '#' to finish. Allowed values are Nickel or Lead-Acid. Note that Nickel includes both NiMH and NiCad. SHUNT RESISTANCE SubMenu: sets the value of the shunt resistance in milliohms. This value can be further automatically calibrated by using the CALIBRATE CURRENT SubMenu below. EFFICIENCY SubMenu: sets the charging efficiency of your charger/battery combination. It is a percentage between 0.1 and 100. Typically 80%. CALIBRATE CURRENT SubMenu: calibrate the value of the shunt resistance automatically. This is calculated from the entered instantanenous value of the load current. CYCLE THRESHOLD SubMenu: sets the cycle detection threshold. It is a percentage between 10 and 40. Typically 25%. This also clears the cycle count. LOAD AMP GAIN SubMenu: sets the value of the load amplifier gain. Typically, this is 60 for the MAX4080SASA. For the MAX4080TASA it is 20. CHARGE AMP GAIN SubMenu: sets the value of the charge amplifier gain. Typically this is 60 for the MAX4080SASA. It is independent of the load amplifier. DISPLAY SUBMENUS BRIGHTNESS SubMenu: sets the brightness of the LCD Backlight. Use the 'A' and 'B' buttons to change and '#' to set. The value is a percentage of full brightness. TIMEOUT SubMenu: sets the backlight timeout period in seconds. Typically 15 seconds. battery voltage you press ‘3’. To enter the menu system, press ‘#’. Once in the menu system, use ‘A’ and ‘B’ to move up and down the menu and the number digits to enter a SubMenu. To enter numbers, you use the digits, the ‘*’ for the decimal point and the ‘D’ key as backspace. In all cases you use the ‘#’ to exit the SubMenu and go back to the previous menu. From the main menu, press ‘#’ to exit the menu system and restore the current reading. You should also refer to the panels which explain the menu system in more detail. Peukert’s Law and efficiency For lead-acid batteries, Peukert’s law states that the change in capacity is not a linear function of the current drain. Specifically, Peukert’s law states that: ∆C = Ik∆t where ∆C is the capacity, ∆t is the time, I is the instantaneous current drain and k is a constant higher than 1.0 and typically between 1.1 and 1.3. The meter will take into account Peukert’s law when computing the capacity of the battery. The value of the constant k will vary for different batteries and you must set this in the BATTERY>Peukert’s Constant SubMenu. There is no easy way to compute the correct “k” value for your system. It is there as a way of adjusting the meter 84  Silicon Chip SET 5V RAIL SubMenu: calibrates the ADC system by entering the voltage of the 5V rail. SENSE RESISTANCE SubMenu: sets the value of the sense resistor in Ohms. Typically this is 10. This can also be automatically set by using the DETECT SENSE RESISTANCE SubMenu below. DETECT SENSE RES. SubMenu: automatically calibrates the value of the sense resistor by entering the value of the instantaneous circuit current. if you have enough experience with the meter and wish to tune it. Cell chemistry and synchronisation By synchronisation, we mean that when certain conditions are met, the meter sets the capacity to either full or empty capacity automatically. You can see at any time when the last synchronisation occurred by going to the DETECTION>Last Sync. SubMenu. For example, when the meter detects the end of charge, it sets the capacity to full capacity. The synchronisation algorithms are different depending on the cell chemistry. For Nickel-based batteries, the full capacity synchronisation occurs if the meter detects a trickle charge and the battery voltage is above the maximum voltage for the duration of the detection period. When the battery voltage is detected to be dropping and is below the minimum voltage (for the duration of the detection period and is monotonically decreasing at each detection point) then the battery capacity is synchronised to zero. This is because a Nickel battery’s voltage will, once it has been discharged beyond a point, drop dramatically and quickly. For a lead-acid battery, the end of charge is detected if there is a trickle current and the battery voltage is above siliconchip.com.au DETECTION SUBMENUS SYSTEM SUBMENUS SHUTDOWN VOLTAGE SubMenu: sets the voltage below which the meter will shut down to protect the battery -- eg, 11V for a SLA Battery. BEEPER STATUS SubMenu: enables or disables the beeper function using the 'A' and 'B' buttons. Use the '#' button to exit. CAPACITY ALARM SubMenu: sets the capacity below which the meter will emit an audible alarm. Use the 'A' and 'B' buttons to change and '#' to set. Typically 0%. It ranges from -60% to 100%. AVERAGE SAMPLES SubMenu: sets the number of samples that will be averaged for all readings. Typically this is 30. STANDBY THRESHOLD SubMenu: sets the current threshold. When the load and charge currents are below this, the meter enters Standby mode. Typically 0.05A. FIRMWARE VERSION SubMenu: shows the firmware version. Useful for debugging or reporting bugs or errors. TRICKLE CURRENT SubMenu: sets the trickle current. When the charging current is below this the meter considers the battery to be trickle charging. Typically 1/100th of the AH capacity. MIN. VOLTAGE SubMenu: sets the minimum voltage of the battery - eg, for a SLA this may be typically 11.5V, whereas for a NiMH battery this could be typically 1.1V per cell. LAST SYNC. SubMenu: shows the time elapsed since the last time the battery capacity was synchronised. A value of N/A indicates the capacity has not been recently synchronised. MAX. VOLTAGE SubMenu: sets the maximum voltage of the battery - eg, for a SLA this may be typically 13.8V, whereas for a NiMH battery this could be typically 1.2V per cell. LAST LOG SAMPLE SubMenu: shows how much time has elapsed since the last log sample was captured. DETECTION PERIOD SubMenu: sets the detection period in seconds for synchronising the battery capacity. Typically 30 seconds. DETECTION POINTS SubMenu: sets the number of intervals in the detection period. Used only for Nickel batteries. Typically 4 points. LAST SYNC. SubMenu: shows the time elapsed since the last time the battery capacity was synchronised. A value of N/A indicates the capacity has not been recently synchronised. DETECTION SUBMENU the maximum voltage for the duration of the detection period. In this case, the battery capacity is again set to full capacity. Note that there is no empty capacity synchronisation for Lead Acid batteries. However, you should note that Lead Acid batteries should never be discharged beyond a certain point or they will be damaged. Set the detection period by going to the DETECTION >Detection Period SubMenu. A typical value here is 30 seconds. You should also set the number of detection points (only relevant for Nickel batteries). This is set at 4 by default. The trickle current threshold can be set by going to the DETECTION>Trickle Current SubMenu. This is typically C/100 or so of the full battery capacity. So for a 20Ah battery this would be close to 200mA. It really depends on your charger, however. Set the Standby current (the current below which the meter will go into standby), by going to the DETECTION>Standby Current SubMenu. A typical value will be 50mA. The meter considers any current higher than the standby current and lower than the trickle threshold to be a trickle current for the purpose of synchronisation. Low capacity alarm An alarm will be heard when the capacity of the mesiliconchip.com.au USB CONNECTED SubMenu: indicates whether the meter is connected to a PC via the USB. The number in brackets is the state of the USB enumeration - eg 0=DETACHED, 6=CONFIGURED. TOTAL LOG TIME SubMenu: shows how much time has been logged in total. It indicates that this period of time has been logged. RESTORE DEFAULTS SubMenu: restores default values for most settings. Note that hardware-dependent settings such as the sense resistance aren't changed. TURN METER OFF SubMenu: turns the meter off. Note that USB power must be absent for this. The meter will turn off if the choice is confirmed by pressing '*'. SYSTEM SUBMENU ter falls below the set level (as a percentage). Go to the DETECTION>Capacity Alarm SubMenu to set the minimum capacity. The minimum capacity ranges from –60% to 100%. The capacity of the battery will go negative if it is discharged beyond the zero point. If you wish, you can disable the audible beeping by going to the SYSTEM>Beeper Status SubMenu and setting it to OFF. Overload and under-voltage protection An optional external relay can be connected to switch the load on and off. The charger can be left connected at all times, however, as shown in Fig.4 last month. The relay energises to connect the load to the load terminal of the shunt, so the shunt terminal can connect to the relay common and the load can connect to the relay’s NO (normally open) terminal. Once the relay is installed, the microcontroller will control it. If you decide to use a relay, make sure it is able to switch the required current. For an 80A system we recommend a 150A relay (eg, Jaycar SY-4073). If you are using lower currents there are several 60A automotive relays available, eg, Jaycar SY-4074 or Altronics S-4339. July 2009  85 LOGGING SUBMENUS RELAY SUBMENUS LOGGING ERROR SubMenu: sets the relative percentage error for logging RLE compression. The lower the error, the more resolution the data will exhibit. Typically 20%. RELAY SYSTEM SubMenu: enables or disables the relay system using buttons 'A' and 'B'. Use '#' to exit. When the relay system is off, the relay remains off. Turn off if you are not using an external relay. MIN. ABSOLUTE ERROR SubMenu: sets the minimum absolute error for logging RLE compression. The lower the error the more resolution the data will exhibit. Typically 0.1. RELAY COIL RESISTANCE SubMenu: sets the resistance of the coil of the external relay (optional). If you are using a dropping resistor in series with the coil, enter the total (ie, sum) of the coil & resistor. If you are not using a relay, disable it in the RELAY SYSTEM SubMenu below. SAMPLE PERIOD SubMenu: sets the sampling period in seconds. Samples are taken at a frequency equal to the reciprocal of this period. The range is from 200ms-1day. RELAY OFF VOLTAGE SubMenu: sets the voltage below which the relay switches off. Typically this is slightly higher than the minimum battery voltage. Ch. 1 LOGS SubMenu: sets what reading channel 1 logs. Use the buttons 'A' or 'B' to change and '#' to set. Here channel 1 is disabled. RELAY HYSTERESIS SubMenu: sets the voltage hysteresis added to the cut-off voltage. The relay will switch back on when the voltage exceeds this sum. Ch. 2 LOGS SubMenu: sets what reading channel 2 logs. Use the buttons 'A' or 'B' to change and '#' to set. Here it is set to log the battery voltage. MAX. LOAD CURRENT SubMenu: sets the maximum load current for overload protection. If the load current exceeds this current for the duration set below, the relay switches off. A soft-fuse then trips. It is reset by pressing S1. Ch. 3 LOGS SubMenu: sets what reading channel 3 logs. Use the buttons 'A' or 'B' to change and '#' to set. Here it is set to log the capacity percentage of full charge. MAX. CURRENT DURATION SubMenu: sets the maximum load current duration in seconds. The relay will switch off if the load current exceeds the max load current setting above for this time. Ch. 4 LOGS SubMenu: sets what reading channel 4 logs. Use the buttons 'A' or 'B' to change and '#' to set. Here it is set to log the charging current. OVERLOAD FUSE STATUS SubMenu: shows the state of the overload fuse. The fuse trips if there is an overcurrent condition. The only way to reset the fuse is to press S1. 'Short' means that the fuse allows current, 'Open' that it has blown. LOG MODE SubMenu: sets either CAPTURE mode (Cpt.) or OVERWRITE mode (Ovr.) for the RLE Buffer. Use the buttons 'A' or 'B' to change and '#' to set. RLE BUFFER POSITION SubMenu: shows the state of the RLE Buffer. The brackets indicate the start and end of the buffer and its position. The number of bytes in the buffer is also shown. RELAY SUBMENU This panel and the ones on previous pages show the various SubMenus – Detection, System, Logging, Relay, Battery, Display, Calibration – in more detail and how to access their parameters. Each of the submenus has a number of options and these are displayed in the LCD readout as you step through. LOGGING SUBMENU Note that these relays run from 12V. If your battery system is higher than 12V, a dropping resistor (in series with the relay coil) will be needed. Its value is calculated using Ohm’s law, taking into account the coil resistance of the relay. For example, if your relay coil resistance is 180Ω and yours is a 24V system, a 180Ω 5W resistor would be used. Similarly, for a 48V system you would need a 560Ω 5W resistor (actually 540Ω but 560Ω is the closest standard value). A 1N4004 (or similar) diode must be connected across the relay coil to quench any back-EMF when the relay switches off. See Fig.4 from last month. Enter the value of the coil (or coil and series resistor) in the RELAY>Relay Where to get the parts . . . At least one supplier will be making a kit available for the Smart Battery Capacity Meter. It is possible there will be others but Altronics have indicated that their stores and mail/web order will have a kit soon (Cat K1700) for $175.00 – see www.altronics.com.au If you wish to put together your own kit, then most parts are commonly available and you should have no problem obtaining them. One exception is the PC board which (as with all SILICON CHIP boards) is available in from RCS Radio, 41 Arlewis St, Chester Hill NSW 2162. Phone (02) 9738 0330. The only other component you may have problems obtaining is the programmed PIC­18F2550-I/SP microcontroller. This is available direct from SILICON CHIP for $25.00 including P&P. 86  Silicon Chip Coil Resistance SubMenu, as well as enabling the Relay System by going to the RELAY>Relay System SubMenu. On an under-voltage condition the relay will turn off, switching off the load and thereby saving the battery from possible (and irreparable) damage. Note that the relay “off” voltage is usually slightly higher than the shut down voltage (the latter, typically, should not ever be reached and is only a fail-safe measure as detailed shortly). The relay will only turn back on when the battery voltage rises above the sum of the relay off voltage and the relay hysteresis (both measured in Volts). This adds a measure of hysteresis avoiding ‘hunting’. The trip point and hysteresis are set by going to the RELAY>Relay Off Voltage & RELAY>Relay Hysteresis SubMenus. For an over-current condition, you set the maximum current and its duration before the relay switches off and trips a software fuse. siliconchip.com.au Fig.14: this screen grab is from the Microsoft Excel spreadsheet program. We have imported the CSV file obtained by running the command “battcap.exe -l” and graphed the battery voltage as a function of time. The relay (and hence the load) will remain off indefinitely after the fuse trips. The only way to reset this software fuse is to press S1. The battery voltage should bounce back up once the load is disconnected. Note that the relay will only turn back on once the voltage is above the sum of the relay off voltage and the hysteresis voltage. The relay system should be switched off (RELAY>Relay System) if not used. Fail-safe shutdown When the voltage of the battery drops below the level set in the DETECTION>ShutDown Voltage SubMenu, the circuit (as well as the relay) will turn off. This is a fail-safe measure and in normal operation should never occur. It is there to protect the battery in the last resort. After power is lost, the meter is turned on again by pressing S1. If the voltage is still too low, the meter will again shut down but not before you have a chance to access the menu system by pressing ‘#’. This allows you to change any settings if needs be, before the meter shuts down (so you are never ‘locked out’ completely). into VIDEO/TV/RF? Television & Video Technology – by KF Ibrahim New edition has a full and compre-hensive guide to video and TV tech-nology including HDTV and DVD, $ 58 starting with fundamentals. $ 70 NEW LOW PRICE! DVD Players and Drives $ 95 NEW LOW PRICE! $ 85 – by KF Ibrahim DVD technology and applications - ideal for engineers, technicians, students, installation and sales staff. Practical Guide To Satellite TV – by Garry Cratt The book written by an Aussie for Aussie conditions. Everything you need to know – including what you cannot do! 7th ed. $ 49 Hands-On Zigbee – by Fred Eady $ 9650 NEW LOW PRICE! $ 75 An in-depth look at the clever little 2.4GHz wireless chip that’s starting to be found in a wide range of equipment from consumer to industrial. $ There’s something to suit every RF fan in the SILICON CHIP reference bookshop: see the bookshop pages in this issue 75 RF Circuit Design – by Chris Bowick A new edition of this classic RF NEW LOW PRICE!design text - tells how to design and integrate RF components $ 74 into virtually any circuitry. Practical RF H’book – by Ian Hickman A reference work for technic90 ians, engineers, students and NEW LOW PRICE! the more specialised enthusiast. Covers all the key topics in $ 73 RF that you need to understand. $ ! Audio ! RF ! Digital ! Analog ! TV ! Video ! Power Control ! Motors ! Robots ! Drives ! Op Amps ! Satellite siliconchip.com.au July 2009  87 Note that when the meter has lost power and starts again, the capacity reading will revert to 50% and may not be accurate until the next synchronisation, or until you manually declare the battery at full capacity by going to the BATTERY>Declare Full Now SubMenu. RLE compression Fig. 12: a screen grab showing the result of running the command “battcap.exe -i” to get information on the current settings. RLE (Run Length Encoding) Compression is used for data logging using an internal buffer. Run-length encoding works by substituting a consecutive run of similar readings by a single reading and a multiplicity. For example, the sequence 1.0, 1.0, 1.0, 1.0, 1.0 would be encoded as (1.0, 5) to save space. Depending on the set RLE Relative Error and the RLE Absolute Error, the compression is lossy or lossless. It is lossless if both the errors are set to 0. If not, the compression will be lossy and can achieve a good compression ratio. For example, if the relative error is set to 5%, the readings 1.0, 1.02, 1.03, 0.98, 0.99 will be encoded as (1.0, 5) since each is within ±5% of the first reading. This can save a lot of space in the local buffer allowing you to log a greater period of time. The trade off is of course accuracy. RLE is simple to implement and ideally suited to this type of logging application, where the readings are changing slowly over time. You can log up to four different readings at any time and each reading can be one of the following: battery Voltage, time remaining or charging, load current, charge current, circuit current, relay current, net current, capacity (AH) or capacity (%). To set up logging, you go to the LOGGING SubMenu. The logging data is stored locally and can be downloaded to a PC using the USB interface. Over time, this can become a useful set of data in monitoring the state of batteries to allow you to not only get peak performance but longest life. Conclusion Fig.13: this shows the result of running the command line “battcap.exe -x” – the real-time readings are displayed every second. 88  Silicon Chip As you can see, the SILICON CHIP Battery Capacity Meter has comprehensive features that will allow you to monitor the health of your battery and charger system. It is not difficult to build and can be easily calibrated using a digital SC multimeter (DMM). siliconchip.com.au