-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delays in loop() cause erratic PID.compute() values #60
Comments
Hm, and then there's this post on your original blog
which probably makes me one of those new users. I guess the question is how to fix the situation. If I am able to pass the algorithm the elapsed time, would it still work okay? |
Also check out my PID implementation for my flight controller: https://github.com/Lauszus/LaunchPadFlightController/blob/master/src/PID.c and the PID code for the Balanduino balancing robot: https://github.com/TKJElectronics/Balanduino/blob/master/Firmware/Balanduino/Motor.ino. |
This does not work! If you look at the SetSampleTime() code
You can see that if '0' is passed in as 'NewSampleTime', the value of 'SampleTime' will not be changed! The 'if' statement needs to be changed to 'if (NewSampleTime >= 0) Frank |
I'm using the PID Library for a balancing robot and it seems to be exhibiting strange behavior.
You can view the complete code here:
https://github.com/owhite/balancing_bot/blob/master/src/balancing.ino
but I believe the relevant section is here:
The issue is this. MPUupdate() sets position by performing an I2C call to a MPU9250 module, and it returns position - the tilt of the MPU09250. Then the code calls pid.Compute(). The problem is that some calls to MPUupdate() take a lot longer than others and when it does the return values from pid.Compute() jump to some extreme value.
This is an example of print output:
The fifth line down from that out is an example.
Where I have an unusually long delay time and it gives me a much larger PID value even though the position is the same. So basically when there is a long call to the MPU it screws up my pid values, and then my balancing robot jitters. Any suggestions?
The text was updated successfully, but these errors were encountered: