




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、计算机控制专题实验 指导老师:王永昌 景州 成员: 提交时间:2013.6.14 实验地点:西一楼 联系电话:一、实验目的 (1)掌握计算机控制系统各个环节的设计以及系统的组成。(2)通过实验使我们能够较熟练地设计计算机控制系统的各个环节和完整的系统,熟练掌握系统的调试和控制器参数的整定方法。(3)巩固和深化理论教学内容,培养学生的工程实践技能,综合运用所学专业知识解决实际问题的能力。二、实验设备1计算机一台2数据采集卡PCI-9112卡一块,端子板LD-9188一块及电缆3温度控制箱一套4WindowsXP系统,Matlab软件,ADLINK软件包。(Labview软件)三、实验内容与要求1
2、 了解温度控制系统的构成,熟悉各环节的工作原理。掌握MatlabGUI设计系统监控画面及编程方法。2 熟练应用MatlabGUI设计系统监控画面,要求监控画面中有:1)控制系统名称“温度监控系统”与“设计人:”,2)显示实时温度控制曲线,横坐标为时间单位秒,纵坐标为温度,范围为0100C,加网格,3)数字显示实时温度,与控制输出,4)显示控制棒图,标记温度设定值,实时温度,控制输出,5)设定值温度与PID三个参数,并可以实时修改,6)可选的优化方法,7)有运行,停止,保存,结束等按钮功能。3 设计编写采样、滤波、PID控制及优化算法等相关程序。4 完成PID参数整定,调试出稳定的温度控制系统,
3、观察并分析过程控制的PID整定规律。保存最佳的整定参数与控制曲线图。四、实验硬件与软件的说明1数字采集卡:数据采集卡PCI-9112插在主板上的PCI插槽中,包含数字信号与模拟信号两种。模拟信号有两种模拟输入:16路单端模拟输入(A0A15)和8路差分模拟输入(AL0AL7/AH0AH7),2路模拟量输出(AO1和AO2)。引脚图见图1。图1 16路单端模拟输入和8路差分模拟输入引脚图引脚说明:(模拟输入/输出与定时计数器)AI n Analog Input Channel n (single-ended)AIH nAnalog High Input Channel n (differenti
4、al)AIL nAnalog Low Input Channel n (differential)ExtRef nExternal Reference Voltage for D/A CH nAO nAnalog Output Channel nExtCLKExternal Clock InputExtTrigExternal Trigger SignalCLKClock input for 8254GATEGate input for 8254COUT n Signal output of Counter nV.ERFVoltage ReferenceA.GNDAnalog GroundGN
5、DGround实验中采用单端输入与输出,模数转换通道选用A/D的0号通道和数模转换通道选用D/A的0号通道。图2 数据采集卡与端子板联接图系统中数据采集卡PCI-9112与端子板PCLD-9188连接示意图如图2所示:CN3为PCI-9112的模拟量通道连接端口,CN1和CN2为数字量通道连接端口,实验中只连接模拟量通道CN3。初次安装按照系统提示对数据采集卡进行初始化设置,ADLINK软件包中含有硬件驱动的软件,实验中需要安装PCI-9112的驱动程序。2ADLINK软件包说明:ADLINK软件包包含了数据采集卡的软硬件驱动程序和用户手册,首先阅读Software Installation
6、Guide手册,掌握数据采集卡的设备驱动与软件驱动的安装。开始设计时可以通过用户手册NuDAQ/NuIPC9112 Series掌握数据采集卡PCI9112及编程的有用信息,但其后面的例程主要针对C语言,编程可参阅ADLINK软件包中的PCI-DASK的用户手册。通过NuDAQ ACLD Series Termination Boards Users Manual 端子板用户手册,查看ACLD-9188的资料。针对Matlab的驱动需要了解安装ADLINK软件包中的DAQ-MTLB应有软件,通过阅读该软件的用户手册DAQ-MTLB Manual掌握Matlab对数据采卡进行输入输出的方法。通过
7、DAQ-MTLB-Utilities-PCI Configure Utility对数据采集卡进行设置。五 实验内容1) 硬件系统构成 硬件系统有:(1)用于采集被控量的数据采集卡,模拟输入输出通道;(2)控制计算机,用于设置设定值、计算偏差实现控制;(3)被控系统,温度控制箱。2) 软件系统安装方法需要安装Matlab软件及ADLINK软件。3) 应用MatlabGUI进行监控画面的设计过程(1)设置设定值、P、I、D、采样周期、横轴点数的静态文本框;(2)设置设定值、P、I、D、采样周期、横轴点数的文本编辑框,用于实验时调整控制参数;(3)设置显示控制曲线及网格的控制按钮;(4)设置读入数据
8、、启动/停止、保存图形的按钮;(5)设置二维曲线及棒图绘图区。4) 程序的设计过程(1)PID算法k时刻控制器输出量为:其中, 为k的偏差,。P为比例带, 为积分常数,为微分常数。(2)滤波滤波分为数字滤波和模拟滤波,计算机系统中一般都使用数字滤波。数字滤波技术有程序判断滤波、中值滤波、算术平均滤波、加权平均滤波、一阶惯性滤波等。常用滤波有均值滤波、中值滤波以及惯性滤波等等。 均值滤波:连续采样多次取平均值作为被控量的测量值; 中值滤波:连续采样多次取其中间值作为测量值; 惯性滤波:。(3)采样频率采样周期的上限受香农定理限制,下限受计算机在一个周期的工作量的限制。采样频率过低,会在频率域产生
9、混叠,从而导致失真。采样频率过高,采样点数过多,计算量很大。(4)数字采集卡读写添加输入输出设备:ai_device=analoginput(mwadlink,0);ao_device=analogoutput(mwadlink,0);为设备添加通道:addchannel(ai_device,0);addchannel(ao_device,0);采样数据:getsample(ai_device);输出数据:putdata(ao_device,C(i)/20);5) PID参数的整定规律与结果分析比例:增加比例系数,加快系统响应,减小稳态误差。但比例带太小会使系统有较大的超调和振荡,破坏系统的稳
10、定性。积分:主要用于减小系统的稳态误差。减小积分系数有利于减小超调,提高系统的稳定性。但消除稳态误差的速度将随之减慢。微分:增大微分系数可以加速系统的响应,使超调量减小,增加系统的稳定性,但系统的抗干扰能力下降。 整定的次序通常为:先比例,再积分,后微分。整定比例系数:置将由小变大,使系统曲线略有超调。如果此时系统的稳态误差已落入误差带范围内,则系统只使用比例控制就可以了。整定积分系数:在比例控制的基础上,若系统还有较大的稳态误差,则需要加入积分控制。首先将调好的比例系数减小10%到30%,再讲积分系数由小到大调节,直到稳态误差落入误差带之内为止。整定微分系数:在稳态误差消除的基础上,若系统的
11、动态响应还是不能满足要求,可酌情加入微分控制。使从小到大的增加,同时略减小、的值,反复调试,直至满足各个性能制表的要求为止6) 保存的时实控制画面(调节参数过程)(1)(2)(3)六、程序function varargout = 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,
12、 , . gui_Callback, );if nargin & isstr(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);endfunction aaa_OpeningFcn(hObject, eventdata, handles, varargin)handles.output = hObject;guidata
13、(hObject, handles);function varargout = aaa_OutputFcn(hObject, eventdata, handles) %设置控件回调函数global s P I D flag cscs=0;s=str2num(nan);P=str2num(nan);I=str2num(nan);D=str2num(nan);set(handles.pushbutton2,String,启动);function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCB
14、O)% 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, aft
15、er 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 backg
16、round on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a futu
17、re 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_CreateF
18、cn(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
19、 & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction 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 han
20、dles 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
21、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,d
22、efaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction 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(hOb
23、ject,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
24、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,Back
25、groundColor,white);endfunction 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%
26、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 e
27、mpty - 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);endfunction edit6_Callback(hO
28、bject, 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
29、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 Creat
30、eFcns 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 checkbox1.function checkbox1_Callback(hObj
31、ect, eventdata, handles)global csif get(hObject,Value)=get(hObject,Max) cs=1;else cs=0;endfunction checkbox2_Callback(hObject, eventdata, handles)if get(hObject,Value)=get(hObject,Max) axes(handles.axes1); grid on;else axes(handles.axes1); grid off;endfunction pushbutton1_Callback(hObject, eventdata
32、, handles)%设置控件功能global s P I D N tfcontent= ;s=str2double(get(handles.edit1,String);if isnan(s) content=strcat(content,设定值);endP=str2double(get(handles.edit2,String);if isnan(P) if content= content=strcat(content,、); end content=strcat(content,P值);endI=str2double(get(handles.edit3,String);if isnan(
33、I) if content= content=strcat(content,、); end content=strcat(content,I值);endD=str2double(get(handles.edit4,String);if isnan(D) if content= content=strcat(content,、); end content=strcat(content,D值);endtf=str2double(get(handles.edit5,String);if isnan(tf) if content= content=strcat(content,、); end cont
34、ent=strcat(content,采样周期);endN=str2double(get(handles.edit6,String);if isnan(N) if content= content=strcat(content,、); end content=strcat(content,横轴点数);endif content= errordlg(strcat(content,输入错误),参数错误);end% - Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, h
35、andles)%设置控件功能global s P I D flag N tf csif (isnan(s)|isnan(P)|isnan(I)|isnan(D)|isnan(tf)|isnan(N) errordlg(请先读入数据);elseif get(hObject,String)=启动 flag=1; set(hObject,String,停止);else flag=0; set(hObject,String,启动);endai_device=analoginput(mwadlink,0);addchannel(ai_device,0);ao_device=analogoutput(mw
36、adlink,0);addchannel(ao_device,0);i=1;d=0;while flag=1 axes(handles.axes1); t(i)=0; for j=1:20; t(i)=t(i)+getsample(ai_device); %采集数据 end e(i)=s-t(i); S(i)=s; d=d+e(i); if I*d200 d=200/I; elseif I*d1 %PID算法计算输出控制量 C(i)=P*e(i)+I*d+D*(e(i)-e(i-1); else C(i)=P*e(i)+I*d; endC(i)=C(i)/20;%限幅 if C(i)5 %防止
37、输出过高,从而损坏仪器或达到饱和 C(i)=5; end putdata(ao_device,C(i); start(ao_device); hold on; cla; plot(t,b); if cs=1 plot(C,g); %绘制控制量曲线 end plot(S,r); %绘制设定值曲线 if iN axis(0 N -5 110); text(1,105,strcat(strcat(实时温度:,num2str(t(i),); text(N/2,105,strcat(strcat(控制输出:,num2str(C(i),V); else axis(i-N+1,i+1 -5 110); te
38、xt(i-N,105,strcat(strcat(实时温度:,num2str(t(i),); text(i-N/2,105,strcat(strcat(控制输出:,num2str(C(i),V); endaxes(handles.axes3);cla;axis(0 10 0 100); text(0,90,strcat(strcat(实时温度:,num2str(t(i),); text(5,90,strcat(strcat(控制输出:,num2str(C(i),V);line(0,10,100,100)hold onbar(1,s,r);hold onbar(5,t(i),b);hold on
39、bar(9,C(i),g);hold off i=i+1; pause(tf);endif flag=0 putdata(ao_device,0); %输出控制量 start(ao_device);endendfunction pushbutton3_Callback(hObject, eventdata, handles)filename,pathname = uiputfile( *.bmp;*.jpg;*.png;*.fig;*.*, 保存到,Untitled);axes(handles.axes1);%h=getframe(handles.axes1);saveas(gca,strcat(pathname,filename);% - Executes on mouse press over axes background.function axes1_ButtonDownFcn(hObject, eventdata, handles)% hObjec
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025车辆买卖合同范本
- 2025简约装修房合同示范文本
- 2025保密协议合同书范文
- 2025年商业店铺续租协议合同范本
- 2025汽车租赁合同范本3
- 《消化道异物附件》课件
- 《全球重要国家角色》课件
- 《腹部CT分型》课件
- 《南京商业概要》课件
- 《知名人士生平》课件
- 第五课滴答滴答下雨了课件
- 新教师岗前培训讲座中小学教学常规PPT
- 李子奈《计量经济学》(第5版)笔记和典型题(含考研真题)详解
- 影像医学科影像质量评价与持续改进工作一年记录(PDCA)
- 现浇梁钢管柱+贝雷片支架验收表
- 赵武灵王胡服骑射-课件
- 2023年口腔医学(副高)历年真题
- 主体工程实体质量实测实量检查表
- 高中物理选择性必修一同步练习册电子版
- 大理石测量平台校验规程
- 基于JSP的校园网站的设计与实现-毕业设计
评论
0/150
提交评论