试验交换机基本配置试验Word下载.docx
- 文档编号:17511650
- 上传时间:2022-12-06
- 格式:DOCX
- 页数:19
- 大小:78.69KB
试验交换机基本配置试验Word下载.docx
《试验交换机基本配置试验Word下载.docx》由会员分享,可在线阅读,更多相关《试验交换机基本配置试验Word下载.docx(19页珍藏版)》请在冰豆网上搜索。
在实际应用中A为缓变量,因此,要滤除直流分量不能用常量减法,只能用高通滤波器,其传递函数为:
PLL电路构成如下:
环路中加入倍频器,锁相输出频率为1/2输入频率。
为使环路得到较好的稳定性,环路滤波器采用一阶滤波器。
根据系统入锁频差要求
大约在10~20Hz之间。
(选10Hz)
由于BPSK信号的相位为阶跃函数,为保证跟踪锁相环开环增益在保证环路稳定的条件下取较大值,开环增益中起主要作用的VCO增益取5000Hz/V。
3.解调电路设计
解调电路由乘法器与低通滤波器构成。
为保证低频数字信号的波形,采用通带平坦型2阶BUTTER低通滤波器,使通带内的相移较小。
截止频率20Hz
4.采集卡驱动程序设计
MATLAB用S函数编写硬件接口,S函数在MATLAB中的调用过程为
根据接口定义与要求,驱动程序由下列程序构成:
test_matlab.cpp:
/*$Revision:
1.3$*/
//AutomaticallygeneratedbyMATLABProjectWizardversion1.0
/*
*Basedonsfuntmpl_basic.c:
Basic'
C'
templateforalevel2S-function.
*
*-------------------------------------------------------------------------
*|Seematlabroot/simulink/src/sfuntmpl_doc.cforamoredetailedtemplate|
*Copyright1990-2000TheMathWorks,Inc.
*$Revision:
1.3$
*/
#include"
iostream.h"
#include<
math.h>
windows.h>
P1202DRV.H"
P1202DRVMyDrv;
#ifdef__cplusplus
extern"
C"
{//usetheCfcn-callstandardforallfunctions
#endif//definedwithinthisscope
*YoumustspecifytheS_FUNCTION_NAMEasthenameofyourS-function
*(i.e.replacesfuntmpl_basicwiththenameofyourS-function).
#defineS_FUNCTION_LEVEL2
#defineS_FUNCTION_NAMEtest_matlab
*Needtoincludesimstruc.hforthedefinitionoftheSimStructand
*itsassociatedmacrodefinitions.
simstruc.h"
/*Errorhandling
*--------------
*Youshouldusethefollowingtechniquetoreporterrorsencounteredwithin
*anS-function:
*ssSetErrorStatus(S,"
Errorencountereddueto..."
);
*return;
*Notethatthe2ndargumenttossSetErrorStatusmustbepersistentmemory.
*Itcannotbealocalvariable.Forexamplethefollowingwillcause
*unpredictableerrors:
*mdlOutputs()
*{
*charmsg[256];
{ILLEGAL:
tofixuse"
staticcharmsg[256];
"
}
*sprintf(msg,"
Errordueto%s"
string);
*ssSetErrorStatus(S,msg);
*}
*Seematlabroot/simulink/src/sfuntmpl_doc.cformoredetails.
/*====================*
*S-functionmethods*
*====================*/
/*Function:
mdlInitializeSizes===============================================
*Abstract:
*ThesizesinformationisusedbySimulinktodeterminetheS-function
*block'
scharacteristics(numberofinputs,outputs,states,etc.).
staticvoidmdlInitializeSizes(SimStruct*S)
{
/*Seesfuntmpl_doc.cformoredetailsonthemacrosbelow*/
ssSetNumSFcnParams(S,0);
/*Numberofexpectedparameters*/
if(ssGetNumSFcnParams(S)!
=ssGetSFcnParamsCount(S)){
/*Returnifnumberofexpected!
=numberofactualparameters*/
return;
}
ssSetNumContStates(S,0);
ssSetNumDiscStates(S,0);
if(!
ssSetNumInputPorts(S,0))return;
//ssSetInputPortWidth(S,0,1);
//ssSetInputPortRequiredContiguous(S,0,true);
/*directinputsignalaccess*/
//ssSetInputPortDirectFeedThrough(S,0,1);
ssSetNumOutputPorts(S,1))return;
ssSetOutputPortWidth(S,0,1);
ssSetNumSampleTimes(S,2);
ssSetNumRWork(S,0);
ssSetNumIWork(S,0);
ssSetNumPWork(S,1);
ssSetNumModes(S,0);
ssSetNumNonsampledZCs(S,0);
//ssSetOptions(S,0);
//ssSetOptions(S,SS_OPTION_ALLOW_CONSTANT_PORT_SAMPLE_TIME);
mdlInitializeSampleTimes=========================================
*Thisfunctionisusedtospecifythesampletime(s)foryour
*S-function.Youmustregisterthesamenumberofsampletimesas
*specifiedinssSetNumSampleTimes.
staticvoidmdlInitializeSampleTimes(SimStruct*S)
ssSetSampleTime(S,0,CONTINUOUS_SAMPLE_TIME);
ssSetOffsetTime(S,0,0.0);
ssSetSampleTime(S,1,1.0/SAMPLERATE);
ssSetOffsetTime(S,1,0.0);
//ssSetOutputPortSampleTime(S,0,0.01);
//ssSetOutputPortOffsetTime(S,0,0);
//#defineMDL_INITIALIZE_CONDITIONS/*Changeto#undeftoremovefunction*/
#undefMDL_INITIALIZE_CONDITIONS
#ifdefined(MDL_INITIALIZE_CONDITIONS)
/*Function:
mdlInitializeConditions========================================
*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)
mdlStart=======================================================
*Thisfunctioniscalledonceatstartofmodelexecution.Ifyou
*havestatesthatshouldbeinitializedonce,thisistheplace
*todoit.
staticvoidmdlStart(SimStruct*S)
{
/*for(i=0;
i<
1024;
i++)
wave[i]=sin(i*2*3.1416/102.4);
P1202DRV*MyDrv=newP1202DRV;
if(MyDrv==NULL)
ssSetErrorStatus(S,"
errormessage"
return;
ssGetPWork(S)[0]=(void*)MyDrv;
if(MyDrv->
Init())
MyDrv->
StartScan();
#endif/*MDL_START*/
mdlOutputs=======================================================
*Inthisfunction,youcomputetheoutputsofyourS-function
*block.Generallyoutputsareplacedintheoutputvector,ssGetY(S).
staticvoidmdlOutputs(SimStruct*S,int_Ttid)
//constreal_T*u=(constreal_T*)ssGetInputPortSignal(S,0);
real_T*y=ssGetOutputPortRealSignal(S,0);
real_Tval,Sampletime;
P1202DRV*MyDrv=(P1202DRV*)ssGetPWork(S)[0];
Sampletime=ssGetT(S);
val=MyDrv->
Read(Sampletime);
if(val>
100.0)
Dataoverflow!
y[0]=val;
#defineMDL_UPDATE/*Changeto#undeftoremovefunction*/
#undefMDL_UPDATE
#ifdefined(MDL_UPDATE)
mdlUpdate======================================================
*Thisfunctioniscalledonceforeverymajorintegrationtimestep.
*Discretestatesaretypicallyupdatedhere,butthisfunctionisuseful
*forperforminganytasksthatshouldonlytakeplaceonceper
*integrationstep.
staticvoidmdlUpdate(SimStruct*S,int_Ttid)
#endif/*MDL_UPDATE*/
#defineMDL_DERIVATIVES/*Changeto#undeftoremovefunction*/
//#undefMDL_DERIVATIVES
#ifdefined(MDL_DERIVATIVES)
mdlDerivatives=================================================
*Inthisfunction,youcomputetheS-functionblock'
sderivatives.
*Thederivativesareplacedinthederivativevector,ssGetdX(S).
staticvoidmdlDerivatives(SimStruct*S)
#endif/*MDL_DERIVATIVES*/
mdlTerminate=====================================================
*Inthisfunction,youshouldperformanyactionsthatarenecessary
*attheterminationofasimulation.Forexample,ifmemorywas
*allocatedinmdlStart,thisistheplacetofreeit.
staticvoidmdlTerminate(SimStruct*S)
Stop();
Close();
deleteMyDrv;
/*======================================================*
*Seesfuntmpl_doc.cfortheoptionalS-functionmethods*
*======================================================*/
/*=============================*
*RequiredS-functiontrailer*
*=============================*/
#ifdefMATLAB_MEX_FILE/*IsthisfilebeingcompiledasaMEX-file?
simulink.c"
/*MEX-fileinterfacemechanism*/
#else
cg_sfun.h"
/*Codegenerationregistrationfunction*/
#endif
}//endofextern"
scope
P1202DRV.H:
//P1202DRV.h:
interfacefortheP1202DRVclass.
//
//////////////////////////////////////////////////////////////////////
#if!
defined(AFX_P1202DRV_H__455B5152_0FD1_4D8F_9BD3_9DFD0C69E6E7__INCLUDED_)
#defineAFX_P1202DRV_H__455B5152_0FD1_4D8F_9BD3_9DFD0C69E6E7__INCLUDED_
#if_MSC_VER>
1000
#pragmaonce
#endif//_MSC_VER>
#defineBUFFLEN1000
#defineNUMCHAN1
#defineINITFLAG0X1
#defineACTIVEFLAG0X2
#defineSCANFLAG0X4
#defineREADFLAG0x8
#defineSAMPLERATE4000
classP1202DRV
intinitflag,buffindex,readcount;
intErrorFlag;
time_TTs,StartTime,EndTime;
DWORDdwP1,dwP2;
WORDwChannelStatus[32],wChannelConfig[32],wStatus;
WORDwCard0Buf0[BUFFLEN*32],wCard0Buf1[BUFFLEN*32];
public:
P1202DRV();
virtual~P1202DRV();
intInit();
intClose();
intStartScan();
doubleRead(time_TSampleTime);
intStop();
WORDCardRead();
};
#endif//!
P1202DRV.C:
//P1202DRV.cpp:
implementationoftheP1202DRVclass.
////////////////////////////////////////
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 试验 交换机 基本 配置
![提示](https://static.bdocx.com/images/bang_tan.gif)