|
readHoldingRegs |
Top |
|
readHoldingRegs read Modbus Server holding registers values (Hardware: Modbus dual Masters Adaptor from Dafulai Electronic Inc ) Since R2019b
Library: Modbus Client ( Dafulai Electronics) /readHoldingRegs
Description
This block reads holding registers values. Start Address is from Input port "StartAddr" (1-based address without 4x prefix), Read Quantities are from the dimension of Input port "Data Var" . 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 "Data Var" is 5 elements's vector. Actually the words Quantities will be 5 x 2 =10. (From "StartAddr" to "StartAddr"+9). Why do we use the dimension of Input port "Data Var" instead of "holding Data QTY" scalar? The reason is for "Embedded Code generator", in this way, embedded code will know variable 's holding register address easily.
If any error (CRC, Timeout, Not supported FC, address range,....) occurs, Outport "Data" will keep previous value, and Outport "Success" will be false.
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 reading holding registers address from 1 to 3 of Modbus RTU/ASCii Server with Server ID=2.
Please open "your Modbus Client library folder"/examples/example2_readHoldingregs.slx (You must change USB serial Port number in Modbus Setup block according to your physical USB port number).
For "Modbus Setup" block, the parameters are set up below:
For "readHoldingRegs" block, the parameters are set up below:
Our example can access both Modbus RTU and Modbus ASCii. RTU or ASCii is decided by ConfigTool.exe software. You can run general Modbus Slave Simulator software such as "Modbus Salve" to change holding registers values addressing 40001 to 40004, you will see its result in our Simulink example.
|