Go Down

Topic: Convert Fixed-point to actual value(decimal) (Read 923 times) previous topic - next topic


I have ASIC IC is provide Raw data in Fixed-point format Q24 (24bit)

I need to convert to decimal by

Actual value = raw_data*LSB

LSB = 150/[( (2^24) - 1 )*0.6 ] = 150/10066329 = 1.49011E-5.

Range raw data is  0 ~ 10066329

I want to calculate Actual value in to uint 32bit and keep the precision in 2 or 3 decimal point.
for example If full scale raw data will be   10066329 and I wan to convert to Actual value , for 2 decimal point >> 15000 or for 3 decimal point >> 150000

I found the way to do this is
1. Scale factor << but need to reduce the raw data precision for prevent data not over flow in 32 bit
2. floating point << make MCU no efficiency

What the way I should select? Any one please suggest me.


if I have understood, you want to store the "actual value", in the range (0.0, 150.0), into a 32 bit integer with three decimal points by multiplying this number by 1000. Therefore you have an integer number in the range (0, 150000). An unsigned integer, 32 bit, can store any number between 0 and 4294967295, so I don't see any problem.

Go Up