Float to int bits

HI everyone,

I was wondering if I could please get some help. I am trying to convert a floating value to individual bits so I can convert it to 2 16 bit registers to send through modbus to a plc.

I have been trying to use all sorts of function and this is what I have so far.

Blockquote

test = msg.payload;
f = Float.floatToIntBits(test);
msg.payload = f;
return msg;

Blockquote

It does not seem to be working.
I am getting this error ReferenceError: Float is not defined (line 2, col 1)

Kind Regards
Sam

That is Java not JavaScript.

Use a function node and the Buffer object

Use the write float function to add your value then read 2 integers out.

Hi Steve,

Thanks for pointing me in the right direction. Coding is new to me but generally I can follow instructions. Works a treat.

Regards
Sam

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