Modbus: Reset value at Communication Error



  • Hi

    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?

    Thanks


  • administrators

    Hi @dickesc,
    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:

    0_1563460736405_6a8e4e53-2944-49f0-9c3e-545fe6350972-image.png

    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.

    Best regards,
    Martin



  • Hi

    Thanks, works perfectly!