Modbus Write
Libraries:
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F7xx Based Boards
Description
The Modbus Write block writes data to the register(s) of the server device.
The Modbus Write block accepts data of type uint16
for
single register write operations and [Nx1] vector data of type uint16
for multiple register write operations.
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
Input
Parameters
Version History
Introduced in R2025a