# 比例谐振（PR）控制器的学习过程记录

12 篇文章 36 订阅

0、前言

1、PR控制器和PI控制器对比

1.1 传递函数表达式对比

1.2 波特图对比

2、离散化预备知识

2.1 离散化表达式

2.2 离散化方法

2.3 离散化练习题

3. 使用Matlab离散PR控制器

4、逆变器仿真模型中使用PR闭环控制器

## 1、PR控制器和PI控制器对比

### 1.1 传递函数表达式对比

$G_{PI}\left ( s \right )=K_p + \frac{K_i}{s}$

$G_{PR-ideal}\left ( s \right )=K_p + \frac{K_rs}{s^{2}+\omega _o^{2}}$

$G_{PR}\left ( s \right )=K_p + \frac{2K_r\omega _cs}{s^{2}+2\omega _cs+\omega _o^{2}}$

### 1.2 波特图对比

% this is Matlab code:
Ki=10;
Kp=1;
PIs1=tf([Kp,Ki],[1,0])
Kp=10;
PIs2=tf([Kp,Ki],[1,0])
Kp=100;
PIs3=tf([Kp,Ki],[1,0])
bode(PIs1,PIs2,PIs3)
title('Bode Diagram of PI: Kp=1,10,100. Ki=10')
grid on

Kp=1
Ki=1
PIs1=tf([Kp,Ki],[1,0])
Ki=10
PIs2=tf([Kp,Ki],[1,0])
Ki=100
PIs3=tf([Kp,Ki],[1,0])
figure(2)
bode(PIs1,PIs2,PIs3)
grid on
title('Bode Diagram of PI: Kp=1. Ki=1,10,100')

Kr=1;
Kp=1;
PR_ideal1 = Kp + tf([Kr,0],[1,0,wo^2])
Kp=10;
PR_ideal2 = Kp + tf([Kr,0],[1,0,wo^2])
Kp=100;
PR_ideal3 = Kp + tf([Kr,0],[1,0,wo^2])
bode(PR_ideal1,PR_ideal2,PR_ideal3)
grid on
title('Bode Diagram of ideal PR: Kp = 1,10,100. Kr = 1')

Kp=1;
Kr=1;
PR_ideal1 = Kp + tf([Kr,0],[1,0,wo^2])
Kr=10;
PR_ideal2 = Kp + tf([Kr,0],[1,0,wo^2])
Kr=100;
PR_ideal3 = Kp + tf([Kr,0],[1,0,wo^2])
figure(4)
bode(PR_ideal1,PR_ideal2,PR_ideal3)
grid on
title('Bode Diagram of ideal PR: Kp = 1. Kr = 1,10,100')

Kr=1;
Kp=1;
PR1=Kp+tf([2*Kr*wc,0],[1,2*wc,wo^2])
Kp=10;
PR2=Kp+tf([2*Kr*wc,0],[1,2*wc,wo^2])
Kp=100;
PR3=Kp+tf([2*Kr*wc,0],[1,2*wc,wo^2])
bode(PR1,PR2,PR3)
grid on
title('Bode Diagram of actual PR: Kp = 1,10,100. Kr = 1')

Kp=1;
Kr=1;
PR1=Kp+tf([2*Kr*wc,0],[1,2*wc,wo^2])
Kr=10;
PR2=Kp+tf([2*Kr*wc,0],[1,2*wc,wo^2])
Kr=100;
PR3=Kp+tf([2*Kr*wc,0],[1,2*wc,wo^2])
bode(PR1,PR2,PR3)
grid on
title('Bode Diagram of actual PR: Kp = 1. Kr = 1,10,100')

PI和PR的Kp作用类似，都是增大开环增益，增加控制精度。

Ki和Kr作用类似：降低系统稳态误差。

## 2、离散化预备知识

### 2.1 离散化表达式

$\frac{Y\left ( z \right )}{U\left ( z \right )}=\frac{a_0+a_1z^{-1}+a_2z^{-2}+...+a_nz^{-n}}{b_0+b_1z^{-1}+b_2z^{-2}+...+b_nz^{-n}}$

$b_0y\left ( k \right )+b_1y\left ( k-1 \right )+b_2y\left ( k-2 \right )+...+b_ny\left ( k-n \right )=a_0u\left ( k \right )+a_1u\left ( k-1 \right )+a_2u\left ( k-2 \right )+...+a_nu\left ( k-n \right )$

### 2.2 离散化方法

 Zero-order hold $X\left ( z \right )=\left ( 1-z^{-1} \right )Z\left \{ L^{-1}\left \{ \frac{X\left ( s \right )}{s} \right \} \right \}$ First-order hold $X\left ( z \right )=\frac{\left ( z-1 \right )^2}{zT_s} Z\left \{ L^{-1}\left \{ \frac{X\left ( s \right )}{s^2} \right \} \right \}$ Forward Euler $s=\frac{z-1}{T_s}$ Backward Euler $s=\frac{z-1}{zT_s}$ Trapezoid(Tustin) $s=\frac{2}{T_s}\frac{z-1}{z+1}$ Tustin with pre-warping $s=\frac{\omega _0}{tan\left ( \frac{\omega _0T_s}{2} \right )}\frac{z-1}{z+1}$ Zero-pole matching $z=e^{sT_s}$ Impulse invariant $X\left ( z \right )=Z\left \{ L^{-1}\left \{ X\left ( s \right ) \right \} \right \}$

### 2.3 离散化练习题

$\frac{Y\left ( s \right )}{U\left ( s \right )}=K_p+\frac{K_i}{s}+K_ds$

$s=\frac{2}{T_s}\frac{z-1}{z+1}$代入上式，得到

$\frac{Y\left ( s \right )}{U\left ( s \right )}=K_p+\frac{K_i}{\frac{2}{T_s}\frac{z-1}{z+1}}+K_d\frac{2}{T_s}\frac{z-1}{z+1}$

$\frac{Y\left ( z \right )}{U\left ( z \right )}= \frac{\frac{\left ( 2T_sK_p+T_s^2K_i+4K_d \right )}{2T_s}+\frac{\left ( 2T_s^2K_i-8K_d \right )}{2T_s}z^{-1}+\frac{\left ( -2T_sK_p+T_s^2K_i+4K_d \right )}{2T_s}z^{-2}}{1-z^{-2}}$

$\frac{Y\left ( z \right )}{U\left ( z \right )}= \frac{6001-12000z^{-1}+5999z^{-2}}{1-z^{-2}}$

 Kp=1;Ki=2;Kd=3;Ts=1e-3;
PID=tf([Kd,Kp,Ki],[1,0])
c2d(PID,1e-3,'tustin')

Transfer function:
6001 z^2 - 1.2e004 z + 5999
---------------------------
z^2 - 1

Sampling time: 0.001


SYSD = C2D(SYSC,TS,METHOD) computes a discrete-time model SYSD with
sampling time TS that approximates the continuous-time model SYSC.
The string METHOD selects the discretization method among the following:
'zoh'       Zero-order hold on the inputs
'foh'       Linear interpolation of inputs
'impulse'   Impulse-invariant discretization
'tustin'    Bilinear (Tustin) approximation.
'matched'   Matched pole-zero method (for SISO systems only).
The default is 'zoh' when METHOD is omitted.

## 3. 使用Matlab离散PR控制器

Kp=1;
Kr=10;
wc=2*pi*5;
wo=2*pi*50;
PRs=Kp+tf([2*Kr*wc,0],[1,2*wc,wo^2])
PRz = c2d(PRs,1e-3,'tustin')


Transfer function:
1.297 z^2 - 1.847 z + 0.643
---------------------------
z^2 - 1.847 z + 0.9405

Sampling time: 0.001

y_k - 1.847*y_k1 + 0.9405*y_k2 = 1.297*u_k - 1.847*u_k1 +0.643*u_k2;

y_k = 1.297*u_k - 1.847*u_k1 +0.643*u_k2 + 1.847*y_k1 - 0.9405*y_k2 ;

## 4、逆变器仿真模型中使用PR闭环控制器

PR控制器实现框图：

04-26
03-24

02-04 1187
03-13 1万+
03-31
05-01 536
08-18
07-03 2794
03-07 426
12-26 801
03-31 2569
09-27 8589

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。