Viết chương trình cho giao diện tính toán

Một phần của tài liệu Thiết kế động cơ không đồng bộ ba pha (Trang 106)

Để chương trình chạy theo yêu cầu thiết kế của bài toán trên, ta viết chương trình như sau:

function varargout = TINHTOAN(varargin) gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @TINHTOAN_OpeningFcn, ... 'gui_OutputFcn', @TINHTOAN_OutputFcn, ... 'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else

gui_mainfcn(gui_State, varargin{:}); end

Function TINHTOAN_OpeningFcn(hObject, eventdata, handles, varargin)

handles.output = hObject; guidata(hObject, handles);

function varargout = TINHTOAN_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;

function Dt_Callback(hObject, eventdata, handles) function Dt_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function L_Callback(hObject, eventdata, handles) function L_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function bg_Callback(hObject, eventdata, handles) function bg_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function Z_Callback(hObject, eventdata, handles) function Z_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function Kc_Callback(hObject, eventdata, handles) function Kc_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function Bsixma_Callback(hObject, eventdata, handles) function Bsixma_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function Udmpha_Callback(hObject, eventdata, handles) function Udmpha_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function d1_Callback(hObject, eventdata, handles) function d1_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function Npha1_Callback(hObject, eventdata, handles) function Npha1_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function Nb1_Callback(hObject, eventdata, handles) function Nb1_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function d_Callback(hObject, eventdata, handles) function d_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function dcd_Callback(hObject, eventdata, handles) function dcd_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function Pdm_Callback(hObject, eventdata, handles) function Pdm_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function Wday1_Callback(hObject, eventdata, handles) function Wday1_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function CV7_Callback(hObject, eventdata, handles) function CV7_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function CV8_Callback(hObject, eventdata, handles) function CV8_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function TINHTOAN_Callback(hObject, eventdata, handles) tinhtoan(handles)

function d2_Callback(hObject, eventdata, handles) function d2_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function KldSB_Callback(hObject, eventdata, handles) function KldSB_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function J_Callback(hObject, eventdata, handles) function J_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function ni_Callback(hObject, eventdata, handles) function ni_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function GAMMA_Callback(hObject, eventdata, handles) function GAMMA_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function cosPHI_Callback(hObject, eventdata, handles) function cosPHI_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function edit23_Callback(hObject, eventdata, handles) function edit23_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

% --- Executes on button press in THOAT.

function THOAT_Callback(hObject, eventdata, handles) % hObject handle to THOAT (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

close;

%TAO HAM TINH TOAN

function tinhtoan(handles) % KHAI BAO BIEN TOAN CUC

global Dt L bg br Z Kc Bsixma Udmpha d1 d2 KldSB J ni GAMMA cosPHI M

% DUONG KINH TRONG LOI THEP STATOR Dt

Dt=get(handles.Dt,'string'); Dt=str2num(Dt); %BE DAY LOI THEP

L=get(handles.L,'string'); L=str2num(L); %BE DAY GONG LOI THEP STATOR

bg=get(handles.bg,'string'); bg=str2num(bg); % BE DAY RANH STATOR

br=get(handles.br,'string'); br=str2num(br); % TONG SO RANH STATOR

Z=get(handles.Z,'string'); Z=str2num(Z);

% HE SO XEP CHAT CUA LOI THEP STATOR THUONG 0,93 DEN 0,95 Kc=get(handles.Kc,'string'); Kc=str2num(Kc);

%

Bsixma=get(handles.Bsixma,'string'); Bsixma=str2num(Bsixma); % DIEN AP DINH MUC PHA

Udmpha=get(handles.Udmpha,'string'); Udmpha=str2num(Udmpha); d1=get(handles.d1,'string'); d1=str2num(d1); d2=get(handles.d2,'string'); d2=str2num(d2); h=get(handles.h,'string'); h=str2num(h); KldSB=get(handles.KldSB,'string'); KldSB=str2num(KldSB); J=get(handles.J,'string'); J=str2num(J); ni=get(handles.ni,'string'); ni=str2num(ni); gamma=get(handles.gamma,'string'); gamma=str2num(gamma); cosPHI=get(handles.cosPHI,'string'); cosPHI=str2num(cosPHI); %cv=get(handles.cv,'string'); cv=str2num(cv); % GAN CHUOI

% TINH TOAN (DANG 6 DAU RA) % dau sao

% Udsao=sqrt(3)*Udmpha % dau tam giac

% Uddelta=Udmpha %Npha1=(Dt-L)/pdm %Nb1=Npha1/2

% BUOC 2 XÁC DINH SO CUC Pmin_1=(0.4*Dt)/bg

if 2<=Pmin_1<5 Pmin=4

else 1<Pmin_1<3 Pmin=2

end

% BUOC 3

% buoc cuc (anfasixma=0.71) to=(pi*Dt)/(Pmin*1000) % tu thong phi=0.71*to*L*Bsixma % BUOC 4 (knc=0.94) Bg=(phi*10000)/(2*bg*L*0.94) % hoac Bg=(0.71*pi*Dt*Bsixma)/(2*kc*bg*Pmin) % BUOC 5 Br=(pi*Dt*Bsixma)/(Z*br)

% gioi han cua Bgmax=1.4T va Brmax=1.5T % BUOC 6 lap bang

%if Bg>1.5 % chon_lai %end %if Br>1.4 % chon_lai %end

% BUOC 7 (day quan 1 lop) to_phay=Z/Pmin

q=to_phay/3

anfa_dien=180/to_phay

% day quan 1 lop, dong khuon phan tan don gian

kdq=sin((q*anfa_dien*pi)/(2*180))/(q*sin((anfa_dien*pi)/(2*18 0))) % BUOC 8 Aa=to*L*10000 Aa=round(Aa) if 15<Aa<50 kE=0.83 else 50<Aa<100

kE=0.88 end %if 100<Aa<150 % kE=0.92 %else 150<Aa<400 % kE=0.94 %end %if Aa>400 % kE=0.96 %end Npha=round((kE*Udmpha)/(4*1.07*50*phi*kdq)) % f=50 % tong so boi_pha=Z/2*3 tongsoboi_pha=Z/(2*3) Nb=round(Npha/(tongsoboi_pha)) % BUOC 9

% tiet dien day cach dien n=1; ur=1; kld=0.46

Sr=round(((d1+d2)/2)*(h-d2/2)+((pi*d2*d2)/8)) Scd=(kld*Sr)/(ur*Nb*n)

% duong kinh cach dien dcd_1=2*sqrt(Scd/3.14) if 0.4<dcd_1<0.6 dcd=0.5 else 0.6<dcd_1<0.7 dcd=0.65 end

% duong kinh day tran (can lam tron so) d=dcd-0.05 % lam tron voi so gan

% BUOC 10

% chon mat do dong dien theo cap % cap A: J=5.5 den 6.5

% cap B, E: J=6.5 den 7.5 J=6.5

Idmpha=(pi*d*d*J)/4 % BUOC 11 ni=0.77; cosphi=0.8 Pdm=3*Udmpha*Idmpha*ni*cosphi Pdm=round(Pdm); % BUOC 12 hr=14 KL=(3.14*gamma*(Dt+hr))/Z % chu vi khuon %CV=2*(KL*y+Lphay) CV7=(2*(KL*7+(L*1000+9)))/10 CV8=(2*(KL*8+(L*1000+9)))/10 % L'=L+(5mm den 10mm) %L_phay=L+8(L+8)

% khoi luong day quan

%Lpha=Pdm*Nb1*tongsoboi_pha Lpha=(Nb*(CV8*4+CV7*2))/10 L3pha=3*Lpha

Wday=(1.1*8.9*L3pha*pi*d*d*0.0001)/4 % XUAT KET QUA

set(handles.Npha1,'string',num2str(Npha)); set(handles.Nb1,'string',num2str(Nb)); set(handles.d,'string',num2str(d)); set(handles.dcd,'string',num2str(dcd)); set(handles.CV7,'string',num2str(round(CV7))); set(handles.CV8,'string',num2str(round(CV8))); set(handles.Wday1,'string',num2str(Wday)); set(handles.Pdm,'string',num2str(Pdm));

function br_Callback(hObject, eventdata, handles) function br_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

% --- Executes during object creation, after setting all properties.

function popupmenu1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end A = str2double(get(hObject,'string')); handles.metricdata.concs = A; guidata(hObject,handles) user_entry= handles.metricdata.A; uisave(variables,A)

save ketqua.xls A-ascii

function h_Callback(hObject, eventdata, handles) function h_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

function gamma_Callback(hObject, eventdata, handles) function gamma_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end

% --- Executes on button press in reset.

function reset_Callback(hObject, eventdata, handles) set(handles.Dt,'string',num2str(0)); set(handles.L,'string',num2str(0)); set(handles.bg,'string',num2str(0)); set(handles.br,'string',num2str(0)); set(handles.Z,'string',num2str(0)); set(handles.Kc,'string',num2str(0)); set(handles.Bsixma,'string',num2str(0));

set(handles.Udmpha,'string',num2str(0)); set(handles.d1,'string',num2str(0)); set(handles.d2,'string',num2str(0)); set(handles.h,'string',num2str(0)); set(handles.KldSB,'string',num2str(0)); set(handles.J,'string',num2str(0)); set(handles.ni,'string',num2str(0)); set(handles.gamma,'string',num2str(0)); set(handles.cosPHI,'string',num2str(0)); set(handles.Npha1,'string',num2str(0)); set(handles.Nb1,'string',num2str(0)); set(handles.d,'string',num2str(0)); set(handles.dcd,'string',num2str(0)); set(handles.CV7,'string',num2str(round(0))); set(handles.CV8,'string',num2str(round(0))); set(handles.Wday1,'string',num2str(0)); set(handles.Pdm,'string',num2str(0));

Một phần của tài liệu Thiết kế động cơ không đồng bộ ba pha (Trang 106)

Tải bản đầy đủ (PDF)

(120 trang)