What is MODBUS-ASCII?

MODBUS is a communication protocol developed in the late 1970s for use with programmable logic controllers (PLCs). It has since become a de facto standard communication protocol, and it is now a commonly available means of connecting industrial electronic devices.

MODBUS can use either ASCII (American Standard Code for Information Interchange) or RTU (Remote Terminal Unit) mode for transferring data. In this context, you're asking about MODBUS-ASCII.

MODBUS-ASCII format is human-readable and easier to debug, but it is less efficient than the RTU mode. Each 8-bit byte of data is sent as two ASCII characters, which increases the amount of data that needs to be sent. In addition to this, MODBUS-ASCII mode uses a Longitudinal Redundancy Check (LRC) for error checking, which is less robust than the Cyclical Redundancy Check (CRC) used by MODBUS-RTU.

In MODBUS-ASCII, messages start with a colon (":") character, and end with a Carriage Return and Line Feed pair (CRLF). Each data byte within a message is represented by 2 ASCII characters, which encode the hexadecimal value of the data byte. Error checking is done via an LRC, which is a form of checksum.

The simplicity of MODBUS-ASCII makes it straightforward to implement and debug, and the human-readability of the data can be a significant advantage in some situations. However, its inefficiency and weaker error checking can be a disadvantage in noisy environments or where high data rates are needed.

Example:

In MODBUS-ASCII, a request or response message follows a certain structure:

:IDFCDDDDCRCCCRLF

    :: Every MODBUS-ASCII message begins with a : character.
    ID: This specifies the device's address (ID).
    FC: The Function Code, which specifies the operation to be performed.
    DDDD: This is the data field, which carries different meanings depending on the operation code.
    CRCC: This is the Longitudinal Redundancy Check (LRC) value used for error checking.
    CRLF: This is a 'Carriage Return' and 'Line Feed' character which signifies the end of the message.

For example, a MODBUS-ASCII message might look like:

:010300000001FD

To interpret this message:

    :: Start of MODBUS-ASCII message
    01: Device address is 1
    03: Function Code 3 (Read Holding Registers)
    0000: Starting address (address 0)
    0001: Number of registers to read (1 register)
    FD: This is the LRC for error checking. It is calculated by taking the complement of the sum of all bytes in the message, and adding 1 (also known as the two's complement).
    CRLF: Not shown in this example, but in an actual message, each message ends with a 'Carriage Return' and 'Line Feed' character.

Please note that this ASCII message is in hex form so each pair of characters represents a byte. And the LRC used for error checking is calculated to check whether the data has been transmitted correctly. In a response message, the data field contains the values of the requested registers. The response for this example would include the values read from the requested register.


Your shopping cart is empty!