Hello,
I’m using the modbus RTU with the X20CS1030 to connect to up to 5 devices and read information from them.
I want to read the information from one device at a time so I have created a state machine where I read the information from the first one, after the reading has done I enable the reading of the second one and so on.
To do that I’m using the MBMaster FB but I cannot understand 100% its functionality:
- how the output “recordnum” is calculated? (In the help it’s: “Number of the entry in the data object currently being processed”)
- the “exectute” output should go TRUE when the FB has completed the command given (“Command executed (execute = 1)”) and I saw that the command given is automatically reset. But what I see is that the reading is not completed when the “execute” is true.
What I could state is that the reading is completed when the recordnum reaches the maximum value (all records read) and it is reset to zero. Only in that case I’m sure that the reading has been completed and I can use the values read.
So my process is:
- activate the reading command in the dataobject,
- if execute goes true, force again the reading command and go to the next step
- wait for the recordnum to reach the maximum value
- reset the command.
Do you have any other ideas on how to use this FB properly?
Probably I should use MBMCmd()…
Thank you
Andrea