1. 程式人生 > >位置式和增量式PID演算法

位置式和增量式PID演算法

一、PID框圖:

在這裡插入圖片描述
在這裡插入圖片描述

模擬的PID公式

u ( t ) = K p
[ e ( t ) + 1 T
i
0 t e ( t
) d t + T d d e ( t ) d t ] u(t) = Kp [e(t) + \frac{1}{Ti} \int ^t_0 e(t) dt + Td \frac {de(t)}{dt} ]

將PID公式離散化,推匯出位置式PID公式

u ( k ) = K p [ e k + 1 T i j = 0 k e j + T d e k e k 1 T ] u(k) = Kp [e_k + \frac{1}{Ti} \sum ^k_{j=0} e_j + Td \frac {e_k - e_{k-1}}{T} ]

= K p e k + K p T i j = 0 k e j + K p T d e k e k 1 T = Kp *e_k + \frac{Kp}{Ti} \sum ^k_{j=0} e_j + Kp*Td \frac {e_k - e_{k-1}}{T}

= A e k + B ( j = 0 k 1 e j + e k ) + C ( e k e k 1 ) = Ae_k + B(\sum ^{k-1}_{j=0} e_j +e_{k})+C(e_{k}-e_{k-1})

推匯出增量式PID公式

Δ u k = u k u k 1 = K p [ e k e k 1 + T T i e k + T d e k 2 e k 1 + e k 2 T ] \Delta u_k= u_k- u_{k-1}= Kp [e_k - e_{k - 1}+ \frac{T}{Ti} e_k + Td \frac {e_k -2 e_{k-1} + e_{k-2}}{T} ]

= K p ( 1 + T T i + T d T ) e k K p ( 1 + 2 T d T ) e k 1 + K p T d T e k 2 = Kp(1+ \frac{T}{Ti} + \frac{Td}{T} )e_k - Kp(1+ \frac{2Td}{T} )e_{k-1}+Kp\frac{Td}{T} e_{k-2}

= A e k + B e k 1 + C e k 2 = Ae_k + Be_{k-1}+Ce_{k-2}

其中,偏差=目標值-反饋值 e k = r ( t ) y ( t ) e_{k}=r(t)-y(t)