![]() |
My error derivative is going crazy
I'm trying to get PID control for the gyro working, and so far P is working fine. The D, however, is going to unreasonable values because my angle_err_last variable doesn't work at all. Here's my teleop.c function, sans gyro bias calc and printfs. I'm using the new code with C18 3.10.
Code:
void Teleop(void)I set all of the variables as long to avoid type mismatches. The angle_err_last variable jumps all over the place, never coinciding with what angle_err actually was. Anyone know why? edit: I commented out everything touching angle_err_last except for the declaration, and it still went all over the place. |
Re: My error derivative is going crazy
angle_err_last should be static.
|
Re: My error derivative is going crazy
It worked. Thank you.
|
Re: My error derivative is going crazy
I am not sure if this applies to your case, but if you're integrating the gyro output to get angular position, and then differentiating it to get the change in angular position, wouldn't it be more efficient to just scale the rate output of the gyro? I think that you are differentiating the error though, I am not sure if this has any advantage. From my understanding, the D term of a PID loop is to slow down as you approach the goal, to reduce overshooting/oscillations.
|
| All times are GMT -5. The time now is 23:15. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi