07-25-2024 01:37 AM
Hello All,
I am trying to read some data over Modbus TCP using the LabVIEW Modbus Driver.
The out of the Modbus holding register read which gives out U16 array needs to be converted to floating point.
I have been using a typecast to SGL array to do this but the values I am getting are not correct. I think that I need to use a swapped floating point instead. Is there a way to do this?
I tried the swap word block but it didn't seem to help. I'm using LabVIEW 2021.
Solved! Go to Solution.
07-25-2024 01:45 AM - edited 07-25-2024 01:49 AM
Hi Silverfang,
@Silverfang- wrote:
I have been using a typecast to SGL array to do this but the values I am getting are not correct. I think that I need to use a swapped floating point instead. Is there a way to do this?
I tried the swap word block but it didn't seem to help. I'm using LabVIEW 2021.
You forgot to attach your VI and example data…
Giving a generic answer: create an U32 from two U16 words using JoinNumbers (using the right word order), then you typecast to SGL!
07-25-2024 02:26 AM - edited 07-25-2024 02:29 AM
Hello GerdW,
Thank you for the solution. This worked. Only issue is that my INT16 is an array so I had to extract my individual array elements and join them and then convert to float to test this.
Possible to apply a similar solution to a whole array or do I have to do this for every 2 elements individually?
07-25-2024 04:34 AM - edited 07-25-2024 04:36 AM
Hi Silverfang,
@Silverfang- wrote:
Possible to apply a similar solution to a whole array or do I have to do this for every 2 elements individually?
Decimate the U16 array into two arrays, then apply JoinNumbers & TypeCast (to array of SGL)…
Or: SplitNumbers the U16 array into two U8 arrays, interleave those into one U8 array, convert into string, UnflattenFromString into array of SGL…