资源简介
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')
代码片段和文件信息
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:DataLength1:2) = 0;
BackEMFAfterLPFLog(1:DataLength1: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(eaeb)
u = k*sign(I_hat-I(i:)‘);
I_Gradient_hat = V(i:)‘ / ls - I_hat * (rs/ls) - u /ls; %%u=Bemf
BackEMFCommandLog(i1:2) = u;
if (i == 1)
continue;
end
%%Get Back-EMF on Clarke axis
%First order butterworth filter cut-off Freq=50h
相关资源
- libssh2-1.8.0-vs2010项目
- UDPserver开发附SQLite、Log4CPP等
- C++ 在程序中执行SQL Server脚本
- C++ 使用ADO连接SQL Server数据库
- vc++和sqlserver.rar
- websocket C++ Server端简单demo
- vs2008(mfc)通过ADO连接SQL SERVER 2008
- bm3d_C语言源码&matlab源码及测试图片
- STM32与触摸芯片BS83B12A-3通过IIC通信读
- C++操作SQL Server数据库新增 删除 修改
- MinGW-w64 C/C++ 编译器
- matlab与C/C++混合编程
- 数字图像处理与机器视觉 光盘
- c++调用webservice(包括静态和动态以及
- 将matlab的图嵌入MFC
- matlab扩展编程
- MFC中用c++语言实现连接SQLServer2008附添
- c++调用matlab函数
- Visual C++ SQL Server数据库开发与
- 数字图像处理与机器视觉Visual C++与
- Visual Studio C#数据库开发经典案例
- c++用SQL语句实现SQL Server的增、删、改
- MFC_Socket_Server.rar
- 基于C++ socket编程实现的websocket服务器
- tdm64-gcc-9.2.0.exe
- 数字图像处理与机器视觉:第二版V
- 数字图像处理与机器视觉_VC与Matlab实
- MFC 编写的仪器测试软件
- 精通图像处理经典算法MATLAB版2014年版
- 量子行为粒子群优化 原理及其应用
评论
共有 条评论