Saturday 14 September 2013

(re)Calibrating the IMAX B6 AC charger

The B6AC charger (counterfeit)
a variant of the traditional B6
Just 1min of work and you'll have the pin header installed
Since cheap (read: counterfeit) B6 chargers bought online on the internet cannot be trusted, you will find hereunder the results of my research to recalibrate my IMAX B6AC clone and make it a viable solution.
On forums, you can find lots of info about changing the voltage divider resistors inside the charger. This is totally counter-productive. If your meter is not precise, it only needs recalibration. Changing these resistors by more precise ones (without recalibration) will only make your charger worse (since it has already been calibrated for the less precise resistors).
Some people recommend using a 6s Li-po (or who 3s in series) to re-calibrate it. I also find it risky since you need a reliable way to charge it before re-calibrating your charger.
This forum post shows (see posts 27 and 28) how a voltage divider and a reliable voltage source can be used. This is the method we will use.

Similar chargers 

The IMAX B6 is not the only charger based on this design (source). We can therefore hope this calibration procedure would work with these chargers:
  • RC-Power B6 charger
  • Imax B6
  • Turnigy Accucel-6
  • GT Power A-6
  • Mystery B6

Re-enabling the calibration menu

Depending on where you got your charger from, it may or may not have been calibrated before. The firmware is conceived in such a way that the calibration process can be done only once. We are therefore going to hack the firmware to remove this limitation.
This hack has been elaborated by Sp5, dusk and tolyan23 from RCGroups (less cryptic explanations here). 
You don't have to perform the hack yourself, it is already made and available on-line: we can download it directly from here (for some reason, he password protected his zip. The password is written in the post as well).
To load the new firmware you will need an AVR programmer (I'm using an usbasp), its drivers and avrdude.
Not even necessary
but highly recommended

Install a pin header to your charger and plug your AVR programmer

A cheap USBASP
from eBay
Parts you will need:
  • an ASP programmer
  • a 6-pin (matching) pin header

The first part is easy. You need to solder the pin header to the programming port (holes) on your charger, see the image below.
    B6 programming port holes

    Just 1min of work and you'll have the pin header installed
    Now that the port is installed, we will need to connect the programmer (as shown in the image below). Location commencing from square place SCK MISO MOSI RESET GND V+ (from left to right when you hold the charger in its normal position which is the opposite from the picture).
    Note for beginners: SCK and SCL are the same thing.
    Your programmer needs to be connected as show above

    Loading the software

    Avrdude syntax:
    • The chip markings are: ATMega32 16AU, the first parameter of avrdude will be '-p m32' (tells which chip we are programming)
    • With an usbasp, the second parameter will need to be '-c usbasp' (tells which programmer we are using)
      Note: you may need to replace the “usbasp” if you are using another one. More info on avrdude (syntax) here.
    To program the charger, I used the following command under the console in windows (administrator mode):

    First we make a backup flash (just in case) and eeprom (will be useful later):
    avrdude -p m32 -c usbasp -U flash:r:"flash.hex":i
    avrdude -p m32 -c usbasp -U eeprom:r:"eeprom.hex":i
    Alternative 1: Program with the hacked firmware above:
    avrdude -p m32 -c usbasp -U flash:w:"ImaxMod.hex":i
    Alternative 2: you can follow the instructions here and modify your flash.hex file with a hex editor. This one is free. you can then load it back:
    avrdude -p m32 -c usbasp -U flash:w:"flash.hex":i
    Finally we can restore the original eeprom values (e.g. if you want to keep your settings/calibration values)
    avrdude -p m32 -c usbasp -U eeprom:w:"eeprom.hex":i
    Now that it's programmed, we can check the calibration menu comes up by pressing the button 1 and button 3 during the charger start-up. The calibration procedure will be described below.
    Note: If you calibrate it wrong, you can always recover your original eeprom values with the command above.
    The calibration menu is unlocked
    press button 1 + button 3 during start-up

    Building a calibration bench

    So if we want to calibrate the B6 charger, we will need a precise calibration bench. Building these can be cheap, it is calibrating the calibration bench that will be a little more tricky. The bench I made is based on the schematics I found here.
    DC Boost Buck regulator
    from eBay

    What we'll need

    • A variable output DC DC converter. I personally chose a "DC Boost Buck Regulator" (can be found on eBay for about 2€ shipped worldwide. It accepts any input between 3 and 35v (and therefore 5v from USB, which is easy to get) to 2.2 to 30v (and therefore the 25.2v we need). We will only need to adjust the potentiometer to adapt the output voltage and we will therefore need a ...
    • Precise voltmeter is needed to adapt the output voltage to 25.2v (or 25.19). Please be careful, cheap multimeters are far from precise enough (some can be off by a couple of volts !).
    • 100 Ohm 0.1% resistors. If you look on ebay, search for '100R'. Just make sure the precision is 0.1% since they will be used as a voltage divider to simulate 4.2v cells.

    100 Ohm 0.1% resistors
    • Banana plugs and some wire
    • A 6s JST balance plug
    • A prototype board (if you want to make things clean)
    • Tin & and a soldering iron
    Building the calibration bench
    To build the calibration bench you will need to connect the usb male plug to your dc voltage booster input. The output needs to be connected to the banana plugs (mind the polarity) and to the balance connector: connect the red wire to the + and the last black wire to the -. Finally connect all your 100 ohm 0.1% resistors in series between these wires (+ and -), connecting each of the balance wires between each resistor pair (it will all be simpler if you have a look a the diagram below). 

    Going back to school formulas, we can check we do not exceed the USB max current (500mA):
    V=R x I
    In our case:
    I = 25.2V/600Ohm = 42mA
    Even with a inefficient DC step up we should be ok...

    A little hot glue, and it will be ready to be used

    Proceed with the (re)calibration

    The calibration bench
    ready to use
    With all this assembled, you need a precision multimeter to adapt (there is a screw on the dc converter, see the diagram above) the output voltage to 25.2v precisely (25.19v is even better). Make sure you adapt the voltage with the circuit connected to your charger since the data acquisition chain of your charger might impact the output voltage (it should not but might anyway, we're talking about a cheap dc converter after all). 

    Now that your calibration bench is ready, connect your bench to a usb socket, the banana and balance plug to your charger (make sure the male banana plugs do not touch each-other or anything when plugging the USB). Hold the button 1 & 3 of your charger while powering it, your charger will automatically recalibrate the balancing circuit. Once it's done, switch it off and power it while pressing the 2 & 4 buttons. Using the up and down buttons set the voltage value to 25.2v and press enter.

    You're done! 
    Note : I recommend you check the battery voltages after your first charge... just to make sure...

    Since I recalibrated my charger, I won't need my calibration bench anymore so if anyone wants it, I'll sell it at the cost of its components: 14 EUR (plus shipping) and expect the person who purchases it to do the same, and so on... I leave the organisation of this 'calibration community' to the comment section below: