cancel
Showing results for 
Search instead for 
Did you mean: 

My battery management system card is not communicating via RS485 with STM32

sezear07
Associate II

Hello,

I have a SEPLOS brand battery management system card, and I want to read temperature and voltage data from this card. Initially, I will use an STM32F407VGT6 board to read data from the SEPLOS battery management system card via RS485. I am sending the commands first to get the data, but although the data is being sent, I cannot perform the reading operation. What do you think could be the reason for this problem?

The PDF I will send below contains an information sheet about how I should read data from the SEPLOS brand battery management system via RS485. Please look at the PDF and my code to see if you can find where I might be making a mistake.

 

WhatsApp Görsel 2024-06-20 saat 21.37.12_9c1a0877.jpg

WhatsApp Görsel 2024-06-20 saat 21.37.12_c44ef19d.jpg

  

WhatsApp Görsel 2024-06-20 saat 21.37.12_d9796b56.jpg

thank you for answer

27 REPLIES 27

If you initialize the UART/USART for 485 comm and use the correct alternate function DE pin, the DE pin is set high and low automatically. If you are using some other GPIO pin, you have to explicitly set or reset it before the transmit or receive command.

In this picture you have shorted DE + /RE if you are using a device with these two signal lines, short them and connect to one GPIO. While transmitting place this pin as 1 and immediately after transmit, place it to zero so that receive will be active.

Techn
Senior

It is not mandatory to use DMA, you can use any mode to read the data. Basically read means send a command to

CORRECT address as se the DIP switch. Make sure that you send the command bytes correctly, Check sum and Length etc. While sending keep DE/RE to  1 so that transmission happens and immediately switch over to 0 for the unit to respond. Receive till 0x0D

eg of query command from the datasheet

Techn_0-1719034206311.png

if you prefer to read in your main loop keep reading till you get 0x0D or in interrupt you can receive one byte  each till you assemble all bytes till 0x0D. Then inform main loop to process the data. The response will happen if you send it to the correct address, else nil. At least one message you hand code carefully and test it.

Timeout of 500ms can be implemented to avoid infinite waiting.

Yes, my first mistake was here. When sending a command, I need to set the pins to high position, and then when performing the receive operation, I need to set the DE/RE pins to low position. I hope this is the only problem. Do you see any other missing parts in the code?

Yes, I noticed that there is a problem here. The circuit I am using is the MAX485 module. In fact, there are more advanced modules that automatically switch between high and low. If there is an issue, I have also obtained those modules.

Do you know how to manually set the address? For example, I manually keep the address positions at zero and send the command based on the address value 00.

 

As far as I understand, the STM sends commands based on the data in Table 7. For example, after sending the telemetry data at address 00 in Table 7, we should automatically receive the parameters such as cell voltages and cell temperatures listed in Table 8, right? My main question is, if I need to store the temperature and voltage parameters from Table 8 into specific arrays, those bits should correspond to the temperature and voltage values we need. However, it is not specified in Table 8 which bytes the temperature and voltage data should be stored in. In this case, do you think my void SeplosBms_Read(); function is written correctly? Do you see any other errors in the code?

140.PNG

142.PNG

How many devices are there? you need to know the address. earlier you made a statement that transmit is success, does it mean that when you send data, any parameter gets changed in the target device?

make sure that you connect A ->A and B->B  and GND

I am not familiar with your system. There must be some way to set the address by some dip switches. You need to know the set address.

you need to go step by step. Your first problem was how to get some response from the target device. Once you receive that you can start interpreting the data based on table 8,9 .

Let us know once you are able to get response from the target device. 

Table 8 seems clear in the sense that the how many bytes are needed for each parameters, you need to count it as per the table, first read the number of cells and based on that you can count from the start of the frame. Looks like if you read the document multiple times and  analyze you can do it.

 

There is a device, and as far as I understand, the sent parameter does not cause a physical change in the system. Normally, telecommand data causes alarms or physical changes in the system, while telemetry data can only retrieve cell temperature and voltage data.

 

Yes, I am sure about the system's connection because I previously checked if the RS485 module was working correctly with two STM boards. So the connections are correct. If I want to both send and receive data from one STM, I can set the DE/RE pins to high at the beginning and then to low after 500ms.

There is some information about addressing that I will send to you as shown in the image below. As far as I understand, if you have more than one slave device and need to establish a master-slave connection, you may need to change the positions on the DIP switch. But since the STM is a master device and the battery management system is also a master device, I believe the positions should remain at value 0.

 

My thought about Table 8 is that it provides the necessary information about the number of bytes and how much space to allocate, but it does not give complete information on which parameter to store, for example, in the 15th byte. In this case, I made a logical inference and created the SeplosBms_Read() function accordingly, but I am not sure if it is correct

150.PNG

151.PNG