So I have had some success using the previously referenced method combined with the following:
https://discourse.nodered.org/t/modbus-tcp-read-32-bit-registers/1710/2
I am getting a lot of:
"Error: FSM Not Ready To Read At State STOPED"
errors, but I am assuming that is because I am not using the best method for multiple connections to the device. I will work on that, but I wanted to ask why I may be getting some variation in the output valves from what the unit display shows? For example for Load and Rate the values are right on. Load = 59 on display and 59 in Node-Red & Rate = 708 on scale display and 708 in Node-Red. However, the scale displays a totalizer value of say 16371 but Node-Red will show 16320. The Master Total on the scale is 760983 but is - 757760 in Node-Red. Is this a data type error I am not getting correct?
[{"id":"a20a0c7a.58aa5","type":"ping","z":"63c544b0.377b7c","name":"","host":"10.81.210.83","timer":"20","x":250,"y":240,"wires":[["e97704a0.3adae8"]]},{"id":"e97704a0.3adae8","type":"debug","z":"63c544b0.377b7c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":510,"y":240,"wires":[]},{"id":"d6a068f.01b6898","type":"modbus-write","z":"63c544b0.377b7c","d":true,"name":"","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"MHoldingRegisters","adr":"1025","quantity":"2","server":"ed8ff803.7cd708","x":460,"y":360,"wires":[["668471ed.2d32a"],[]]},{"id":"b1e1b014.baf61","type":"inject","z":"63c544b0.377b7c","name":"","topic":"","payload":"[17538,17538]","payloadType":"bin","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":320,"wires":[["d6a068f.01b6898"]]},{"id":"668471ed.2d32a","type":"debug","z":"63c544b0.377b7c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":750,"y":320,"wires":[]},{"id":"7f5cb91.df46848","type":"modbus-write","z":"63c544b0.377b7c","d":true,"name":"","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"MHoldingRegisters","adr":"1025","quantity":"2","server":"ed8ff803.7cd708","x":460,"y":440,"wires":[["2390cec6.bdce12"],[]]},{"id":"46958a85.ac4544","type":"inject","z":"63c544b0.377b7c","name":"","topic":"","payload":"[0,16]","payloadType":"bin","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":400,"wires":[["7f5cb91.df46848"]]},{"id":"2390cec6.bdce12","type":"debug","z":"63c544b0.377b7c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":750,"y":400,"wires":[]},{"id":"6c9c8574.63a2fc","type":"modbus-write","z":"63c544b0.377b7c","d":true,"name":"","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"MHoldingRegisters","adr":"1025","quantity":"2","server":"ed8ff803.7cd708","x":460,"y":520,"wires":[["ee6b150c.635258"],[]]},{"id":"4df7ae5.022845","type":"inject","z":"63c544b0.377b7c","name":"","topic":"","payload":"[16]","payloadType":"bin","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":480,"wires":[["6c9c8574.63a2fc"]]},{"id":"ee6b150c.635258","type":"debug","z":"63c544b0.377b7c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":750,"y":480,"wires":[]},{"id":"d57488d2.ba1848","type":"function","z":"63c544b0.377b7c","name":"IEEE-754 to float","func":"/* Converts from an number, string, buffer or array representing an IEEE-754 value\n * to a javascript float.\n * The following may be given in msg.payload:\n * A string representing a number, which may be hex or binary\n * examples, \"1735\" \"0x02045789\" 0b01000000010010010000111111011011\n * An integer value\n * A four element array or buffer of 8 bit values, most significant byte first.\n*/ \n// first make a number from the given payload if necessary\nlet intValue;\nif (typeof msg.payload === \"number\") {\n intValue = msg.payload;\n} else if (typeof msg.payload === \"string\") {\n intValue = Number(msg.payload);\n} else if (msg.payload.length == 2) {\n // four byte array or buffer\n intValue = (msg.payload[0] << 8) + msg.payload[1]; //) << 8) + msg.payload[2]) << 8) + msg.payload[3];\n} else {\n node.warn(\"Unrecognised payload type or length\");\n}\n\nmsg.payload = Int2Float32(intValue);\nreturn msg;\n\nfunction Int2Float32(bytes) {\n var sign = (bytes & 0x80000000) ? -1 : 1;\n var exponent = ((bytes >> 23) & 0xFF) - 127;\n var significand = (bytes & ~(-1 << 23));\n\n if (exponent == 128) \n return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);\n\n if (exponent == -127) {\n if (significand === 0) return sign * 0.0;\n exponent = -126;\n significand /= (1 << 22);\n } else significand = (significand | (1 << 23)) / (1 << 23);\n\n return sign * significand * Math.pow(2, exponent);\n}","outputs":1,"noerr":0,"x":810,"y":800,"wires":[["b583499a.503808"]]},{"id":"b583499a.503808","type":"debug","z":"63c544b0.377b7c","name":"Load","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1250,"y":1000,"wires":[]},{"id":"8c6d5df6.63056","type":"function","z":"63c544b0.377b7c","name":"Convert byte array to SIGNED 32-bit integer","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer);\n\n// Represent these bytes as 32-bit unsigned int\nconst value = buf.readInt32BE();\n\n// save the value\nmsg.payload = value;\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":800,"wires":[["d57488d2.ba1848"]]},{"id":"17188367.3d45cd","type":"modbus-read","z":"63c544b0.377b7c","name":"Read 920i Load","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"5","quantity":"2","rate":"3","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"ed8ff803.7cd708","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":160,"y":740,"wires":[["8a2b1e23.32eef"],["8c6d5df6.63056"]]},{"id":"8a2b1e23.32eef","type":"modbus-response","z":"63c544b0.377b7c","name":"","registerShowMax":20,"x":450,"y":740,"wires":[]},{"id":"e0b09a1a.0e54c8","type":"catch","z":"63c544b0.377b7c","name":"","scope":null,"uncaught":false,"x":120,"y":1560,"wires":[["46b17d7b.9d7fa4"]]},{"id":"46b17d7b.9d7fa4","type":"debug","z":"63c544b0.377b7c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":340,"y":1600,"wires":[]},{"id":"4f438621.5569e8","type":"function","z":"63c544b0.377b7c","name":"IEEE-754 to float","func":"/* Converts from an number, string, buffer or array representing an IEEE-754 value\n * to a javascript float.\n * The following may be given in msg.payload:\n * A string representing a number, which may be hex or binary\n * examples, \"1735\" \"0x02045789\" 0b01000000010010010000111111011011\n * An integer value\n * A four element array or buffer of 8 bit values, most significant byte first.\n*/ \n// first make a number from the given payload if necessary\nlet intValue;\nif (typeof msg.payload === \"number\") {\n intValue = msg.payload;\n} else if (typeof msg.payload === \"string\") {\n intValue = Number(msg.payload);\n} else if (msg.payload.length == 2) {\n // four byte array or buffer\n intValue = (msg.payload[0] << 8) + msg.payload[1]; //) << 8) + msg.payload[2]) << 8) + msg.payload[3];\n} else {\n node.warn(\"Unrecognised payload type or length\");\n}\n\nmsg.payload = Int2Float32(intValue);\nreturn msg;\n\nfunction Int2Float32(bytes) {\n var sign = (bytes & 0x80000000) ? -1 : 1;\n var exponent = ((bytes >> 23) & 0xFF) - 127;\n var significand = (bytes & ~(-1 << 23));\n\n if (exponent == 128) \n return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);\n\n if (exponent == -127) {\n if (significand === 0) return sign * 0.0;\n exponent = -126;\n significand /= (1 << 22);\n } else significand = (significand | (1 << 23)) / (1 << 23);\n\n return sign * significand * Math.pow(2, exponent);\n}","outputs":1,"noerr":0,"x":810,"y":960,"wires":[["190d3f03.1929c1","b583499a.503808"]]},{"id":"190d3f03.1929c1","type":"debug","z":"63c544b0.377b7c","name":"Rate","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1270,"y":1100,"wires":[]},{"id":"489f383e.5ab538","type":"function","z":"63c544b0.377b7c","name":"Convert byte array to SIGNED 32-bit integer","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer);\n\n// Represent these bytes as 32-bit unsigned int\nconst value = buf.readInt32BE();\n\n// save the value\nmsg.payload = value;\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":960,"wires":[["4f438621.5569e8"]]},{"id":"69db4071.2903e","type":"modbus-read","z":"63c544b0.377b7c","name":"Read 920i Rate","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"7","quantity":"2","rate":"3","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"ed8ff803.7cd708","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":160,"y":900,"wires":[["2796f80e.7d8af8"],["489f383e.5ab538"]]},{"id":"2796f80e.7d8af8","type":"modbus-response","z":"63c544b0.377b7c","name":"","registerShowMax":20,"x":450,"y":880,"wires":[]},{"id":"346fc1e.e5bf13e","type":"function","z":"63c544b0.377b7c","name":"IEEE-754 to float","func":"/* Converts from an number, string, buffer or array representing an IEEE-754 value\n * to a javascript float.\n * The following may be given in msg.payload:\n * A string representing a number, which may be hex or binary\n * examples, \"1735\" \"0x02045789\" 0b01000000010010010000111111011011\n * An integer value\n * A four element array or buffer of 8 bit values, most significant byte first.\n*/ \n// first make a number from the given payload if necessary\nlet intValue;\nif (typeof msg.payload === \"number\") {\n intValue = msg.payload;\n} else if (typeof msg.payload === \"string\") {\n intValue = Number(msg.payload);\n} else if (msg.payload.length == 2) {\n // four byte array or buffer\n intValue = (msg.payload[0] << 8) + msg.payload[1]; //) << 8) + msg.payload[2]) << 8) + msg.payload[3];\n} else {\n node.warn(\"Unrecognised payload type or length\");\n}\n\nmsg.payload = Int2Float32(intValue);\nreturn msg;\n\nfunction Int2Float32(bytes) {\n var sign = (bytes & 0x80000000) ? -1 : 1;\n var exponent = ((bytes >> 23) & 0xFF) - 127;\n var significand = (bytes & ~(-1 << 23));\n\n if (exponent == 128) \n return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);\n\n if (exponent == -127) {\n if (significand === 0) return sign * 0.0;\n exponent = -126;\n significand /= (1 << 22);\n } else significand = (significand | (1 << 23)) / (1 << 23);\n\n return sign * significand * Math.pow(2, exponent);\n}","outputs":1,"noerr":0,"x":810,"y":1140,"wires":[["16656812.be00a8","b583499a.503808"]]},{"id":"16656812.be00a8","type":"debug","z":"63c544b0.377b7c","name":"Speed","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1250,"y":1180,"wires":[]},{"id":"d499a583.9fdc88","type":"function","z":"63c544b0.377b7c","name":"Convert byte array to SIGNED 32-bit integer","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer);\n\n// Represent these bytes as 32-bit unsigned int\nconst value = buf.readInt32BE();\n\n// save the value\nmsg.payload = value;\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":1140,"wires":[["346fc1e.e5bf13e"]]},{"id":"c57c660f.3c1938","type":"modbus-read","z":"63c544b0.377b7c","name":"Read 920i Speed","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"9","quantity":"2","rate":"3","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"ed8ff803.7cd708","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":160,"y":1080,"wires":[["c9fea5b0.6cdf48"],["d499a583.9fdc88"]]},{"id":"c9fea5b0.6cdf48","type":"modbus-response","z":"63c544b0.377b7c","name":"","registerShowMax":20,"x":450,"y":1060,"wires":[]},{"id":"28eb8113.c339ee","type":"function","z":"63c544b0.377b7c","name":"IEEE-754 to float","func":"/* Converts from an number, string, buffer or array representing an IEEE-754 value\n * to a javascript float.\n * The following may be given in msg.payload:\n * A string representing a number, which may be hex or binary\n * examples, \"1735\" \"0x02045789\" 0b01000000010010010000111111011011\n * An integer value\n * A four element array or buffer of 8 bit values, most significant byte first.\n*/ \n// first make a number from the given payload if necessary\nlet intValue;\nif (typeof msg.payload === \"number\") {\n intValue = msg.payload;\n} else if (typeof msg.payload === \"string\") {\n intValue = Number(msg.payload);\n} else if (msg.payload.length == 2) {\n // four byte array or buffer\n intValue = (msg.payload[0] << 8) + msg.payload[1]; //) << 8) + msg.payload[2]) << 8) + msg.payload[3];\n} else {\n node.warn(\"Unrecognised payload type or length\");\n}\n\nmsg.payload = Int2Float32(intValue);\nreturn msg;\n\nfunction Int2Float32(bytes) {\n var sign = (bytes & 0x80000000) ? -1 : 1;\n var exponent = ((bytes >> 23) & 0xFF) - 127;\n var significand = (bytes & ~(-1 << 23));\n\n if (exponent == 128) \n return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);\n\n if (exponent == -127) {\n if (significand === 0) return sign * 0.0;\n exponent = -126;\n significand /= (1 << 22);\n } else significand = (significand | (1 << 23)) / (1 << 23);\n\n return sign * significand * Math.pow(2, exponent);\n}","outputs":1,"noerr":0,"x":810,"y":1300,"wires":[["dab36a79.eb4a38","b583499a.503808"]]},{"id":"dab36a79.eb4a38","type":"debug","z":"63c544b0.377b7c","name":"Totalizer","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1220,"y":1260,"wires":[]},{"id":"62f08f21.ed4a1","type":"function","z":"63c544b0.377b7c","name":"Convert byte array to SIGNED 32-bit integer","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer);\n\n// Represent these bytes as 32-bit unsigned int\nconst value = buf.readInt32BE();\n\n// save the value\nmsg.payload = value;\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":1300,"wires":[["28eb8113.c339ee"]]},{"id":"53d537b.f896dc8","type":"modbus-read","z":"63c544b0.377b7c","name":"Read 920i Totalizer","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"11","quantity":"2","rate":"3","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"ed8ff803.7cd708","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":170,"y":1240,"wires":[["a90e5d9d.de55e"],["62f08f21.ed4a1"]]},{"id":"a90e5d9d.de55e","type":"modbus-response","z":"63c544b0.377b7c","name":"","registerShowMax":20,"x":450,"y":1220,"wires":[]},{"id":"24342a0d.17d3f6","type":"function","z":"63c544b0.377b7c","name":"IEEE-754 to float","func":"/* Converts from an number, string, buffer or array representing an IEEE-754 value\n * to a javascript float.\n * The following may be given in msg.payload:\n * A string representing a number, which may be hex or binary\n * examples, \"1735\" \"0x02045789\" 0b01000000010010010000111111011011\n * An integer value\n * A four element array or buffer of 8 bit values, most significant byte first.\n*/ \n// first make a number from the given payload if necessary\nlet intValue;\nif (typeof msg.payload === \"number\") {\n intValue = msg.payload;\n} else if (typeof msg.payload === \"string\") {\n intValue = Number(msg.payload);\n} else if (msg.payload.length == 2) {\n // four byte array or buffer\n intValue = (msg.payload[0] << 8) + msg.payload[1]; //) << 8) + msg.payload[2]) << 8) + msg.payload[3];\n} else {\n node.warn(\"Unrecognised payload type or length\");\n}\n\nmsg.payload = Int2Float32(intValue);\nreturn msg;\n\nfunction Int2Float32(bytes) {\n var sign = (bytes & 0x80000000) ? -1 : 1;\n var exponent = ((bytes >> 23) & 0xFF) - 127;\n var significand = (bytes & ~(-1 << 23));\n\n if (exponent == 128) \n return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);\n\n if (exponent == -127) {\n if (significand === 0) return sign * 0.0;\n exponent = -126;\n significand /= (1 << 22);\n } else significand = (significand | (1 << 23)) / (1 << 23);\n\n return sign * significand * Math.pow(2, exponent);\n}","outputs":1,"noerr":0,"x":810,"y":1460,"wires":[["28e2ea6e.57de76","b583499a.503808"]]},{"id":"28e2ea6e.57de76","type":"debug","z":"63c544b0.377b7c","name":"Master Total","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1250,"y":1340,"wires":[]},{"id":"e636ffd5.da3ca","type":"function","z":"63c544b0.377b7c","name":"Convert byte array to SIGNED 32-bit integer","func":"// Create new Buffer based on array bytes\nconst buf = Buffer.from(msg.payload.buffer);\n\n// Represent these bytes as 32-bit unsigned int\nconst value = buf.readInt32BE();\n\n// save the value\nmsg.payload = value;\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":1460,"wires":[["24342a0d.17d3f6"]]},{"id":"89bb8e8f.563d3","type":"modbus-read","z":"63c544b0.377b7c","name":"Read 920i Master Total","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"15","quantity":"2","rate":"3","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"ed8ff803.7cd708","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":180,"y":1400,"wires":[["fac91d2a.8dee"],["e636ffd5.da3ca"]]},{"id":"fac91d2a.8dee","type":"modbus-response","z":"63c544b0.377b7c","name":"","registerShowMax":20,"x":450,"y":1380,"wires":[]},{"id":"ed8ff803.7cd708","type":"modbus-client","z":"","name":"10.81.210.83","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"10.81.210.83","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","reconnectTimeout":"2000"}]