How to detect when a Modbus value becomes stale?

I have a simple flow (pasted below, screenshot as well) that grabs Modbus data for a variable frequency drive (VFD) every 30 seconds via Modbus-TCP. Works great, however...

Yesterday we saw this in Influx:

We have since confirmed via our electrical usage data that the VFD was OFF (for reasons that are unknown at the moment). The problem is that Node-RED seems to have retained the last known value (62.93, taken about 15:52) and kept sending that value to InfluxDB until the VFD came back online about 21:20. This appears as a flat line at 62.93, but we really expected to see 0.

Is there a clever way for me to prevent this "stale" value from being sent to InfluxDB? I do not have Node-RED logs for this period shown.

[{"id":"8a7d4c278f437686","type":"modbus-read","z":"9cb29d33.c5004","name":"Read Data on 30 Quench Pump VFD","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"255","dataType":"HoldingRegister","adr":"200","quantity":"3","rate":"30","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"d99cd9271877f6fc","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":230,"y":1460,"wires":[["f480dd6ce0645ebe"],[]]},{"id":"f480dd6ce0645ebe","type":"function","z":"9cb29d33.c5004","name":"","func":"msg.payload = [\n    [{\n        RotationalSpeed: msg.payload[0]/100,\n    },\n    {\n        MeasType:\"setpoint\",\n        EquipElement:\"quenchpump\",\n        EquipNumber:\"30\"\n    }],\n    [{\n        ElectricalCurrent: msg.payload[1]/100,\n    },\n    {\n        MeasType:\"actual\",\n        EquipElement:\"quenchpump\",\n        EquipNumber:\"30\"\n    }],\n    [{\n        ElectricalVoltage: msg.payload[2]/10,\n    },\n    {\n        MeasType:\"actual\",\n        EquipElement:\"quenchpump\",\n        EquipNumber:\"30\"\n    }]\n];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":1460,"wires":[["25a2db017b2ae3ed"]]},{"id":"25a2db017b2ae3ed","type":"influxdb out","z":"9cb29d33.c5004","influxdb":"a5483d9bc0c8a1db","name":"Influx","measurement":"DoubleRotaryFurnaceElementData","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"heattreat","bucket":"AMPdata","x":850,"y":1460,"wires":[]},{"id":"d99cd9271877f6fc","type":"modbus-client","name":"Mitsubishi 30HP VFD for #30 Quench Pump","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"a5483d9bc0c8a1db","type":"influxdb","hostname":"","port":"8086","protocol":"http","database":"database","name":"","usetls":false,"tls":"","influxdbVersion":"2.0","url":"","rejectUnauthorized":false}]

No, InfluxDB just connects the valid data points.
If you look at the raw data you will understand. It's not node-red sending the value repeatedly.

Thanks @ghayne . Looking at my raw data in InfluxDB (excerpt below) indicates the stale value (62.93) was being populated every 30 sec., beginning about 19:48:54.21. Given my simple flow, I have to believe InfluxDB was getting this value from Node-RED repeatedly.

_time _value
2022-07-19T19:45:24.21Z 63.14
2022-07-19T19:45:54.212Z 63.03
2022-07-19T19:46:24.209Z 63.01
2022-07-19T19:46:54.213Z 62.93
2022-07-19T19:47:24.21Z 63.01
2022-07-19T19:47:54.211Z 62.95
2022-07-19T19:48:24.209Z 62.88
2022-07-19T19:48:54.21Z 62.93
2022-07-19T19:49:24.212Z 62.93
2022-07-19T19:49:54.209Z 62.93
2022-07-19T19:50:24.209Z 62.93
2022-07-19T19:50:54.212Z 62.93
2022-07-19T19:51:24.211Z 62.93
2022-07-19T19:51:54.209Z 62.93
2022-07-19T19:52:24.21Z 62.93
2022-07-19T19:52:54.212Z 62.93

Looks like you will have to find a way of detecting "stale" values then. The graph would however, still look the same :slight_smile:

Is there no way to check for valid data within the Modbus node?

I can set up an alert / alarm in Influx or Grafana to detect this sort of "value cannot repeat more than n times" situation. But I prefer to do it in Node-RED. For the modbus-read node that I am using, I do not see any way for the node to check for valid data. It just seems to keep sending the value that was reported as soon as the VFD shut down. I was thinking some sort of additional node to check for a repeating value of say, 5 times (or 2.5 minutes of the same value, which should never happen). I could then send out an alert or something, or send a null value to Influx (which would then be detectable in Grafana).

Have a look at the filter node!

Do you mean that the VFD was powered down, but the modbus node kept providing data?
You said that you were not sure what was going on at that time, are you sure it was actually powered down rather than not driving the connected system (hence no power usage) but in some fault mode where it was still saying, via modbus, that it was going? If you want to check it then power the drive down and see what happens. The modbus node should go into a fail state when the device is powered down.

[Edit] Or could it be something like the thing being driven had no power, but the VFD was still powered and thought that the drive was still going?

@Colin So at this point, the details are still a bit sketchy, but acc. to one of the few people working when this happened, he saw a code on the VFD that said began with "E", but that could be a lot of things....

We are fairly certain that:

  1. The VFD was never powered down during any part of the time window where it appears flat-lined
  2. The motor (which turns a pump) was almost certainly not running during this time window, because our plant-wide electricity dropped by nearly the exact amount of kwH that the VFD/motor uses.

We also noticed that the voltage increased from ~185V to ~188V about 2 hours before the unit went off. The temperature in the plant was hot at that time (about like London yesterday, although we are nowhere near there).

We will do as you suggest, i.e. power down the drive and see what the Modbus node transmits. At this point, I believe the VFD was powered up, but not driving the connected system (hence no power usage) and in some fault mode where it was still saying, via modbus, that it was going. Maybe we can use the Modbus register to detect this condition in the future.

If the VFD keeps reporting a good value via modbus there is not much you can do in node-red, unless, for example, you could use the fact that it is absolutely constant for a while as a fault indicator.

Possibly one of the modbus registers indicates the health of the system in some way that you could use to know that a fault has occurred.

Otherwise, if it is important that you know whether the pump was actually turning or not, then connect a sensor of some sort that tells you that. A pressure sensor measuring what is being pumped, or a current sensor checking the power being drawn, or an electromechanical device of some sort that indicates rotation, for example.

Thank you, those are all very good paths to follow. I am going to try to alarm if/when the electrical current value flatlines (probably using an Influx query in Grafana's new alerting system), or use the RBE node, or both. We do not have any digital pressure sensors or flow meters, but am sure getting something simple installed would not break the bank.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.