08-18-2019 08:27 AM
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
08-18-2019 10:03 AM
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).
08-18-2019 02:45 PM
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
08-18-2019 03:02 PM
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.
08-19-2019 07:31 AM
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
08-19-2019 07:33 AM
Hello cbutcher ,
May be my explanation confused, please find the details mentioned on last reply
Sandy
08-19-2019 08:34 AM - edited 08-19-2019 08:40 AM
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.
Since i have LabVIEW 2012 i could not see whats in your example.
08-19-2019 09:45 AM - edited 08-19-2019 09:49 AM
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
08-19-2019 09:59 AM
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:
08-19-2019 01:30 PM
Again my question is how to pull a range of holding register from 40001-40050.By creating a single variable with the range?
Sandy