Main Content

Modbus RS485 Slave Read

Slave device reads data from the slave device register over RS485 network

  • Library:
  • Simulink Support Package for Arduino Hardware / Common

  • MODBUS RS485 Slave Read

Description

In the Modbus RS485 Slave Read block, the slave device reads data from its registers. The slave can read data only from one register per read operation.

Simulink® Support Package for Arduino® Hardware supports the MODBUS® communication protocol over the RS485 network. Each device on the RS485 network is referenced by a unique 8-bit address or identifier.

This table categories the slave registers referenced by the Modbus slave device.

Register TypeRegister Size
Coil1-bit
Discrete Input1-bit
Holding Register16-bit
Input Register16-bit

The slave can perform either a read or a write operation on its registers.

Ports

Output

expand all

The block outputs the data read by the slave device from its register as a 1-bit scalar.

  • If you select the Coil or Discrete Input read operations, the slave reads its registers as a 1-bit read operation. The block outputs the read data as a Boolean data type.

  • If you select the Holding Register or Input Register read operations, the slave reads its registers as a 16-bit read operation. The block outputs the read data as a uint16 data type.

Data Types: Boolean | uint16

The block outputs the status of the slave read operation on the slave register.

  • 0: Indicates an unsuccessful read operation, which means that the data received on the data port is invalid.

  • 1: Indicates a successful read operation, which means that the data received on the data port is valid.

Data Types: uint8

Parameters

expand all

Select the type of read operation you want to perform on the slave register. Specify any one of the following:

  • Read Coil: Read data from the coil register address specified in the Coil Address parameter

  • Read Discrete input: Read data from the discrete input register address specified in the Discrete Input Address parameter

  • Read Holding register: Read data from the holding register address specified in the Holding Register Address parameter

  • Read Input register: Read data from the input register address specified in the Input Register Address parameter

To notify the slave to read data from a specific coil register, specify the coil register address in this parameter. For example, for the slave to read data from the coil register with the address 10, enter 10.

Dependencies

To enable this parameter, set Function to Read Coil.

To notify the slave to read data from a specific discrete input register, specify the discrete input register address in this parameter. For example, for the slave to read data from the discrete input register with the address 80, enter 80.

Dependencies

To enable this parameter, set Function to Read Discrete input.

To notify the slave to read data from a specific holding register, specify the holding register address in this parameter. For example, for the slave to read data from the holding register with the address 37, enter 37.

Dependencies

To enable this parameter, set Function to Read Holding register.

To notify the slave to read data from a specific input register, specify the input register address in this parameter. For example, for the slave to read data from the input register with the address 25, enter 25.

Dependencies

To enable this parameter, set Function to Read Input register.

Enter the time interval (in seconds) at which the slave reads data from its register.

Introduced in R2020b