Modbus Master
The Modbus Master feature enables your device to act as a Modbus master (client), allowing you to read from and write to Modbus slave devices. This is essential for industrial automation and equipment integration.
Overview
As a Modbus master, your device can:
- Read sensor data from Modbus slaves
- Control Modbus-enabled equipment
- Monitor industrial instruments
- Integrate with PLCs and SCADA systems
- Collect data from multiple slave devices
Supported Protocols
AppBlocks supports both Modbus variants:
Modbus RTU
- Serial communication (RS-485, RS-232)
- Binary protocol for efficient transmission
- Suitable for industrial environments
- Multiple slaves on single bus
Modbus TCP
- Ethernet-based communication
- Port 502 (standard Modbus TCP port)
- Multiple simultaneous connections
- Higher speed and bandwidth
Configuration
Configure Modbus Master with these properties:
For Modbus RTU:
- Serial Port: COM port for Modbus communication
- Baud Rate: Communication speed (9600, 19200, 38400, etc.)
- Parity: None, Even, or Odd
- Stop Bits: 1 or 2
- Data Bits: 7 or 8
For Modbus TCP:
- IP Address: Slave device IP address
- Port: TCP port (default: 502)
- Timeout: Response timeout in milliseconds
Function Codes
Common Modbus function codes supported:
- FC01: Read Coils (digital outputs)
- FC02: Read Discrete Inputs (digital inputs)
- FC03: Read Holding Registers (read/write data)
- FC04: Read Input Registers (read-only data)
- FC05: Write Single Coil
- FC06: Write Single Register
- FC15: Write Multiple Coils
- FC16: Write Multiple Registers
Related Blocks
Use these blocks for Modbus master operations:
- Modbus Request: Write/Read data to slave devices
- On Modbus Response: Handle successful responses
- On Modbus Timeout: Handle communication failures
Reading from Slaves
To read Modbus data:
- Configure slave device address (1-247)
- Specify register address to read
- Set number of registers to read
- Choose appropriate function code
- Handle response in your application
Writing to Slaves
To write Modbus data:
- Configure slave device address
- Specify register address to write
- Provide data value(s)
- Use appropriate write function code
- Handle confirmation or errors
Multiple Slaves
Communicate with multiple Modbus slaves:
- Sequential polling of slave devices
- Different slave addresses (1-247)
- Configurable polling intervals
- Priority-based communication scheduling
Error Handling
Modbus communication errors:
- Timeout: Slave did not respond
- CRC Error: Data corruption detected
- Exception Codes: Slave reported error
- Invalid Response: Unexpected data received
Use the On Modbus Timeout block to handle errors gracefully.
Linking to Settings
Modbus properties can be linked to settings for:
- Field configuration of slave addresses
- Runtime adjustment of polling rates
- Site-specific communication parameters
Performance Considerations
Optimize Modbus performance:
- Minimize polling frequency
- Batch register reads when possible
- Use appropriate timeout values
- Consider bus loading with multiple slaves
- Implement error retry logic
Use Cases
Common Modbus master applications:
- Reading temperature, pressure, and flow sensors
- Controlling motor drives and actuators
- Integrating with industrial meters
- HVAC system monitoring and control
- Energy management and monitoring
Related Features
- Modbus Slave: Act as Modbus slave
- Variables: Store Modbus data
- Data Tables: Log Modbus readings