Addresses Scan -modbus RTU 11

Hello everyone,
I need some advice on how to pass the addresses contained in an Array, defined as List_Address 0…16, to the FC3 block of the MOD RTU 11 library.
Addresses are inside the „List_Address“ array. I created a for loop that scans the array from 0 to 16 and if the answer is positive it goes to the next address. But I need to stop the for loop, long enough for it to get the response from block FC3.
Thanks for your help .

Hello Rufus,
what exactly is the problem then?
You will have to use multiple cycles if you wisth to read multiple times using FC3.
(You could just read a range of registers thou.)
Or another instance of the FB.
Its not possible to specify which Registers to read only startpoint and datacount.
So you will have to filter the read data after you have read them.

Stoping the loop is definitly not the way to go you have to Read values in one cycle and process the data in the next.
Only at the end of a cycle are data transfered to the BUS.

Hi Oliver , thanks for replay.
Well, the problem is not in reading the registers, the registers are defined from 0 to 123, for all devices connected in modbus 485. I need to interrogate the devices connected in my modbus 485 network sequentially, after receiving the feedback response from the FC3 block.

for example my modbus network is made up of 10 devices:
address slave: 2, 4, 6, 8, 10, 12, 14, 16, 18, 20.

I need to pass these 10 addresses sequentially, the slave address variable will change the slave address on the FC3 block only after receiving a TRUE response from the device.

fc3 block.PNG
I tried to do this, when the pooling flag is true, it assigns the first address contained in the LIST_Address array to the FC3 BLOCK
if the response is true then go to the second address, and so on…
CODE.PNG

Try this method, in pseudo-code…
//START INIT. Define your address pool
MB_ADDR_ARR := [2, 4, 6, 8, 10, 12, 14, 16, 18, 20];
idex := 0;
//END INIT

// Calling of main MB function
MB_AXL_SE_RS485_Master_41.uiSlaveAdress := MB_ADDR_ARR[index];
MB_AXL_SE_RS485_Master_41(„Your FB settings“);
//Process response. Both success and fault. You don’t have to stop if fault, I think.
IF MB_AXL_SE_RS485_Master_41.xDone OR MB_AXL_SE_RS485_Master_41.xError THEN
( „Your additional response process FB’s“)
index := (index + 1) MOD 10; // Make cycle to iterate over address pool
END_IF;

Hello Rufus,</p>what exactly is the problem then?</p>You will have to use multiple cycles if you wisth to read multiple times using FC3.</p>(You could just read a range of registers thou.)</p>Or another instance of the FB.</p>Its not possible to specify which Registers to read only startpoint and datacount.</p>So you will have to filter the read data after you have read them.</p>Stoping the loop is definitly not the way to go you have to Read values in one cycle and process the data in the next.</p>Only at the end of a cycle are data transfered to the BUS.</p>

I am amazed by the solution … if I have to interrogate 128 devices, what do I do 128 reading blocks ?? it seems like a very basic solution.

Try this method, in pseudo-code…</p>//START INIT. Define your address pool</p>MB_ADDR_ARR := [2, 4, 6, 8, 10, 12, 14, 16, 18, 20];</p>idex := 0;</p>//END INIT</p>// Calling of main MB function</p>MB_AXL_SE_RS485_Master_41.uiSlaveAdress := MB_ADDR_ARR[index];</p>MB_AXL_SE_RS485_Master_41(„Your FB settings“);</p>//Process response. Both success and fault. You don’t have to stop if fault, I think.</p>IF MB_AXL_SE_RS485_Master_41.xDone OR MB_AXL_SE_RS485_Master_41.xError THEN</p> ( „Your additional response process FB’s“)</p> index := (index + 1) MOD 10; // Make cycle to iterate over address pool</p> END_IF;</p>

Thanks man , it is seem similar my solution, i try this.

thanks all.