readMyHoldings

Top 

readMyHoldings


read Modbus Server Read-write Holding register value

Since R2019b

 

Library: Modbus Server ( Dafulai Electronics) /readMyHoldings

 

readMyHolding

 

 


 

Description


 

This block reads Read-Write Holding register value. Start Address is from Input port "StartAddr" (1-based address without 4x prefix), Read Quantities are from Input port "QTY in Spec DT". However this Quantities is in unit of Destination Data type.  For example, if Destination  Data type is "uint32", and  Input port "QTY in Spec DT" is 5.  Actually the words Quantities will be 5 x 2 =10. (From "StartAddr" to "StartAddr"+9)

 

Those Read-Write Holding register values are controlled by "Outside Modbus Master",  Simulator cannot control these values except Read-Write watchdog and watchdog type=1 or 2

 

If any error (CRC, Timeout, Not supported FC, address range,....) occurs,  Outport "Data" will return "Empty"

 

Parameters


 

Please double click this block to open parameters dialog below:

 

readMyHoldingParam

 

 

Let us explain parameters.

 

 

Object ID for multiple Modbus slave Simulator Hardware — In one PC, we may use multiple Modbus slave simulators, this is for identifying each one.

 

Word Order —  It denote the words order when register data type is "uint32/int32/single/uint64/int64/double".

 

Data type — Specifies the data format of the register being read from on the Modbus server. It is not Data type of output port "Data".  The data type of output port "Data" is always "double".

 

Which device? (Only for RTU/ASCii)  — This is useful for Modbus RTU/ASCii useful.  it denotes which device we read from. For Modbus TCP Server, just ignore it.

 

 

 

Ports


 

Input

 


 

StartAddr — "double" data type's scalar. It is holding Regs start address (1 based without 4X prefix) you want to read.

 

QTY in Spec DT — "double" data type's scalar.  It is Holding Regs QTY you want to read in specified data type in parameter "Data type".

 

 

Outport


 

Data — "double" data type's vector. It is all Data you read out. If  we didn't read out any data, the output port Data will become empty

 

 

Examples


 

Example:

 

Every 500ms (Wait 0.5 sec block), We are reading read-write holding registers address from 1 to 3 of Modbus RTU Server Device1.

 

 

example1_readholding

 

Please open "your Modbus Server library folder"/examples/example1_readHolding.slx  (You must change USB serial Port number in CAN_setup block according to your physical USB port number).

 

For "Modbus Server Setup" block,  the parameters are set up below:

 

exampl1_setupParm

 

 

For "Read Holding 1 to 3 " block,  the parameters are set up below:

 

 

example1_readHolding_Parm

 

You can run general Modbus master software such as Modbus Poll or ModScan32 to change Holding registers values addressing 1 to 3, you will see its result in Simulink Display block.