08-11-2009 12:16 PM
Hi to all,
I am trying to communicate with a MODBUS Device using NI MODBUS LIbrary (LabVIEW ver 8.6).
I have the requirement to write a floating point value (say 25.5) to the modbus register using the command Write Single Register (06) and then read the same register using Read Input Register (04) to verify the same whether the value returned by the device is 25.5 or something else.
As far as i had studied the MOSBUS Write and read vi's of this library, it converts the data into U8 format before writing to the port and reterives the data into U16 format. So, it will not be possible to write floating point value because the input and output data format of the VI;s will round off the values like 25.5 to 26 and 25.4 to 25.
Can anyone tell me the way how to write 25.5 to the register.
Helping with any ready made example code will be highly helpful to me.
Or any other ways to do it because i just know that i have to read two consecutive Holding Registers if i have to read a floating point value (i read it on the internet).
Regards,
Samriddh Sarbalhi
08-12-2009 04:08 AM
Hi samriddh,
you have to know how your floating point value will be represented in modbus. You have to calculate an U8 U16 or U32 value from it. You need to know which voltage is represented by 1 bit.
Mike
08-12-2009
04:13 AM
- last edited on
04-17-2025
02:58 PM
by
Content Cleaner
Hi Found this KB. It talks about "The Working Principle behind Reading Adjacent (32 Bit) D or F Registers of Modbus". It doesn't explicitly talk about how to read/write floating point but it talks function of registers. So, I'm not very sure if it will help you.
Check if you are using the correct register.
Regards.