Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Proportional–integral–derivative controller
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Discrete implementation=== The analysis for designing a digital implementation of a PID controller in a [[microcontroller]] (MCU) or [[FPGA]] device requires the standard form of the PID controller to be ''discretized''.<ref>{{cite web |url=https://www.scribd.com/doc/19070283/Discrete-PI-and-PID-Controller-Design-and-Analysis-for-Digital-Implementation |title=Discrete PI and PID Controller Design and Analysis for Digital Implementation |publisher=Scribd.com |access-date=2011-04-04 |url-access=registration}}</ref> Approximations for first-order derivatives are made by backward [[finite difference]]s. <math>u(t)</math> and <math>e(t)</math> are discretized with a sampling period <math>\Delta t</math>, k is the sample index. Differentiating both sides of PID equation using [[Newton's notation]] gives: <math>\dot{u}(t) = K_p\dot{e}(t) + K_ie(t) + K_d\ddot{e}(t)</math> Derivative terms are approximated as, :<math>\dot{f}(t_k) = \dfrac{df(t_k)}{dt}=\dfrac{f(t_{k})-f(t_{k-1})}{\Delta t}</math> So, :<math>\frac{u(t_{k})-u(t_{k-1})}{\Delta t} = K_p\frac{e(t_{k})-e(t_{k-1})}{\Delta t} + K_i e(t_{k}) + K_d \frac{\dot{e}(t_{k}) - \dot{e}(t_{k-1})}{\Delta t}</math> Applying backward difference again gives, :<math>\frac{u(t_{k})-u(t_{k-1})}{\Delta t} = K_p\frac{e(t_{k})-e(t_{k-1})}{\Delta t} + K_i e(t_{k}) + K_d \frac{ \frac{e(t_{k})-e(t_{k-1})}{\Delta t} - \frac{e(t_{k-1})-e(t_{k-2})}{\Delta t} }{\Delta t}</math> By simplifying and regrouping terms of the above equation, an algorithm for an implementation of the discretized PID controller in a MCU is finally obtained: :<math>u(t_{k})=u(t_{k-1})+\left(K_p+K_i\Delta t+\dfrac{K_d}{\Delta t}\right) e(t_{k})+\left(-K_p-\dfrac{2K_d}{\Delta t}\right) e(t_{k-1}) + \dfrac{K_d}{\Delta t}e(t_{k-2})</math> or: :<math>u(t_k)=u(t_{k-1})+K_p\left[\left(1+\dfrac{\Delta t}{T_i}+\dfrac{T_d}{\Delta t}\right) e(t_k)+\left(-1-\dfrac{2T_d}{\Delta t}\right)e(t_{k-1}) + \dfrac{T_d}{\Delta t}e(t_{k-2})\right]</math> s.t. <math> T_i = K_p/K_i, T_d = K_d/K_p</math> Note: This method solves in fact <math>u(t) = K_\text{p} e(t) + K_\text{i} \int_0^t e(\tau) \,\mathrm{d}\tau + K_\text{d} \frac{\mathrm{d}e(t)}{\mathrm{d}t} + u_0</math> where <math>u_0</math> is a constant independent of t. This constant is useful when you want to have a start and stop control on the regulation loop. For instance, setting Kp,Ki and Kd to 0 will keep u(t) constant. Likewise, when you want to start a regulation on a system where the error is already close to 0 with u(t) non null, it prevents from sending the output to 0.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)