EBikes – Dual Battery Management System

The only commercial developer of dual battery electric bikes I have seen to date is Bosch, who do an optional Dual Battery kit, which one or two manufacturers have taken up. Being proprietary technology, there is not a lot out there about it. The only two things I can glean are:

1. The real technology is in the Bosch controller, which manages use of the battery, charging and showing information about the batteries on the dashboard. This means it cannot be retrofitted to an earlier Bosch system yet.

2. It doesn’t connect the batteries in parallel, it switches to a battery and uses 10% of power, then switches to the other battery and uses 10% and repeats. This is designed to make sure a battery does not get too “tired” and can recover somewhat before being used again. This will extend the short term range of the two batteries, apparently more than doubling the range of a single battery, and presumably will also extend the life of the cells in the batteries.

This is great, but I cannot afford a bike with a Bosch system, especially as I have only just built my latest Bafang based bike.

Why do I want dual batteries? Firstly, the 13Ah battery supplied with the kit, while only 2 Ah less than the self build Headway battery I was using, is getting a bit frustrating, and secondly I have an excellent 36v 12 cell 15Ah LiFePO4 headway cell battery sitting on a bench not doing much. I could re-purpose the cells, but being able to use them to increase my bike from 430Wh to 1008Wh is quite attractive. These two batteries are an interesting combination. The 13aH Lekkie, is made from 18650 (18mm diameter by 65mm long) cells, some sort of LiPo (Lithium Polymer) probably, each cell being about 3.3 to 3.9 volts. 4 or 5 are grouped in parallel to give the 13 Ah and 10 groups connected in series to give the nominal 36v. The other is made of 40152 Headway cells (40mm by 152mm), each 15Ah, with a voltage range of 3.0 to 3.6v. 12 are connected in parallel to give the 36v nominal. The former weighs 3Kg and sits very neatly on the downtube, the latter is 8Kg and sits in a pair of plastic panniers on the rear rack! http://www.signsofsuccess.co.nz/batteries/ and http://www.signsofsuccess.co.nz/electric-bikes-back-again/

So what do I want this dual battery system to do?

1. I want both batteries to be physically attached for the whole ride, no stopping to physically swap cables etc.

2. I want the system to automatically swap the connection from one battery to another on the fly – no loss of power, no stopping to flick a switch etc. This means it will need to “make before break” – connect the next battery, and when connected, disconnect the previous battery so that it can rest. If a batteries voltage is less than the battery currently in use, the system will stay with the current battery.

3. It must cope with only one battery being connected at a time, or both.

4. There must be no connection between the two batteries while in use, other than the momentary “make before break”, so that the batteries do not attempt to equalize their states of charge.

5. The system shall be self powered by one or other of the attached batteries, no extra connection or battery will be necessary. Battery equalization through this power supply is to be avoided.

6. This is a development platform, the battery swap time, the delay between make and break and the swap algorithm should be easily reprogrammed.

7. It should look good on the bike, and be completely weatherproof, using the Lekkie/Bafang weatherproof connectors used to connect the motor and battery on a standard system.

8. Reverting back to a single battery should be easy and free – no damage to existing components.

How do I propose to achieve all this?

For the working prototype I have the following ideas.

  1. Obviously some reasonably simple control is required, I will use an Arduino micro processor to run a simple C program. I have experience of C on the Arduino, I have two development platforms I can develop and test the components on, and tiny versions are available which take up very little room, yet do everything I need them to do.
  2. Arduino devices run on 5v (or 3.3v) power, and this can be supplied directly to the board via the headers, or can be supplied via a micro USB  plug. To run this off the bike batteries I will need two things. The first is a DC-DC voltage converter, with an input voltage that can cope with a variety of batteries in various states of charge (12s – 41v to  33v, other batteries up to 60v). These converters are readily available. The second is a pair of diodes (or a single diode with two cathodes) so that both batteries can be connected to the input of the voltage converter, without the higher voltage battery trying to charge the lower voltage battery. I have a diode rated at up to 100v (60v RMS) and runs at 20A, with a 150A surge, which should cover all bases!
  3. The Arduino program will use two digital output pins to control two solid state relays (SSR). These SSRs optically isolate the high voltage circuit from the low voltage circuit allowing the relays to be used on the battery positives. They also stop any back flow from one battery to another. Other solutions using MOSFETs have issues with common grounds etc. In addition, the SSRs come ready built, just plug and play. I am using 100v 40 amp relays, to give a bit of leeway (maximum voltage should be about 42V, maximum current should be about 18A).
  4. In order for the Arduino to measure the state of charge of each battery, analog pins on the Arduino will be connected to the positives of each battery. Arduino analog pins have a maximum voltage of 5V, so voltage splitters will be added to reduce the voltage to under 5v, I will be using an 11 to 1 ratio between input and output, so 44v will be reduced to 4v for the Arduino.
  5. The program on the Arduino is quite simple (at the moment). Every 5 or 10 minutes (to be decided) the program will read the voltage of both inputs, and whichever has the highest value will be connected as the next battery, and after a short pause for the relay to do its work (10ms) the previous battery will be disconnected. If a battery is faulty or not connected, the voltage test will ensure that only the working or attached battery will be selected. 10% of usage on my batteries is between 7 and 9 minutes, so a simple timer will have a similar effect to using power meters to decide when to swap. Because the unit will have no switch, it will activate as soon a the first battery is attached, and that battery will be the selected battery. An initial pause of 30 seconds before the first automatic switch will allow both batteries to be connected, and the highest voltage battery to be used.
    // global variables
    //debug variable
    //#define debug 1
    //constants
    //relay output pins
    const int r1Pin = 7 ;
    const int r2Pin = 6 ;
    //battery analog voltage pins
    const int b1Input = 0;
    const int b2Input = 1;
    //duration between switches
    const int duration = 450000;
    const int waitforbattery = 30000;
    //overlap for make before break
    const int overlap = 20;
    //constant to convert sensor to voltage
    // ((max voltage) / (resolution of analogread) ) * (voltage splitter factor)
    // (5.0/1024.0) * 11.0
    const float voltConv = 0.053711;
    //float variables
    float voltageB1;
    float voltageB2;

    void setup() {
    #ifdef debug
    Serial.begin(9600);
    #endif
    //set relap pins to output
    pinMode(r1Pin, OUTPUT);
    pinMode(r2Pin, OUTPUT);
    //switch on a battery temporarily until both batteries are plugged in
    togglebattery();
    //wait 30 seconds for second battery to switched on or plugged in
    delay (waitforbattery);
    }
    void loop() {
    //switch to better battery
    togglebattery();
    //wait a while before switching again
    delay (duration);
    }

    void togglebattery() {
    // read analog battery sensor values and convert to voltage
    voltageB1 = analogRead(b1Input) * voltConv;
    voltageB2 = analogRead(b2Input) * voltConv;
    #ifdef debug
    Serial.println(voltageB1);
    Serial.println(voltageB2);
    #endif
    // if battery one voltage higher than battery two
    // switch battery one on and switch two off after small delay
    if (voltageB1 > voltageB2) {
    digitalWrite (r1Pin, 1);
    delay (overlap);
    digitalWrite (r2Pin, 0);
    }
    //else switch battery two on and battery one off
    else {
    digitalWrite (r2Pin, 1);
    delay (overlap);
    digitalWrite (r1Pin, 0);
    }
    }

  6. For a weatherproof case, I have a few spare controllers for use with Bafang rear or front wheel motors, one or two of which are not particularly useful. They do have excellent silicon gaskets to provide full weatherproofing, and are also aluminium extrusion which is designed to act as a heat sink for any hot components attached inside. As both relays and the rectifier diode being used on the power converted are designed to be attached to heat sinks, this saves me having to make anything else up. Matching up sizes of components and the case, all components should just fit into the case. The case has mounting points for easy attachment to the bike.
  7. The power converter will be plugged into the Arduino board via a USB plug. This will be easily reached just inside one of the end plates of the aluminium case. If I want to reprogram the Arduino, I can attach a programming cable to the same port, and update the code as required.
  8. I have purchased two Lekkie battery extension cables. This gives me two of each type of connector. The input to the DBMS will be two battery sockets, as found on the Lekkie/Bafang motor, the batteries will plug into these sockets. The output will be a single battery plug, as found on the Lekkie battery that came with the kit, this will plug into the Bafang motor instead of the single battery. This leaves me with a single battery plug, which I will attach via an adapter to the XT90 connector currently on my self built headway battery. At $16 for each cable, these provide a standard connection method, so adding or changing batteries later is easy, and the connections are waterproof.

Early days yet, most parts are ordered, a small circuit board for the power supply diodes and the voltage splitters has been built.

 

Posted in Arduino, Dual Battery Management System, Electric Bikes, Programming, Yuba Mundo eV4
One comment on “EBikes – Dual Battery Management System
  1. Dave says:

    Quick update – most of the components have arrived, and have been assembled and tested. The relays are wonderful, obviously silent. The power supply for the arduino works well, the Arduino ProMicro by Sparkfun was an interesting choice, but a good choice in the end.

    Unfortunately, fitting everything into the case I selected was too hard a jigsaw puzzle, so have ordered a more spacious case that is robust and easy to use, should be here soon, I think Chines New Year slowed things down again!

    I have also ordered a Powertech Digital DC Power Meter (https://www.jaycar.co.nz/digital-dc-power-meter-to-suit-50mv-external-shunt/p/MS6172) from Jaycar. This is effectively the same as Turnigy or Watts Up power meter, but it uses an external shunt, which I also ordered. The shunt which is 100amp, 50mV will be installed in the battery management system, and the meter itself installed on the handlebars. This will make testing and monitoring the two battery usage much easier.

    It’s been a slow job so far, but I have spent hundreds of hours thinking about layout and connections, so the result should be quite slick!

Leave a Reply

Your email address will not be published. Required fields are marked *

*