Skip to content

fancyui/Gobel-Power-RN-BMS-RS485-ModBus

Repository files navigation

Gobel Power RN BMS RS485 Modbus communication

  1. Format

NUM

1

2

3

4

5

6

7

8

9

Byte Count

2

1

1

1

1

2

LENID

2

1

Field Name

SOI

VER

ADR

CID1

CID2

LENGHT

INFO

CHKSUM

EOI

Data Types

ASCII

HEX

HEX

HEX

HEX

HEX

HEX

HEX

HEX

Data

0X37,0X45

0X10

 

0X46

CID2/CID3

 

 

 

 

In order to facilitate faster transmission and easier expansion, the following definitions are made for each field:

Num

Field Name

Meaning

Note

 

Main field

Subfield

 

always 0x37, 0x45

1

SOI

 

Header

 

2

VER

 

Protocol Version

 

3

ADR

 

The address identifies a specific device in a Modbus network

 

4

CID1

 

Control Code

Always 0x46

5

CID2

 

Command information control code

SU->SM

Status code

SM->SU

6

LENGTH

 

Byte length of info, high 4 bits as checksum, low 12 bits representing info length.

No need to divide, directly indicate the byte length

7

INFO

Info Head

Info subfield, defined for the purpose of expanding CID2

Fixed length, 4 bytes

Info Data

The data section of the "info" message

According to the protocol, related to CID2

Info CRC32

Universal Ethernet CRC32 polynomial checksum, only performs checksum on the info data subfield

4 bytes

8

CHKSUM

 

Checksum code: The byte value of all fields except SOI, EOI, and CHKSUM are accumulated, the remainder of the result obtained by taking the modulus of 65536 is then added by 1.

 

9

EOI

 

End Code

Always 0x0D





1. Field VER: Protocol Version Number VER is one byte, the high 4 bits of which represent the major version number of the protocol, and the low 4 bits represent the minor version number of the protocol. For example, when the protocol version number is 2.1, VER is 21H, and when the protocol version number is 2.10, VER is 2AH. The protocol version number of this protocol is V1.0, that is, VER is 10H.



2. Field ADR: Device Address In the instruction sent by the host computer, ADR represents the address of the target slave, which can be 0X01-0XFE. When it is 0XFF, it means that the target slave is all slaves. However, only some commands support this method.



3. CID1, CID2 Fields: Control Identification Code CID refers to the Control Identification Code. CID1 is a fixed value of 0X46H, and CID2 is classified into command code and feedback information according to the sender. When the sender is an upper computer, CID2 is the sent command, referring to the Control Identification Code Table for CID2 and CID3. When the sender is a lower computer, it is the feedback response status code, referring to the RTN table.



4. Field LENGTH: Length of Field INFO Length of the INFO field, including a 4-bit checksum and a 12-bit data length value:

High bits

Low bits

LCHKSUM

LENID (Number of bytes of ASCII code transmitted in INFO)

D15

D14

D13

D12

D11

D10

D9

D8

D7

D6

D5

D4

D3

D2

D1

D0

LENID: Indicates the number of bytes in the INFO field item. When LENID=0, INFO is empty, that is, there is no such item. LENID has only 12 bits, so the maximum number of bytes cannot exceed 4095.

LCHKSUM: The CHKSUM value of LENID with 12 bits, which is calculated as follows:

1>Addition: D11D10D9D8 + D7D6D5D4 + D3D2D1D0

2>Take the remainder when divided by 16

3>Take the complement and add 1.

Example: INFO byte count is 18, which is LENID = 0000 0000 0010B

Sum: 0000B+0001B+0010B = 0011B

Modulo 16 remainder: 0011B

Inverted and added by 1: 1101B

Therefore, LCHKSUM is 1101B.

Please check function field_length() for reference.



5. Field INFO: Information data

Field Name

Byte Count

Description

Main Field

Sub Field

Info Head

CID2

1

While send is SU, CID2=0

While sender is SM, return CID2

CID3

1

Extension or subcommand of CID2.

Reserved

2

0XC5, 0X5C

Info Data

According to CID2/CID3

Check Info Data Table

Info CRC32

4

1. Info Data: Information data which is verified by performing a CRC32 check. Each byte is converted into long data and then CRC32 calculation is performed. The remaining part is padded with 0x00 if the data is insufficient. It is important to note that Info Data has high bytes first.

 

2. CRC32: A type of cyclic redundancy check (CRC) which uses 32 bits.

 

3. Ethernet Polynomial: A polynomial used in Ethernet networks for error detection. It is also known as the CRC-32-IEEE 802.3 polynomial. The polynomial is represented by the hexadecimal number 0x4C11DB7 and can be expressed as X32+X26+X23+X22+X16+X12+X11+X10+X8+X7+X5+X4+X2+X+1.





6. Field CHKSUM

Please check funcition field_chksum().

About

Gobel Power LiFePO4 Battery RN BMS RS485 Modbus Communication

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published