You are on page 1of 2

ASCII and RTU Modes

In ASCII/RTU modes (traditional Modbus) the user chooses either mode along with the serial port parameters (ie. baud rate,
parity, etc). These parameters must be the same for all devices on the Modbus network. Five wires is used for communication
(#18AWG twisted pairs in a shielded jacket is generally recommended). Maximum transmission distance is 350m (1137ft).

ASCII mode: (American Standard Code for Information Interchange). This mode has an advantage of allowing up to 1 second
time intervals to occur between character transmissions without generating an error. It's most useful when communication is
slow. Two ASCII characters are sent as 8-bit data. A start and stop bit are also sent with each message creating a total of 10
bits. 7 data bits comprise the message and 1 bit is added for either even or odd parity. If no parity is used then the extra stop
bit is added to maintain a total transmission of 10 bits. It also uses LRC (Longitudinal Redundancy Check) to make sure what
we sent is what we received.

RTU mode (Remote Terminal Unit). This mode has an advantage of sending more data in the same amount of time as in ASCII
mode. Each message must be transmitted as a continuous stream of data, however. Each 8-bit message will contain two 4 bit
hex characters, thus sending the same amount of information in less space. Since we use an extra data-bit (8 vs 7) we send 11
bits in total. 8 data bits are used and 1 bit is used for either even or odd parity. If no parity is used, then an additional stop bit
is added. This brings our total then to 11 bits (1 start + 8 data + 1 parity + 1 stop = 11 bits). This message uses CRC (Cyclical
Redundancy Check) for error checking.

It is important to note that both ASCII and RTU modes use a master/slave configuration. This means that only a single device
(ie. the master) can issue commands. The other devices (ie slaves) can only respond. The master can send messages to
individual slaves or broadcast to all devices. If peer-to-peer communication is required, an 'upgrade' to the later Modbus Plus is
required. On this type of network, any device can initiate communication with any other device on the network. This adds
many advantages in flexibility of communication. However, even though it is peer-to-peer, on the message level it is
master/slave. In other words, if a device asks another a question, it acts as a master and expects a reply from the other device
which is acting as a slave. Modbus Plus also allows us to interface with up to 32 devices at a total distance of 1500m
(~4875ft). 3 repeaters may be used to get a total distance of 6000m (19,500ft) and 64 devices. Modbus generally needs its
own 12v supply to communicate and each device needs its own supply. In other words, the devices cannot be powered by the
communications line.

ASCII message format:


start(1 character) + address(2 characters) + function(2 characters) + data(x characters) + error check(2 characters) +
ending(2 characters). In ASCII mode the start character is always a ':' (ie. a colon, no quotes included).

The address field contains 2 characters. The valid slave device addresses are 0-247. The master addresses the proper slave
device by putting the slave devices address in this field. When the slave replies back it places its own address in this field so
that the master knows which device has replied. Address 0 is used as a broadcast address. In other words, all slaves will react
to a message with an address of 0.

The function code also contains 2 characters. Valid function codes are 1-255. Some codes are product specific(to Modicon),
others are universal, and still others are reserved for future use. The function code tells the slave device what to do. Some
examples of function codes include reading coil status, reading input status, reading memory locations, forcing coils on, writing
to memory, etc.

The data field comes next and contains information that the slave devices will need to process the request from the master. For
example, which coil statuses should be read, which coils should be forced on, etc.

The data field the slave sends back to the master will contain the data requested or an error code if there was an error. The
error check field in ASCII mode contains the result of the LRC (Longitudinal Redundancy Check) calculation. This calculation is
simply done by adding together all the bytes in the message(excluding the start colon) eliminating any carries, and then 2's
complementing the result.

Lastly, the CR (carriage return) and LF (line feed) characters are added to the message. This tells the receiving device that the
message has ended.

The RTU frames contain the same items except in a more compact form. Here is the message format:
Start(4 character delay time) + address(8 bits) + function code(8 bits) + data(n x 8 bits) + error check(16 bits) + end (4
character delay time)

It is important to note that in ASCII mode there can be up to a 1 second delay between each character transmission but RTU
mode can have a maximum of 1.5 character delay times between each character.

The only differences between ASCII and RTU message formats are the forming of the message, the start/ends, and the error
checking. The start/ends are simply 4 character time pauses. The error checking is CRC (Cyclical Redundancy Check) calculation.

You might also like