Skip to main content

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

Use these blocks for Modbus master operations:

Reading from Slaves​

To read Modbus data:

  1. Configure slave device address (1-247)
  2. Specify register address to read
  3. Set number of registers to read
  4. Choose appropriate function code
  5. Handle response in your application

Writing to Slaves​

To write Modbus data:

  1. Configure slave device address
  2. Specify register address to write
  3. Provide data value(s)
  4. Use appropriate write function code
  5. 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

See Also​