Arduino 4S BMS (Version 7)

INTRODUCTION

Like my previous post about this project, this is a customizable arduino based 4S BMS system. This is now version 7 of hardware and version 21 of software.

The benefit of using this over other low cost solutions is that gives a lot more feedback about what exactly its doing and control over how its doing it. For example setting the limit for the over voltage protection and under voltage protection value.

IMAGES

Here is a couple pictures of my BMS in action on a 4S11P 18650 pack.

FEATURE SET AND SPECIFICATIONS

Now to the key features that makes this project different from the rest:

  1. Adjustable voltage tolerance (maximum difference between cells)
  2. Display individual voltage cell values on an oled i2C display and/or serial print monitor over UART (TX, RX, GND)
  3. Set under-voltage protection value and over-voltage values for series MOSFET
  4. Adjustable balance current with a swapping of drain resistor up to 1A safely
  5. Serial commands for adjusting variables and feedback:
    1. Under voltage protection value
    2. Over voltage protection value
    3. Cell voltage tolerance
    4. Request calibration values
    5. Request status of UVP and OVP event and reset if triggered
    6. Enter calibration mode to re-calibrate if needed for ADC inputs

DOWNLOAD ORIGINAL FILES

Schematic and original kicad files

Arduino Code

NOTE: Arduino BMS A7 hardware is supported only with the current arduino software

HARDWARE

Now lets look into the hardware for this. There are 5 important sections in this board:

  1. Power Section
  2. MCU: Arduino ATMEGA328P running at 8MHz with minicore bootloader
  3. Reference 1.25V voltage for ADC
  4. Voltage dividers for cell measurement into ADC
  5. Balance Section
  6. Series MOSFET Section

POWER SECTION

One of the most important sections in this project is the power section. Key features I was looking for was low Quiescent current because this will be battery operated.

Quiescent current is the amount of current needed to operate an IC.

The current power IC I’m using is a buck converter RT6208G. I chose a buck converter over an LDO because of efficiency, again trying to keep the current draw from the battery low. Key features of this converter is:

  1. Low quiescent current: less than 500nA or 0.5mA
  2. High input voltage: 36Vin max
  3. Small and compact
  4. Efficient: around 80-90%

One thing to mention is that the buck converter I chose is currently out of stock and will not be available until November. I’m currently working on choosing an alternative but any buck converter will work with this.

Figure 1: Power Section

Anything here is that instead of stepping down to 3V3, I stepped down the voltage to 2V7. The image above is wrong and the FB resistor values are picked for an output voltage of 2V7 but it will function the same.

The reason for going with this voltage is because I was trying to minimize the current draw from the battery. I found that 2V7 is the minimum voltage I can use while still being able to use the I2C OLED screen.

MCU and REFERENCE VOLTAGE SECTION

The next section is the Arduino MCU and the external 1.25V reference.

Figure 2: MCU and Reference Section

Here you can see where the ADC pins are attached to the cell pins for measurements. And the digital pins for the control of the mosfets for the balance section. Its pretty straight forward here

On the bottom you can see the external 1.25V voltage reference. I’m sure there are different values I could have gone with but I figured that with a 1.25V I could try and increase resolution even after the voltage dividers. Without accounting for the voltage dividers for measuring the cells, we have a 1.22mV resolution. Not too bad but obviously it will increase with the voltage dividers.

VOLTAGE DIVIDER SECTION

The next section is the voltage divider section which is used to step down the cell voltages to within the voltage reference value, in our case 1.25V max.

My values calculated were based stepping down the voltage value to within 1.20V, that is when a cell is at 4.2V then the divider will be 1.20V. This gives some margin in case the cells get overcharged.

Here you can see the divider circuit. Since the measurements are single-ended measurements and not differential, then everything is reference to ground and there for the higher in cell measurements we go the bigger the voltage divider we need.

I used 100k as the base resistor as I tried to minimize current consumption. The measurement cycle will be slower due to the arduinos 14pF capacitor but thats ok because we sample about 100 measurements to offset this.

BALANCE SECTION

The last section is the balance section. Here the controllers turns off and on the mosfets corresponding to the cell its attached to. When the software determines that ex. cell 2 is higher than the lowest cell, then D1 is triggered and an 18 ohm resistor will start draining some current to let the rest of the cells catch up.

Figure 3: Balance Section

Looking at the bottom section of this circuit ( BAT0 / BAT1 ) you can see resistor value R424, this controls how much current is drained. At full charge of the cell 4.2V, you will see a current drain of 0.23A and then a minimum drain of 0.16A when the cell is at 3.0V.

Since the series mosfets are capable of 4.2A, you can theoretically lower the resistor value to drain more current but I do not suggest draining more than 1A at least with this board.

PROTECTION MOSFET SWITCH SECTION

This section was added for an extra layer of protection and is not needed for the bms balancing functionality to operate.

I’ve added a mosfet switch that utilizes the arduinos digital pin 9 and 10 to control power mosfets that are in series on the positive line of the battery.

Figure 4: MOSFET SWITCH

Theoretically each mosfet can handle around 10A without a heatsink and about 40A per mosfet with a heatsink for a total of 120A total. But here you can add more in parallel for higher current or change the mosfet for a higher current capable one. The mosfets used here are P_Channel mosfets for high side switching.

SOFTWARE

Now to cover the software side of this board, here I will only cover the important sections in which you might want to adjust for your own purposes. Most of the variables you would want to change can be accessed and changed via serial monitor using an FTDI while only connecting the TX, RX, and GND pins.

Here I will list the important sections:

  1. Sampling frequency
  2. Tolerance adjustment
  3. Serial Commands

SAMPLING FREUENCY

//////////////////////////////////////////////
// Sampling number for analog read values.
// Will use this sample size to calculate a
// better estimation of the analog value
//////////////////////////////////////////////
int samples = 100;

Here in the samples variable you can change the value for how many samples the adc takes before creating an averaging of the cells. If you want a smoother value you can increase but I would not go past 250 samples. Remember this will also effect the amount of time it takes to display voltage values.

TOLERANCE ADJUSTMENT

//////////////////////////////////////////////
// This is the max difference that the cells
// can achieve in respect to each other
//////////////////////////////////////////////
float tol = 0.01; // 10mV max voltage difference

Here in the tol variable, it is used to as a reference for when the balancing of the cells should stop. The cells will balance until all cells are within 10mV of each other. This might not be exact because with the last 2 cells the register voltage different might be greater than 10mV due to a higher voltage divider but the measured voltage is around +/- 25mV of the actual cell voltage.

SERIAL COMMANDS

The most important part is the serial commands because this allows you to make changes without having to reflash the arduino.

Below we have a list of 6 serial commands that I will explain in details on how to enter the values into the serial monitor.


/* This is the table for entering into different modes and how to 
 *  enter commands within serial console
 *  
 *  modes:
 *  1. Display ADC calibration values = 1001
 *  2. Enter adc auto calibration     = 1002
 *  3. Adjust minimum and maximum     = 1003
 *     voltage threshold for OVP
 *     and UVP
 *  4. Used to set all digital outputs
 *     to low                         = 1004
 *  5. Erase all EEPROM values        = 1005
 *  6. Reset series switch value      = 1006
 *  7. Display status for Reset, UVP
 *     OVP state condition            = 1007
 *
 *  
 *  1.Example of displaying calibration values
 *    Serial window: mode
 *    Serial window: 1001
 *  
 *  2.Example of entering into auto calibration mode
 *    Serial window: mode,vref1,vref2,vref3,vref4
 *    Serial window: 1002,4.00,8.00,12.00,16.00
 *
 *  3.Example of entering UVP and OVP values
 *    Serial window: mode,UVP,OVP
 *    Serial window: 1003,3.10,4.15
 *    
 */

Lets look at the first command entry.

  • 1001
    • This will display the calibration values that is stored in EEPROM
  • 1002
    • This will enter calibration mode. Since there might be some offset from what the adc reads vs the actual value, I added a calibration mode that will add the offset to each adc value to try and get the values closer to the actual.
    • To enter calibration mode you will need to enter:
      • 1002,vef1,vef2,vef3,vef4
      • The vef1-4 values are the actual measurements of the battery cells
    • Calibration setup:
      • Enter 1004 first to turn off all balancing MOSFETS
      • Measure each cell value with a multimeter to get the actual value
      • Then enter calibration mode by entering 1002,3.54,3.76,3.20,3.56 as an example for vef values
  • 1003
    • This will adjust the values set for under voltage protection and over voltage protection. So if lets say 3.1V is set value for under-voltage protection then if any one of the cells drop below this value then the series FET will trigger if you have it attached.
    • This command is only valid if you use digital pin 9 and 10 for the series FET switch.
    • Enter 1003,UVP,OVP
    • 1003,3.2,4.2
  • 1004
    • Used to set all balancing values to low so that no cell is draining current. This is usually used for testing purposes.
    • Enter 1004,1 for setting all values to low
    • Enter 1004,0 to go back to normal balancing operation
  • 1005
    • This is used to erase all eeprom values
  • 1006
    • If UVP or OVP is triggered then you will need to reset this fault condition
    • Enter 1006,0
    • NOTE: If values are above or below the UVP and OVP values then resetting the 1006 command will not allow current to pass

CONCLUSION / FUTURE UPDATES

I’m very happy on how this project has progressed but its far from perfect and I will continue to optimize both the software and hardware to make it easier to integrate into a battery.

Future updates in my roadmap:

  1. Optimize the Power MOSFET Switch circuit to handle higher currents
  2. Possibly combine the mosfet control to one pin as using two might not be needed. UVP and OVP conditions open circuit the mosfet bidirectional switch
  3. Add current sense capability for overcurrent protection.
  4. My next big protection is creating a 7-8S BMS as well as a separate UVP, OVP, and Over-current protection board that will operate independently from the 8S BMS board but will still communicate via I2C to pass current data to the BMS board

If you have any questions or any suggestions or improvements please feel free to ask or comment.

Thank you and hope you enjoyed this project.