|
writeHoldingRegs |
Top |
|
writeHoldingRegs write Modbus Server holding registers (Hardware: Modbus dual Masters Adaptor from Dafulai Electronic Inc ) Since R2019b
Library: Modbus Client ( Dafulai Electronics) /writeHoldingRegs
Description
This block writes holding registers. Start Address is from Input port "StartAddr" (1-based address without 4x prefix), Write Quantities are from the dimension of Input port "DataIn" . However this Quantities is in unit of Destination Data type. For example, if Destination Data type (parameter: Register data type) is "uint32", and Input port "DataIn" is 5 elements's vector. Actually the words Quantities will be 5 x 2 =10. (From "StartAddr" to "StartAddr"+9).
If any error (CRC, Timeout, Not supported FC, address range,....) occurs, Outport "DataOut" will keep previous value, and Outport "Success" will be false. Otherwise, write successfully, Outport "DataOut" will be input port "DataIn", and Outport "Success" will be true.
Parameters
Please double click this block to open parameters dialog below:
Let us explain parameters.
Ports
Input
Outport
Examples
Example:
Every 500ms (Wait 0.5 sec block), We are writing holding registers address from 1 to 2 of Modbus TCP Server (ip address: 127.0.0.1, port=502) with Server ID=1.
Please open "your Modbus Client library folder"/examples/example3_writeHoldingregs.slx (You must change "Hardware USB or BT Serial Port" in Modbus Setup block according to your physical USB port number).
For "Modbus Setup" block, the parameters are set up below:
For "writeHoldingRegs" block, the parameters are set up below:
You can run general Modbus Slave Simulator software such as "Modbus Salve" to see holding registers values addressing 40001 to 40002 when we modify values we write to holdings.
|