Modbus RTU
Hello all,
I need to stablish a Modbus RTU RS485 communication with various devices, being the AXC F 2152 with an Axioline AXL SE RS485 the Master.
I'm reading the documentation of the Modbus RTU library and trying to assembly an example program to see how i'm going to do it once i get to the real project, i still dont have the hardware so i can't really try it.
My questions are the next:
Being the PLC the master, if i want to read for example holding registers from a certain slave, according to the docs i would just use the MB_RTU_FC3, assign the correct parameters and i would start receiving data from that device right?
If i want then to read from another slave, and i add another time this MB_RTU_FC3, do i need to use another udt variable for the arrReadData and udtMbData variables in this one? Or are the same from the other FC? I guess for the arrReadData should be a different one if i dont want that data to get lost from one slave read to the other one, but for the udtMbData i'm not so sure, in the docs it says:
"The block communicates via this structure with the FC Blocks"
This make me think it could be the same one for all the blocks that i use in the program.
Could you send me some help with this?
Thank you very much in advance!
Kind Regards,
Nacho
I need to stablish a Modbus RTU RS485 communication with various devices, being the AXC F 2152 with an Axioline AXL SE RS485 the Master.
I'm reading the documentation of the Modbus RTU library and trying to assembly an example program to see how i'm going to do it once i get to the real project, i still dont have the hardware so i can't really try it.
My questions are the next:
Being the PLC the master, if i want to read for example holding registers from a certain slave, according to the docs i would just use the MB_RTU_FC3, assign the correct parameters and i would start receiving data from that device right?
If i want then to read from another slave, and i add another time this MB_RTU_FC3, do i need to use another udt variable for the arrReadData and udtMbData variables in this one? Or are the same from the other FC? I guess for the arrReadData should be a different one if i dont want that data to get lost from one slave read to the other one, but for the udtMbData i'm not so sure, in the docs it says:
"The block communicates via this structure with the FC Blocks"
This make me think it could be the same one for all the blocks that i use in the program.
Could you send me some help with this?
Thank you very much in advance!
Kind Regards,
Nacho
Comments
Here is the answer from the PLCnext Engineer support team:
You have to use array of slaves addresses and variable, for iteration over this array.
Also you have to use MB_RTU_FC3.xDone(xError) output to initiate response processing function of arrReadData binded to iteration variable value, and cyclically iterate slave address by rising positive trigger.
MB_RTU_FC3_1(
xActivate := your_var,
xSendRequest := False,
xEnablePoll := TRUE,
tPollInterval := T#250ms,
uiSlaveAddress := MB_Slave[iter].Addr,
uiStartAddress := MB_Slave[iter].Reg,
iDataCount := MB_Slave[iter].Cnt,
//xActive => BOOL,
//xBusy => BOOL,
//xDone => BOOL,
//xError => BOOL,
//arrReadData := arrModbus2_W_1_125,
udtMbData := udtModbus2_Data);
IF MB_RTU_FC3_1.xDone THEN
DEV_DATA[iter] := MB_RTU_FC3_1.arrReadData;
END_IF;
IF MB_RTU_FC3_1.xDone or MB_RTU_FC3_1.xError THEN
iter := (iter + 1) mod 24;
END_IF;