Main Content

Modbus RS485 Server Write

Server device writes data to server device register over RS485 network

  • Library:
  • Simulink Coder Support Package for STMicroelectronics Nucleo Boards/ Common

    Embedded Coder Support Package for STMicroelectronics Discovery Boards/ STM32F746G-Discovery

    Embedded Coder Support Package for STMicroelectronics Discovery Boards/ STM32F769I-Discovery

    Embedded Coder Support Package for STMicroelectronics Discovery Boards/ STM32L475-Discovery (B-L475E-IOT01A)

  • MODBUS RS485 Server Write

Description

In theModbus RS485 Server Writeblock, the server device writes data to its registers. The server can write data only to one register per write operation.

金宝app®Coder™ Support Package for STMicroelectronics®Nucleo BoardsandEmbedded Coder®Support Package for STMicroelectronics Discovery Boardssupports 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 server registers referenced by the MODBUS server device.

Register Type Register Size
Coil 1-bit
Discrete Input 1-bit
Holding Register 16-bit
Input Register 16-bit

Ports

Input

expand all

The input to the block is the data to be written to its registers by the server as a 1-bit scalar.

  • If you select the Coil or Discrete Input write operations, the server writes data to its registers as a 1-bit write operation having the Boolean data type.

  • 如果你选择保持寄存器或输入Register write operations, the server writes data to its registers as a 16-bit write operation having the uint16 data type.

Data Types:Boolean|uint16

Output

expand all

The block outputs the status of the server write operation on the server device register.

  • 1: Indicates an unsuccessful write operation to the server registers.

  • 0: Indicates a successful write operation to the server registers.

Dependencies

To enable this port, select theOutput statusparameter.

Data Types:uint8

Parameters

expand all

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

  • Write Coil: Write data to the coil register address specified in theCoil Addressparameter

  • Write Discrete input: Write data to the discrete input register address specified in theDiscrete Input Addressparameter

  • Write Holding register: Write data to the holding register address specified in theHolding Register Addressparameter

  • Write Input register:输入指定的寄存器地址写入数据ed in theInput Register Addressparameter

To notify the server to write data to a specific coil register, specify the coil register address in this parameter. For example, for the server to write data to the coil register with the address10, enter10.

Dependencies

To enable this parameter, setFunctiontoWrite Coil.

To notify the server to write data to a specific discrete input register, specify the discrete input register address in this parameter. For example, for the server to write data to the discrete input register with the address80, enter80.

Dependencies

To enable this parameter, setFunctiontoWrite Discrete input.

To notify the server to write data to a specific holding register, specify the holding register address in this parameter. For example, for the server to write data to the holding register with the address37, enter37.

Dependencies

To enable this parameter, setFunctiontoWrite Holding register.

To notify the server to write data to a specific input register, specify the input register address in this parameter. For example, for the server to write data to the input register with the address25, enter25.

Dependencies

To enable this parameter, setFunctiontoWrite Input register.

When you select theOutput Statusparameter, the block configures an output port,Status. The port outputs the status message.

Version History

Introduced in R2021b