From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

IEEE 754 U32 to SGL conversion

Code and Documents

Attachment

I have added a LabVIEW IEEE 754 conversion function here to convert a 32 bit information (array of four U8 elements) into SGL and vice versa. This function provides the same functionality like the IEEE 754 Converter (JavaScript), V0.13, shown on http://www.h-schmidt.net/FloatConverter/IEEE754.html.

I have added this conversion VI as an example here because I have searched for a LabVIEW converter but haven´t found one (maybe because it´s that simple to build one in LV). This function might help to transmit/receive data (Arrays of U8) by making use of the UDS palette within the Automotive Diagnostic Command Set LabVIEW Addon. DBLs could also be converted by adding little changes to the VI.

It´s a LabVIEW 2014 SP1 vi.

Have fun!

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
crossrulz
Knight of NI Knight of NI
Knight of NI
on

Instead of the Type Cast, you should consider using the Flatten To String and the Unflatten From String.  The Flatten/Unflatten allow you to choose the endianess of the value.  This will come in particularly handy when dealing with values coming from Matlab (which uses Little Endian while LabVIEW uses Big Endian).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Contributors