LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

32bit float value from analyzer

Hi,

 

I am using Labview2014, I have established with some analyzer via Modbus TCP/IP and created some double type variable but how can I get the float value as I can see some raw values now.

Should I use seperate VI's for converting the values?

 

 

 

Regards

Sandy

0 Kudos
Message 1 of 24
(3,000 Views)

Hi Sandy,

 

You have a double type variable and want the float value? I'm guessing you mean you have the integer values from the holding register and want to convert them to some other units.

To do this you'll need to know the appropriate scaling for the variable. The information is probably available in the (programming, if there are multiple) manual for your analyzer.

 

Using separate VIs to do different tasks is a good "best-practice", so you should go ahead and do that (make sure you're also using a Project to simplify management of the multiple VI files).


GCentral
0 Kudos
Message 2 of 24
(2,972 Views)

I'm confused (or maybe you are confused) by your Post.  Your title says "32bit float value", which sounds like a "single-precision Float", yet you refer to "some double type variable", which sounds like a 64-bit double precision Float.  You also refer to "raw values".  

 

You didn't attach code so we can see what you are really doing, nor did you attach documentation for "some analyzer", so we don't really know the format of the data it sends to you.  If, however, it is sending 32-bit Floats, and you are using (in your LabVIEW analysis routine) Dbls, this should be no problem -- simply wire the Sgls (32-bit floats) coming from your Device to your Dbl "wires" (you'll probably get a red Coercion dot that you can probably ignore).

 

It is unlikely that your device needs the added precision of Dbl, so they may have saved some space and time by using the smaller Sgl.  Of course, we can't be sure what your situation really is ...

 

Bob Schor

0 Kudos
Message 3 of 24
(2,955 Views)

Remember that modbus registers are only 16 bits.

 

So:

1.  Is your situation like cbutcher says where you may need to scale a single register 16-bit value to get a larger floating point value?

2.  Is your situation like Bob says?  Then you will need to take a pair of registers and typecast them to a SGL floating point type.

0 Kudos
Message 4 of 24
(2,951 Views)

Hi,

 

My situation is like Bob says, the transmitter is giving the scaled value in two registers ie 40005 & 40006 as float value. I have used the 16bit register and swaped with typecast function and its working. Since there are 50 values I need to capture from different analyzers I will have to create each pair of registers and then create another 50 tags to make it as a real value. Is it possible to read the first 50 holding registers ie 400001 to 400050 and then make it swaped in an array?

 

Sandy

0 Kudos
Message 5 of 24
(2,886 Views)

Hello cbutcher ,

 

May be my explanation  confused, please find the details mentioned on last reply

 

Sandy

0 Kudos
Message 6 of 24
(2,879 Views)

Something like this?
Convert U16 array to SGL array. Remove "Swap Words" or insert "Swap Bytes" after "Swap Words" if needed.
VI attached.

If you do not need the "Swap Words" function you can remove the cast to U32 array.


U16_array_to_SGL_array.PNG
Since i have LabVIEW 2012 i could not see whats in your example.

0 Kudos
Message 7 of 24
(2,865 Views)

Sandy,

 

     Did you realize you combined U1 and U2, with U2 being put in the High byte and U1 in the Low byte, then swapped them, so that U1 was High, and U2 Low, thereby "undoing" the order you used to combine them?  You can, of course, fix this by adding another "Swap Words" (or adding another three "Swap Words"), or maybe doing something else (I'm not telling!) and getting rid of the Swap Words.

 

     Also look at RolfO's suggestion of another way to combine 2 U16s into a U32 ...  Here the Swap Words may well be necessary, depending on the order your device presents the pieces.

 

Bob Schor

0 Kudos
Message 8 of 24
(2,844 Views)

Assuming that In1 is the first value in the array you create, and In2 is the second (and then you have 3&4, 5&6, on to 49&50 or 99&100) then you can use the solution described by RolfO, but not exactly as shown in the image.

 

Since you're swapping the low and high, and wiring them opposite to one another, you can simply wire them in order and remove the swap.

That leaves you with the following:

Wordswaped_BD.png


GCentral
0 Kudos
Message 9 of 24
(2,837 Views)

Again my question is how to pull a range of holding register from 40001-40050.By creating a single variable with the range? 

 

Sandy

0 Kudos
Message 10 of 24
(2,822 Views)