This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
mission:log:2012:10:06:free-and-open-source-junsi-icharger-data-logger [2012-10-07 08:04] – [Charging] chrono | mission:log:2012:10:06:free-and-open-source-junsi-icharger-data-logger [2013-06-30 12:45] (current) – [Charging] chrono | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== FOSS Data-Logging for Junsi iCharger ====== | ||
+ | Batteries in general and lithium based batteries in particular require special attention, when it comes to charging and balancing. For this reason, the lab has a Junsi iCharger 1010B+, which offers a complete battery management solution for virtually every battery technology out there and some non-battery related features as well (like DC-Motor burn-in and foam-cutting programs). | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | It has proved itself as reliable hardware for over a year, especially taking care of the custom made LiPo battery packs for the [[mission: | ||
+ | |||
+ | ===== ===== | ||
+ | |||
+ | Luckily, the USB port is actually just a serial port based on the cp210x serial to USB converter. Remember to build and load the kernel module, it should look like this, when you plug-in the iCharger: | ||
+ | |||
+ | < | ||
+ | [2865177.518351] usb 1-6.2: new full-speed USB device number 60 using ehci_hcd | ||
+ | [2865177.604715] usb 1-6.2: New USB device found, idVendor=10c4, | ||
+ | [2865177.604720] usb 1-6.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 | ||
+ | [2865177.604723] usb 1-6.2: Product: Junsi iCharger 1010B+ | ||
+ | [2865177.604726] usb 1-6.2: Manufacturer: | ||
+ | [2865177.604728] usb 1-6.2: SerialNumber: | ||
+ | [2865177.605380] cp210x 1-6.2:1.0: cp210x converter detected | ||
+ | [2865177.668344] usb 1-6.2: reset full-speed USB device number 60 using ehci_hcd | ||
+ | [2865177.753915] usb 1-6.2: cp210x converter now attached to ttyUSB0 | ||
+ | </ | ||
+ | ===== Python Code ===== | ||
+ | |||
+ | The following code will read, translate and calculate all vital battery and voltage/ | ||
+ | |||
+ | |||
+ | <sxh python; toolbar: | ||
+ | # | ||
+ | # -*- coding: utf-8 -*- | ||
+ | # | ||
+ | ######################################################################## | ||
+ | # | ||
+ | # This program is free software: you can redistribute it and/or modify | ||
+ | # it under the terms of the GNU General Public License as published by | ||
+ | # the Free Software Foundation, either version 3 of the License, or | ||
+ | # (at your option) any later version. | ||
+ | # | ||
+ | # This program is distributed in the hope that it will be useful, | ||
+ | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+ | # | ||
+ | # GNU General Public License for more details. | ||
+ | # | ||
+ | # You should have received a copy of the GNU General Public License | ||
+ | # along with this program. If not, see < | ||
+ | # | ||
+ | ######################################################################## | ||
+ | |||
+ | import os, sys | ||
+ | import time | ||
+ | import serial | ||
+ | |||
+ | # discharge end voltage (empty) | ||
+ | |||
+ | dchg_end = 3.2 | ||
+ | |||
+ | |||
+ | # iCharger modes of operation | ||
+ | mop=[None]*13 | ||
+ | |||
+ | mop[1] | ||
+ | mop[2] | ||
+ | mop[3] | ||
+ | mop[4] | ||
+ | mop[5] | ||
+ | mop[6] | ||
+ | mop[7] | ||
+ | mop[8] | ||
+ | mop[9] | ||
+ | mop[10] = "Foam cut" | ||
+ | mop[11] = " | ||
+ | mop[12] = " | ||
+ | |||
+ | # configure the serial connections | ||
+ | # change according to the ttyUSB assigned to the iCharger (dmesg) | ||
+ | |||
+ | ser = serial.Serial( | ||
+ | port='/ | ||
+ | ) | ||
+ | |||
+ | ser.open() | ||
+ | ser.isOpen() | ||
+ | |||
+ | ### MAIN ############################################################# | ||
+ | |||
+ | while 1 : | ||
+ | |||
+ | line = ser.readline () | ||
+ | raw = line.split (';' | ||
+ | |||
+ | v_bat = float (raw[4])/ | ||
+ | v_c1 = float (raw[6])/ | ||
+ | v_c2 = float (raw[7])/ | ||
+ | v_c3 = float (raw[8])/ | ||
+ | v_in = float (raw[3])/ | ||
+ | i_chg = int (raw[5])*10 | ||
+ | i_sum = float (raw[18])/ | ||
+ | t_int = float (raw[16])/ | ||
+ | t_ext = float (raw[17])/ | ||
+ | |||
+ | s_vc1 = ((float (raw[6])/ | ||
+ | s_vc2 = ((float (raw[7])/ | ||
+ | s_vc3 = ((float (raw[8])/ | ||
+ | s_bat = round ((((float(raw[4])/ | ||
+ | - | ||
+ | |||
+ | print " | ||
+ | print " | ||
+ | print "Cell 1: " | ||
+ | print "Cell 2: " | ||
+ | print "Cell 3: " | ||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | print "Temp INT: " | ||
+ | print "Temp EXT: " | ||
+ | print ">>" | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | It only requires the pyserial package, on gentoo you can just: | ||
+ | |||
+ | <code bash> | ||
+ | $ emerge -av pyserial | ||
+ | </ | ||
+ | |||
+ | To run the application, | ||
+ | |||
+ | <code bash> | ||
+ | $ python pycharger.py | ||
+ | </ | ||
+ | |||
+ | There was not enough time to come up with a fancy pygtk or any other graphical implementation to show the data in real-time on a graph. Since the basic code, the data-mapping and the calculations are done and released under GPL3+ now, maybe someone else can step-in and extend the features to have realtime graphs :) | ||
+ | ===== Examples ===== | ||
+ | |||
+ | ==== Monitoring Mode ==== | ||
+ | |||
+ | The following example shows the data-log output of pycharger.py, | ||
+ | |||
+ | < | ||
+ | Mode: | ||
+ | Batt: | ||
+ | Cell 1: 4.064 V (86.4%) | ||
+ | Cell 2: 4.072 V (87.2%) | ||
+ | Cell 3: 4.067 V (86.7%) | ||
+ | Supply: | ||
+ | Charge Current: 0 mA | ||
+ | Charge Amount: | ||
+ | Temp INT: 34.3 °C | ||
+ | Temp EXT: 22.3 °C | ||
+ | >> | ||
+ | |||
+ | Mode: | ||
+ | Batt: | ||
+ | Cell 1: 4.065 V (86.5%) | ||
+ | Cell 2: 4.071 V (87.1%) | ||
+ | Cell 3: 4.068 V (86.8%) | ||
+ | Supply: | ||
+ | Charge Current: 0 mA | ||
+ | Charge Amount: | ||
+ | Temp INT: 33.8 °C | ||
+ | Temp EXT: 22.5 °C | ||
+ | >> | ||
+ | |||
+ | Mode: | ||
+ | Batt: | ||
+ | Cell 1: 4.064 V (86.4%) | ||
+ | Cell 2: 4.071 V (87.1%) | ||
+ | Cell 3: 4.067 V (86.7%) | ||
+ | Supply: | ||
+ | Charge Current: 0 mA | ||
+ | Charge Amount: | ||
+ | Temp INT: 33.8 °C | ||
+ | Temp EXT: 22.2 °C | ||
+ | >> | ||
+ | </ | ||
+ | |||
+ | ==== Charging ==== | ||
+ | |||
+ | The same battery pack, at the end of a charge cycle, in the final balancing phase: | ||
+ | |||
+ | < | ||
+ | Mode: | ||
+ | Batt: | ||
+ | Cell 1: 4.2 V (100.0%) | ||
+ | Cell 2: 4.205 V (100.5%) | ||
+ | Cell 3: 4.205 V (100.5%) | ||
+ | Supply: | ||
+ | Charge Current: 180 mA | ||
+ | Charge Amount: | ||
+ | Temp INT: 40.0 °C | ||
+ | Temp EXT: 26.7 °C | ||
+ | >> | ||
+ | |||
+ | Mode: | ||
+ | Batt: | ||
+ | Cell 1: 4.2 V (100.0%) | ||
+ | Cell 2: 4.205 V (100.5%) | ||
+ | Cell 3: 4.205 V (100.5%) | ||
+ | Supply: | ||
+ | Charge Current: 180 mA | ||
+ | Charge Amount: | ||
+ | Temp INT: 39.7 °C | ||
+ | Temp EXT: 26.6 °C | ||
+ | >> | ||
+ | |||
+ | Mode: | ||
+ | Batt: | ||
+ | Cell 1: 4.194 V (99.4%) | ||
+ | Cell 2: 4.205 V (100.5%) | ||
+ | Cell 3: 4.204 V (100.4%) | ||
+ | Supply: | ||
+ | Charge Current: 170 mA | ||
+ | Charge Amount: | ||
+ | Temp INT: 39.7 °C | ||
+ | Temp EXT: 26.6 °C | ||
+ | >> | ||
+ | |||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | Although the code could only be tested with the 1010B+ here, it is likely to be compatible to all sister models. If you have a different Junsi model and are able to test the code, please be so kind and leave some feedback for other people, who also look for free and open-source data logging alternatives. | ||
+ | |||
+ | <WRAP round tip> | ||
+ | If you're looking for a cheap grid power supply to drive the charger, **any old PC AT or ATX power supply will do**, since the charger itself is nothing else but a versatile buck/boost converter, regulated by a micro controller and assisted by a battery of balancing resistors. The 12V output of a 300W ATX supply is being used here. | ||
+ | </ | ||
+ | |||
+ | {{tag> | ||
+ | |||
+ | {{keywords> | ||
+ | |||
+ | |||
+ | ~~DISCUSSION~~ |