|
Re: Floating Points and rounding
you can most certainly deal with floating point numbers! just be careful about typecasting, because PIC C defaults to integers.... so you have to typecast everything.
multiplying by 180/127 is not a good idea... first of all because the range on the servo is not 180... its either 160 or 210 (i forgot). multiply by the decimal... you wil run into less problems.
otherwise...
float PAN_DEGREE = (160.0f / 127.0f);
TRUE_PAN_DEGREE = (float)PAN_SERVO * PAN_DEGREE;
notice the forced decimals and the f.
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
Last edited by Uberbots : 15-01-2007 at 20:07.
Reason: wrong ratio
|