View Single Post
  #12   Spotlight this post!  
Unread 16-02-2008, 02:00
duane's Avatar
duane duane is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Vacaville
Posts: 98
duane is an unknown quantity at this point
Send a message via AIM to duane
Re: Potentiometer arm control

Quote:
Originally Posted by RyanN View Post
It will not try to use floating point or just use that fraction and multiply it? I thought that would work.
As already mentioned, integers do integer method. In order to maintain precision with integer math, you want to do division with the largest numbers possible. Division will always loose precision.

What was shown will work, but you might even get a little better precision by doing...

wrist_pos = (-11*arm_pos + 1670*5) / 5;

This maximizes the numerator before dividing by the denominator.
__________________
Duane Murphy
Mentor - Software
Vanden Vikings FIRST Team 701
http://www.vandenrobotics.com