Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Proportional–integral–derivative controller
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Proportional–integral–derivative controller
(section)
Add topic