We have introduced the physical layer and data link layer of the HART protocol. In this article, we will describe the message structure. I hope everyone can understand this knowledge. And master its frame structure.
Message structure
As shown in the following figure, a message includes the source address, destination address, and check bit. Each response message includes the status of the on-site device to ensure smooth communication. Data bit availability depends on the actual situation. Generally, 2 to 2 bytes can be transferred per second ~ 3 messages.
PREAMBLE START ADDRCOM BCNT STATUS DATA PARITY
Sequent delimiter address command number Data Length response code Data byte parity
Previously versions of HART protocol 5.0 generally use a "short structure". If a single field device only uses 4 ~ When measuring the 20 mA current signal, the address of the slave device is 0; otherwise, for multiple devices, the address of the slave device is from 1 ~ 15. This short-structured address is randomly allocated with 1 ~ 15. The HART Protocol version 5.0 introduces a "long structure". This format is unique from the device address. Like the physical address in each Nic, It is not repeated across the world, generally, it occupies 38 of the 5 address bytes. The 38-bit address information includes the manufacturer's code, device number, and device identification code. This format reduces the possibility of incorrect transmission and receiving. Currently, most host devices support both long and compatible short structures. When the response signal of the slave machine does not have a "unique" identifier code, the zero number Command provided by HART 5.0 and later versions can be used for device address recognition in short frames. In other words, the host determines whether the structure format is "long" or "short" based on whether the response signal has a "unique" identifier code ".
The composition of a message frame:
1) PREAMBLE introduction byte, generally 5 ~ 20 FF hexadecimal bytes. It is actually a synchronous signal, and various communication devices can make slight adjustments accordingly to ensure information synchronization. When communication starts, 20 FF introductions are used. When the server responds to 0 signals, it will tell the host that he "wants" to receive several byte introductions, in addition, the host can also use the 59 command to tell the slave server how many introductions will be applied during the response.
2) START byte. The structure used for the START is "long" or "short", the source of the message, and whether the message is in "burst" mode. When the host to the slave is short, the start position is 02 and the long frame is 82. The short structure value from the host to the host is 06, and the long structure value is 86. For the "burst" mode, the short structure value is 01 and the long structure is 81. After the device receives two FF bytes for communication, it will listen for the start bit.
3) ADDR address byte, which includes the host address and slave address. As mentioned above, the short structure occupies 1 byte and the long structure occupies 5 bytes. Regardless of the long structure or short structure, because the HART protocol allows two hosts to exist, we use the highest bit of the first byte to distinguish between. The value 1 indicates the first host address, the second host is represented by 0. The "burst" mode is a special case. values 0 and 1 are displayed alternately. That is to say, in this mode, equal opportunities are granted to two hosts. 1 indicates the "burst" mode, and the short structure uses the first byte 0 ~ The value ranges from 0 to 4 bits ~ The slave address of 15 is assigned to 0 at the fifth and sixth digits. The long structure uses the last six digits to indicate the code of the slave manufacturer. The second byte indicates the Model Code of the slave device. The last three bytes indicate the Model Code of the slave device ~ Five bytes indicate the serial number of the slave device and constitute a "unique" flag.
MA Host address |
BM Burst Mode |
0 |
0 |
SA Slave |
SA Machine |
SA Location |
SA Address |
Short frame address Structure
In addition, if the 38-bit low value of the long structure is 0, it indicates the broadcast address, that is, the message is sent to all devices.
4) The COM command byte. Its range is 253, And the HEX 0 ~ is used ~ FD. 31,127,254,255 is the reserved value.
5) the total length of BCNT data. Its value indicates the number of bytes from the next byte of BCNT to the end excluding the validation byte. The receiving device can identify the validation byte or the end of the message. Because the maximum data size is 25 bytes, the value ranges from 0 ~ 27.
6) STATUS byte, also known as "response code". As the name suggests, it only exists in two bytes when the slave server responds to the host message. It will report communication errors, status of commands received, such as busy devices, unrecognized commands, etc.) and the operating status of the slave machine.
If an error is found during communication, the maximum bit of the first byte is set to 1, and the other 7 bytes report the error details, and the total number of 7th bytes is 0. Otherwise, when the highest bit of the first byte is 0, the communication is normal, the other 7 bits indicate the command response, and the other 2nd bits indicate the status information of the field device.
Communication errors found by UART generally include parity check, overflow, and structure errors. There can be 128 command response codes, indicating errors and warnings. They can be of a single meaning or multiple meanings. We define and define them using special commands. The field equipment status information is used to indicate the fault and abnormal operation mode.
7) in the frame structure of the HART protocol, DATA bytes. First of all, I want to explain that not all commands and responses contain DATA bytes, he cannot exceed 25 bytes at most. As the communication speed increases, he is asking to relax this standard ). The data format can be an unsigned integer, which can be 8, 16, 24, 32 B), floating point number in IEEE754 single precision Floating Point format) or ASCII string, as well as a pre-defined unit data list. The specific number of data depends on different commands.
8) the CHK parity is a vertical parity, starting from the start byte to the first byte of the parity. In addition, each byte has a one-bit check bit. The combination of the two can detect three-bit sudden errors.