Modbus Read
Libraries:
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F7xx Based Boards
Description
In the Modbus Read block,
Client: Read data from a Modbus® server connected on the RS485 network.
Server: Reads data from its own registers.
The Modbus Read block outputs the values read as an [Nx1] array of
uint16
or logical values based on the register category.
Embedded Coder® Support Package for STMicroelectronics® STM32 Processors supports the Modbus communication protocol over the RS485 network. The client and the server must be connected on the same RS485 network for successful Modbus communication. Each device on the RS485 network is referenced by a unique 8-bit address or identifier.
This table categories the server device registers referenced by the Modbus client device.
Register Type | Register Size | Allowed Client Operation on Register |
---|---|---|
Coil | 1-bit | Read and Write |
Discrete Input | 1-bit | Read |
Holding Register | 16-bit | Read and Write |
Input Register | 16-bit | Read |
The client can perform either a read or a write operation (depending on the register type) on register(s) of a server device.
Note
Ensure that the number of client write registers does not exceed the server read register count.
To enable the Modbus communication on a particular UART, navigate to the Configuration Parameters > Hardware Implementation > Target hardware resources > USART/UART properties of the model and perform the following:
Enable the Modbus on required USART/UART peripheral.
Select the MODBUS Mode parameter as Server or Client. If you set the MODBUS Mode to
Server
, configure the registers accordingly.Select the register type to configure and enter the register address in the Start address field. For more information, see UART/USART.
Examples
Ports
Output
Parameters
Version History
Introduced in R2025a