06-09-2011 09:36 AM
I am currently attempting to use labVIEW 2010 to read temperature and mass flow information off of a modbus instrument. However the instrument returns all values in 2 16 bit hex words in "Intel Bytes" ordering. I am having trouble converting this information to a usable signed decimal. For example:
Word 1 Word 2 Signed Integer
527E 41C0 +24.0402793884277340
I have attempted to merge the words and cast to decimal but to no avail. Any help or tips are appreciated as I am new to labVIEW and working with raw data in general.
My current code is attached.
Solved! Go to Solution.
06-09-2011 09:47 AM - edited 06-09-2011 09:48 AM
Is 24.040... what you're supposed to get? You're talking about an integer, but this is floating point.
Anyway, if this is what you want to get it's quite simple:
06-09-2011 09:49 AM - edited 06-09-2011 09:52 AM
You don't even need to index the array, if the elements are in the correct order you can directly feed an array of 2 U16 into the typecast to SGL:
06-09-2011 10:36 AM
I have attempted to implement your first solution (as it was the most logical based on what I was reading from my device), however as you can see it doesn't appear to be working correctly. Can you spot my error? For reference I have included a screen shot of my VI running along with the expected value in the program to the left. I have attempted to reverse the wiring order but to no avail.
06-09-2011 10:38 AM
You're doing a type cast to DBL, which is 64 bits. You need to type cast to SGL (32 bits).
06-09-2011 10:52 AM
Ah OK that would make sense! But I must ask, I can't seem to find the a constant for SGL anywhere in the menus. Sorry for the idiot question however this it my first week working with LabVIEW and I'm still getting used to how the menus are organized.
06-09-2011 10:59 AM
right-click the diagram constant...representation...SGL.
06-09-2011 11:06 AM
Thanks! Now I can interpenetrate the information I need.
06-09-2011 11:07 AM
On a side note, there is also an idea that would make code images less ambiguous in terms of numeric representations.
(Personally, I always insist of attaching code or code snippets instead of images to make things unique. A flat image can never fully show all important aspects of a program.)
06-09-2011 11:12 AM - edited 06-09-2011 11:14 AM
@altenbach wrote:
On a side note, there is also an idea that would make code images less ambiguous in terms of numeric representations.
(Personally, I always insist of attaching code or code snippets instead of images to make things unique. A flat image can never fully show all important aspects of a program.)
I fully agree, even though the data type is visible on the indicator.
I don't have a clue why the Code Snippet Tool does no longer allow me to create a snippet (LV 8.5.1). It used to work...
EDIT: ah, I just figured it out again... works only when something is selected. My bad.