Hi,
i did take a look at the code concerning the modbus errors.
Here my picture as far as i read the code:
- All modbus variables are handled by devices.
- The variables assigned to an device are read / written by an own task.
- The task uses bulk commands to read / write the registers of the modbus server.
- The task takes care of communication errors and sets the error flag for the device accordingly.
The conclusion is:
Since the modbus vars are read/written with bulk commands, there is no chance to generate a sperate errorflag for each modbus var. Due to the bulk commands the task is just not able to determin, if the value stored in the var is correct. This has to be handled by a separate logic in the device connected by modbus itself.
Now the isue is, that using a modbus var with an outdated value or outputs not written might have bad consequences for the application. To separate the management of devices and adressing from the logic itself, it is necessary to be able to get the error flag set in the device by just using the var defined in a programm.
I'm aware that this is a double-edged sword, since it should be from any interest where the value workded with comes from in a pure plc. So the question is, if there already is a way to solve this?
One solution, i could imagine, is to create a modbus var on the connected device that contains the actual timestamp and assing it to a var on the plc. This var then could be used to determin if the stored values are valid anymore. I'm not sure if this would be the best practice, since the allocation of inputs / outputs has to be taken in account by the program itself.
Any hints / thoughts about the ideas would be appreciated. Thanks in advance...
Best regards
Gregor