Modbus CRC & LRC Error Checking: Calculation, Troubleshooting, and Packet Diagnosis

How CRC-16 and LRC error detection works in Modbus RTU and ASCII — calculation methods, common causes of checksum failures, and step-by-step packet diagnosis with Wireshark and serial tools.

Categories:

Overview

Every Modbus serial frame includes an error-checking field — CRC-16 for RTU mode and LRC for ASCII mode. When a CRC or LRC mismatch occurs, the entire frame is discarded silently — no exception response is returned, no error code is generated. The master simply times out.

CRC errors are the most frustrating Modbus RTU failures to diagnose because they produce no visible error message — just timeouts. This guide covers how error checking works, what causes mismatches, and how to diagnose them using packet captures and serial diagnostic tools.

Modbus RTU frame structure with CRC-16 error detection fields highlighted

CRC-16 (Modbus RTU)

How It Works

CRC-16 is calculated over all frame bytes except the CRC itself — from the slave address through the last data byte. The result is a 16-bit value appended to the frame in low-byte-first order (little-endian).

ParameterValue
AlgorithmCRC-16/MODBUS
Polynomial0x8005 (normal) / 0xA001 (reflected)
Initial value0xFFFF
Input reflectionYes (LSB first)
Output reflectionYes
Final XOR0x0000
Byte order in frameLow byte first, then high byte

CRC Calculation Steps

  1. Initialize CRC register to 0xFFFF
  2. For each byte in the message (address through data): a. XOR the byte with the low byte of the CRC register b. For each of 8 bits:
    • If LSB of CRC = 1: shift right, XOR with 0xA001
    • If LSB of CRC = 0: shift right only
  3. The final CRC register value is the CRC-16
  4. Append to frame: low byte first, then high byte

Worked Example

Request: Read 1 holding register from slave 1, address 0 → bytes 01 03 00 00 00 01

StepCRC Value
Initial0xFFFF
After byte 0x01 (address)0xFF800x40BF
… (continue for all bytes)
Final CRC0x0A84
Frame CRC bytes84 0A (low byte first)

Complete frame: 01 03 00 00 00 01 84 0A

[!TIP] Don’t calculate CRC by hand — use a diagnostic tool or online calculator. The CAS Modbus Scanner calculates CRC automatically. For verification, many free “Modbus CRC calculator” tools are available online.

CRC Error Detection Capability

Error TypeDetection
Any single-bit error✅ Always detected
Any two-bit error✅ Always detected
Any odd number of bit errors✅ Always detected
Burst errors ≤16 bits✅ Always detected
Random corrupted frame~99.998% detection rate (1 in ~65,536 chance of false acceptance)

LRC (Modbus ASCII)

How It Works

LRC (Longitudinal Redundancy Check) is a simple 8-bit checksum used in ASCII mode. It is calculated over the decoded byte values (not the ASCII characters) from the slave address through the last data byte.

LRC Calculation Steps

  1. Sum all bytes (address + function code + data) as unsigned 8-bit values
  2. Take the two’s complement of the sum (negate and mask to 8 bits)
  3. The result is the LRC byte (transmitted as 2 hex-ASCII characters)

Worked Example

Request bytes: 01 03 00 00 00 01

StepValue
Sum0x01 + 0x03 + 0x00 + 0x00 + 0x00 + 0x01 = 0x05
Two’s complement0x100 - 0x05 = 0xFB
LRC byte0xFB
In ASCII frameCharacters 'F' 'B'

Complete ASCII frame: :0103000000017E\r\n

[!NOTE] LRC is weaker than CRC-16 — it cannot detect all multi-bit errors. This is one reason RTU mode is preferred for production installations. LRC is sufficient for low-noise environments and debugging sessions.

Common Causes of CRC Errors

Electrical / Physical Layer

CauseSymptomFix
Missing terminationIntermittent CRC errors, worse at higher baud ratesAdd 120Ω termination at both trunk ends — see RS-485 Physical Layer guide
Star wiring topologyRandom CRC errors across all devicesRe-wire as daisy chain — see Multi-Device Daisy Chain guide
Loose screw terminalsIntermittent per-device CRC errorsRe-tighten all connections, tug-test each wire
Cable too longCRC errors increase with distanceVerify within RS-485 distance limits, add repeater if needed
Electromagnetic interferenceCRC errors correlate with equipment operation (VFD starts, motors, etc.)Route cables away from noise sources, use shielded cable
Ground potential differenceCRC errors on long runs between buildingsRun signal ground (common) wire through entire chain, ground shield at one end only
Bad USB-to-serial converterCRC errors at higher baud rates, works fine at 9600Use a quality converter with hardware UART; some cheap converters introduce timing jitter

Configuration / Protocol Layer

CauseSymptomFix
Baud rate mismatch100% CRC errors — no successful communicationMatch all devices to same baud rate
Parity mismatch100% CRC errorsMatch parity (Even, Odd, or None) on all devices
Data bits mismatch100% CRC errorsRTU requires 8 data bits; ASCII uses 7
Stop bits mismatchIntermittent CRC errorsMatch stop bit count (usually 1 with parity, 2 without)
Inter-character gapIntermittent CRC errors at higher baud ratesSlow serial ports may exceed the 1.5 character-time threshold — reduce baud rate

Software / Gateway Layer

CauseSymptomFix
Wrong CRC byte order100% CRC errors despite correct calculationCRC must be low byte first in RTU frames
CRC calculated over wrong bytes100% CRC errorsCRC covers address through data, not the entire frame
Half-duplex timingOccasional CRC errors, device-dependentIncrease turnaround delay between TX and RX

Diagnosing CRC Errors

Step 1: Isolate the Problem

  1. Test one device at a time — disconnect all but one device from the bus
  2. If CRC errors persist with a single device → problem is configuration, cable, or converter
  3. If CRC errors only appear with multiple devices → topology or termination issue

Step 2: Verify Serial Parameters

Confirm all devices and the master have identical settings:

ParameterMust Match
Baud rate9600, 19200, 38400, etc.
Data bits8 (for RTU)
ParityEven, Odd, or None
Stop bits1 or 2

Step 3: Capture and Analyze Packets

Using the CAS Modbus Scanner

  1. Connect the scanner to the RS-485 bus
  2. Send a known request (e.g., FC03, read 1 register from address 0)
  3. View the raw hex response — the scanner displays CRC validity
  4. If CRC invalid, compare the received bytes against the expected CRC

Using Wireshark (Modbus TCP Only)

For Modbus TCP captures:

mbtcp

Wireshark natively decodes Modbus TCP frames and flags protocol errors. Note that Modbus TCP does not use CRC — it relies on TCP’s built-in error detection. If you’re seeing corrupted data over TCP, the problem is likely at the application layer, not the transport layer.

Using a Serial Port Monitor (Modbus RTU)

For RS-485/RS-232 captures, use a serial port monitor that shows raw hex bytes:

  1. Capture the raw byte stream
  2. Identify frame boundaries (look for >3.5 character-time gaps)
  3. Extract each frame: address + FC + data + CRC
  4. Recalculate the CRC and compare to the received CRC
  5. If they don’t match, examine which byte(s) differ

Step 4: Check Physical Layer

If packet analysis confirms corruption (received bytes differ from expected):

  1. Swap D0/D1 wires — incorrect polarity can cause apparent CRC errors
  2. Check termination — measure resistance between D0 and D1 at both trunk ends (should be ~60Ω total with 2× 120Ω terminators in parallel)
  3. Shorten the cable — temporarily connect with a short cable to rule out distance
  4. Replace the converter — USB-to-serial adapters are a common source of timing-related CRC errors

[!WARNING] CRC errors that appear only at higher baud rates (19200+) and disappear at 9600 baud are almost always caused by either missing termination or a poor quality USB-to-serial converter. Fix the physical layer before attempting software workarounds.

CRC and Gateway Transparency

When a gateway converts between Modbus RTU and Modbus TCP:

DirectionCRC Handling
TCP → RTUGateway adds CRC to the serial frame (TCP doesn’t use CRC)
RTU → TCPGateway strips CRC from the serial frame, builds MBAP header
RTU → RTU (through a repeater)Repeater recalculates and regenerates CRC

The gateway recalculates the CRC for every serial frame — it never passes through a CRC from one side to the other. If you see CRC errors on the serial side of a TCP-to-RTU gateway, the problem is on the serial side (wiring, termination, baud rate), not on the TCP side.

Chipkin Tools

Need more help?

If this page does not resolve the issue, contact Chipkin support with the product model, protocol details, and any diagnostics you have already captured.

Open Chipkin Support