Main Content

Modbus TCP/IP Client Read

Client device reads data from server device register(s) over TCP/IP network

Since R2022a

Add-On Required: This feature requires the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms add-on.

  • NVIDIA Modbus TCP/IP Client Read block icon

Libraries:
NVIDIA Jetson and NVIDIA DRIVE / Network

Description

In the Modbus TCP/IP Client Read block, the client device reads data from the register(s) of the server device.

MATLAB® Coder™ Support Package for NVIDIA® Jetson™ and NVIDIA DRIVE® Platforms supports the Modbus® communication protocol over the TCP/IP network on Jetson platforms. The client and the server must be connected to the TCP/IP network for successful Modbus communication.

Note

The Modbus TCP/IP Client Read block is not supported on NVIDIA DRIVE platforms.

The client can perform either a read, write, or a read and write operation on the server register depending on the server register(s) type.

Register TypeRegister SizeOperation Performed by client
Coil1-bitRead and write
Discrete Input1-bitRead
Holding Register16-bitRead and write
Input Register16-bitRead

Ports

Output

expand all

The block outputs the data read by the client from the server device register(s) as a N-by-1 vector, where N represents the number of registers on the server device.

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

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

Data Types: Boolean | uint16

The block outputs the status of the client read operation on the server device 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

Enter the IP address of the server device. The client reads data from this server device.

Programmatic Use

Block Parameter: serverIP
Type: character vector
Values: '127.0.0.1' | Valid IP address
Default: '127.0.0.1'

Select the type of read operation you want to perform on the server register(s). Specify one of these:

ValueDescription
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.

Read Multiple Coils

Read data from multiple coil registers depending on the values specified in the Coil Address and Number of Coils parameters.

Read Multiple Discrete Inputs

Read data from multiple discrete input registers depending on the values specified in the Discrete Input Address and Number of Discrete Inputs parameters.

Read Multiple Holding Registers

Read data from multiple holding registers depending on the values specified in the Holding Register Address and Number of Holding registers parameters.

Read Multiple Input Registers

Read data from multiple input registers depending on the values specified in the Input Register Address and Number of Input registers parameters.

Programmatic Use

Block Parameter: Function
Type: character vector
Values: 'Read Coil' | 'Read Discrete Input' | 'Read Holding Register' | 'Read Input Register' | 'Read Multiple Coils' | 'Read Multiple Discrete Inputs' | 'Read Multiple Holding Registers' | 'Read Multiple Input Registers'
Default: 'Read Coil'

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

To notify the client to read data from a group of coil registers, specify the address of the first coil register in the group. For example, for the client to read data from the coil registers with addresses ranging from 10 to 14, enter 10.

Dependencies

To enable this parameter, set Function to Read Coil or Read Multiple Coils.

Programmatic Use

Block Parameter: CoilAddress
Type: character vector
Values: '0' | scalar
Default: '0'

Enter the number of coil registers from which you want the client to read the data. For example, for the client to read data from the coil registers with addresses ranging from 10 to 14, enter 5.

Dependencies

To enable this parameter, set Function to Read Multiple Coils.

Programmatic Use

Block Parameter: numElements_coil
Type: character vector
Values: '1' | scalar
Default: '1'

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

To notify the client to read data from a group of discrete input registers, specify the address of the first discrete input register in the group. For example, for the client to read data from the discrete input registers with addresses ranging from 80 to 89, enter 80.

Dependencies

To enable this parameter, set Function to Read Discrete Input or Read Multiple Discrete Inputs.

Programmatic Use

Block Parameter: DiscreteInputAddress
Type: character vector
Values: '0' | scalar
Default: '0'

Enter the number of discrete input registers from which you want the client to read the data. For example, for the client to read data from the discrete input registers with addresses ranging from 80 to 89, enter 10.

Dependencies

To enable this parameter, set Function to Read Multiple Discrete Inputs.

Programmatic Use

Block Parameter: numElements_input
Type: character vector
Values: '1' | scalar
Default: '1'

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

To notify the client to read data from a group of holding registers, specify the address of the first holding register in the group. For example, for the client to read data from the holding registers with addresses ranging from 37 to 44, enter 37.

Dependencies

To enable this parameter, set Function to Read Holding Register or Read Multiple Holding Registers.

Programmatic Use

Block Parameter: HoldingRegisterAddress
Type: character vector
Values: '0' | scalar
Default: '0'

Enter the number of holding registers from which you want the client to read the data. For example, for the client to read data from the holding registers with addresses ranging from 37 to 44, enter 8.

Dependencies

To enable this parameter, set Function to Read Multiple Holding Registers.

Programmatic Use

Block Parameter: numElements_holdingReg
Type: character vector
Values: '1' | scalar
Default: '1'
  • To notify the client to read data from a specific input register, specify the input register address in this parameter. For example, for the client to read data from the input register with the address 25, enter 25.

  • To notify the client to read data from a group of input registers, specify the address of the first input register in the group. For example, for the client to read data from the input registers with addresses ranging from 25 to 26, enter 25.

Dependencies

To enable this parameter, set Function to Read Input Register. or Read Multiple Input Registers

Programmatic Use

Block Parameter: InputRegisterAddress
Type: character vector
Values: '0' | scalar
Default: '0'

Enter the number of input registers from which you want the client to read the data. For example, for the client to read data from the input registers with addresses ranging from 25 to 26, enter 2.

Dependencies

To enable this parameter, set Function to Read Multiple Input Registers.

Programmatic Use

Block Parameter: numElements_inputReg
Type: character vector
Values: '1' | scalar
Default: '1'

Enter the time interval (in seconds) at which the client reads data from the server device register(s).

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar | vector
Default: '0.1'

Version History

Introduced in R2022a