I need to build a NodeJS server-based prototype that reads industrial modbus data.
I am reading two consecutive 16bit decimal registers that provide me an array with two entries:
// eg transaction = [ 17007, -2621 ]
or // eg transaction = [ 17007, 0000 ]
This value should translate to electrical frequency, approx = ~60.00 (hz) (at least it should if the data I'm given is right)
I am aware that I need to combine the two registers values in the array and convert the data either to 32-bit float .. but how:
a) how to combine them without casting them as something they aren't
b) how to covert them to 32 bit float
I think I need to use some type of parseInt()
and then toString(10)
- one suggestion was to convert each to hex using parseInt(num, 10).toString(16)
and then convert that joined hex to a string or possibly float using parseFloat()
but again how to join the two separate parts first.
I've not found solutions to this, surprisingly.