Modbus: Reset value at Communication Error
I am reading some values from a modbus power meter (e.g. active power in watts)
Everything fine so far.
But i have a little problem:
If the power of the power meter fails, mervis gets a communication error.
The PLC value stays at the last value read from the power meter.
How can i "reset" this value to "0" if there is a communication error?
simply - you cannot. But I think you are trying to somehow get the information about the failed communication, is that correct?
If so, each Modbus group of elements has so called "attributes", which are special variables, which for example tell you when the last communication occured, and what is the last state of the communication exchange:
What you are probably looking for is the _commerror variable. When true, the current value in all the elements is not correct, since the communication is broken. If false, the values are correct.
Include this _commerror variables into your program to detect and work around the communication errors.
Thanks, works perfectly!