0

I have a project that is basically to analyze the effects of quantization on orientation estimation algorithms. I have sensor data from gyroscope that looks like this when using float datatype:

gx=-0.001064650843716541
gy=-0.0042603487041181585
gz=0.0053267448770866945

When i use "sc_fixed < 16,8,SC_TRN,SC_SAT >" dedicating 8 bits to the integar part and remaining bits to the fractional part, i get the following results,

gx=-.00390625
gy=-.0078125
gz=.00390625

I am just failing to understand how does quantization worsen these values. I have tried to used the following bit configurations:

"sc_fixed < 24,10,SC_TRN,SC_SAT >"
"sc_fixed < 32,10,SC_TRN,SC_SAT >"
"sc_fixed < 32,11,SC_TRN,SC_SAT >"

The results are effected but now as much when i use < 16,8 >

9
  • 1
    You probably don't want fixed point. You certainly don't want fixed point with just 8 bits for the fractional part. With 8 bits for the fractional part, you get a resolution of 1/256, or 0.00390625. So you can represent the numbers 0, 0.00390625, 0.0078125, 0.01171875, ..., but nothing in between. Your gx, gy, and gz numbers are very small, so it's not surprising they got "rounded off" (worsened) badly when coerced into being multiples of 1/256. Commented May 3, 2024 at 17:26
  • It looks like your numbers are all comfortably less than 0.01. Even a fixed-point format that devoted all of its bits to the fraction (none to the integer) would still waste a lot of resolution for these numbers. I'd say you want to use something like 16 bits, with -6 of them for the integer, and the other 22 for the fraction. That'd let you represent numbers from 0 to 0.015625, with a resolution of about 0.0000002. (But, yes, I'm sort of kidding about the -6 bits for the integer. :-) ) Commented May 3, 2024 at 17:44
  • Bottom line, if you're bound and determined to use fixed point, it looks like you want to devote as many bits as you can to the fraction, with few or none devoted to the integer. Commented May 3, 2024 at 17:48
  • Thank you for your response Steve. It was very helpless. Is there a way to find out what would be the minimum number of bits to represent those values without rounding error? Commented May 3, 2024 at 17:57
  • I like your sense of humor :') I actually cant dedicate very less bits to the integar part since these values would serve as an input for the orientation estimation algorithms like Madgwick, Mahony and im supposed to use fixed point datatype across all operations Commented May 3, 2024 at 18:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.