Modern Modbus & Serial Communication Engineering Guide
To test Modbus TCP slave equipment or communicate over physical serial COM ports (RS-232 / RS-485), you must first download the GoGG PC Hardware Bridge and run it on your local system. Standard web browsers do not possess native operating system privileges to open raw serial ports or direct industrial TCP sockets. The lightweight Bridge agent (Bridge.exe) operates locally on your machine (127.0.0.1:8765) to safely broker Modbus telegrams, serial packets, and loopback simulation tests.
Personal Development & Testing Purpose Only: PortTester Studio and the GoGG PC Hardware Bridge (Bridge.exe) are provided strictly for individual engineering development, protocol learning, hardware benchmarking, and offline laboratory testing. They are NOT certified or rated for commercial production machinery, life-safety automation, or live factory floor control. Any deployment in commercial or production environments is done at your own sole risk. GoGG and the software authors accept no liability or responsibility for any industrial equipment damage, operational failure, communication loss, production downtime, or financial damages resulting from the use of this software.
The Modbus protocol, originally established by Modicon (now Schneider Electric) in 1979, remains the premier industrial messaging architecture for programmable automation controllers, servo drives, temperature transmitters, Variable Frequency Drives (VFDs), power meters, and human-machine interfaces (HMIs). This guide details the protocol specifications, frame formats, floating-point byte arrangement, serial port arbitration, and integration with the GoGG PC Hardware Bridge.
1. Modbus TCP, Modbus RTU & Raw Serial Modes
PortTester Studio supports three primary industrial communication modes selectable from the top connection bar:
- Modbus TCP (Ethernet): Connect to Ethernet Modbus slave devices, PLCs, inverters, and power meters by entering the target IP address, TCP port (typically 502), and Unit ID, or test offline using the built-in simulator mode.
- Modbus RTU (Serial RS-232 / RS-485): Communicate over physical COM ports with automatic header and checksum attachment in both Master Mode (polling field devices) and Slave Mode (simulating a slave device with automatic replies).
- General Raw Serial (ASCII / HEX): Send and receive unframed ASCII strings or hexadecimal byte sequences with configurable prefix/suffix strings and line terminators (CR, LF, CRLF) for barcode readers, scales, and microcontroller boards.
2. Standard Modbus Function Codes and Register Addressing
Modbus categorizes device memory into four distinct object tables, traditionally identified by 5-digit or 6-digit reference numbers:
| Function Code | Action | Access Type | Target Memory Table | Reference Prefix |
|---|---|---|---|---|
01 (0x01) |
Read Coils | Read / Write | Discrete Output Bits | 00001 - 09999 (0xxxx) |
02 (0x02) |
Read Discrete Inputs | Read Only | Physical Sensor Inputs | 10001 - 19999 (1xxxx) |
03 (0x03) |
Read Holding Registers | Read / Write | Analog Outputs & Parameters | 40001 - 49999 (4xxxx) |
04 (0x04) |
Read Input Registers | Read Only | Analog Sensor Measurements | 30001 - 39999 (3xxxx) |
05 (0x05) |
Write Single Coil | Write | Force Bit ON (0xFF00) / OFF (0x0000) | 0xxxx |
06 (0x06) |
Write Single Register | Write | Preset Single 16-bit Register | 4xxxx |
15 (0x0F) |
Write Multiple Coils | Write | Preset Sequence of Bit Coils | 0xxxx |
16 (0x10) |
Write Multiple Registers | Write | Preset Continuous 16-bit Registers | 4xxxx |
3. 32-Bit Floating Point & Multi-Word Byte Swapping
Because the base Modbus protocol strictly defines registers as 16-bit integers, representing IEEE-754 32-bit single-precision floating-point measurements (such as temperature, flow rate, or power wattage) requires combining two adjacent 16-bit registers (4 bytes: A, B, C, D). However, various PLC and instrument manufacturers store and transmit these 4 bytes in different endianness configurations:
- ABCD (Big-Endian / Motorola): Standard high-word first, high-byte first. Used by Allen-Bradley, Yokogawa, and modern Beckhoff PLCs.
- CDAB (Word-Swapped / Modicon): Low-word first, high-byte first. The standard format deployed in Schneider Electric Modicon PLCs, ABB inverters, and standard flow meters.
- BADC (Byte-Swapped): High-word first, byte-swapped order.
- DCBA (Little-Endian / Intel): Low-word first, low-byte first. Common in x86 edge PC gateways and embedded micro-controllers.
PortTester's Live Register Decoder dynamically computes all 4 permutations simultaneously, eliminating trial-and-error calculations during instrumentation commissioning.
4. PC Hardware Bridge & Serial COM Setup
While modern web browsers restrict direct physical RS-232/485 serial and low-level TCP socket manipulation, the GoGG PC Local Hardware Bridge provides a zero-latency WebSocket and REST relay on http://127.0.0.1:8765:
- Download and extract `Bridge.zip` from the download link above.
- Launch
Bridge.exeon your Windows PC. - Connect your USB-to-RS485 adapter (FTDI / CH340 / CP2102) to your sensor bus, and ensure the 120Ω termination resistor is installed at both ends of the transmission line.
- Select Serial Modbus RTU / COM in PortTester, click 🔄 to refresh ports, choose your COM port and baud rate, and execute requests with live packet decoding.
5. Serial Modbus RTU vs. General Raw Serial Communication
Industrial serial links support both structured protocols like Modbus RTU and non-delimited Raw Serial streams:
- Modbus RTU (Structured Industrial Telegrams): Operates in strict master/slave mode with 16-bit CRC checksums. PortTester supports both Master Mode (querying remote field devices) and Slave Mode (simulating slave instruments with real-time auto-replies across FC 01~16).
- General Raw Serial (ASCII & Hex Streaming): Engineered for microcontrollers (Arduino, ESP32, STM32), barcode scanners, electronic weight scales, flow sensors, and laboratory test instruments. Bytes and text strings are transmitted transparently without Modbus CRC framing. Configurable transmit line terminators (None, CR, LF, CRLF) ensure immediate interoperability with ASCII command sets (SCPI, AT commands).
- Real-Time Auto-Reply Engine: When Auto-Reply is active in Slave mode, the GoGG Hardware Bridge automatically calculates 16-bit CRC checksums in sub-millisecond intervals and updates register tables, enabling two-way closed-loop simulation testing without physical equipment.
6. Schema-Free Live Register Poller & Address Discovery Scanner
When commissioning field equipment without an existing register map, the Live Poller & Scanner tab enables rapid reverse-engineering and real-time diagnostics across any Modbus TCP or RTU device:
-
3-Mode Address Resolution: Seamlessly switch between Standard 4xxxx (
40001 → PDU 0x0000), 0-Based PDU (0 → 0x0000), and Raw Direct (40001 → 0x9C41) to match any controller's addressing convention without reconnecting. -
Simultaneous Multi-Format Grid: Every register row decodes
UINT16,INT16,HEX, 16-bit interactiveBIN, 2-byteASCII, and adjacent 2-wordINT32/FLOAT32values in real time, with instant dropdown switching for 32-bit word order (AB CDBig-Endian vs.CD ABWord-Swapped) and ASCII byte order (Hi-Lovs.Lo-Hi). - Automatic Chunked Polling & Change Highlight: Requests exceeding 100 registers are automatically segmented into compliant Modbus blocks and merged into a single table. Registers whose values change flash amber/green with a cumulative change counter and timestamp, allowing engineers to isolate heartbeats, encoders, and live analog sensors using the Changed Only filter.
-
Inline Editing & Address Range Scanner: Double-clicking any value cell transmits an immediate
FC06(single word) orFC16(32-bit / multi-character string) write command, while clicking any individual bit in theBINcolumn toggles that bit in place. The built-in Scan Ranges tool probes standard and custom address blocks to report responsive regions and non-zero registers, and custom aliases can be exported or imported as CSV maps.
7. Frequently Asked Questions (FAQ)
Q: What causes Modbus Exception Code 02 (Illegal Data Address)?
A: Exception 02 occurs when the slave controller does not contain the requested register number, or when reading past the boundary of the configured register map. Note that Modbus addresses are 0-based over the wire (e.g., holding register 40001 corresponds to address 0x0000 in the PDU).
Q: Why does my RS-485 communication result in CRC errors?
A: Common causes include swapped A(+) and B(-) differential signal lines, mismatched baud rates or parity configurations, missing common ground reference causing high common-mode voltage, or insufficient 3.5 character time delays between consecutive query packets.
Related Reference Guides: Modbus TCP vs. Modbus RTU Protocol Architecture • Modbus CRC-16 & ASCII LRC Frame Checksum Calculation • RS-232, RS-422 & RS-485 Wiring, Termination & Fail-Safe Bias