08-19-2013 11:24 PM
I have an application were in i acquire sensor data to labview and apply DSP algorithms to obtain floating point values. i need to convert floating point values to unsigned 16-bit integer values.I need the unsigned data values to communicate with MIL-STD-1553 bus. Any help would be appreciated.
Regards,
Manjunath Kamasani
08-20-2013 12:18 AM
@kamasani wrote:
I have an application were in i acquire sensor data to labview and apply DSP algorithms to obtain floating point values. i need to convert floating point values to unsigned 16-bit integer values.I need the unsigned data values to communicate with MIL-STD-1553 bus. Any help would be appreciated.
You can consider converting floating point values to fixed point value (refer to link-1 & link-2 and then to 16-bt integer.
08-20-2013 12:20 AM
This link might also be of interest for you.
08-20-2013 12:26 AM
Hi
Floating point numeric values can be converted to unsigned 16-bit integer values using the function "To Unsigned Word Integer Function" in the Conversion VIs and Functions subpallette. This subpallette is part of Numeric function pallette. check help to see whether it meets your req.
08-20-2013 12:32 AM
@Gogineni wrote:
Hi
Floating point numeric values can be converted to unsigned 16-bit integer values using the function "To Unsigned Word Integer Function" in the Conversion VIs and Functions subpallette. This subpallette is part of Numeric function pallette. check help to see whether it meets your req.
This conversion will led to data loss, I think OP wants to maintain the precision (to some extent) and is looking to convert the floating point number to integer, so that it can be sent over MIL bus.
08-20-2013 01:35 AM - edited 08-20-2013 01:39 AM
There is no right answer to such a vague request. Conversion of a float to an integer will always result in loss of precision, range or both. The question is what loss is desired/acceptable. If the decimal part of the numeric value should be maintained, then the To Unsigned Word Integer conversion is right. Typically however the uint16 maps its values to some range, such as 0-2.25 A. Then you would have to do a scaling of the value similar to
uint16val = value / 2.25 * 65535
The last number is simply the maximum range value that the uint16 can assume. If less bits of the uint16 are relevant for the value (it could be for instance 15 bits and the highest bit is effectively a direction bit) then that value would have to be changed accordingly (2^15 -1 = 32767) and of course put correctly into the 16 bit integer using boolean operators with the right mask.