• ### Overcurrent protection

10/07/2019 at 11:01 0 comments

BMS have very interested overcurrent protection.

BMS have three levels overcurrent protection:

- slow protection;

- fast protection;

- short-circuit protection.

For using this protections checkbox "Doubled Overcurrent and short-circuit value" mast be reset (see below).

So how do you set up all three levels?

## 1. Set correct "Current Res" value.

At BMS installed shunts (see below).

The program window JbdTools necessary to set the resistance of the current-measuring stage. But if you just calculate this resistance formula conductivities addition, it does not mean that you set the correct value of the shunt. In my BMS sets 1 mOhm, but only 0.5 mOhm current calculation is correct.

So you need to:

- set the calculated resistance;

- load the battery for a specific load;

- to adjust the value of the shunt in the program so that the current was determined correctly.

## 2. Set DSGOC

This value must correspond to the maximum current that flows for a long time (> 1 sec). In my case it is 30 A, 3 seconds.

## 3. Set DSGOC2

Current value  set in the field voltage.

If I want a quick disconnect from the current of 50 A at 8 ms, then I install DSGOC2 I*R = 50 A * 0.0005 Ohm = 25 mV.

## 3. Set SC Value

It is short-circuit value (see paragraph 3).

Set the time of the reset of this error (see below).

• ### Wrote a library for Arduino

09/05/2019 at 14:04 0 comments
• ### Code for working with BMS

08/08/2019 at 06:40 0 comments

# Introduction

The files below I used in my project to communicate with BMS.
My project uses two types of BMS: JBD or Lithuanian BMS.

I am using STM32F303.

My implementation is very sophisticated. Therefore, I did not post it for a long time. But the people are asking, so hold on.

# How i worked with this class?

1. Attached the header file:

`#include "BMS.hpp"`

2. I did create global variables (in main.cpp):

```//For BMS
HAL_StatusTypeDef bufferHalStatus = HAL_OK;
uint8_t * requestMessage = new uint8_t[9];
uint8_t lenRequestMessage = 7; ///< 7 For China BMS. Change if used Tiny BMS.
uint8_t * dmaBuffer;
uint16_t lenDmaBuffer = 34; ///< length message from Tiny BMS
BmsData batteryData;```

2. Enabled DMA Fill and Timer Interrupts.

```// For BMS
HAL_NVIC_DisableIRQ(DMA1_Channel6_IRQn);
HAL_NVIC_DisableIRQ(TIM6_DAC_IRQn);```

3. In the thread, the BMS has defined a message that will be sent after a response from the BMS.

```	requestMessage[0] = 0xDD;
requestMessage[1] = 0xA5;
requestMessage[2] = 0x03;
requestMessage[3] = 0x00;
requestMessage[4] = 0xFF;
requestMessage[5] = 0xFD;
requestMessage[6] = 0x77;```

4. Defined a dma buffer, created an instance of the BMS class. Launched the mode of automatic sending requests to BMS.

```dmaBuffer = new uint8_t[lenDmaBuffer];
BMS bms;
bms.autoSenderModeEnable();```

5. I read data with bms in a loop. In the case of a successful read (batteryData.halStatus == HAL_OK), you can work with data.

for (;;) { batteryData = bms.readBmsData(); if (batteryData.halStatus == HAL_OK) { telemetryMessage.ADC_battery = batteryData.chargePercentage; /*.more.*/ } else { /* error */ }

6. Below stm32f3xx_it.c file:

```/**
* @brief Handler interrupt DMA1 channel6.
*
* 1. Resets timer 6 for reset timeout event BMS UART BUS.
* 2. Sends a new request to the BMS.
*/
void DMA1_Channel6_IRQHandler(void) {

if (((DMA1->ISR) & DMA_ISR_TCIF6) != 0)
{
// 1. Resets timer 6 for reset timeout event BMS UART BUS.
bufferHalStatus = HAL_OK;
__HAL_TIM_SET_COUNTER(&htim6, 0);

// 2. Sends a new request to the BMS
bmsInterruptedCountRxDMA++;
//HAL_UART_Transmit(&huartBMS, requestMessage, lenRequestMessage, 100);
}

HAL_DMA_IRQHandler(&hdma_usart2_rx);
}
/**
* @brief Handler interrupt TIM6
*
* Intended for set timeout event if blank UART more 1 sec.
* After 0,5 с - send requset message.
* Thereafter 0,5 sec set timeout.
*/
void TIM6_DAC_IRQHandler(void) {
HAL_TIM_IRQHandler(&htim6);

if (timeout500msAlreadyBeen == 1) {
bufferHalStatus = HAL_TIMEOUT;
}

bmsInterruptedCountTim6++;
//    HAL_UART_Transmit(&huartBMS, requestMessage, lenRequestMessage, 100);
//    HAL_UART_Receive_DMA(&huartBMS, dmaBuffer, lenDmaBuffer);
}

```

If you have questions, then write in telegram.

• ### BMS current consumption

06/11/2019 at 11:52 0 comments

I measured the currents of the consumption of the BMS itself.

The results are below.

 Mode Current consumption The load is not connected, the LED on the board is not on. 70 uA, and every five seconds 150..200 uA The load is not connected, the LED on the board is not on, BMS connected to PC through UART 100 uA, and every five seconds 200 uA LED on the board is on 18 mA
• ### Change of firmware

06/04/2019 at 08:25 0 comments

The manufacturer shared the firmware for BMS from 12.06.2018. We really liked this firmware, as it works adequately with the button. The images below show how the firmware changes. Firmware In here.