liba 0.1.15
An algorithm library based on C/C++
|
proportional integral derivative controller More...
#include "a.h"
Go to the source code of this file.
Data Structures | |
struct | a_pid |
instance structure for PID controller More... | |
Macros | |
#define | a_pid_init(ctx) |
initialize for PID controller | |
Typedefs | |
typedef struct a_pid | a_pid |
typedef struct a_pid | a::pid |
Functions | |
void | a_pid_set_kpid (a_pid *ctx, double kp, double ki, double kd) |
set proportional integral derivative constant for PID controller | |
double | a_pid_run (a_pid *ctx, double set, double fdb) |
calculate for PID controller | |
double | a_pid_pos (a_pid *ctx, double set, double fdb) |
calculate for positional PID controller | |
double | a_pid_inc (a_pid *ctx, double set, double fdb) |
calculate for incremental PID controller | |
void | a_pid_zero (a_pid *ctx) |
zeroing for PID controller | |
proportional integral derivative controller
A proportional integral derivative controller (PID controller or three-term controller) is a control loop mechanism employing feedback that is widely used in industrial control systems and a variety of other applications requiring continuously modulated control.
\[ u(t) = K_p\left[e(t)+\frac{1}{T_i}\int{e(t)}\text{dt}+T_d\frac{\text{d}e(t)}{\text{d}t}\right] \]
\[ u(k) = K_p\left[e(k)+\frac{T}{T_i}\sum^k_{i=0}e(i)+\frac{T_d}{T}[e(k)-e(k-1)]\right] \]
\begin{aligned} u(k) &= K_p e(k) + q\sum^k_{i=0} K_i e(i) + K_d [e(k)-e(k-1)] \\ &= (K_p+K_d) e(k) + q\sum^k_{i=0}K_i e(i) + (-K_d) e(k-1) \\ &\begin{cases}q=0&|\sum\limits^{k-1}_{i=0}K_ie(i)|>E \bigvee [\sum\limits^{k-1}_{i=0}K_ie(i)]K_ke(k)>0 \\ q=1\end{cases} \end{aligned}
\begin{aligned} \Delta u(k) &= K_p [e(k)-e(k-1)] + K_i e(k) + K_d [e(k)+e(k-2)-2e(k-1)] \\ &= (K_p+K_i+K_d) e(k) + (-K_p-2K_i) e(k-1) + K_d e(k-2) \end{aligned}
https://en.wikipedia.org/wiki/PID_controller