|
readInputRegs |
Top |
|
readInputRegs read Modbus Server input registers values (Hardware: Modbus dual Masters Adaptor from Dafulai Electronic Inc ) Since R2019b
Library: Modbus Client ( Dafulai Electronics) /readInputRegs
Description
This block reads input registers values. Start Address is from Input port "StartAddr" (1-based address without 3x 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 "Input Data QTY" scalar? The reason is for "Embedded Code generator", in this way, embedded code will know variable 's input 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 input registers address from 1 to 3 of Modbus RTU/ASCii Server with Server ID=10.
Please open "your Modbus Client library folder"/examples/example1_readinputregs.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 "readInputRegs" 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 Input registers values addressing 30001 to 30003, you will see its result in our Simulink example.
|