Modbus: association between slaves & master

Hello,

How can I associate multiple slaves to one master?

mySerialMaster  : FbMbMasterSerial := 

( xConnect    := TRUE,
udiBaudrate := 9600,
usiDataBits := 8,
eParity     := WagoTypesCom.eTTYParity.Even,
eStopBits   := WagoTypesCom.eTTYStopBits.One,
eHandshake  := WagoTypesCom.eTTYHandshake.None,
ePhysical   := WagoTypesCom.eTTYPhysicalLayer.RS485_HalfDuplex,
eFrameType  := eMbFrameType.RTU,
tTimeOut    := T#2000MS
);

utQuery         : typMbQuery := 

(   bUnitId         := 1,       // Slave address e43
bFunctionCode   := 16#04,   // read input registers
uiReadAddress   := 50514,       // Start address
uiReadQuantity  := 10,      // Quantity of wanted registers
uiWriteAddress  := 0,       // not needed for FC4
uiWriteQuantity := 0,       // not needed for FC4
awWriteData     := [124(0)] // not needed for FC4
);

utQuery2        : typMbQuery := 

(   bUnitId         := 10,       // Slave address e33
bFunctionCode   := 16#04,   // read input registers
uiReadAddress   := 50514,       // Start address
uiReadQuantity  := 10,      // Quantity of wanted registers
uiWriteAddress  := 0,       // not needed for FC4
uiWriteQuantity := 0,       // not needed for FC4
awWriteData     := [124(0)] // not needed for FC4
);

utQuery3        : typMbQuery := 

(   bUnitId         := 21,       // Slave address e34
bFunctionCode   := 16#04,   // read input registers
uiReadAddress   := 50514,       // Start address
uiReadQuantity  := 10,      // Quantity of wanted registers
uiWriteAddress  := 0,       // not needed for FC4
uiWriteQuantity := 0,       // not needed for FC4
awWriteData     := [124(0)] // not needed for FC4
);

xTxTrigger      : BOOL;             (* Set this variable once to start a job.
                                       This variable will be automatically reset by the master
                                       when the job is completed.
                                    *)

utResponse      : typMbResponse;    (* After the job is completed, you can find the result
                                       in this structure.
                                    *)

tonDelay        : TON := (PT := T#20MS); // This is the silence time between two requests
//— delay between two requests ----------------------
tonDelay( IN := (NOT tonDelay.Q) AND (NOT xTxTrigger));
//xTxTrigger S= tonDelay.Q; // trigger the next request

//— call cyclic the master --------------
mySerialMaster( I_Port      := myserialport,        // my serial port
utQuery     := utQuery,
xTrigger    := xTxTrigger,
utResponse  := utResponse
);

I would like to associate the 3 slaves: utQuery, utQuery2, utQuery3 with the master mySerialMaster

Thank you for your help

Hi,

see here:

It’s for Modbus TCP, but it’s similar with RTU.

Hi,
I used Digital Twins for that purpose. Here is an example.

I tested it the RS-485 on a CC100 as well and it worked.

Cheers xxyzz