計算機控制專題實驗資料_第1頁
計算機控制專題實驗資料_第2頁
計算機控制專題實驗資料_第3頁
計算機控制專題實驗資料_第4頁
計算機控制專題實驗資料_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

專題實驗2013.6.14一樓聯(lián)系電話:LD-9188PbKw)MatlabGIMatlabGUI1)×××2顯示溫0~100C,3顯示4顯示5D并67止保存結(jié)束等按鈕功寫樣濾波PID等相關(guān)序。PID穩(wěn)觀察分析PID規(guī)律保存最佳。1PCI6~87 2121。1 168/AIn—―AnalogInputChanneln(single-ended)AIHn—―AnalogHighInputChanneln(differential)AILn—―AnalogLowInputChanneln(differential)ExtRefn—―ExternalReferenceVoltageforD/ACHnAOn—―AnalogOutputChannelnExtCLK—―ExternalClockInputExtTriExternalTriggerSignalClockinputfor8254etrTnltfrneA.GND——AnalogGroundGND——GroundA/D的0號通道和數(shù)模轉(zhuǎn)換通道選用D/A的0號通道。圖2數(shù)據(jù)采集卡與端子板聯(lián)接圖系統(tǒng)中數(shù)據(jù)采集卡PCI-9112與端子板PCLD-9188連接示意圖如圖2所示:CN3為PCI-9112的模擬量通道連接端口,CN1和CN2為數(shù)字量通道連接端口,實驗中只連接模擬量通道CN3。軟件包中含PCI-9112的驅(qū)動程序。2.ADLINK軟件包說明:ADLINK軟件包包含了數(shù)據(jù)采集卡的軟硬件驅(qū)動程序和用戶手冊首先閱讀SoftwareInstallationGuide手冊,掌握數(shù)據(jù)采集卡的設(shè)備驅(qū)動與軟件驅(qū)動的安裝。開始設(shè)計時可以通過用戶手冊NuDAQ/NuIPC9112 Series掌握數(shù)據(jù)采集卡PCI9112及編程的有用信息,但其后面的例程主要針對C語言,編程可參閱ADLINK軟件包中的PCI-DASK的用戶手冊。通過NuDAQ ACLD SeriesTerminationBoardsUser’sManual端子板用戶手冊,查看ACLD-9188的資料。MatlabADLINKDAQ-MTLB應(yīng)有軟DAQ-MTLBManualMatlab對數(shù)據(jù)采卡進DAQ-MTLB->Utilities->PCIConfigureUtility對數(shù)據(jù)采集卡進行設(shè)置。:、偏差現(xiàn)溫度箱。軟安裝方法需要安裝MatlabADLINK。應(yīng)MatlabGUI畫面過程P、I、D、樣周期、橫軸點靜態(tài)文本框;PID;、啟動/;PID法ku(k)

1

1

e(n)

e(k)]P T in0ke(k)e(k)e(k)PTTi d。。樣周期一周期限。樣過域產(chǎn)生混疊從而導(dǎo)致失真。樣過,樣點過很大。字讀寫添備:ai_device=analoginput('mwadlink',0);為備添:addchannel(ai_device,0);addchannel(ao_device,0);采樣數(shù)據(jù):getsample(ai_device);輸出數(shù)據(jù):putdata(ao_device,C(i)/20);PID參數(shù)的整定規(guī)律與結(jié)果分析比例:增加比例系數(shù),加快系統(tǒng)響應(yīng),減小穩(wěn)態(tài)誤差。但比例帶太小會使系統(tǒng)有較大的超調(diào)和振蕩,破壞系統(tǒng)的穩(wěn)定性。積分:主要用于減小系統(tǒng)的穩(wěn)態(tài)誤差。減小積分系數(shù)有利于減小超調(diào),提高系統(tǒng)的穩(wěn)定性。但消除穩(wěn)態(tài)誤差的速度將隨之減慢。微分:增大微分系數(shù)可以加速系統(tǒng)的響應(yīng),使超調(diào)量減小,增加系統(tǒng)的穩(wěn)定性,但系統(tǒng)的抗干擾能力下降。整定的次序通常為:先比例,再積分,后微分。整定比例系數(shù):置將由小變大,使系統(tǒng)曲線略有超調(diào)。如果此時系統(tǒng)的穩(wěn)態(tài)誤差已落入誤差帶范圍內(nèi),則系統(tǒng)只使用比例控制就可以了。整定積分系數(shù):在比例控制的基礎(chǔ)上,若系統(tǒng)還有較大的穩(wěn)態(tài)誤差,則需要加入積分控制。首先將調(diào)好的比例系數(shù)減小%到%,再講積分系數(shù)由小到大調(diào)節(jié),直到穩(wěn)態(tài)誤差落入誤差帶之內(nèi)為止。、值,反復(fù)調(diào)試,直至滿足各個性能制表的要求為止保存的時實控制畫面(調(diào)節(jié)參數(shù)過程)(1)(2)(3)、程序functionvarargout=aaa(varargin)gui_Singleton=1;gui_State=struct('gui_Name', mfilename,...'gui_Singleton', gui_Singleton,...'gui_OpeningFcn',@aaa_OpeningFcn,...'gui_OutputFcn', @aaa_OutputFcn,...'gui_LayoutFcn', [],...'gui_Callback', ifnargin&isstr(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elseend

gui_mainfcn(gui_State,varargin{:});functionaaa_OpeningFcn(hObject,eventdata,handles,varargin)handles.output=hObject;guidata(hObject,handles);functionvarargout=aaa_OutputFcn(hObject,eventdata,handles)%設(shè)置控件回調(diào)函數(shù)globalsPIDflagcs=0;s=str2num('nan');P=str2num('nan');I=str2num('nan');D=str2num('nan');set(handles.pushbutton2,'String','啟動');functionedit1_Callback(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit1astext% str2double(get(hObject,'String'))returnscontentsofedit1asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit1_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.% SeeISPCandCOMPUTER.if ispc && get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit2_Callback(hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit2astext% str2double(get(hObject,'String'))returnscontentsofedit2asdouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit2_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.% SeeISPCandCOMPUTER.if ispc && get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit3_Callback(hObject,eventdata,handles)%hObjecthandletoedit3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit3astext% str2double(get(hObject,'String'))returnscontentsofedit3asdouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit3_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.% SeeISPCandCOMPUTER.if ispc && get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit4_Callback(hObject,eventdata,handles)%hObjecthandletoedit4(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit4astext% str2double(get(hObject,'String'))returnscontentsofedit4asdouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit4_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit4(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.% SeeISPCandCOMPUTER.if ispc && get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit5_Callback(hObject,eventdata,handles)%hObjecthandletoedit5(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit5astext% str2double(get(hObject,'String'))returnscontentsofedit5asdouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit5_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit5(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.% SeeISPCandCOMPUTER.if ispc && get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit6_Callback(hObject,eventdata,handles)%hObjecthandletoedit6(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit6astext% str2double(get(hObject,'String'))returnscontentsofedit6asadouble%---Executesduringobjectcreation,aftersettingallproperties.functionedit6_CreateFcn(hObject,eventdata,handles)%hObject handletoedit6(seeGCBO)%eventdata reserved-tobedefinedinafutureversionofMATLAB%handles empty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.% SeeISPCandCOMPUTER.if ispc && get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end%---Executesonbuttonpressincheckbox1.functioncheckbox1_Callback(hObject,eventdata,handles)globalcsifget(hObject,'Value')==get(hObject,'Max')cs=1;elseend

cs=0;functioncheckbox2_Callback(hObject,eventdata,handles)ifget(hObject,'Value')==get(hObject,'Max')axes(handles.axes1);gridon;end

axes(handles.axes1);gridoff;functionpushbutton1_Callback(hObjecteventdatahandles)%globalsPIDNtfcontent='';s=str2double(get(handles.edit1,'String'));ifisnan(s)content=strcat(content,'endP=str2double(get(handles.edit2,'String'));ifisnan(P)ifcontent~=''end

endcontent=strcat(content,'PI=str2double(get(handles.edit3,'String'));ifisnan(I)ifcontent~=''content=strcat(content,'、');end

endcontent=strcat(content,'I值');D=str2double(get(handles.edit4,'String'));ifisnan(D)ifcontent~=''content=strcat(content,'、');end

endcontent=strcat(content,'D值');tf=str2double(get(handles.edit5,'String'));ifisnan(tf)ifcontent~=''content=strcat(content,'、');end

endcontent=strcat(content,'采樣周期');N=str2double(get(handles.edit6,'String'));ifisnan(N)ifcontent~=''content=strcat(content,'、');end

endcontent=strcat(content,'橫軸點數(shù)');ifcontent~=''errordlg(strcat(content,'輸入錯誤'),'參數(shù)錯誤');end%---Executesonbuttonpressinpushbutton2.functionpushbutton2_Callback(hObject,eventdata,handles)%設(shè)置控件功能globalsPIDflagNtfcsif((((isnan(s)||isnan(P))||isnan(I))||isnan(D))||isnan(tf))||isnan(N)errordlg('請先讀入數(shù)據(jù)');elseifget(hObject,'String')==elseflag=0;set(hObject,'String','endai_device=analoginput('mwadlink',0);addchannel(ai_device,0);ao_device=analogoutput('mwadlink',0);addchannel(ao_device,0);i=1;d=0;whileflag==1axes(handles.axes1);t(i)=0;forj=1:20;t(i)=t(i)+getsample(ai_device); ende(i)=s-t(i);S(i)=s;d=d+e(i);ifI*d>200d=200/I;elseifI*d<-100d=-100/I;endifi>1 %PIDC(i)=P*e(i)+I*d+D*(e(i)-e(i-1));elseC(i)=P*e(i)+I*d;endC(i)=C(i)/20;%ifC(i)<0 %C(i)=0;elseifC(i)>5 C(i)=5;endputdata(ao_device,C(i));start(ao_device);holdon;cla;ifcs==1plot(C,'g')曲線endplot(S,'r'); %ifi<Naxis([0N-5110]);'elseaxis([i-N+1,i+1-5110]);endaxes(handles.axes3);cla;axis([0100100]);'line([0,10],[100,100])holdonbar([1],[s],'r');holdonbar([5],[t(i)],'b');holdonbar([9],[C(i)],'g');holdoffend

i=i+1;pause(tf);ifflag==0putdata(ao_device,0); start(ao_device);endendfunctionpushbutton3_Callback(hObject,eventdata,handles)[filename,pathname]=uiputfile({'*.bmp';'*.jpg';'*.png';'*.fig';'*.*'},'保存到','Untitled');axes(handles.axes1);%h=getframe(handles.axes1);saveas(gca,strcat(pathname,filename));%---Executesonmousepressoveraxesbackground.functionaxes1_ButtonDownFcn(hObject,eventdata,handles)%hObjecthandletoaxes1(seeGCBO)%eventdatarese

溫馨提示

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

最新文檔

評論

0/150

提交評論