What is Modbus TCP?
Modbus TCP is an industrial communication protocol that enables data acquisition from industrial devices over TCP/IP networks. It provides a standardized method for reading data from PLCs, sensors, and other industrial equipment using Ethernet infrastructure.Device Profile Configuration
Connection Parameters
Configure the communication settings for your Modbus TCP device:| Parameter | Description | Default Value | Range/Format | Required |
|---|---|---|---|---|
| Host | IP address of the Modbus TCP device | - | IPv4 format | Yes |
| Port | TCP port number for Modbus communication | 502 | 1-65535 | No |
| ReadingFrequency | Interval between reading cycles (ms) | 1000 | 100-60000 | No |
| ConnectTimeOut | Connection timeout duration (ms) | 1000 | 500-30000 | No |
| ReceiveTimeOut | Response timeout duration (ms) | 1000 | 500-30000 | No |
| DataFormat | Byte order for multi-register data | ABCD | ABCD, BADC, CDAB, DCBA | No |
Data Format Options
The DataFormat parameter determines how multi-register values are interpreted:- ABCD: Big-endian, high word first (default)
- BADC: Big-endian, low word first
- CDAB: Little-endian, high word first
- DCBA: Little-endian, low word first
Tag Configuration
Basic Tag Settings
Each tag represents a data point from your Modbus device and requires:- Name: Descriptive identifier for the data point
- Address: Modbus address specification
- Data Type: Type of data to read
- Length: Number of registers to read (for String/Bytes only)
- Polling Interval: Individual polling frequency (0 = use device default)
Address Format
Address Components
| Component | Description | Default | Example |
|---|---|---|---|
| s=station | Modbus station/slave ID | 1 | s=2 |
| x=function | Read function code | 3 | x=4 |
| address | Register or coil number | - | 100 |
| .bit | Specific bit within a register | - | .5 |
Function Codes
| Function Code | Operation | Address Prefix | Description |
|---|---|---|---|
| 01 | Read Coils | x=1; | Read discrete output coil status |
| 02 | Read Discrete Inputs | x=2; | Read discrete input contact status |
| 03 | Read Holding Registers | (default) | Read holding register values |
| 04 | Read Input Registers | x=4; | Read input register values |
Address Examples
| Address Format | Description | Function Code |
|---|---|---|
100 | Holding register 100 | 03 |
s=2;100 | Register 100 on station 2 | 03 |
x=4;100 | Input register 100 | 04 |
s=2;x=4;100 | Input register 100 on station 2 | 04 |
100.0 | Bit 0 of holding register 100 | 03 |
x=2;100 | Discrete input 100 | 02 |
x=1;100 | Coil 100 | 01 |
Data Types
Fixed-Size Data Types
| Data Type | Size (Registers) | Size (Bytes) | Description | Range |
|---|---|---|---|---|
| Bool | - | 1 bit | Boolean value (coil/discrete) | true/false |
| Short | 1 | 2 bytes | Signed short integer | -32,768 to 32,767 |
| UShort | 1 | 2 bytes | Unsigned short integer | 0 to 65,535 |
| Int | 2 | 4 bytes | Signed integer | -2,147,483,648 to 2,147,483,647 |
| UInt | 2 | 4 bytes | Unsigned integer | 0 to 4,294,967,295 |
| Float | 2 | 4 bytes | Single-precision floating point | IEEE 754 single precision |
| Long | 4 | 8 bytes | Signed long integer | Large signed integer values |
| ULong | 4 | 8 bytes | Unsigned long integer | Large unsigned integer values |
| Double | 4 | 8 bytes | Double-precision floating point | IEEE 754 double precision |
| DateTime | 4 | 8 bytes | Date and time value | Date and time representation |
Variable-Length Data Types
| Data Type | Description | Length Usage | Calculation |
|---|---|---|---|
| String | Variable-length string for text data | Required | Characters = Length × 2 |
| Bytes | Variable-length byte data for binary data | Required | Bytes = Length × 2 |
Configuration Examples
Temperature Sensor
Pump Status
Device Name String
Energy Counter
Variable-Length Data Configuration
String Data Type
- Length: Number of registers to read for string data
- Character Count: Each register contains 2 ASCII characters
- Total Characters: Length × 2
Bytes Data Type
- Length: Number of registers to read for binary data
- Byte Count: Each register contains 2 bytes
- Total Bytes: Length × 2
Advanced Features
Bit-Level Reading
Read specific bits from registers by adding.bit to the address:
Dynamic Data Format
Override the default data format for specific tags:Best Practices
Performance Optimization
- Group Sequential Addresses: Place related tags in consecutive registers
- Optimize Polling Intervals: Use appropriate frequencies based on data change rates
- Minimize Station Queries: Group tags by station number
- Use Appropriate Data Types: Choose the most efficient data type
- Exact Length Sizing: Set Length to match exact data size for String/Bytes
Polling Interval Guidelines
- Critical Data: 100-500ms for critical process data
- Status Information: 1-5 seconds for status monitoring
- Configuration Data: 10+ seconds for slowly changing data
Length Parameter Guidelines
- String: Set Length based on expected text length
- Bytes: Set Length based on binary data size
- Performance: Avoid unnecessarily large Length values
- Device Limits: Check device documentation for maximum register ranges
Troubleshooting
Connection Issues
| Issue | Possible Cause | Solution |
|---|---|---|
| Connection Timeout | Network connectivity, wrong IP/port | Verify network settings and device availability |
| Connection Refused | Device not responding, firewall blocking | Check device status and network configuration |
| Intermittent Disconnections | Network instability, timeout settings | Adjust timeout values and check network stability |
Data Reading Errors
| Issue | Possible Cause | Solution |
|---|---|---|
| Invalid Address | Address doesn’t exist on device | Check device documentation for valid address ranges |
| Data Format Error | Wrong byte order for multi-register values | Adjust DataFormat parameter (ABCD, BADC, etc.) |
| Function Code Error | Device doesn’t support function code | Try different function codes (03, 04, 01, 02) |
| Length Parameter Error | Wrong Length for String/Bytes | Set correct Length value for variable data types |
| Address Range Error | Length exceeds available registers | Reduce Length or check device memory map |
Diagnostic Steps
- Network Connectivity: Ping the device IP address
- Port Accessibility: Verify port 502 is accessible
- Address Validation: Check device memory map documentation
- Function Code Testing: Try reading with different function codes
- Data Format Testing: Test different byte order options
- Length Validation: Ensure Length parameter is correct for variable data types
Technical Specifications
Protocol Compliance
- Modbus TCP: Full compliance with Modbus Application Protocol v1.1b3
- Message ID Management: Automatic increment for request tracking
- Error Detection: TCP-based error handling and timeout management
- Data Integrity: Built-in validation and retry mechanisms
Performance Characteristics
- Maximum Tags: Limited by device capacity and network bandwidth
- Update Rate: Configurable from 100ms to 60 seconds per tag
- Concurrent Devices: Multiple device connections supported
- Data Throughput: Optimized for industrial monitoring applications
Memory Areas
| Memory Area | Function Code | Address Prefix | Data Types | Typical Use |
|---|---|---|---|---|
| Coils | 01 | x=1; | Bool | Digital outputs status |
| Discrete Inputs | 02 | x=2; | Bool | Digital inputs status |
| Holding Registers | 03 | (default) | All types | Process variables, setpoints |
| Input Registers | 04 | x=4; | All types | Sensor readings, measurements |