emModbusMasterWrite | Top Next

emModbusMasterWrite embedded Modbus Master writing registers Since R2019b Library: embeddedCreatorLib ( Dafulai Electronics) / Embedded Modbus Master / emModbusMasterWrite Description This block sends writing register command to a modbus server or a group of modbus servers. You can only send command when modbus master "idle". So input port "En" must connect block "isMB_Idle" output port. Parameters Please double click this block to open parameters dialog below: Let us explain parameters.
• | Server IDs — Scalar or Vector. It is Modbus server ID or called Server address. Modbus master will write to devices with these Server IDs. Value range is 0 to 247. 0 means "broadcast" writing ( write to all nodes in the Modbus network)
• | Command Seq No — drop list from 1 to 15 which is sequence Number in tab "Write Command Seqs" of block "emModbusMasterSetup". The big sequence number has low writing priority. All writing commands have higher priority than reading commands.
• | Write Operation type — It is selected automatically from block "emModbusMasterSetup" according to "Command Seq No". If you want to change it, please modify in block "emModbusMasterSetup". It can be one of "Single-Write-holding"/ "Multiple-Write-holdings" / "Single-Write-coil" / "Multiple-Write-coils" / "Mask-write-holding".
• | Word-Endian when multiple Words — drop list from "Big-endian" and "Little-endian". When writing data is dual words, it tell us word's endian.
Ports Input
• | En — "logical" data type's scalar. Only when it is true will this block executes writing function. So "En" generally connects output port of block "isMB_Idle" in order to make sure writing only when Modbus master is in "Idle" state.
• | StartAddr — "uint16" data type's scalar. It is Modbus Server registers' start address (1-based without prefix "4X","0X"). 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 can be "uint8/int8/uint16/int16/uint32/int32/single" when register is holding or "logical" when register is coil. If data type is uint8 or int8, one data will occupy 16 bits of holding register.
Outport
• | Done — "logical" data type's scalar. It denotes whether communication between PC and Target has finished. "Done" does not mean success. It may success or fail.
• | Success — "logical" data type's scalar. It denotes whether writing success. If you write to multiple servers in one sequence, true means writing to all servers success in this sequence. Any server failed will cause Output port "Success" to be false. In one sequence of writing for multiple servers situation, if you want to know every server operation success or fail, please use block "isMB_WriteOK". It will give you detail.
Examples