实例介绍
clear all
%%Set motor parameter
ls = 0.0085;
rs = 2.875;
rated_flux = 0.175;
Pole_pair = 4;
%%Run PMSM control model
SampingTime = 0.000001;
sim('pmsm_ideal/pmsm_ideal.slx');
DataLength = length(V);
%%Sliding Mode Observer Parameter
I_hat=[0;0];
I_Gradient_hat=[0;0];
k = 200;
%%Log Data
BackEMFCommandLog(1:DataLength,1:2) = 0;
BackEMFAfterLPFLog(1:DataLength,1:2) = 0;
EstimateTheata(1:DataLength) = 0;
EstimateW(1:DataLength) = 0;
EstimateWAfterLPF(1:DataLength) = 0;
EstimateTheataAfterCompensate(1:DataLength) = 0;
RealAngle(1:DataLength) = 0;
for i=1:DataLength
%%Sliding Mode Obsevvation
I_hat = I_hat SampingTime * I_Gradient_hat;
%k*sign(I_hat-I(i,:)') >= Max(ea,eb)
u = k*sign(I_hat-I(i,:)');
I_Gradient_hat = V(i,:)' / ls - I_hat * (rs/ls) - u /ls; %%u=Bemf
BackEMFCommandLog(i,1:2) = u;
if (i == 1)
continue;
end
%%Get Back-EMF on Clarke axis
%First order butterworth filter, cut-off Freq=50hz
BackEMFAfterLPFLog(i,:) = 0.00015705*BackEMFCommandLog(i,:)' 0.00015705*BackEMFCommandLog(i-1,:)' 0.99968*BackEMFAfterLPFLog(i-1,:)';
%%Get Estimate Electrical Angle
EstimateTheata(i) = atan2(-BackEMFAfterLPFLog(i,1),BackEMFAfterLPFLog(i,2));
%Shift(-pi to pi)
if(EstimateTheata(i) < 0)
EstimateTheata(i) = 2*pi EstimateTheata(i);
end
%%Get Estimate Electrical Speed
EstimateW(i) = (EstimateTheata(i) - EstimateTheata(i-1));
%Compensate phase change
if( EstimateW(i) > pi)
EstimateW(i) = 2*pi-EstimateW(i);
elseif ( EstimateW(i) < -pi)
EstimateW(i) = 2*pi EstimateW(i);
end
EstimateW(i) = EstimateW(i) / SampingTime;
%First order butterworth filter, cut-off Freq=50hz
EstimateWAfterLPF(i) = 0.00015705*EstimateW(i) 0.00015705*EstimateW(i-1) 0.99968*EstimateWAfterLPF(i-1);
%%Compensate Estimate Electrical Angle phse shift
EstimateTheataAfterCompensate(i) = EstimateTheata(i) atan(EstimateWAfterLPF(i)/(100*pi));
if(EstimateTheataAfterCompensate(i) > 2*pi)
EstimateTheataAfterCompensate(i) = EstimateTheataAfterCompensate(i) - 2 * pi;
end
%%Get Real Electrical Angle
RealAngle(i) = atan2(sin(theata(i)),cos(theata(i)));
%Shift(-pi to pi)
if(RealAngle(i) < 0)
RealAngle(i) = 2*pi RealAngle(i);
end
end
T = [0:SampingTime:SampingTime*(DataLength-1)];
%%Plot Estimate Angle and Speed
figure('Name','SMO Data');
subplot(2,1,1);
plot(T,EstimateTheata);
title('SMO Estimate Electrical Theata');
xlabel('time')
ylabel('£c');
subplot(2,1,2);
plot(T,EstimateWAfterLPF)
title('SMO Estimate Electrical Speed');
ylabel('W');
xlabel('time')
%%Real Angle and SMO Angle
figure('Name','Real Angle and SMO Angle');
plot(T,RealAngle);
hold on
plot(T,EstimateTheataAfterCompensate,'--');
hold off
xlabel('time')
ylabel('£c');
legend('RealAngle','Senserless Angle')
%%Set motor parameter
ls = 0.0085;
rs = 2.875;
rated_flux = 0.175;
Pole_pair = 4;
%%Run PMSM control model
SampingTime = 0.000001;
sim('pmsm_ideal/pmsm_ideal.slx');
DataLength = length(V);
%%Sliding Mode Observer Parameter
I_hat=[0;0];
I_Gradient_hat=[0;0];
k = 200;
%%Log Data
BackEMFCommandLog(1:DataLength,1:2) = 0;
BackEMFAfterLPFLog(1:DataLength,1:2) = 0;
EstimateTheata(1:DataLength) = 0;
EstimateW(1:DataLength) = 0;
EstimateWAfterLPF(1:DataLength) = 0;
EstimateTheataAfterCompensate(1:DataLength) = 0;
RealAngle(1:DataLength) = 0;
for i=1:DataLength
%%Sliding Mode Obsevvation
I_hat = I_hat SampingTime * I_Gradient_hat;
%k*sign(I_hat-I(i,:)') >= Max(ea,eb)
u = k*sign(I_hat-I(i,:)');
I_Gradient_hat = V(i,:)' / ls - I_hat * (rs/ls) - u /ls; %%u=Bemf
BackEMFCommandLog(i,1:2) = u;
if (i == 1)
continue;
end
%%Get Back-EMF on Clarke axis
%First order butterworth filter, cut-off Freq=50hz
BackEMFAfterLPFLog(i,:) = 0.00015705*BackEMFCommandLog(i,:)' 0.00015705*BackEMFCommandLog(i-1,:)' 0.99968*BackEMFAfterLPFLog(i-1,:)';
%%Get Estimate Electrical Angle
EstimateTheata(i) = atan2(-BackEMFAfterLPFLog(i,1),BackEMFAfterLPFLog(i,2));
%Shift(-pi to pi)
if(EstimateTheata(i) < 0)
EstimateTheata(i) = 2*pi EstimateTheata(i);
end
%%Get Estimate Electrical Speed
EstimateW(i) = (EstimateTheata(i) - EstimateTheata(i-1));
%Compensate phase change
if( EstimateW(i) > pi)
EstimateW(i) = 2*pi-EstimateW(i);
elseif ( EstimateW(i) < -pi)
EstimateW(i) = 2*pi EstimateW(i);
end
EstimateW(i) = EstimateW(i) / SampingTime;
%First order butterworth filter, cut-off Freq=50hz
EstimateWAfterLPF(i) = 0.00015705*EstimateW(i) 0.00015705*EstimateW(i-1) 0.99968*EstimateWAfterLPF(i-1);
%%Compensate Estimate Electrical Angle phse shift
EstimateTheataAfterCompensate(i) = EstimateTheata(i) atan(EstimateWAfterLPF(i)/(100*pi));
if(EstimateTheataAfterCompensate(i) > 2*pi)
EstimateTheataAfterCompensate(i) = EstimateTheataAfterCompensate(i) - 2 * pi;
end
%%Get Real Electrical Angle
RealAngle(i) = atan2(sin(theata(i)),cos(theata(i)));
%Shift(-pi to pi)
if(RealAngle(i) < 0)
RealAngle(i) = 2*pi RealAngle(i);
end
end
T = [0:SampingTime:SampingTime*(DataLength-1)];
%%Plot Estimate Angle and Speed
figure('Name','SMO Data');
subplot(2,1,1);
plot(T,EstimateTheata);
title('SMO Estimate Electrical Theata');
xlabel('time')
ylabel('£c');
subplot(2,1,2);
plot(T,EstimateWAfterLPF)
title('SMO Estimate Electrical Speed');
ylabel('W');
xlabel('time')
%%Real Angle and SMO Angle
figure('Name','Real Angle and SMO Angle');
plot(T,RealAngle);
hold on
plot(T,EstimateTheataAfterCompensate,'--');
hold off
xlabel('time')
ylabel('£c');
legend('RealAngle','Senserless Angle')
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论