|
Re: printf isn't printf-ing. Help!
Quote:
|
Originally Posted by Meandmyself
Current.theta is an unsigned int, and deltat is incremented every 25ms, so generally like 1 or 2. I'm going to try playing around with the order of operations, see if i can get it to work. What if instead of multipying by .08, I divided by 1/.08? would that still force the pic to use floating point calculations?
|
To stay away from all floating point (and maintain accuracy) do all your multiplication first followed by your divisions.
e.g.,
current.theta += (unsigned long) ((gyroin + gyroprev - 1023) * deltat * 8 / 100) + 2000;
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
|