|
writeMyReadOnlyRegs |
Top |
|
writeMyReadOnlyRegs write Modbus Server Read-only register value Since R2019b
Library: Modbus Server ( Dafulai Electronics) /writeMyReadOnlyRegs
Description
This block writes Read-only register values. Start Address is from Input port "StartAddr" (1-based address without 3x or 4x prefix), write Quantities are decided by Input port "Data" vector's element numbers and parameter "Data type". For example, if parameter Data type is "uint32", and Input port "Data" contains 5 elements vector. Actually the words Quantities will be 5 x 2 =10. (From "StartAddr" to "StartAddr"+9)
Those Read-only registers are only readable for "Outside Modbus Master". Simulator (Our PC) will control these values (writable).
If succeed to write, output port "Success" will become true, otherwise false.
This is very important block. All simulated data are from this block for words registers.
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 set Input registers addressing at 30078 and 30079 (it is address 78 and 79 if no prefix) increase 1 for Modbus RTU Server Device1. Note: addressing at 30078 and 30079 combines one "uint32" data with "big-endian"
Please open "your Modbus Server library folder"/examples/example3_writeInputRegs.slx (You must change USB serial Port number in Modbus Server Setup block according to your physical USB port number).
For "Modbus Server Setup" block, the parameters are set up below:
For "write input Regs address 78 to 79" block, the parameters are set up below:
You can run general Modbus master software such as Modbus Poll or ModScan32 to view input registers values addressing 30078 to 30079. We put ModScan32 result below:
Notes: Because input port "Data" is "double" type, when increasing 1 causes over 0xFFFFFFFF, although input port "Data" can be over 0xFFFFFFFF, the register result will be limit to 0xFFFFFFFF due to "uint32" data type of register. If you want to return to zero when uint32 data is over 0xFFFFFFFF, you must modify Simulink model.
|