I have designed a control system and coded in arduino atmega2560 and works well . I have problem converting to fixed point. The reason being that the coefficients on the float model are larger than 1. I have two of them, a1=0.021 and a2= 3600. My input is from an 16 bit ADC (Q15). So how to scale everything within the range -1 to +1?
It would help to see
more any of the expressions you are now doing, presumably, with floating point arithmetic.
Examples of all the different things you are calculating and some idea of the precision you want in the results.
You could say
something anything you can share about your application too.
I require precision upto 1 decimal place. my application is basically sin/cos encoder interface and I have to decipher the encoder shaft position.
Either you use slow floating point or fast integer arithmetic. For integers you can scale all or selected values by e.g. 1000 and take care of that factor yourself in calculations.
do you mean I divide my input and the coefficients in such a way that it fits over the range -1 to +1? Will i not loose the precision? As mentioned earlier, one of the coefficient is .021 and I am afraid that after division, the value will be to small
Why the range -1 to +1? Fixed point means a fixed number of decimal digits after the decimal point, not the number of leading digits before the decimal point.
With 3 decimals the value 0.021 becomes 21, 3600 becomes 3600000.
Ok but the number 3600000 does not fit in Q15 range!!. If I could some how convert all the numbers in Q15 , then my processing becomes easier.
No need to scale all values. The individual scale factors have to be handled in every operation.
Which is why it would be helpful if we could see your expressions. Fixed point can require some flexibility of scale at various points.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.