This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR6043: Where do I find USS_getResultsInFloat() )

Part Number: MSP430FR6043

Good day everyone,

I am using the demo code "FR6043_USSSWLib_template_example" for my gas metering setup.

As I want to transfer the measurement results via i2c I would like to know how to decode the results from fixedResults to a Float value.

I think the answer lies in "USS_getResultsInFloat()" as used in "ussWsLibAlgorithm.c" but I can't find the code for that function as it is defined extern and I searched through all files that are provided by the library..

I would be greatly appreciated if you could provide me the code of the function.

Thank you, Sincerely

Lukas

  • Hi Lukas,

    I believe that the function you are looking for is defined in our precompiled USS library, so you won't be able to find its definition in the SDK. I tried searching through our SDK and did not find a definition for you. 

    However, looking at the USSSWLib template example code, it appears that it already uses the floating point version of the USS algorithm, assigning the values to USS_Algorithms_Results algResults, the float version of the USS Algorithm results struct. I would expect that when you run the template example code, the results will already be in float format, provided you haven't changed that. Can you confirm that your template example uses the above results struct, and this algorithm to generate the results: USS_runAlgorithms()?

  • You're right the inital template code does give me the result as a float, however I would like to actually use the fixedResults inside of the USS_runAlgorithms() because I can transmit those easier via i2c to my external circuit. But as I need to recalculate the float in my overall system outside of the chip, I would like to know how you get the floats back from the fixedResults so I can do that myself. Might it be possible that you provide the maths involved to me? Or tell me how the measured ToF is separated into 4 bytes of data?

  • I see. Thanks for confirming and explaining the use case here.

    I think there are two options here. I do not know what devices are used in your overall system, but the immediate option that you should explore is to install the MSP-IQMATHLIB, which has functions defined for converting IQMath values into floats. You can read more about these functions in section 4.2 of the IQMath users guide. The download will feature a pre-compiled library that you can link in your code project.

    Your other option will take a little more coding but you may find it to be easier. You can take a look at section 2.2 of the IQMath users guide linked above to see how IQMath numbers are formatted, With the example provided there, I think it is a relatively straightforward conversion to make. It also looks like the link above is intended only for MSP430 microcontrollers so assuming you are converting for a different device, this would probably be the way to go.

    I would assume that the USS_getResultsInFloat() function just uses the IQMath library conversion to go from iq16 to float in the USS code.

  • Thank you very much for your support!

**Attention** This is a public forum