Technical Applications Notes Index | Media Centre

Product Index

Industrial

Commercial

Residential

OEM

Services

Catalogues



1-800-565-6699
Customer
Information Centre
Your Complete
Customer Service
Connection
 Download PDF Version  
TN054
Size: 82KB
Format : PDF

Right Click and Choose Save Target As... to Save
 
   
 Related Products  


 
   
 
Understanding the difference between Modbus RTU and Modbus ASCII (TN054)

September 21, 2000

Many people ask what is the difference between Modbus RTU and Modbus ASCII. The following note will explain how the message is coded for transmission, why RTU is more efficient but why it is not good for modem networks.

First, let’s look at the structure of a modbus message. Note that all modbus messages are written in terms of hex numbers.

Address (Controller) Modbus Function Code Data Definition e.g. -> Address Hi Address Low Number of points Hi Number of points Low Checksum (either LRC or CRC)
2 char. 2 char. 2 char. per field 2 char. 2 char. 2 char. 2 char. 2 char. or 16 bits

The exact usage of the data definition of the message depends on the modbus function code, see reference guide for structure of each function.

To more easily follow the coding we will take a sample message and code it using both ASCII and RTU

Example: We will read 3 holding registers from controller 17. Addresses to be read are 40108- 40110. When composing a modbus message memory references start at 0 not 1. Therefore 400108 would be entered as 107.

Address (controller) Function Address Hi Address Low Number of points Hi Number of points Low Checksum
11 (11hex=17dec) 03 00 6B (6B=107) 00 03 To be defined based on method of coding

The above message can now be coded to be transmitted either using ASCII or RTU.

ASCII:
When using ASCII each hexadecimal character in the modbus message is sent as one ASCII character that is then turned into binary. Therefore 1 modbus character = 1 ASCII character = 10 bits (1 start 7 data 1 parity 1 stop)

ASCII uses 3 characters to delimit the message as follows:
Start of message :
End of message CRLF

Because of this delimiting of the message any delays in the transmission medium will not cause the message to be misinterpreted by the receiving device. ASCII uses a longitudinal redundancy check (LRC) as the checksum. The checksum is calculated after the message is converted to binary.

The resulting ASCII mode modbus message is :1103006B0003CSCRLF (CS = checksum)

This ASCII mode modbus message must now be modulated onto the communication link using the ASCII method of character coding. To do this each character must be converted to binary. To make this easier we add an intermediate step. We convert the ASCII character to its Hex equivalent.

3A313130333030364230303033CS0D0A

Now each of these Hex equivalents of the ASCII codes must be coded into binary, 10 bits per character.

3A = S0111010PS 1 st S = start bit
P = parity bit 2 nd S = stop bit.

31 = S0110001PS
31 = S0110001PS
30 = S0110000PS
33 = S0110011PS
30 = S0110000PS
30 = S0110000PS
36 = S0110110PS
42 = S1000010PS
30 = S0110000PS
30 = S0110000PS
30 = S0110000PS
33 = S0110011PS

Checksum LRC= 20bits The LRC checks the contents of the message exclusive of the beginning colon (3A) and the CRLF (0D0A)
0D = S0001101PS
0A = S0001010PS

Total message 160 bits.

Note: Alternately, the ASCII mode modbus message could have been converted to any numbering system such as Octal or Decimal. The resulting binary pattern would be the same.

RTU:
When using RTU each character in the modbus message is sent as four bits. Therefore 2 modbus character = 1 packet = 11 bits (1 start 8 data 1 parity 1 stop)

RTU uses 3.5 characters spaces (or silences) to delimit the message. Because of this delimiting of the message any delays in the transmission medium will cause the message to be misinterpreted by the receiving device. Therefore RTU is not well suited for modem communications.

RTU uses a cyclical redundancy check (CRC) as the checksum. The checksum is calculated after the message is converted to binary.

The resulting RTU modbus message is T1-T2-T3- T4 1103006B0003CS T1-T2-T3-T4 (T1/2/3/4 = silence interval)(CS = checksum)

This RTU mode modbus message must now be modulated onto the communication link using the RTU method of character coding. To do this each character must be converted to binary, four bits per character.

e.g. 1 = 0001 1 = 0001 0 = 0000 3 = 0011 0 = 0000 0 = 0000 6 = 0110 B = 1011 0 = 0000 0 = 0000 0 = 0000 3 = 0011

Now every 2 characters (four bits each) are packaged together into an eleven-bit packet

11 = S00010001PS 1 st S = start bit P =
parity bit 2 nd S = stop bit.
03 = S00000011PS
00 = S00000000PS
6B = S01101011PS
00 = S00000000PS
03 = S00000011PS
Checksum CRC= 16bits

Total message 82 bits. Note that the time associated with 3.5 character gaps to delimit the message consumes an equivalent of 14 bits. The 3.5 character gaps at the end of the message is used to end the message and also to start the next message so we will not add these 14 bits to this message.

Total message including delimiting is 96 bits

We can see that at any given Baud rate RTU is much more efficient then ASCII. However due to the silence gaps needed for RTU, ASCII is better suited to modem communications.

If you have any questions please contact us at 1-800- 387-8247.


Copyright© Schneider Electric Canada 2003 All Rights Reserved