10通信原理综合标准实验报告.docx
- 文档编号:10518180
- 上传时间:2023-02-17
- 格式:DOCX
- 页数:22
- 大小:74.31KB
10通信原理综合标准实验报告.docx
《10通信原理综合标准实验报告.docx》由会员分享,可在线阅读,更多相关《10通信原理综合标准实验报告.docx(22页珍藏版)》请在冰豆网上搜索。
10通信原理综合标准实验报告
实验十九通信原理综合实验-BPSK调制解调
【设计要求】
设计2PSK调制解调器。
设计环境:
设计指标:
BPSK调制载波由信号发生器参数,数据信号由微机参数,两个信号不同步。
载波信号幅度Vpp=2V,标称频率100Hz,误差
10%
PLL入锁频率范围
10Hz
跟踪范围>
20Hz
数据信号速率5baud,0/1方波。
【系统设计】
1.总体设计
根据系统设计指标,设计系统框图如下:
调制系统由乘法器构成。
硬件信号发生器产生的载波信号与本地信号发生器产生的调制信号构成。
其中:
为载波频率,
为载波初始相位。
解调系统由载波恢复电路和相干解调器构成。
由于BPSK信号中没有载波频率分量,因此,需要进行非线性变换。
为进行系统性能比较,设计一非同步解调参考解调电路。
2.载波恢复模块设计
载波恢复模块由平方倍频器与分频PLL构成
平方器输出为:
在实际应用中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
#include
#include"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.
*/
#include"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);
*return;
*}
*
*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);
if(!
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);
}
/*Function:
mdlInitializeSampleTimes=========================================
*Abstract:
*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========================================
*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)
{
/*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())
{
ssSetErrorStatus(S,"errormessage");
return;
}
MyDrv->StartScan();
}
#endif/*MDL_START*/
/*Function:
mdlOutputs=======================================================
*Abstract:
*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)
ssSetErrorStatus(S,"Dataoverflow!
");
y[0]=val;
}
#defineMDL_UPDATE/*Changeto#undeftoremovefunction*/
#undefMDL_UPDATE
#ifdefined(MDL_UPDATE)
/*Function:
mdlUpdate======================================================
*Abstract:
*Thisfunctioniscalledonceforeverymajorintegrationtimestep.
*Discretestatesaretypicallyupdatedhere,butthisfunctionisuseful
*forperforminganytasksthatshouldonlytakeplaceonceper
*integrationstep.
*/
staticvoidmdlUpdate(SimStruct*S,int_Ttid)
{
}
#endif/*MDL_UPDATE*/
#defineMDL_DERIVATIVES/*Changeto#undeftoremovefunction*/
//#undefMDL_DERIVATIVES
#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)
{
P1202DRV*MyDrv=(P1202DRV*)ssGetPWork(S)[0];
if(MyDrv==NULL)
return;
MyDrv->Stop();
MyDrv->Close();
deleteMyDrv;
return;
}
/*======================================================*
*Seesfuntmpl_doc.cfortheoptionalS-functionmethods*
*======================================================*/
/*=============================*
*RequiredS-functiontrailer*
*=============================*/
#ifdefMATLAB_MEX_FILE/*IsthisfilebeingcompiledasaMEX-file?
*/
#include"simulink.c"/*MEX-fileinterfacemechanism*/
#else
#include"cg_sfun.h"/*Codegenerationregistrationfunction*/
#endif
#ifdef__cplusplus
}//endofextern"C"scope
#endif
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>1000
#defineBUFFLEN1000
#defineNUMCHAN1
#defineINITFLAG0X1
#defineACTIVEFLAG0X2
#defineSCANFLAG0X4
#defineREADFLAG0x8
#defineSAMPLERATE4000
#include
#ifdef__cplusplus
extern"C"{//usetheCfcn-callstandardforallfunctions
#endif//definedwithinthisscope
#defineS_FUNCTION_LEVEL2
#defineS_FUNCTION_NAMEtest_matlab
#include"simstruc.h"
#ifdef__cplusplus
}//endofextern"C"scope
#endif
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();
public:
intInit();
intClose();
intStartScan();
doubleRead(time_TSampleTime);
intStop();
WORDCardRead();
};
#endif//!
defined(AFX_P1202DRV_H__455B5152_0FD1_4D8F_9BD3_9DFD0C69E6E7__INCLUDED_)
P1202DRV.C:
//P1202DRV.cpp:
implementationoftheP1202DRVclass.
//
/////////////////////////////////////
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 10 通信 原理 综合 标准 实验 报告