|
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.
|