|
emModbusSlaveReadHoldings
embedded Modbus Server updates holding register value.
Since R2019b
Library: embeddedCreatorLib ( Dafulai Electronics) / embedded Modbus Slave & Debugger / emModbusSlaveReadHoldings

Description
This block will update my Modbus server holding register value periodically. So External Modbus client can get the latest holding register value.
Notes: Any Port name with "Right Arrow" (à) symbol contains "built-in" probe. So in PC side, you can watch its value directly by "Display" block, you don't need add "Probe" block (our emProbe) before "Display" block. Of cause, you can still use "Mux" block to collect all watching variables and then connect one "emProbe" which connects "Display" block. In this way, you can decrease communication traffic.
Parameters
Please double click this block to open parameters dialog below:

Let us explain parameters.
| • | Modbus Server ID or node address — tell system this block is for which Modbus Server node. You just choose from drop list which is from "emModbusSlaveDebugSetup" block. |
| • | Register data type — It is Modbus holding register data type, It can be "uint16, int16, uint32, int32 and single (4 bytes float)". When data type's byte QTY is over 2 bytes, it will have word order endian parameter. |
| • | Word Order — It is visible when Register data type is "uint32, int32, single". It tells system words order : Big-endian or Little-endian. |
| • | Value Factor for integer data type when reg and In port "Data" have different type — It can be "1x, 10x, 100x, and 1000x". We will explain meaning in parameter "In-Port Data type:" below. |
| • | In-Port "Data" type: — It can be "uint16, int16, uint32, int32 and single (4 bytes float)". The embedded firmware translates input port "Data" to Modbus holding register data. When input port "Data" is data type of "single" (4 bytes float) and Modbus holding register data type is "uint16 or int16 or uint32 or int32", Modbus holding register data value will be input port "Data" value times "Value factor" and then round it to integer. For example, input port "Data"=[2.35 5.8], holding register data value will be [24 58] if Value Factor is 10x. |
Similarly, When input port "Data" is data type of "uint16 or int16 or uint32 or int32" and Modbus holding register data type is "single", Modbus holding register data value will be input port "Data" value ÷ "Value factor" . For example, input port "Data"=[278 -567], holding register data value will be [2.78 -5.67] if Value Factor is 100x.
| • | Sample time in sec (-1 for inherited): — Sample time for this block. It is the same meaning as general Simulink block . |
Ports
Input
| • | StartAddr — "uint16" data type's scalar. It is Modbus Server holding registers' start address (1-based without prefix "4X"). It must be from Constant block or from "emProbe" output because both PC side and embedded side must know its value. |
| • | Data — Scalar or Vector. Data type is decided by parameter "In-Port 'Data' type". It is equal to input port Data. |
Outport
| • | Ok — "logical" data type's scalar. In PC side, it denotes whether communication between PC and Target is OK. In embedded target side, it denotes whether holding register range you read is valid. |
| • | Data — Scalar or Vector. Data type is decided by parameter "In-Port 'Data' type". It is holding register data source. |
Examples
|