基于MATLAB GUI的用PID自動(dòng)控制.doc_第1頁(yè)
基于MATLAB GUI的用PID自動(dòng)控制.doc_第2頁(yè)
基于MATLAB GUI的用PID自動(dòng)控制.doc_第3頁(yè)
基于MATLAB GUI的用PID自動(dòng)控制.doc_第4頁(yè)
基于MATLAB GUI的用PID自動(dòng)控制.doc_第5頁(yè)
已閱讀5頁(yè),還剩33頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

自動(dòng)控制原理MATLAB課程設(shè)計(jì)自動(dòng)化-2何志東20112544目錄MATLAB課程設(shè)計(jì)-1界面介紹-3操作演示-5程序流程示意圖-11源程序-13 一.界面介紹本次課程設(shè)計(jì)的界面如上圖所示,一共有一下4個(gè)模塊:1. 數(shù)據(jù)輸入與轉(zhuǎn)換模塊2. 系統(tǒng)菜單模塊3. 數(shù)據(jù)輸出模塊4. 圖形顯示模塊接下來(lái)將逐一介紹。左上方為數(shù)據(jù)輸入與轉(zhuǎn)換模塊,包括系統(tǒng)函數(shù)的輸入,根軌跡校正參數(shù),以及頻率相應(yīng)參數(shù)的輸入(頻響尚未完成,所以該模塊輸入的數(shù)據(jù)只會(huì)被記錄而暫無(wú)更多的功能)。其中系統(tǒng)函數(shù)能夠通過按鈕選擇為傳遞函數(shù)形式,或者是零極點(diǎn)形式。同樣,根據(jù)你的函數(shù),你可以選擇誤差系數(shù)的選項(xiàng)。在輸入模塊中我們提供了將超調(diào)量轉(zhuǎn)換成阻尼比的功能。左下方為系統(tǒng)菜單模塊,在完成了數(shù)據(jù)輸入之后選擇菜單,將可以提供如系統(tǒng)地根軌跡圖,閉環(huán)階躍響應(yīng),穩(wěn)態(tài)分析等功能。特別是在選擇了“根軌跡校正”的選項(xiàng)后,能夠根據(jù)你所提供的指標(biāo)進(jìn)行超前滯后根軌跡綜合,并且顯示出校正后的根軌跡。并且能將校正后的系統(tǒng)的階躍響應(yīng)與校正之前的階躍響應(yīng)相比較。系統(tǒng)菜單模塊旁邊則是系統(tǒng)的數(shù)據(jù)輸出模塊。每一項(xiàng)菜單的選項(xiàng)都會(huì)有數(shù)據(jù)輸出,并都將在這里顯示。右邊是圖形顯示模塊,上面的兩個(gè)文本框則是可以輸出文本并且給出開環(huán)系統(tǒng)的極點(diǎn)。二.操作演示 這項(xiàng)程序一共有8個(gè)菜單選項(xiàng),對(duì)應(yīng)8個(gè)不同的操作如下清單:1. 根軌跡圖在演示中都將以系統(tǒng) 作為操作演示的例子。2. 階躍響應(yīng) 在計(jì)算階躍響應(yīng)的同時(shí),還會(huì)在輸入模塊顯示該系統(tǒng)的時(shí)域動(dòng)態(tài)參數(shù)。3. Nyquist圖4. Nichols圖5. Bode圖6. 穩(wěn)態(tài)分析 在“穩(wěn)態(tài)分析”選項(xiàng)中,程序?qū)?huì)計(jì)算書閉環(huán)系統(tǒng)的極點(diǎn),并且計(jì)算出在有半軸的極點(diǎn)的個(gè)數(shù)。由此便可以判斷系統(tǒng)是否穩(wěn)定。7. 單位反饋 程序?qū)?huì)在系統(tǒng)函數(shù)中輸出閉環(huán)的系統(tǒng)的傳遞函數(shù)形式。8. 根軌跡校正 在選擇這個(gè)選項(xiàng)之前,必須要給程序輸入必要的指標(biāo)參數(shù):阻尼比,自然震蕩頻率,誤差系數(shù)以及需要的相位裕量。 此時(shí)可以將原系統(tǒng)的根軌跡顯示在右邊的圖形顯示模塊,再選擇“根軌跡校正”,這時(shí)就會(huì)新生成兩個(gè)界面,一個(gè)是校正后的系統(tǒng)的根軌跡,另一個(gè)則是對(duì)比原系統(tǒng)與新系統(tǒng)的閉環(huán)階躍響應(yīng)。同時(shí)新系統(tǒng)的傳遞函數(shù)將會(huì)顯示在數(shù)據(jù)輸出模塊。在命令窗口中也能看到校正環(huán)節(jié)的傳遞函數(shù)。 三.程序流程示意圖開始(1) .數(shù)據(jù)輸入部分 get函數(shù)得到字符串Str2num 轉(zhuǎn)換成數(shù)字 (2) .數(shù)據(jù)輸出部分同上 (3) .菜單部分開始菜單8菜單7菜單6菜單5菜單4菜單3菜單2菜單1獲取菜單字符串 (4) .子函數(shù)超前校計(jì)算校正轉(zhuǎn)置應(yīng)提供的超前相角根據(jù)指標(biāo)求得主導(dǎo)極點(diǎn)開始正由幅值條件確定校正后的系統(tǒng)增益計(jì)算校正轉(zhuǎn)置零極點(diǎn)位置 (5) .子函數(shù)滯后校正最后再適當(dāng)調(diào)整,以便滿足指標(biāo)要求確定計(jì)算偶極子,并且要靠近原點(diǎn),兩者相差倍由需要的指標(biāo)計(jì)算應(yīng)該增大的吾儕系數(shù)值,以及根據(jù)指標(biāo)求得主導(dǎo)極點(diǎn)開始 四.源程序主函數(shù):Untitled.m function varargout = untitled(varargin)% UNTITLED M-file for untitled.fig% UNTITLED, by itself, creates a new UNTITLED or raises the existing% singleton*.% H = UNTITLED returns the handle to a new UNTITLED or the handle to% the existing singleton*.% UNTITLED(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in UNTITLED.M with the given input arguments.% UNTITLED(Property,Value,.) creates a new UNTITLED or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before untitled_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to untitled_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help untitled % Last Modified by GUIDE v2.5 03-Mar-2014 12:47:49 % Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, untitled_OpeningFcn, . gui_OutputFcn, untitled_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);end if nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT % - Executes just before untitled is made visible.function untitled_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to untitled (see VARARGIN) % Choose default command line output for untitledhandles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes untitled wait for user response (see UIRESUME)% uiwait(handles.figure1); % - Outputs from this function are returned to the command line.function varargout = untitled_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structurevarargout1 = handles.output; % -function Untitled_1_Callback(hObject, eventdata, handles)% hObject handle to Untitled_1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % -function Untitled_2_Callback(hObject, eventdata, handles)% hObject handle to Untitled_2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % -function t2_Callback(hObject, eventdata, handles)% hObject handle to t2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,String) returns contents of edit1 as text% str2double(get(hObject,String) returns contents of edit1 as a double % - Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,String) returns contents of edit2 as text% str2double(get(hObject,String) returns contents of edit2 as a double % - Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function edit3_Callback(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,String) returns contents of edit3 as text% str2double(get(hObject,String) returns contents of edit3 as a double % - Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function edit4_Callback(hObject, eventdata, handles)% hObject handle to edit4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,String) returns contents of edit4 as text% str2double(get(hObject,String) returns contents of edit4 as a double % - Executes during object creation, after setting all properties.function edit4_CreateFcn(hObject, eventdata, handles)% hObject handle to edit4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function edit5_Callback(hObject, eventdata, handles)% hObject handle to edit5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,String) returns contents of edit5 as text% str2double(get(hObject,String) returns contents of edit5 as a double % - Executes during object creation, after setting all properties.function edit5_CreateFcn(hObject, eventdata, handles)% hObject handle to edit5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function edit6_Callback(hObject, eventdata, handles)% hObject handle to edit6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,String) returns contents of edit6 as text% str2double(get(hObject,String) returns contents of edit6 as a double % - Executes during object creation, after setting all properties.function edit6_CreateFcn(hObject, eventdata, handles)% hObject handle to edit6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function edit7_Callback(hObject, eventdata, handles)% hObject handle to edit7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,String) returns contents of edit7 as text% str2double(get(hObject,String) returns contents of edit7 as a double % - Executes during object creation, after setting all properties.function edit7_CreateFcn(hObject, eventdata, handles)% hObject handle to edit7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function edit8_Callback(hObject, eventdata, handles)% hObject handle to edit8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,String) returns contents of edit8 as text% str2double(get(hObject,String) returns contents of edit8 as a double % - Executes during object creation, after setting all properties.function edit8_CreateFcn(hObject, eventdata, handles)% hObject handle to edit8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end % - Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) global Kpva %誤差系數(shù) global num; %傳遞函數(shù)的輸入分子 global den; %傳遞函數(shù)的輸入分母 global zero; %開環(huán)系統(tǒng)零點(diǎn) global pole; %閉環(huán)系統(tǒng)極點(diǎn) global Kgain; %傳遞函數(shù)增益K global q; %阻尼比 global sys; %開環(huán)系統(tǒng) global sysback ; %閉環(huán)系統(tǒng) global overshoot; %超調(diào)量 global Ts; %調(diào)整時(shí)間Ts global Tr; global Tp; %峰值時(shí)間Tp global Wn; %頻率 global flag1; %標(biāo)志1為傳遞函數(shù),0為零極點(diǎn) global flagk; %標(biāo)志為-1為KP,標(biāo)志為0為KV,標(biāo)志為1為KA global Kpva %誤差系數(shù) global xw; %相位裕量 global ypm %頻率響應(yīng)中的相角裕度 q = get( handles.edit4 , String ); overshoot = get( handles.edit5 , String ); ypm = get( handles.edit7 , String ); Tr = get( handles.edit8 , String ); Tp = get( handles.edit6 , String ); Wn = get( handles.edit9 , String ); Kpva = get( handles.edit25 , String ); xw = get( handles.edit27 , String ); q = str2num(q);overshoot = str2num(overshoot);ypm = str2num(ypm);Tp = str2num(Tp);Wn = str2num(Wn);Kpva = str2num(Kpva);xw = str2num(xw); %獲得數(shù)據(jù)numtem = get( handles.edit1 , String );dentem = get( handles.edit2 , String );Kgain = get( handles.edit3 , String ); % 格式轉(zhuǎn)換,將字符格式轉(zhuǎn)換成數(shù)字格式 numtem = str2num( numtem ); dentem = str2num( dentem ); Kgain = str2num( Kgain ); if flag1 = 0 %判斷系統(tǒng)形式 sys = zpk(numtem,dentem,Kgain); zero=numtem; pole=dentem; endif flag1 =1 sys = tf(numtem,dentem); num=numtem; den=dentem; end sysback=feedback(sys,1); %單位反饋 % -function uipanel1_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to uipanel1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % - Executes on button press in radiobutton5.function radiobutton5_Callback(hObject, eventdata, handles)% hObject handle to radiobutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,Value) returns toggle state of radiobutton5global sys ;grid onnyquist(sys); title(奈奎斯特圖); saveas( gcf,Nyquist,.bmp); % - Executes when selected object is changed in uipanel1.function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)% hObject h

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論