I was looking for a good simple way to read the scratchpad of a RIO through Node-RED. Searching the forums I found the following post:
Well the RIO doesn’t have a control engine, so I ended up using good old trusty Modbus with the node-red-contrib-modbus nodes. This would work with a PAC as well over the network, but you would need to use PAC Manager to lookup the Unit ID and address to use (or calculate it yourself).
Here is how I read a float value from the scratchpad using Node-RED:
In groov manage look up the Modbus Unit ID and Address for the 0th float element:
Unit ID is 110, address is 4096.
In Node-RED I dropped a Modbus-Read node on the flow and configured it as follows (Floats are 4 bytes so we need to read 2 16 bit registers):
The “Server” configuration node is setup as localhost and using the default port on the RIO for modbus which is 8502 (A PAC would be just 502 and the host would be the hostname or IP address of the PAC):
I left the other settings at the defaults.
const buf = Buffer.from(msg.payload.buffer); msg.payload.float = buf.readFloatBE(); return msg;
Now msg.payload.float will have the value from the first float scratchpad element.