
Implementing PID on a Microcontroller: Important Considerations and Tips
Explore the essential aspects of implementing PID control on a microcontroller, including the PID equation, sample time considerations, handling derivative kick, on-the-fly tuning changes, and mitigating integrator windup. Learn how to address common challenges efficiently in your mechatronics engineering projects.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Implementing PID on a microcontroller BJ Furman ME 190 Mechatronics Engineering Design 11NOV2015 (adapted from: http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/)
PID equation Figure from Matlab Help (Designing PID Controllers with the PID Tuner) Parallel form u= = r(t) y(t) Standard form ??=? let ??= ? ??= ??? ?? ? ?????? = ? ? ? +1 ??(?) ?? u= ? ? ?? +?? ?? 0
Important considerations o Sample Time o Derivative Kick o On-The-Fly Tuning Changes o Reset Windup Mitigation o On/Off (Auto/Manual) o Initialization (bump-less transfer) o Controller Direction
Sample Time o Need to call at a regular interval o Use millis() or an interrupt (cont.)
Derivative Kick The problem ? ?????? = ? ? ? +1 ??(?) ?? ? ? ?? +?? ?? 0 t ( ) t ( ) t ( ) de dr dy = dt r(t) dt dt if constant is t ( ) t ( ) de dy = 0 dt dt Derivative Spikes t ( ) t ( ) de dy = dt dt
On-the-fly tuning changes When things go bump
On-the-fly tuning changes, cont. Calculate the contribution for the integral term differently: Before After
Integrator windup The problem
Integrator windup, cont. (same as before)
Integrator windup, cont. The result
On/Off (automatic or manual) The problem
On/Off, cont. (same as before)
Initialization The problem
Initialization, cont. (same as before)
Initialization, cont. Bumpless transfer
Direction The problem: should an increase in y (the output) lead to an increase or a decrease in the manipulating variable (u, the output of the controller)? Direct acting (Kp, Ki, Kd should be positive) Reverse acting (Kp, Ki, Kd should be negative)
Direction, cont. (same as before)