Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

B&R Serial Communication Diagnostics — Complete Reference

Serial communication (RS232 and RS485) remains pervasive on legacy B&R machines, connecting the PLC to drives, scales, barcode readers, operator terminals, and other devices. When serial communication fails, the symptoms can range from intermittent data corruption to complete device unresponsiveness — and the original device specifications are almost never available. This document covers how to sniff serial traffic between the PLC and serial-connected devices, common B&R serial protocol patterns, how to decode the data streams, and how to replace or reconfigure serial connections when the original setup is unknown. Cross-references: cp1584-hardware-ref.md for RS232/RS485 hardware details, io-sniffing.md for general sniffing techniques, and modbus-gateway.md for Modbus serial gateway configuration.

Table of Contents

  1. Overview of B&R Serial Communication
  2. B&R Hardware Platforms and Serial Capabilities
  3. Serial Interface Modules: System 2003 / 2005
  4. Serial Interface Modules: X20 System
  5. Wiring and Pinouts for RS232 and RS485
  6. Baud Rate, Parity, and Stop Bit Configuration
  7. Flow Control and Handshake Issues
  8. B&R Software Libraries for Serial Communication
  9. How to Sniff Serial Traffic Between PLC and Serial-Connected Devices
  10. Tools for Serial Sniffing
  11. How to Decode Serial Data
  12. Protocol Analysis: MODBUS RTU Over Serial
  13. Protocol Analysis: Custom ASCII and Binary Protocols
  14. Reconfiguring or Replacing Serial Connections When Specs Are Unknown
  15. Serial-to-Ethernet Conversion Options
  16. Common Serial Communication Failures and Debugging
  17. Troubleshooting Matrices
  18. References and Further Reading

1. Overview of B&R Serial Communication

B&R Automation (Bernecker + Rainer) industrial controllers use serial communication (RS232, RS485, RS422) extensively for connecting to third-party devices — sensors, drives, HMIs, barcode readers, weigh scales, temperature controllers, and more. Understanding how to diagnose, sniff, and decode serial traffic is critical when commissioning systems, troubleshooting intermittent failures, or reverse-engineering undocumented connections.

B&R serial communication spans three major hardware families:

  • System 2003 — compact DIN-rail controllers with integrated or plug-in serial modules
  • System 2005 — modular rack-based controllers with interface modules (IF260, IF671, IF622, etc.)
  • X20 System — modular I/O with base modules providing integrated serial, plus dedicated communication interface modules (X20CS1020, X20IF1030, X20IF1082, etc.)

On the software side, two primary libraries handle serial I/O:

  • DV_Frame — general-purpose raw serial frame I/O (user-defined protocols, ASCII, binary)
  • DRV_mbus — Modbus RTU master/slave with automatic CRC and function code handling

2. B&R Hardware Platforms and Serial Capabilities

2.1 X20CP1584 / X20CP1585 / X20CP1586

The X20CP158x series are compact X20 CPUs with integrated serial and Ethernet:

InterfaceTypeConnectionMax DistanceMax Rate
IF1RS23212-pin terminal block X20TB1215 m115.2 kbit/s
IF2Ethernet (10/100/1000)RJ45100 m1 Gbit/s

IF1 RS232 Pinout on X20TB12 terminal block:

TerminalSignalDirection
9TxD (Transmit Data)Output from PLC
10RxD (Receive Data)Input to PLC
11GND (Signal Ground)Reference
12Shield / FE (Functional Earth)Chassis/shield

The RS232 interface is not electrically isolated from the PLC logic on most X20CP158x models. Use shielded cable with shield bonded at one end only to prevent ground loops.

2.2 X20CP1484 / X20CP1485 / X20CP1486

Similar to the 158x series but with Ethernet limited to 10/100 Mbit/s on IF2. IF1 is RS232 via the same X20TB12 terminal block pinout.

2.3 X20CP0482 / X20CP0484

Entry-level X20 CPUs. The serial interface is provided by the base module (X20BB52) and exposed on the power supply module’s (X20PS9600) terminal block. IF1 = RS232 at up to 115.2 kbit/s.

2.4 CP476 (System 2003)

Compact controller with integrated serial port. Uses DB9 connector for RS232:

  • Pin 2: TXD (Transmit)
  • Pin 3: RXD (Receive)
  • Pin 5: GND (Signal Ground)

Supports both RS232 and RS485 depending on model variant. Programmed using the DV_Frame library.

2.5 Base Modules with Integrated Serial (X20 System)

A critical architectural detail: on the X20 system, the integrated serial interface lives on the base module, not on the power supply module:

Base ModuleIntegrated SerialInterface TypeMax Rate
X20BB52COM1 (RS232)RS232115.2 kbit/s
X20BB62NonePower feed only
X20BB72COM1 (RS232)RS232115.2 kbit/s
X20BB82COM1 (RS232/RS422/RS485)Software-selectable115.2 kbit/s

The X20PS9600 power supply module passes the RS232 signals from the base module to its terminal block. A second X20PS9600 will not provide a second serial port — each X20 segment allows exactly one PS module.


3. Serial Interface Modules: System 2003 / 2005

3.1 IF260 — Programmable Interface Module

The IF260 (3IF260.60-1) is a System 2005 interface module that can function as either a CPU or as a programmable interface processor. The module auto-detects its operating mode from the slot position:

  • Slot 0 — operates as a CPU
  • Other slots — operates as a programmable interface processor

This allows the IF260 to offload serial communication processing from the main CPU. It runs its own Automation Basic program and can handle multiple serial protocols independently.

3.2 IF622 — Triple Serial Interface (1×RS232, 2×RS485/RS422)

The IF622 (3IF622.9) provides:

  • IF1: 1× RS232 interface
  • IF2, IF3: 2× RS485/RS422 interfaces

All interfaces are electrically isolated. Used in System 2005 racks for expanding serial connectivity beyond what the CPU provides natively.

3.3 IF671 — Triple Communication Module (RS232, RS485/RS422, CAN)

The IF671 (3IF671.9) provides three isolated communication interfaces on a single module:

  • IF1: RS232
  • IF2: RS485/RS422
  • IF3: CAN bus

This is the most versatile serial interface module for System 2005, covering RS232 point-to-point, RS485 multi-drop, and CAN bus in one card.

3.4 IF261 / IF262 / IF3xx Series

  • IF261 — CPU module variant for System 2003/2005
  • IF262 — Interface processor for serial protocols
  • IF3xx series — Various interface modules for specific fieldbus protocols (Profibus DP, CANopen, DeviceNet) with optional serial sub-interfaces

3.5 CP260 — Serial + CAN Interface Module

The CP260 (3CP260.60-1) provides:

  • 1× RS485/RS422 interface
  • 1× CAN interface

Used as a compact interface processor or standalone communication node.


4. Serial Interface Modules: X20 System

4.1 X20CS1020 — RS232/RS422/RS485 Communication Module

ParameterValue
Interface standardEIA-232-F / EIA-422 / EIA-485
ConfigurationSoftware selectable (no DIP switches)
Max baud rate115.2 kbit/s
HandshakeRTS/CTS or XON/XOFF (RS232 mode)
Bus connectionX2X Link to local controller
Electrical isolationYes

Device name in Automation Studio: CS1020_IF1

This is the standard choice for adding a second serial port to an X20 controller when the base module’s integrated port is already in use.

4.2 X20IF1030 — RS232 Interface Module

ParameterValue
Interface standardEIA-232-F
Max baud rate115.2 kbit/s
Connector9-pin D-Sub female
Electrical isolationNo

Designed for point-to-point RS232 serial connections. Note: The X20IF1030 is RS232 only — do not confuse it with the X20IF1031 (RS422/RS485) or X20IF1041 (RS422/RS485 isolated). For multi-drop RS485 networks, use X20IF1031 or X20IF1041. See modbus-gateway.md for the complete serial module comparison.

4.3 X20IF1082 — Configurable RS232/RS485

Single configurable channel supporting either RS232 or RS485 communication. Software-configurable interface standard.

4.4 X20IF1072 — RS485 Interface Module

Dedicated RS485 interface for the X20 system. Used for serial remote connection of complex devices.

4.5 X20PS9600 — Power Supply (Serial Pass-Through)

Not a serial module itself — the X20PS9600 passes RS232 signals from the base module (e.g., X20BB52) to its terminal block:

TerminalSignalDirection
1+24 VDCInput (field supply)
20 VDCInput (field return)
9TxD (RS232)Output
10RxD (RS232)Input
11GNDSignal ground
12Shield / FEFunctional Earth

5. Wiring and Pinouts for RS232 and RS485

5.1 RS232 DB9 Standard Pinout (Male Connector, DTE Side)

PinSignalAbbreviationDirection (DTE)
1Data Carrier DetectDCDInput
2Received DataRXDInput
3Transmitted DataTXDOutput
4Data Terminal ReadyDTROutput
5Signal GroundGND
6Data Set ReadyDSRInput
7Request To SendRTSOutput
8Clear To SendCTSInput
9Ring IndicatorRIInput

5.2 RS232 Wiring: Straight-Through vs Null-Modem

Straight-through cable (PC/PLC to modem/peripheral):

DTE (PLC)          DCE (Device)
Pin 3 (TXD)  →   Pin 2 (RXD)
Pin 2 (RXD)  ←   Pin 3 (TXD)
Pin 5 (GND)  —   Pin 5 (GND)

Null-modem cable (PLC to PLC, or PLC to PC configured as DTE):

Device A            Device B
Pin 3 (TXD)  →   Pin 2 (RXD)    (crossed)
Pin 2 (RXD)  ←   Pin 3 (TXD)    (crossed)
Pin 5 (GND)  —   Pin 5 (GND)    (straight)
Pin 7 (RTS)  →   Pin 8 (CTS)    (crossed)
Pin 8 (CTS)  ←   Pin 7 (RTS)    (crossed)

5.3 RS485 Wiring

RS485 uses differential signaling (A/B or +/−) and supports multi-drop (up to 32 devices on a single bus):

                    120Ω
Master ──── A ───────────────── A ──── Slave 1
         │                             │
         └──── B ───────────────── B ─┘
               │                     │
              GND                   GND
                                           120Ω (at far end)

RS485 connection rules:

  • Use twisted pair cable (e.g., 1 pair of Cat5e or dedicated RS485 cable)
  • 120 Ω termination resistors at both ends of the bus
  • Common ground connection recommended but keep ground currents minimized
  • Maximum cable length depends on baud rate (EIA-485 standard, twisted-pair cable, 120 Ω termination):
    • 115.2 kbit/s → max ~200 m (conservative: 100 m in noisy environments)
    • 19.2 kbit/s → max ~1000 m
    • 9600 baud → max ~1200 m

5.4 B&R X20 Terminal Block Serial Wiring

For X20CP1584 and similar CPUs using X20TB12:

  • TxD connects to terminal 9
  • RxD connects to terminal 10
  • GND connects to terminal 11
  • Shield connects to terminal 12 (FE)

Use shielded twisted pair cable (LiYCY 3×2×0.14 mm²). Bond shield to FE at the cabinet entry only — do not ground both ends.

5.5 RJ45 to DB9 RS232 Adapter (Common for B&R Field Wiring)

Some B&R installations use RJ45 connectors for serial field wiring. A common mapping:

RJ45 PinDB9 PinSignal
18 (CTS)Clear To Send
26 (DSR)Data Set Ready
32 (RXD)Receive Data
420 (DTR)Data Terminal Ready
53 (TXD)Transmit Data
65 (GND)Signal Ground
77 (RTS)Request To Send
84 (DTR)Data Terminal Ready

Note: RJ45-to-serial pinout varies by manufacturer. Always verify with a multimeter before connecting.


6. Baud Rate, Parity, and Stop Bit Configuration

6.1 Standard Configuration Parameters

ParameterStandard ValuesCommon Industrial Setting
Baud rate300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 1152009600 (most common), 19200, 38400
Data bits7, 88
ParityNone, Even, Odd, Mark, SpaceNone or Even
Stop bits1, 21 (or 2 with parity=Even at 9600 → “9600-8-E-1”)

6.2 Common Configurations

NotationBaudDataParityStopUse Case
9600-8-N-196008None1Most common default; Modbus RTU, generic sensors
19200-8-N-1192008None1Faster sensors, HMIs
9600-8-E-196008Even1Modbus RTU with error detection
9600-7-E-196007Even1Legacy serial devices
115200-8-N-11152008None1High-speed serial, programming ports

6.3 Configuring in B&R Automation Studio

In the IO Configuration view, set the serial port properties:

ParameterAutomation Studio Setting
Device nameIF1, CS1020_IF1, etc.
Baud rateInteger (9600, 19200, etc.)
Data bits8 (or 7)
ParitydvPARITY_NONE, dvPARITY_EVEN, dvPARITY_ODD
Stop bits1 (or 2)
HandshakedvHANDSHAKE_NONE, dvHANDSHAKE_RTSCTS

In code (DV_Frame):

openInfo.baudrate   := 9600;
openInfo.dataBits   := 8;
openInfo.parity     := dvPARITY_EVEN;
openInfo.stopBits   := 1;
openInfo.handshake  := dvHANDSHAKE_NONE;

In code (DRV_mbus for Modbus RTU):

openInfo.baudrate   := 9600;
openInfo.parity     := dvPARITY_EVEN;   (* Modbus RTU commonly uses Even parity *)

6.4 Maximum Baud Rates by B&R Hardware

HardwareMax Baud Rate
X20CP1584 IF1 (RS232)115.2 kbit/s
X20CS1020115.2 kbit/s
X20IF1030 (RS232)115.2 kbit/s
IF622, IF671115.2 kbit/s
System 2003 CP modules115.2 kbit/s

7. Flow Control and Handshake Issues

7.1 Types of Flow Control

TypeMethodUse Case
NoneNo flow controlMost industrial devices, short cables, well-matched speeds
Hardware (RTS/CTS)PLC asserts RTS when ready to receive; device asserts CTS when readyHigh-speed links, large data transfers, printers
Software (XON/XOFF)Embedded control characters (0x11/0x13) in data streamLegacy systems, avoid in binary protocols
DSR/DTRPeripheral signals ready stateModems, some legacy equipment

7.2 Common Handshake Problems

ProblemSymptomCauseFix
RTS/CTS not connectedPartial data, truncated framesMissing handshake lines in cableAdd RTS/CTS wires or disable handshake
CTS held lowNo data transmittedDevice not asserting CTSCheck device ready state, disable RTS/CTS
RTS/CTS polarity mismatchData flow stopsSome devices use inverted RTS/CTSUse null-modem adapter with crossed handshake lines
XON/XOFF in binary dataCommunication corruptionBinary data contains 0x11/0x13 bytesDisable XON/XOFF; use hardware handshake or none

7.3 B&R-Specific Flow Control Notes

  • X20BB52 base module exposes RTS and CTS on the PS9600 terminal block (check exact pin assignment in datasheet)
  • X20CS1020 supports RTS/CTS and XON/XOFF in RS232 mode
  • For Modbus RTU over RS485, flow control is typically None — the protocol handles framing via 3.5 character silent intervals
  • When using DV_Frame with dvHANDSHAKE_RTSCTS, the library manages RTS automatically

8. B&R Software Libraries for Serial Communication

8.1 DV_Frame Library

The DV_Frame library is the primary general-purpose serial communication library for B&R controllers. It provides raw frame-level access to serial ports.

Key Functions:

FunctionPurpose
DV_FrameOpenOpen serial port with configuration (baud, parity, data bits, stop bits, handshake)
DV_FrameWriteWrite raw bytes to serial port
DV_FrameReadRead bytes with configurable terminators (CRLF, timeout, length)
DV_FrameCloseClose serial port and release handle
DV_FrameIoctlIoctl-level control (line status, buffer flush, break signal)

Modes:

  • dvFRAME_MODE_RAW — raw byte I/O, no protocol framing
  • Terminator options: dvFRAME_TERMINATOR_CRLF, dvFRAME_TERMINATOR_LF, custom delimiter

Example — Opening a Serial Port:

VAR
    fbFrame   : DV_FrameOpen_Type;
    openInfo  : DV_FrameOpen_Info_Type;
    rxBuffer  : ARRAY[0..63] OF USINT;
    rxLen     : UDINT;
    handle    : UDINT;
END_VAR

openInfo.deviceName   := 'IF1';
openInfo.mode          := dvFRAME_MODE_RAW;
openInfo.baudrate      := 9600;
openInfo.dataBits      := 8;
openInfo.parity        := dvPARITY_NONE;
openInfo.stopBits      := 1;
openInfo.handshake     := dvHANDSHAKE_NONE;
openInfo.rxBufferSize  := SIZEOF(rxBuffer);
openInfo.rxBuffer      := ADR(rxBuffer);

DV_FrameOpen(fbFrame, openInfo);
IF fbFrame.status = 0 THEN
    handle := fbFrame.handle;
END_IF

Example — Sending a Query:

VAR
    fbWrite   : DV_FrameWrite_Type;
    query     : USINT := 16#52;  (* 'R' = ASCII 0x52 *)
END_VAR

DV_FrameWrite(fbWrite, handle, ADR(query), 1);

Example — Reading a CRLF-Terminated Response:

VAR
    fbRead : DV_FrameRead_Type;
END_VAR

DV_FrameRead(fbRead, handle, ADR(rxBuffer), SIZEOF(rxBuffer), rxLen,
             dvFRAME_TERMINATOR_CRLF);
IF fbRead.status = 0 THEN
    (* rxBuffer[0..rxLen-1] contains the response *)
END_IF

8.2 DRV_mbus Library (Modbus RTU)

The DRV_mbus library provides Modbus RTU master and slave functionality with automatic CRC-16 handling.

Key Functions:

FunctionPurpose
DRV_mbusOpenOpen Modbus RTU channel (master or slave mode)
DRV_mbusReadRegRead holding registers (FC03) or input registers (FC04)
DRV_mbusWriteRegWrite single register (FC06) or multiple registers (FC16)
DRV_mbusCloseClose Modbus channel

Example — Modbus RTU Master:

VAR
    fbMbus   : DRV_mbusOpen_Type;
    fbRead   : DRV_mbusReadReg_Type;
    openInfo : DRV_mbusOpen_Info_Type;
    regValue : UINT;
END_VAR

openInfo.deviceName := 'IF1';
openInfo.mode       := dvMBUS_MODE_RTU_MASTER;
openInfo.baudrate   := 9600;
openInfo.parity     := dvPARITY_EVEN;
openInfo.timeout    := 500;  (* ms *)

DRV_mbusOpen(fbMbus, openInfo);
IF fbMbus.status = 0 THEN
    DRV_mbusReadReg(fbRead, fbMbus.handle,
                    slaveAddr := 1,
                    funcCode  := dvMBUS_FC04_INPUT,
                    regAddr   := 16#0001,
                    regQty    := 1,
                    pData     := ADR(regValue),
                    dataLen   := SIZEOF(regValue));
END_IF

8.3 Choosing Between DV_Frame and DRV_mbus

CriterionUse DV_FrameUse DRV_mbus
ProtocolCustom/proprietary, ASCII, binaryModbus RTU
CRC handlingManualAutomatic
Frame delimitersConfigurable3.5 char silent interval
ComplexityHigher (you build the protocol)Lower (function call API)

9. How to Sniff Serial Traffic Between PLC and Serial-Connected Devices

9.1 Why Sniff Serial Traffic?

  • Determine unknown protocol parameters (baud rate, parity, framing)
  • Capture request/response patterns for reverse engineering
  • Debug intermittent communication failures
  • Verify PLC program behavior against expected protocol
  • Identify timing issues, bus contention, or signal integrity problems

9.2 Methods for Sniffing

Method 1: Hardware Tap (Non-Intrusive — RS232 Only)

For RS232 point-to-point connections, insert a Y-cable or hardware tap between the PLC and the device:

PLC TXD ────────────────────── Device RXD
          │
          └──── Sniffer RXD

PLC RXD ────────────────────── Device TXD
          │
          └──── Sniffer TXD

Hardware needed:

  • Passive RS232 monitor Y-cable (3-plug DB9)
  • Or build one: connect sniffer’s RXD to both TXD lines (with diodes for isolation)

Limitations: RS232 only (voltage levels must be compatible). Cannot easily tap RS485 mid-bus without disturbing differential signaling.

Method 2: RS485 Tap (Intrusive but Low-Impact)

For RS485 multi-drop buses:

  • Connect the sniffer as an additional node on the bus with a high-impedance RS485 transceiver
  • The sniffer listens only (never transmits) to avoid disturbing bus traffic
  • Ensure proper 120 Ω termination is maintained

Method 3: Oscilloscope / Logic Analyzer (Non-Intrusive)

Connect probes to the TXD/RXD (RS232) or A/B (RS485) lines. This is the best method because:

  • No electrical loading of the bus
  • Captures exact timing and signal integrity
  • Can detect electrical noise, reflections, and voltage levels
  • Works for both RS232 and RS485

Method 4: Software Sniffer (Windows PC)

If the serial traffic passes through a PC (e.g., USB-to-serial adapter):

  • Install a serial port monitor driver that intercepts IOCTL calls
  • Tools: HHD Serial Port Monitor, COM Sniffer, Serial Port Monitor (eltima)
  • These capture all read/write operations at the driver level
  • Non-intrusive to the application but requires the traffic to pass through the monitored PC

9.3 Sniffing B&R PLC Serial Traffic

B&R PLCs run their own real-time OS, so software-based sniffing directly on the PLC is not possible with standard tools. To sniff traffic from a B&R controller:

  1. Hardware approach (recommended): Use a logic analyzer or oscilloscope on the serial lines
  2. Y-cable approach (RS232): Insert a passive tap between PLC and device, connect to a PC running serial terminal software
  3. B&R diagnostic approach: Add logging in the PLC program using DV_Frame to echo both TX and RX data to a second serial port or to Ethernet
  4. Modbus diagnostic: Use DRV_mbus built-in error counters to track CRC errors, timeouts, and exception codes

10. Tools for Serial Sniffing

10.1 Software Tools

ToolPlatformKey FeaturesBest For
HHD Serial Port MonitorWindowsNon-intrusive driver-level sniffing, multiple view modes (table, dump, terminal), Modbus RTU/ASCII decoding, session recordingGeneral RS232/RS485 debugging on PC
Serial Port Monitor (eltima)WindowsCOM port interception, data filtering, IRP/IOCTL tracking, Modbus RTU decodeDeep protocol analysis on Windows
COM SnifferWindowsLogs data, IOCTLs, and signals; works on ports already in useMonitoring already-open COM ports
SerialToolmacOS/Linux/WindowsCOM sniffer with multi-platform support, data loggingCross-platform serial monitoring
Free Serial AnalyzerWindowsNon-intrusive RS232/RS422/RS485 packet snifferBudget option
PuTTY / TeraTermWindows/LinuxTerminal emulation for raw serial monitoringSimple connect-and-observe
RealTermWindowsSerial terminal with hex display, logging, macro scriptingBinary protocol debugging

10.2 Hardware Tools

ToolKey FeaturesBest For
Saleae Logic / Logic 28–16 channel digital logic analyzer with async serial protocol decode, Modbus RTU analyzer, export to CSVTiming analysis, protocol decode, baud rate verification
Sigrok / PulseViewOpen-source logic analyzer software supporting many hardware probesBudget logic analysis, open-source workflow
PicoScopeOscilloscope with serial protocol decoding (RS232, RS485, Modbus, CAN)Signal integrity + protocol decode in one tool
Bus PirateMulti-protocol tool supporting UART, SPI, I2C, raw binary; can sniff and injectReverse engineering, protocol exploration
RS232 / RS485 breakout boxInline connector with LEDs for TXD/RXD/CTS/RTS statusQuick visual verification of signal activity
USB-to-Serial adapter + software snifferFTDI/CH340 adapter to capture traffic on PCSoftware-level monitoring when traffic routes through PC

10.3 Saleae Logic Analyzer for Serial Protocol Decode

Saleae Logic analyzers (Logic 4, Logic 8, Logic Pro 8/16) can read and decode RS232, RS485, and RS422 signals up to ±25V:

Setup steps:

  1. Connect ground probe to circuit ground
  2. Connect channel probes to TXD and RXD (RS232) or A and B (RS485 differential pair)
  3. For RS232: Use the “Async Serial” analyzer with correct baud rate, parity, stop bits
  4. For RS485: May require RS485-to-TTL receiver chip to convert differential to logic levels
  5. Set up “Modbus RTU” analyzer on top of the async serial decode for Modbus devices

What you get:

  • Decoded hex/ASCII data in real time
  • Timing measurements between frames
  • Protocol-level decode (Modbus function codes, register addresses, CRC)
  • Export to CSV, JSON, or screenshot for documentation

11. How to Decode Serial Data

11.1 Step-by-Step Decode Process

Step 1: Capture Raw Data

Use a logic analyzer or serial sniffer to capture the raw bitstream. Record:

  • All bytes in hex format
  • Timestamps between bytes
  • Direction (TX vs RX)

Step 2: Determine Baud Rate

If baud rate is unknown:

  1. Measure bit duration with oscilloscope: Connect to TXD line, trigger on falling edge, measure one bit width. Baud rate = 1 / bit_width_seconds.
  2. Common baud rates to try: 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200
  3. Auto-detect approach: Set logic analyzer to each common baud rate and see which produces valid ASCII or consistent framing
  4. Bit-width reference table:
Baud RateBit Duration (μs)Character Time (10 bits)
3003333 μs33.3 ms
1200833 μs8.33 ms
2400417 μs4.17 ms
4800208 μs2.08 ms
9600104 μs1.04 ms
1920052 μs0.52 ms
3840026 μs0.26 ms
5760017.4 μs0.174 ms
1152008.68 μs0.087 ms

Step 3: Determine Frame Format

Standard UART frame: [Start bit (0)] [5-9 data bits] [Parity bit (optional)] [1-2 Stop bits (1)]

If the data looks garbled, try:

  • 8-N-1 (most likely)
  • 8-E-1 (common for Modbus RTU)
  • 7-E-1 (legacy devices)
  • 8-O-1, 7-N-2

Step 4: Identify Protocol Type

IndicatorsProtocol Type
Readable ASCII text (letters, numbers, CR, LF)ASCII/text protocol
Hex bytes with fixed-length blocks and checksumBinary protocol
Byte patterns: [addr][FC][data][CRC_lo][CRC_hi]Modbus RTU
Fixed header + length byte + payload + checksumCustom binary protocol
<STX>...<ETX><LRC>Start/stop delimited protocol
$GP...*CS<CR><LF>NMEA 0183 (GPS, marine)

Step 5: Analyze Message Structure

For each captured message:

  1. Identify the master request (PLC sends) and slave response (device replies)
  2. Look for fixed patterns in the first few bytes (address, command)
  3. Look for repeating structures in the data payload
  4. Look for the last 1-2 bytes — often a checksum (CRC-16, LRC, sum)
  5. Note timing between request and response

Step 6: Verify Checksums

Common checksum algorithms:

  • CRC-16 (Modbus): Polynomial 0x8005, init 0xFFFF — used in Modbus RTU
  • LRC (Longitudinal Redundancy Check): XOR of all bytes — used in Modbus ASCII
  • Sum checksum: Add all bytes, take lower byte
  • CRC-CCITT (0x1021): Used in various industrial protocols

Use an online CRC calculator or embedded code to verify.

11.2 Example: Decoding a Custom ASCII Protocol

Captured hex dump (PLC → Sensor):

52 0D 0A

Decoded: R\r\n (ASCII “R” + CRLF) — this is a read request.

Captured hex dump (Sensor → PLC):

2B 32 33 2E 34 35 20 43 0D 0A

Decoded: +23.45 C\r\n — temperature reading in ASCII.

11.3 Example: Decoding a Binary Protocol

Captured hex dump (PLC → Device):

01 03 00 00 00 0A C5 CD

Decoded as Modbus RTU:

  • 01 = Slave address (1)
  • 03 = Function code (Read Holding Registers)
  • 00 00 = Starting register address (0x0000)
  • 00 0A = Quantity of registers (10)
  • C5 CD = CRC-16 (Modbus)

12. Protocol Analysis: MODBUS RTU Over Serial

12.1 Modbus RTU Frame Structure

┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
│ Address  │ Function │  Data    │  Data    │ CRC Low  │ CRC High │
│ (1 byte) │ (1 byte) │ (N bytes)│ (N bytes)│ (1 byte) │ (1 byte) │
└──────────┴──────────┴──────────┴──────────┴──────────┴──────────┘
  • Address: Slave device address (1–247)
  • Function code: Operation type (01–06, 15–16 most common)
  • Data: Register address, quantity, write values
  • CRC-16: CRC-16/Modbus (polynomial 0x8005, initial value 0xFFFF)

12.2 Common Function Codes

FCNameDirectionData Bytes
01Read CoilsMaster → Slave → MasterAddr (2) + Qty (2) → Coil status (N)
02Read Discrete InputsMaster → Slave → MasterAddr (2) + Qty (2) → Input status (N)
03Read Holding RegistersMaster → Slave → MasterAddr (2) + Qty (2) → Register values (2×N)
04Read Input RegistersMaster → Slave → MasterAddr (2) + Qty (2) → Input register values (2×N)
05Write Single CoilMaster → Slave → MasterAddr (2) + Value (2)
06Write Single RegisterMaster → Slave → MasterAddr (2) + Value (2)
15Write Multiple CoilsMaster → Slave → MasterAddr (2) + Qty (2) + Outputs (N)
16Write Multiple RegistersMaster → Slave → MasterAddr (2) + Qty (2) + Values (2×N)

12.3 Modbus RTU Timing

The end of a Modbus RTU frame is defined by a 3.5 character silent interval on the bus:

Baud Rate3.5 Char Time
9600 (11 bits/char)~4.0 ms
19200 (11 bits/char)~2.0 ms
38400 (11 bits/char)~1.0 ms
115200 (11 bits/char)~0.3 ms

The inter-frame delay must be at least this long. The inter-character delay must be less than 1.5 character times or the frame is considered incomplete.

12.4 Modbus Exception Response

If a slave cannot process a request, it returns an exception response:

┌──────────┬──────────┬──────────┬──────────┬──────────┐
│ Address  │ FC + 0x80│Exception │ CRC Low  │ CRC High │
│ (1 byte) │ (1 byte) │  Code    │ (1 byte) │ (1 byte) │
└──────────┴──────────┴──────────┴──────────┴──────────┘

Common exception codes:

CodeMeaning
01Illegal Function
02Illegal Data Address
03Illegal Data Value
04Server Device Failure

12.5 Analyzing Modbus RTU with B&R DRV_mbus

When using DRV_mbus, the library handles CRC and framing automatically. To debug:

  1. Monitor fbRead.status after each DRV_mbusReadReg call
  2. Check for CRC errors: dvMBUS_ERR_CRC indicates electrical noise or baud rate mismatch
  3. Check for timeouts: dvMBUS_ERR_TIMEOUT means the slave didn’t respond
  4. Check for exception codes: Non-zero slave response with error code indicates addressing or register problems
  5. Log all reads/writes: Echo the request parameters and responses to a log file or HMI for pattern analysis

12.6 Tools for Modbus RTU Analysis

ToolTypeCapabilities
QModMasterFree Windows GUIModbus RTU master/slave simulator, register read/write
PicoScope + Modbus decodeOscilloscopePhysical-layer decode with timing analysis
Saleae Logic 2 + Modbus RTU analyzerLogic analyzerProtocol-level decode with function code parsing
HHD Serial Port MonitorSoftware snifferDriver-level capture with Modbus RTU decoding overlay
CAS Modbus ScannerFree scannerScans slave addresses and registers on a serial bus
Python pyModbusScriptingProgrammatic Modbus RTU scanning and testing

13. Protocol Analysis: Custom ASCII and Binary Protocols

13.1 ASCII Protocols

Many industrial sensors use simple ASCII request/response patterns:

Pattern 1: Command-Response (read request)

PLC sends:  "R\r\n"        (request reading)
Device:     "+23.45 C\r\n" (response with value)

Pattern 2: Addressed Multi-Drop

PLC sends:  "$01RD\r\n"   (address 01, read command)
Device 01: "!01+23.45\r\n" (addressed response)

Pattern 3: Set-Command

PLC sends:  "SET 100\r\n"  (set value to 100)
Device:     "OK\r\n"        (acknowledgment)

Analysis approach for ASCII:

  1. Capture traffic and view as ASCII text
  2. Identify request vs response by direction
  3. Look for delimiters (CR, LF, CRLF, semicolon, comma)
  4. Identify data format (decimal, hex, scientific notation)
  5. Map command set by observing different PLC operations

13.2 Binary Protocols

Binary protocols use structured byte sequences with headers, addresses, commands, data, and checksums:

Typical structure:

┌───────┬───────┬───────┬───────┬───────┬──────────┐
│ STX   │ ADDR  │ CMD   │ LEN   │ DATA  │ CHECKSUM │
│ 0x02  │ (1B)  │ (1B)  │ (1B)  │ (nB)  │ (1-2B)  │
└───────┴───────┴───────┴───────┴───────┴──────────┘

Analysis approach for binary:

  1. Capture multiple transactions and align them by frame boundaries
  2. Look for fixed byte values in position 0 (start marker: 0x02, 0xAA, 0x55)
  3. Look for the length field — count data bytes to confirm
  4. Verify the checksum against candidate algorithms
  5. Correlate known values (e.g., if you know a sensor reads 25.3°C, find 0x0199 or 0x9919 in the data)
  6. Determine byte order (big-endian vs little-endian) by comparing known values

13.3 Mixed Protocols

Some devices use a mix of ASCII commands and binary data (e.g., text headers with binary payloads). Look for transitions between printable and non-printable byte ranges.


14. Reconfiguring or Replacing Serial Connections When Specs Are Unknown

14.1 Systematic Approach to Unknown Serial Connections

When you inherit a system with undocumented serial connections:

Phase 1: Physical Investigation

  1. Identify the hardware: Locate the serial module (IF1, CS1020, IF622, etc.)
  2. Trace the wiring: Follow cables from the PLC serial port to the connected device
  3. Identify the connector type: DB9, terminal block, RJ45
  4. Note the cable type: Shielded/unshielded, twisted pair count
  5. Check for RS485 termination: Look for 120 Ω resistors on the bus ends

Phase 2: Capture Traffic

  1. Use a logic analyzer to capture raw serial data
  2. Determine baud rate by measuring bit width (see Section 11)
  3. Determine frame format (8-N-1, 8-E-1, etc.)
  4. Save hex dumps of multiple request/response cycles

Phase 3: Protocol Identification

  1. Check if the traffic matches Modbus RTU (address + FC + data + CRC pattern)
  2. Check for ASCII patterns (readable text, CR/LF delimiters)
  3. Check for known vendor protocols (Mitsubishi MC Protocol, Siemens S7, Omron Host Link, Allen-Bradley DF1)
  4. Search online for the connected device’s protocol documentation

Phase 4: Replication

  1. Once the protocol is understood, implement it in B&R using DV_Frame (custom) or DRV_mbus (Modbus)
  2. Test with the captured device to verify matching behavior
  3. Document the protocol for future maintenance

14.2 Common Vendor Serial Protocols Found in B&R Installations

ProtocolVendorDetection Pattern
Modbus RTUMany vendors[addr][FC 01-16][data][CRC-16]
Modbus ASCIIMany vendorsColon start :, LRC end, CRLF
DF1Rockwell/Allen-BradleyACK 0x06, NAK 0x15, DLE 0x10 escape
MC ProtocolMitsubishi[ENQ][station][PC][command][data][SUM]
Host LinkOmron@xx[cmd][data][FCS]*\r\n
S7-200 PPISiemensStart 0x10, dest/src address, function, CRC
CompoWay/FOmron[STX 0x02][station][SID][data][ETX 0x03][FCS]

14.3 Practical Tips for Unknown Protocol Reverse Engineering

  1. Start with the defaults: Try 9600-8-N-1 first (covers ~80% of industrial devices)
  2. Leverage the device manual: Even partial documentation helps identify the protocol family
  3. Correlate with known I/O: If you know what the PLC is controlling (e.g., a drive speed), look for that value in the captured data
  4. Use pattern matching: Many binary protocols use fixed headers or sync bytes (0x55AA, 0x0243, etc.)
  5. Test with a Bus Pirate: Send known bytes and observe the device response to build a command set
  6. Check B&R source code: If you have the Automation Studio project, search for DV_Frame or DRV_mbus calls to understand the current implementation

14.4 Migrating from Serial to Ethernet

When replacing a serial connection:

  1. Keep the serial link operational during migration
  2. Install serial-to-Ethernet converters (see Section 15)
  3. Configure the converter for the exact serial parameters (baud, parity, etc.)
  4. Test Ethernet-side connectivity before cutting over
  5. Update the B&R PLC program to use TCP/UDP or Modbus TCP instead of serial

15. Serial-to-Ethernet Conversion Options

15.1 Why Convert Serial to Ethernet?

  • Extend serial device reach beyond 1200 m (RS485) or 15 m (RS232)
  • Centralize serial devices on an Ethernet network for SCADA/PC access
  • Replace aging serial infrastructure while keeping legacy devices
  • Enable remote monitoring of serial traffic over IP
  • Add redundancy and easier troubleshooting via network tools

15.2 Serial-to-Ethernet Device Servers

Moxa NPort Series (Industry Standard)

ModelPortsSerial TypesFeatures
NPort 51101RS232Basic, cost-effective
NPort 51501RS232/422/485 selectableSoftware selectable
NPort 52102RS232/422/485Multi-port
NPort 52502RS232/422/485Industrial-grade
NPort 61101RS232Basic
NPort 62502RS232/422/485Advanced
NPort DE-2111RS232/422/485Compact

Operating modes:

  • Virtual COM mode: Presents serial ports as virtual COM ports on a remote PC — transparent to existing software
  • TCP Server mode: Device server listens for TCP connections — PLC or PC initiates connection
  • TCP Client mode: Device server initiates TCP connection to a specified IP:port
  • UDP mode: Connectionless datagram mode for low-latency applications
  • Pair connection: Two device servers form a transparent serial tunnel

Other Manufacturers

ManufacturerProduct LineNotes
LantronixXPort, UDS1100Compact embedded solutions
Digi InternationalPortServer, ConnectPortWide range of port counts
PerleIOLANIndustrial-grade, DIN-rail mount
Silex TechnologySX-DS SeriesCost-effective alternatives
USR IOTUSR-TCP232Budget-friendly

15.3 B&R-Specific Integration

B&R X20 controllers can communicate with serial-to-Ethernet converters using:

MethodLibraryConfiguration
Modbus TCP → Modbus RTU conversionNPort in “Modbus Gateway” modeConfigure NPort to translate Modbus TCP to Modbus RTU; PLC uses Modbus TCP library
TCP Socket (raw)B&R Socket libraries (AsTCP, AsUDP)B&R opens TCP connection to NPort in TCP Server mode; sends/receives raw serial data
Virtual COM (Windows)DV_Frame via USB/COM portIf B&R Gateway PC is used, NPort creates virtual COM; PC software uses COM port

15.4 Serial-to-Serial Conversion

When the PLC has the wrong serial type:

ConverterConvertsNotes
RS232 → RS485 converterSingle-ended to differentialEnables RS485 multi-drop from RS232 port
RS485 → RS232 converterDifferential to single-endedIsolates RS485 device from RS232 PLC
RS422 → RS232 converterDifferential to single-endedFor RS422 sensors
RS485 → Ethernet (Moxa)Serial to IPFull protocol conversion

15.5 Configuration Considerations

When setting up serial-to-Ethernet converters:

  1. Match serial parameters exactly: Baud rate, parity, data bits, stop bits, flow control must match the device
  2. Set TCP timeouts: Configure idle timeout, connection retry, and reconnection behavior
  3. Latency: Add inter-character delay if the converter sends too fast for the serial device
  4. Buffering: Configure FIFO size for burst data
  5. Termination: If converting RS485, maintain proper 120 Ω bus termination
  6. Network redundancy: Use dual-NIC converters (e.g., Moxa NPort 6000 series) for redundant Ethernet

16. Common Serial Communication Failures and Debugging

16.1 Physical Layer Problems

FailureSymptomsCauseDebug Method
No signal on TXDNo response from devicePort not opened, wrong device name, hardware faultProbe TXD with oscilloscope; check DV_FrameOpen status
Garbled dataRandom/wrong charactersBaud rate mismatch, parity mismatchTry all common baud rates; check parity settings
Intermittent failuresCommunication works sometimesLoose connector, noise, ground loop, cable too longReseat connectors; add ferrite chokes; check shielding
No signal on RXDDevice sends but PLC doesn’t receiveRXD/TXD swapped, cable fault, wrong pinoutVerify pin-to-pin mapping; swap TXD/RXD; test with null-modem
Signal reflection / corruptionErrors increase with cable lengthMissing termination resistors on RS485Add 120 Ω resistors at both ends of RS485 bus
Ground loopErratic behavior, equipment resetsShield grounded at both endsGround shield at one end only; use isolated serial modules

16.2 Protocol Layer Problems

FailureSymptomsCauseDebug Method
Timeout errorsdvFRAME_ERR_TIMEOUT or dvMBUS_ERR_TIMEOUTDevice not responding, wrong slave address, wiring faultVerify device power; check slave address; probe bus activity
CRC errorsdvMBUS_ERR_CRCParity mismatch, electrical noise, baud rate errorSet correct parity; add termination; reduce cable length
Framing errorsWrong byte valuesBaud rate close but not exact (e.g., 4800 vs 9600)Verify baud rate precisely with oscilloscope
Buffer overrundvFRAME_ERR_OVERRUNPLC not reading fast enough, high baud rateIncrease read frequency; lower baud rate; increase buffer size
Wrong register valuesDevice responds but data is wrongIncorrect register address, wrong data type, byte orderVerify register map; check big/little endian interpretation

16.3 Configuration Problems

FailureSymptomsCauseFix
Port won’t openDV_FrameOpen returns errorPort already in use by another taskCheck for duplicate open calls; close unused ports
Wrong device nameCannot open serial portIncorrect device name stringVerify name in IO configuration: IF1, CS1020_IF1
PS9600 red overload LEDSegment power faultOvervoltage, short circuit, second PS moduleCheck 24 V supply; inspect for shorts; remove duplicate PS
Second serial port not workingOnly one port activeAdded second PS9600 instead of CS1020Replace second PS9600 with X20CS1020
Flow control mismatchPartial data transferRTS/CTS enabled on one side onlySet flow control to None on both sides, or wire all handshake lines

16.4 Environmental Problems

ProblemImpactMitigation
EMI/RFI interferenceCorrupted frames, CRC errorsUse shielded cable; route away from VFDs and motors; add ferrite chokes
Temperature extremesIntermittent failures, connector corrosionUse industrial-rated connectors; proper cabinet ventilation
VibrationLoose connections, intermittent open circuitsUse screw terminals with lock-washers; avoid relying on friction-fit connectors
MoistureShort circuits, corrosionUse IP-rated enclosures; sealed connectors; desiccant in cabinet

17. Troubleshooting Matrices

17.1 Quick Diagnostic Flowchart

Serial Communication Failure
│
├─ No data at all?
│   ├─ Probe TXD with oscilloscope → No signal?
│   │   ├─ Check DV_FrameOpen / DRV_mbusOpen status
│   │   ├─ Verify device name (IF1 vs CS1020_IF1)
│   │   └─ Check if port is already open by another task
│   │
│   └─ TXD active but no response?
│       ├─ Verify RXD wiring (swap TXD/RXD)
│       ├─ Check device power
│       ├─ Verify slave address (Modbus)
│       └─ Check signal ground connection
│
├─ Garbled/wrong data?
│   ├─ Try 9600-8-N-1 (most common)
│   ├─ Try 9600-8-E-1 (Modbus RTU)
│   ├─ Try 19200-8-N-1
│   ├─ Measure bit width with oscilloscope for exact baud rate
│   └─ Check parity on both sides
│
├─ Intermittent failures?
│   ├─ Check RS485 termination (120 Ω at both ends)
│   ├─ Check for ground loops (shield grounded at both ends)
│   ├─ Inspect connectors for looseness
│   ├─ Measure cable length vs baud rate limits
│   └─ Check for EMI sources near cable run
│
└─ CRC / framing errors?
    ├─ Verify parity matches on both sides
    ├─ Reduce baud rate
    ├─ Replace cable with shielded twisted pair
    ├─ Add RS485 termination if missing
    └─ Check for signal reflections with oscilloscope

17.2 B&R-Specific Troubleshooting Matrix

SymptomLikely Root CauseAction
No characters on TxD (terminal 9)DV_FrameOpen/DRV_mbusOpen never reached status 0Check function block status in watch window; verify IO config of COM port
Garbage charactersBaud rate / parity mismatchCompare device DIP/settings with IO config; measure bit width
dvFRAME_ERR_TIMEOUTNo response from deviceSwap TXD/RXD; verify GND; check shield termination; verify device power
dvFRAME_ERR_OVERRUNBaud rate too high or noisy cableLower baud rate; use shielded twisted pair cable
DRV_mbus CRC errorParity mismatch or electrical noiseSet parity to Even; add 120 Ω termination on RS485 legs
PS9600 red overload LEDOvervoltage or short on busCheck 24 V supply; inspect terminals for shorts
Second PS9600 fittedBus conflict (one PS per segment)Remove second PS9600; install X20CS1020 for additional serial
Intermittent communicationGround loop from double-grounded shieldGround shield at cabinet entry only

17.3 Field Commissioning Checklist

#StepExpected ResultPass Criteria
1Power segment with 24 VDCPS green LED solidNo red overload LED
2Measure +24 V on PS terminals23.5–28.0 VDCWithin input spec
3Verify TxD idle voltage-5 V to -12 V (RS232)RS232 spec compliant
4Send test byte; probe RxD at deviceCorrect byte on scopeSignal polarity matches
5Trigger query; capture response on RxDExpected data pattern visibleNo framing errors
6Run cyclic programValues update correctlyStatus = 0 in watch window
7Run for 1 hourNo intermittent errorsError counter remains 0

18. References and Further Reading

B&R Documentation

  • B&R Automation Help Portal: https://help.br-automation.com — DV_Frame library reference, DRV_mbus library reference, X20 system manuals
  • X20CP158x / X20CP358x Datasheet: Available from br-automation.com — IF1/IF2 interface specifications and pinouts
  • X20 System User’s Manual: Comprehensive X20 hardware and configuration guide
  • B&R Automation Studio Online Help: Integrated in IDE; covers IO configuration, serial port setup, library functions
  • System 2005 User’s Manual: Covers IF260, IF622, IF671 interface modules

Serial Communication References

  • TIA-232-F (RS-232) Standard: Official electrical specification
  • TIA-485 (RS-485) Standard: Differential multi-point serial specification
  • Modbus Protocol Specification: https://www.modbus.org — Free download of Modbus RTU/TCP specification
  • Saleae Logic Analyzer Documentation: Protocol decode guides, async serial analyzer setup
  • PicoScope Modbus Decoding Guide: https://www.picotech.com/library/knowledge-bases/oscilloscopes/modbus-serial-protocol-decoding

Tools and Software

  • HHD Serial Port Monitor: https://hhdsoftware.com/serial-port-monitor
  • Saleae Logic Analyzer: https://www.saleae.com
  • COM Sniffer: https://comsniffer.com
  • Moxa NPort Configuration Guide: https://www.moxa.com
  • QModMaster (free Modbus tool): Available on SourceForge
  • RealTerm (serial terminal): https://realterm.sourceforge.io
  • PuTTY (terminal emulator): https://www.putty.org

Community Resources

  • B&R Community Forum: https://community.br-automation.com — Search for serial communication topics
  • PLCtalk.net: https://www.plctalk.net — Industrial automation forums with B&R discussions
  • EEVblog Forum: https://www.eevblog.com/forum — Reverse engineering and protocol analysis discussions
  • Stack Overflow / Electronics Stack Exchange: Serial protocol debugging Q&A

Cross-References


Document covers B&R serial communication diagnostics for System 2003, System 2005, and X20 platforms. Compiled from B&R official documentation, community forums, and industrial automation reference materials.


Key Findings

  1. B&R serial interfaces (IF1030/IF1041/IF1051) are standard RS232/RS485 — any serial sniffer or protocol analyzer can capture the traffic. The challenge is decoding the application-layer protocol, not the physical layer.
  2. The RS232 interface (IF1) factory default is 57600 bps, not 115200 bps — always try 57600 first when connecting to an unknown PLC. The baud rate can be configured higher but the default must be assumed.
  3. Non-invasive serial tapping requires a Y-cable or tap adapter — never break the serial connection on a running machine. Use a 3-port RS232/RS485 tap that monitors traffic passively. See diagnostic-workstation.md for hardware recommendations.
  4. B&R has no proprietary serial protocol documentation for serial-connected devices — the protocol implementation is in the PLC program (which you don’t have). Reverse-engineer the protocol by capturing traffic and correlating with known device behavior.
  5. Serial baud rate auto-detection is feasible using statistical analysis — capture raw byte traffic at a high sample rate and use Python to identify the most likely baud rate by analyzing inter-byte timing patterns.
  6. Modbus RTU over RS485 is the most common serial protocol on B&R systems — if the OEM used Modbus RTU, standard Modbus tools can decode the traffic immediately. See modbus-gateway.md for details.