|
Re: Gyro PID User drive - How we did it
The algorithm and implementation look great. There's a bit of confusion in the comments, where it misrepresents the equation as being based only on the error and not on the derivative or integral, but the code does what I'd expect from a full PID controller. (Or it would, if you hadn't commented out the line doing the I accumulation. You should probably say something explicit about having removed it, in order not to confuse anyone.)
One other thing is completely unrelated to what the code is doing, and likely won't cause problems, but still ought to be corrected as soon as possible. You're treating 255 as the highest possible pwm value. In the IFI system, the maximum should instead be 254. Where you "invert" the right side output value, you similarly need to subtract from 254 instead of 255 -- that way, the 127 "neutral" value remains as it is.
|