铂电阻温度测量及工作台实验.docx

上传人:b****0 文档编号:10111062 上传时间:2023-05-23 格式:DOCX 页数:31 大小:621.97KB
下载 相关 举报
铂电阻温度测量及工作台实验.docx_第1页
第1页 / 共31页
铂电阻温度测量及工作台实验.docx_第2页
第2页 / 共31页
铂电阻温度测量及工作台实验.docx_第3页
第3页 / 共31页
铂电阻温度测量及工作台实验.docx_第4页
第4页 / 共31页
铂电阻温度测量及工作台实验.docx_第5页
第5页 / 共31页
铂电阻温度测量及工作台实验.docx_第6页
第6页 / 共31页
铂电阻温度测量及工作台实验.docx_第7页
第7页 / 共31页
铂电阻温度测量及工作台实验.docx_第8页
第8页 / 共31页
铂电阻温度测量及工作台实验.docx_第9页
第9页 / 共31页
铂电阻温度测量及工作台实验.docx_第10页
第10页 / 共31页
铂电阻温度测量及工作台实验.docx_第11页
第11页 / 共31页
铂电阻温度测量及工作台实验.docx_第12页
第12页 / 共31页
铂电阻温度测量及工作台实验.docx_第13页
第13页 / 共31页
铂电阻温度测量及工作台实验.docx_第14页
第14页 / 共31页
铂电阻温度测量及工作台实验.docx_第15页
第15页 / 共31页
铂电阻温度测量及工作台实验.docx_第16页
第16页 / 共31页
铂电阻温度测量及工作台实验.docx_第17页
第17页 / 共31页
铂电阻温度测量及工作台实验.docx_第18页
第18页 / 共31页
铂电阻温度测量及工作台实验.docx_第19页
第19页 / 共31页
铂电阻温度测量及工作台实验.docx_第20页
第20页 / 共31页
亲,该文档总共31页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

铂电阻温度测量及工作台实验.docx

《铂电阻温度测量及工作台实验.docx》由会员分享,可在线阅读,更多相关《铂电阻温度测量及工作台实验.docx(31页珍藏版)》请在冰点文库上搜索。

铂电阻温度测量及工作台实验.docx

铂电阻温度测量及工作台实验

 

综合测控实验

 

班级:

组员:

 

铂电阻温度测量实验

一、实验目的

1、了解铂电阻的温度特性与曲线,学会用铂电阻测量温度

2、学会使用matlab编程,采集电压信号波形并显示在面板上

3、了解并掌握信号处理方法,将采集到的电压信号转换成温度信号显示出来

二、实验原理

1、铂电阻测温原理。

金属铂电阻的性能十分稳定,在-260°C~+630°C之间,铂热电阻用作标准温度计,在0~630°C之间铂电阻与温度呈如下关系:

Rt=R0(1+AT+BT²)

式中:

R0=1000Ω,A=0.3973973*10-²,B=-0.58973*10-6

恒压型的铂电阻测温电路如图所示,该电路也是常用的测温电路之一,其中Vin为恒定输入电压,W1用于零点调整,W2用于范围调整,该电路的输出电压Vout为:

Vout=R1ΔR*Vin/(R1+R0+ΔR)(R1+R0)

由式可知,在恒压条件下,其输出电压取决于Vin和R1。

当R1=22KΩ,Vin=12V时,在0~100°C范围内,电路灵敏度为1.89mV/°C.

本实验采用铂电阻PT100,它在0°时候对应的电阻为1K,可以用其分度表查询阻值对应的温度,可以发现其温度几乎呈线性变化。

2、数据采集与操作。

利用matlab编程,将采集到的电压信号波形显示出来,并将其电压对应的温度计算后显示出来。

调节试验箱的变阻器以使电路的电压对应的温度值等于实时温度以进行标定再列出温度电压关系。

具体步骤分为:

1、SIMULINK动态仿真。

Simulink模块包括一系列输入、状态和输出。

输出是采样时间、输入、模块状态的函数,它执行仿真的步骤如下图所示:

 

1、数据采集程序设计。

2、数据处理及数据的可视化和界面处理。

三、实验步骤

1、硬件连线。

根据实验指导书,连接线路,将因温度变化引起的电阻变化通过电路放大以电压的变化表现出来。

为确认连线无误及元件的好坏,将线路连好后打开电源,用万用电表测输出电压端的电压变化,调节变阻器,观察电压是否随之变化,用手握住铂电阻,使其升温,观察电压是否变化,若都变化,则可以开始下一步。

实验会温度大约为26°,对应电压值大约为50mV。

2、软件编程。

1、数据采集。

新建一个文件夹,选择为当前目录,打开simulink,选择User-DefinedFunctions/S-FunctionExamples/C-filesS-Function//BasicC-MEXTemplate,根据所定义模块的功能,将该自动生成的文件重命名,并存入你指定的文件夹中将模版的c文件另存,文件名Myon.cpp。

将Function改成和文件名一样。

得到的cpp文件如下:

#defineS_FUNCTION_NAMEMyon//定义一个新文件Myon

#defineS_FUNCTION_LEVEL2//定义文件为level-2格式

/*

*Needtoincludesimstruc.hforthedefinitionoftheSimStructand

*itsassociatedmacrodefinitions.

*/

•#include"simstruc.h"

•#include"abc.h"

•doublebuffer[5000];//定义全局变量,通道的缓存buffer

•doublebuffer1[5000];//定义另一个全局变量buffer1

•intpnum;//读取指针数

•charch[8];//读取8通道2进制表示值

•staticvoidmdlInitializeSizes(SimStruct*S)

//查询S-function模块的输入输出端口数,端口容量,以及S-function所需的其他对象(如,状态个数等)。

•{

•/*Seesfuntmpl_doc.cformoredetailsonthemacrosbelow*/

•ssSetNumSFcnParams(S,0);//期望参数数目

•/*Numberofexpectedparameters*/

•if(ssGetNumSFcnParams(S)!

=ssGetSFcnParamsCount(S))

•//期望参数数目不等于实际参数数目时

•{

•/*Returnifnumberofexpected!

=numberofactualparameters*/

•return;

•}

•ssSetNumContStates(S,0);//设置连续状态个数

•ssSetNumDiscStates(S,0);//设置非连续状态个数

•if(!

ssSetNumInputPorts(S,3))return;//第一个参数为模块的数据结构,第二个参数指定模块有几个输入接口

•ssSetInputPortWidth(S,0,1);//第一个参数为模块的一个数据结构,第二个参数为接口编号,第三个参数指定第二个参数所指定接口的宽度

•ssSetInputPortRequiredContiguous(S,0,true);/*directinputsignalaccess*/

•ssSetInputPortWidth(S,1,1);

•ssSetInputPortRequiredContiguous(S,1,true);

•ssSetInputPortWidth(S,2,1);

•ssSetInputPortRequiredContiguous(S,2,true);//三个输入

•/*

•*Setdirectfeedthroughflag(1=yes,0=no).

•*Aporthasdirectfeedthroughiftheinputisusedineither

•*themdlOutputsormdlGetTimeOfNextVarHitfunctions.

•*Seematlabroot/simulink/src/sfuntmpl_directfeed.txt.

•*/

•ssSetInputPortDirectFeedThrough(S,0,1);

•ssSetInputPortDirectFeedThrough(S,1,1);

•ssSetInputPortDirectFeedThrough(S,2,1);//第一个参数为模块的数据结构,第二个为接口的编号,第三个用于指定接口的输入数据是否能在mdloutputs中调用

•if(!

ssSetNumOutputPorts(S,1))return;//输出函数的参数意义同上

•ssSetOutputPortWidth(S,0,1);

•ssSetNumSampleTimes(S,1);

•ssSetNumRWork(S,0);

•ssSetNumIWork(S,0);

•ssSetNumPWork(S,0);

•ssSetNumModes(S,0);

•ssSetNumNonsampledZCs(S,0);

•ssSetOptions(S,0);

•}

•/*Function:

mdlInitializeSampleTimes=========================================

•*Abstract:

•*Thisfunctionisusedtospecifythesampletime(s)foryour

•*S-function.Youmustregisterthesamenumberofsampletimesas

•*specifiedinssSetNumSampleTimes.

•*/

•staticvoidmdlInitializeSampleTimes(SimStruct*S)//设置采样时间

•{

•ssSetSampleTime(S,0,CONTINUOUS_SAMPLE_TIME);

•ssSetOffsetTime(S,0,0.0);

•}

•#defineMDL_INITIALIZE_CONDITIONS/*Changeto#undeftoremovefunction*/

•#ifdefined(MDL_INITIALIZE_CONDITIONS)

•/*Function:

mdlInitializeConditions========================================

•*Abstract:

•*Inthisfunction,youshouldinitializethecontinuousanddiscrete

•*statesforyourS-functionblock.Theinitialstatesareplaced

•*inthestatevector,ssGetContStates(S)orssGetRealDiscStates(S).

•*Youcanalsoperformanyotherinitializationactivitiesthatyour

•*S-functionmayrequire.Note,thisroutinewillbecalledatthe

•*startofsimulationandifitispresentinanenabledsubsystem

•*configuredtoresetstates,itwillbecallwhentheenabledsubsystem

•*restartsexecutiontoresetthestates.

•*/

•staticvoidmdlInitializeConditions(SimStruct*S)

•{

•}

•#endif/*MDL_INITIALIZE_CONDITIONS*/

•#defineMDL_START/*Changeto#undeftoremovefunction*/

•#ifdefined(MDL_START)

•/*Function:

mdlStart=======================================================

•*Abstract:

•*Thisfunctioniscalledonceatstartofmodelexecution.Ifyou

•*havestatesthatshouldbeinitializedonce,thisistheplace

•*todoit.

•*/

•staticvoidmdlStart(SimStruct*S)//添加采集卡初始化以及开启采集任务

•{

•if(ADCardInit()!

=1)//初始化采集卡,如果成功则返回1

•{

•ssSetErrorStatus(S,"Can'tfindtheDAQCard!

");

•}

•DAQ1(0x10,5000,1024*4,buffer);//对5通道进行采集

•pnum=0;

•}

•#endif/*MDL_START*/

•/*Function:

mdlOutputs=======================================================

•*Abstract:

•*Inthisfunction,youcomputetheoutputsofyourS-function

•*block.Generallyoutputsareplacedintheoutputvector,ssGetY(S).

•*/

•staticvoidmdlOutputs(SimStruct*S,int_Ttid)

•{

•intLength=1024*4;//读取buffer长度

•ReadDaq(5,Length,buffer);//从采集卡中读取buffer

•real_T*y=ssGetOutputPortRealSignal(S,0);//获取输出指针

•if(pnum>=Length)pnum=0;//判断指针是否已满

•*y=buffer[pnum];//指出第pnum个点的值

•pnum++;//指针加1

•}

•#defineMDL_UPDATE/*Changeto#undeftoremovefunction*/

•#ifdefined(MDL_UPDATE)//定义更新函数

•/*Function:

mdlUpdate======================================================

•*Abstract:

•*Thisfunctioniscalledonceforeverymajorintegrationtimestep.

•*Discretestatesaretypicallyupdatedhere,butthisfunctionisuseful

•*forperforminganytasksthatshouldonlytakeplaceonceper

•*integrationstep.

•*/

•staticvoidmdlUpdate(SimStruct*S,int_Ttid)

•{

•}

•#endif/*MDL_UPDATE*/

•#defineMDL_DERIVATIVES/*Changeto#undeftoremovefunction*/

•#ifdefined(MDL_DERIVATIVES)

•/*Function:

mdlDerivatives=================================================

•*Abstract:

•*Inthisfunction,youcomputetheS-functionblock'sderivatives.

•*Thederivativesareplacedinthederivativevector,ssGetdX(S).

•*/

•staticvoidmdlDerivatives(SimStruct*S)

•{

•}

•#endif/*MDL_DERIVATIVES*/

•/*Function:

mdlTerminate=====================================================

•*Abstract:

•*Inthisfunction,youshouldperformanyactionsthatarenecessary

•*attheterminationofasimulation.Forexample,ifmemorywas

•*allocatedinmdlStart,thisistheplacetofreeit.

•*/

•staticvoidmdlTerminate(SimStruct*S)

•{

•ADCardQuit();

•}//退出采集卡

•/*======================================================*

•*Seesfuntmpl_doc.cfortheoptionalS-functionmethods*

•*======================================================*/

•/*=============================*

•*RequiredS-functiontrailer*

•*=============================*/

•#ifdefMATLAB_MEX_FILE/*IsthisfilebeingcompiledasaMEX-file?

*/

•#include"simulink.c"/*MEX-fileinterfacemechanism*/

•#else

•#include"cg_sfun.h"/*Codegenerationregistrationfunction*/

•#endif

 

对文件作出一些系应该,使其能满足本次试验的需要,将输入输出设置为适应本实验需要的参数,本次试验采取3个输入接口,设置好了之后还有进行标注:

得到mytemp1.mdl文件

采集卡初始化及数据采集中,试验采用单通道,选择5通道。

修改相应语句。

2、数据的可视化和界面处理。

Matlab提供了丰富的绘图功能和界面处理方法,都是通过语句控制以生成界面。

我们小组爱用的是matlab自带的GUI直接生成的模块库选择相应的需要的模块生成一个界面,当模块保存后会自动生成一个m文件。

界面如下:

生成m文件如下:

functionvarargout=mytest(varargin)//输出参数的个数等于输入参数的个数

gui_Singleton=1;

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

'gui_Singleton',gui_Singleton,...

'gui_OpeningFcn',@mytest_OpeningFcn,...

'gui_OutputFcn',@mytest_OutputFcn,...

'gui_LayoutFcn',[],...

'gui_Callback',[]);//GUI初始界面代码

ifnargin&&ischar(varargin{1})

gui_State.gui_Callback=str2func(varargin{1});

end

ifnargout

[varargout{1:

nargout}]=gui_mainfcn(gui_State,varargin{:

});

else

gui_mainfcn(gui_State,varargin{:

});

end

%Endinitializationcode-DONOTEDIT

%---Executesjustbeforemytestismadevisible.

functionmytest_OpeningFcn(hObject,eventdata,handles,varargin)

%Thisfunctionhasnooutputargs,seeOutputFcn.

%hObjecthandletofigure

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%varargincommandlineargumentstomytest(seeVARARGIN)

%Choosedefaultcommandlineoutputformytest

handles.output=hObject;

%Updatehandlesstructure

guidata(hObject,handles);

%UIWAITmakesmytestwaitforuserresponse(seeUIRESUME)

%uiwait(handles.figure1);

%---Outputsfromthisfunctionarereturnedtothecommandline.

functionvarargout=mytest_OutputFcn(hObject,eventdata,handles)//得到可变个数返回值

%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);

%hObjecthandletofigure

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%Getdefaultcommandlineoutputfromhandlesstructure

varargout{1}=handles.output;//指出参数个数

functionedit1_Callback(hObject,eventdata,handles)

//设置第一个动态文本框回调属性

%hObjecthandletoedit1(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%Hints:

get(hObject,'String')returnscontentsofedit1astext

%str2double(get(hObject,'String'))returnscontentsofedit1asadouble

%---Executesduringobjectcr

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2