View Single Post
  #6   Spotlight this post!  
Unread 25-02-2007, 23:04
Render Render is offline
Registered User
AKA: Robert Udicious
FRC #1885 (Robocats)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Haymarket, Virginia
Posts: 18
Render will become famous soon enoughRender will become famous soon enough
Re: Gyro PID User drive - How we did it

one way you could improve your code is remove the floats since they are very expensive to the processor and replace them with a numerator and denominator. Then when doing your math you do everything for that portion and divide last.

ex.
char Kp = 5;
char kpDiv = 100;

pTerm = (Kp * p_error) / KpDiv;

You will lose the precision of having a floating point value in the end, but with PWM values I do not think that matters anyways

also I am wondering why your errors are floats?

Last edited by Render : 25-02-2007 at 23:08.