MATLAB数值仿真FOC矢量控制

MATLAB数值仿真FOC矢量控制

本文通过数值仿真加深对FOC矢量控制的理解。状态空间方程本质上是微分方程,本文的核心之处利用四阶龙格库塔方法求解PMSM状态空间方程。在建模的过程中,整个模型中,忽略了逆变器建模,电机状态方程选择了旋转轴系的状态方程,因此省去了unti-park环节。仿真模型分为三个子模块,电机状态方程求解模块(PMSM模块)、控制环路模块、坐标变换模块,代码基本通过MATLAB-Function模块实现。

Simulink整体截图

在这里插入图片描述

PMSM模块1
function [id_now,iq_now,n_now,theta_now,d] = rungekutta_PMSM(uq,ud)
% id_now = id_last+Ts*(ud-R*id_last+omega_e*Ld*iq_last)/Ld;
% iq_now = iq_last+Ts*(uq-R*iq_last-omega_e*Ld*id_last-omega_e*psi_f)/Lq;
persistent iq_last id_last omega_last theta_last j
if isempty(iq_last)
    iq_last = 0;
    id_last = 0;
    omega_last = 0;
    theta_last = 2;
    j = 5000;
end
% Ld = 0.0028;
% Lq = 0.0028;
% Pn = 4;
% psi_f = 0.109;
% J = 0.000245;
% R = 1.86;

Ld = 0.0068;
Lq = 0.0152;
Pn = 3;
psi_f = 0.24;
J = 0.001;
R = 0.98;
if j<2
    load = 2;
else
    load = 0;
end

Ts = 0.0001;
% h = Ts/2;
h = Ts;
k=zeros(4,4);
id_last_initial = id_last;
iq_last_initial = iq_last;
omega_last_initial = omega_last;

for i=1:1:3
    k(i,1) = (ud-R*id_last+omega_last*Ld*iq_last)/Ld;
    k(i,2) = (uq-R*iq_last-omega_last*Ld*id_last-omega_last*psi_f)/Lq;
    Te = 1.5*Pn*iq_last*psi_f;
    k(i,3) = (Te-load)/J/Pn;
    %k(i,4) = omega_last;
    id_last = id_last+h;
    iq_last = iq_last+h;
    omega_last = omega_last+h;
end
id_now = id_last_initial+(k(1,1)+2*k(2,1)+2*k(3,1)+k(4,1))*h/6;
iq_now = iq_last_initial+(k(1,2)+2*k(2,2)+2*k(3,2)+k(4,2))*h/6;
omega_now = omega_last_initial+(k(1,3)+2*k(2,3)+2*k(3,3)+k(4,3))*h/6;
n_now = omega_now*60/2/pi/Pn;
theta_now = theta_last+omega_now*Ts;

id_last = id_now;
iq_last = iq_now;
omega_last = omega_now;
theta_last = theta_now;
j=j-1;
d = j;
控制环路模块2

此模块又分三个子模块,1个速度环和2个电流环模块。

function y = speed_loop(iq_ref,iq_fdb)

persistent error_1 Ui 
if isempty(error_1)
error_1=0;
Ui=0;
end

Lq = 0.0152;
R = 0.98;
a = 3000;
Kp = 0.06;
Ki = 0.04*20;
Ts = 0.0001;

error = iq_ref-iq_fdb;
Up = Kp*error;
Ui = Ki*Ts*error+Ui;
y = Up + Ui;

%限幅
max = 2.4;
min = -max;
if y > max
y = max;
elseif y < min
y =min;
else
y = y;
end
function uq = current_loop_iq(iq_ref,iq_fdb)
persistent error_1 Ui 
if isempty(error_1)
error_1=0;
Ui=0;
end

Lq = 0.0152;
R = 0.98;
a = 3000;
Kp = Lq*a;
Ki = R*a;
Ts = 0.0001;


error = iq_ref-iq_fdb;
Up = Kp*error;
Ui = Ki*Ts*error+Ui;
uq = Up + Ui;

Vdc = 60;
max = 0.9*Vdc*sqrt(1/3);
min = -max;
if uq > max
uq = max;
elseif uq < min
uq = min;
else
uq = uq;
end
function ud = current_loop_id(id_ref,id_fdb)


persistent error_1 Ui 
if isempty(error_1)
error_1=0;
Ui=0;
end

Ld = 0.0068;
R = 0.98;
a = 3000;
Kp = Ld*a;
Ki = R*a;
Ts = 0.0001;


error = id_ref-id_fdb;
Up = Kp*error;
Ui = Ki*Ts*error+Ui;
ud = Up + Ui;

Vdc = 60;
max = 0.9*Vdc*sqrt(1/3);
min = -max;
if ud > max
ud = max;
elseif ud < min
ud =min;
else
ud = ud;
end
坐标变换模块3

可以观察两相静止轴系、三相静止轴系的电流信息

function [alpha,beta] = anti_park(d,q,theta)
alpha = d*cos(theta)-q*sin(theta);
beta = d*sin(theta)+q*cos(theta);
function [a,b,c] = anti_clarke(alpha,beta)
a = alpha;
b = -1/2*alpha+sqrt(3)/2*beta;
c = -1/2*alpha-sqrt(3)/2*beta; 
参考文献

  1. https://blog.csdn.net/qq_50632468/article/details/121179827 ↩︎

  2. https://blog.csdn.net/qq_50632468/article/details/115936457 ↩︎

  3. 袁雷. 现代永磁同步电机控制原理及 MATLAB 仿真[M]. 北京航空航天大学出版社, 2016. ↩︎

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值