LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Enter Floating number in Modbus Register

Hello,

 

I want to set one floating value in modbus register located on 400.but I am not able to do so its only accept real number.

Will you please guide me what should I do in order to solve this problem??

I tried with suggestion which is given in link but still I am not able to connect the output to the modbus which I have mark red in attachment.

http://digital.ni.com/public.nsf/allkb/AD8172B710AFB13F86257974007D6F52

 

Actually I want to set my actual current value same as  measured value that's why I need to do this operation.

 

Thank you very much in advance. 

0 Kudos
Message 1 of 4
(2,902 Views)

It is impossible to debug an image.  Attach an actual VI instead.  An image doesn't show the representation of your constants, or how many elements are in that array.

 

Why is your floating point indicator set to extended precision?  It is very unusual to have a value with that much precision in a modbus application.  Modbus generally doesn't even use double precision.  The registers are usually only single precision and would use two U16 registers so that the 4 bytes would be single precisiobn.

 

If you have a single precision floating point number, then you should typecast that into a U16 integer array (that would then be 2 elements) and pass it to the modbus Write.

Message 2 of 4
(2,876 Views)

The best way what i found is multiply  the number by 100 if after decimal 2 digit precision is OK with you other wise 1000 if 3. digit precision. Then write to register.

                                                               Later when reading read & divide by 100 or 1000 whatever Smiley Wink

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 3 of 4
(2,858 Views)

@Ranjeet_Singh wrote:

The best way what i found is multiply  the number by 100 if after decimal 2 digit precision is OK with you other wise 1000 if 3. digit precision. Then write to register.

                                                               Later when reading read & divide by 100 or 1000 whatever Smiley Wink


In the modbus units I've used, that could certainly result in major problems. The ones I've used, require the type casting as RavensFan mentions. Your method would write a number to a register but it would be an incorrect number. Look at the documentation of your modbus device.

0 Kudos
Message 4 of 4
(2,841 Views)