emModbusSlaveWriteHoldings | Top Next

emModbusSlaveWriteHoldings Embedded Modbus Server receives holding register writing value. Since R2019b Library: embeddedCreatorLib ( Dafulai Electronics) / Modbus Slave & Debugger / emModbusSlaveWriteHoldings Description For embedded target side, this block will receive my Modbus server holding register writing value and embedded target gets data only from this block's Output Data. Block's input port Data is only for PC side to send Holding register data 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.
• | Uart No (In case 2 or 2+ Uarts with the same Server ID) — It is Uart Number Modbus Server uses. This is only used in one Server ID for more different Uarts. In this situation, you cannot connect these 2 or more nodes into one Modbus network because node Sever ID must be unique in one Modbus network.
• | Holding 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 out-port "Data" have different type — It can be "1x, 10x, 100x, and 1000x". We will explain meaning in parameter "out-Port Data type:" below.
• | Use Single holding Reg writing — It will use FC=06 (Single writing holding reg) to replace FC=16 (Multiple writing holding registers).
• | Out-Port "Data" type: — It can be "uint16, int16, uint32, int32 and single (4 bytes float)". The embedded firmware translates Modbus holding register data to output port "Data". When Out 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. And output port "Data" value will be Modbus holding register data value ÷ "Value factor". For example, input port "Data"=[2.35 5.8], holding register data value will be [24 58] and output port "Data"=[2.4 5.8] if Value Factor is 10x.
Similarly, When output 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. But output port "Data" value is Holding register value times "Value factor". For example, input port "Data"=[2.78 -5.67], holding register data value will be [2.78 -5.67], output port "Data" value is [278 -567] 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. Don't care Data type. We only care the size of vector in embedded target. It decides how many items in unit " Holding register data type" will be written. And the value of this input port will be written to target holding registers with/without factor from PC Debug/monitor. If holding registers data type is single, Input port Data value will be written to holding registers. However, if holding registers data type is "uint16/int16/uint32/int32" and output port data type is "single, Input port Data value times parameter factor will be written to holding registers.
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 "Out-Port 'Data' type". It is from holding register data, and may or may not apply "Value factor". Please see parameter "out-Port Data type:" for details.
Examples