10.通信原理綜合_標(biāo)準(zhǔn)實(shí)驗(yàn)報(bào)告.doc_第1頁
10.通信原理綜合_標(biāo)準(zhǔn)實(shí)驗(yàn)報(bào)告.doc_第2頁
10.通信原理綜合_標(biāo)準(zhǔn)實(shí)驗(yàn)報(bào)告.doc_第3頁
10.通信原理綜合_標(biāo)準(zhǔn)實(shí)驗(yàn)報(bào)告.doc_第4頁
10.通信原理綜合_標(biāo)準(zhǔn)實(shí)驗(yàn)報(bào)告.doc_第5頁
已閱讀5頁,還剩17頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

實(shí)驗(yàn)十九 通信原理綜合實(shí)驗(yàn) BPSK調(diào)制解調(diào)【設(shè)計(jì)要求】設(shè)計(jì)2PSK調(diào)制解調(diào)器。設(shè)計(jì)環(huán)境:設(shè)計(jì)指標(biāo):BPSK調(diào)制載波由信號發(fā)生器參數(shù),數(shù)據(jù)信號由微機(jī)參數(shù),兩個(gè)信號不同步。載波信號幅度Vpp2V,標(biāo)稱頻率100Hz,誤差10PLL入鎖頻率范圍10Hz跟蹤范圍20Hz數(shù)據(jù)信號速率5 baud,0/1方波?!鞠到y(tǒng)設(shè)計(jì)】1 總體設(shè)計(jì)根據(jù)系統(tǒng)設(shè)計(jì)指標(biāo),設(shè)計(jì)系統(tǒng)框圖如下:調(diào)制系統(tǒng)由乘法器構(gòu)成。硬件信號發(fā)生器產(chǎn)生的載波信號與本地信號發(fā)生器產(chǎn)生的調(diào)制信號構(gòu)成。 其中:為載波頻率,為載波初始相位。解調(diào)系統(tǒng)由載波恢復(fù)電路和相干解調(diào)器構(gòu)成。由于BPSK信號中沒有載波頻率分量,因此,需要進(jìn)行非線性變換。為進(jìn)行系統(tǒng)性能比較,設(shè)計(jì)一非同步解調(diào)參考解調(diào)電路。2 載波恢復(fù)模塊設(shè)計(jì) 載波恢復(fù)模塊由平方倍頻器與分頻PLL構(gòu)成 平方器輸出為:在實(shí)際應(yīng)用中A為緩變量,因此,要濾除直流分量不能用常量減法,只能用高通濾波器,其傳遞函數(shù)為: PLL電路構(gòu)成如下: 環(huán)路中加入倍頻器,鎖相輸出頻率為1/2輸入頻率。 為使環(huán)路得到較好的穩(wěn)定性,環(huán)路濾波器采用一階濾波器。 根據(jù)系統(tǒng)入鎖頻差要求大約在1020Hz之間。(選10Hz) 由于BPSK信號的相位為階躍函數(shù),為保證跟蹤鎖相環(huán)開環(huán)增益在保證環(huán)路穩(wěn)定的條件下取較大值,開環(huán)增益中起主要作用的VCO增益取5000Hz/V。3 解調(diào)電路設(shè)計(jì)解調(diào)電路由乘法器與低通濾波器構(gòu)成。為保證低頻數(shù)字信號的波形,采用通帶平坦型2階BUTTER低通濾波器,使通帶內(nèi)的相移較小。 截止頻率20Hz4 采集卡驅(qū)動(dòng)程序設(shè)計(jì)MATLAB用S函數(shù)編寫硬件接口,S函數(shù)在MATLAB中的調(diào)用過程為根據(jù)接口定義與要求,驅(qū)動(dòng)程序由下列程序構(gòu)成:test_matlab.cpp:/* $Revision: 1.3 $ */ Automatically generated by MATLAB Project Wizard version 1.0/* * Based on sfuntmpl_basic.c: Basic C template for a level 2 S-function. * * - * | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template | * - * * Copyright 1990-2000 The MathWorks, Inc. * $Revision: 1.3 $ */#include iostream.h#include #include #include P1202DRV.HP1202DRV MyDrv;#ifdef _cplusplusextern C / use the C fcn-call standard for all functions #endif / defined within this scope /* * You must specify the S_FUNCTION_NAME as the name of your S-function * (i.e. replace sfuntmpl_basic with the name of your S-function). */#define S_FUNCTION_LEVEL 2#define S_FUNCTION_NAME test_matlab/* * Need to include simstruc.h for the definition of the SimStruct and * its associated macro definitions. */#include simstruc.h/* Error handling * - * * You should use the following technique to report errors encountered within * an S-function: * * ssSetErrorStatus(S,Error encountered due to .); * return; * * Note that the 2nd argument to ssSetErrorStatus must be persistent memory. * It cannot be a local variable. For example the following will cause * unpredictable errors: * * mdlOutputs() * * char msg256; ILLEGAL: to fix use static char msg256; * sprintf(msg,Error due to %s, string); * ssSetErrorStatus(S,msg); * return; * * * See matlabroot/simulink/src/sfuntmpl_doc.c for more details. */*=* * S-function methods * *=*/* Function: mdlInitializeSizes = * Abstract: * The sizes information is used by Simulink to determine the S-function * blocks characteristics (number of inputs, outputs, states, etc.). */static void mdlInitializeSizes(SimStruct *S) /* See sfuntmpl_doc.c for more details on the macros below */ ssSetNumSFcnParams(S, 0); /* Number of expected parameters */ if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S) /* Return if number of expected != number of actual parameters */ return; ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); if (!ssSetNumInputPorts(S, 0) return; /ssSetInputPortWidth(S, 0, 1); /ssSetInputPortRequiredContiguous(S, 0, true); /*direct input signal access*/ /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: * This function is used to specify the sample time(s) for your * S-function. You must register the same number of sample times as * specified in ssSetNumSampleTimes. */static void mdlInitializeSampleTimes(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);/#define MDL_INITIALIZE_CONDITIONS /* Change to #undef to remove function */#undef MDL_INITIALIZE_CONDITIONS#if defined(MDL_INITIALIZE_CONDITIONS) /* Function: mdlInitializeConditions = * Abstract: * In this function, you should initialize the continuous and discrete * states for your S-function block. The initial states are placed * in the state vector, ssGetContStates(S) or ssGetRealDiscStates(S). * You can also perform any other initialization activities that your * S-function may require. Note, this routine will be called at the * start of simulation and if it is present in an enabled subsystem * configured to reset states, it will be call when the enabled subsystem * restarts execution to reset the states. */ static void mdlInitializeConditions(SimStruct *S) #endif /* MDL_INITIALIZE_CONDITIONS */#define MDL_START /* Change to #undef to remove function */#if defined(MDL_START) /* Function: mdlStart = * Abstract: * This function is called once at start of model execution. If you * have states that should be initialized once, this is the place * to do it. */ static void mdlStart(SimStruct *S) /* for(i=0;iInit() ssSetErrorStatus(S, error message); return; MyDrv-StartScan(); #endif /* MDL_START */* Function: mdlOutputs = * Abstract: * In this function, you compute the outputs of your S-function * block. Generally outputs are placed in the output vector, ssGetY(S). */static void mdlOutputs(SimStruct *S, int_T tid) /const real_T *u = (const real_T*) ssGetInputPortSignal(S,0);real_T *y = ssGetOutputPortRealSignal(S,0);real_T val,Sampletime;P1202DRV *MyDrv = (P1202DRV *)ssGetPWork(S)0; Sampletime=ssGetT(S); val=MyDrv-Read(Sampletime); if(val100.0)ssSetErrorStatus(S, Data overflow!); y0=val;#define MDL_UPDATE /* Change to #undef to remove function */#undef MDL_UPDATE#if defined(MDL_UPDATE) /* Function: mdlUpdate = * Abstract: * This function is called once for every major integration time step. * Discrete states are typically updated here, but this function is useful * for performing any tasks that should only take place once per * integration step. */ static void mdlUpdate(SimStruct *S, int_T tid) #endif /* MDL_UPDATE */#define MDL_DERIVATIVES /* Change to #undef to remove function */#undef MDL_DERIVATIVES#if defined(MDL_DERIVATIVES) /* Function: mdlDerivatives = * Abstract: * In this function, you compute the S-function blocks derivatives. * The derivatives are placed in the derivative vector, ssGetdX(S). */ static void mdlDerivatives(SimStruct *S) #endif /* MDL_DERIVATIVES */* Function: mdlTerminate = * Abstract: * In this function, you should perform any actions that are necessary * at the termination of a simulation. For example, if memory was * allocated in mdlStart, this is the place to free it. */static void mdlTerminate(SimStruct *S)P1202DRV *MyDrv = (P1202DRV *)ssGetPWork(S)0;if(MyDrv=NULL)return;MyDrv-Stop();MyDrv-Close();delete MyDrv;return;/*=* * See sfuntmpl_doc.c for the optional S-function methods * *=*/*=* * Required S-function trailer * *=*/#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */#include simulink.c /* MEX-file interface mechanism */#else#include cg_sfun.h /* Code generation registration function */#endif#ifdef _cplusplus / end of extern C scope#endifP1202DRV.H:/ P1202DRV.h: interface for the P1202DRV class./#if !defined(AFX_P1202DRV_H_455B5152_0FD1_4D8F_9BD3_9DFD0C69E6E7_INCLUDED_)#define AFX_P1202DRV_H_455B5152_0FD1_4D8F_9BD3_9DFD0C69E6E7_INCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER 1000#define BUFFLEN 1000#define NUMCHAN 1#define INITFLAG0X1#define ACTIVEFLAG0X2#define SCANFLAG0X4#define READFLAG0x8#define SAMPLERATE 4000#include #ifdef _cplusplusextern C / use the C fcn-call standard for all functions #endif / defined within this scope #define S_FUNCTION_LEVEL 2#define S_FUNCTION_NAME test_matlab#include simstruc.h#ifdef _cplusplus / end of extern C scope#endifclass P1202DRV int initflag,buffindex,readcount;int ErrorFlag;time_T Ts,StartTime,EndTime;DWORD dwP1,dwP2;WORD wChannelStatus32,wChannelConfig32,wStatus;WORD wCard0Buf0BUFFLEN*32,wCard0Buf1BUFFLEN*32;public:P1202DRV();virtual P1202DRV();public:int Init();int Close();int StartScan();double Read(time_T SampleTime);int Stop();WORD CardRead();#endif / !defined(AFX_P1202DRV_H_455B5152_0FD1_4D8F_9BD3_9DFD0C69E6E7_INCLUDED_)P1202DRV.C:/ P1202DRV.cpp: implementation of the P1202DRV class./#include #include #include #include #include p1202.h#include P1202DRV.h/ Construction/Destruction/P1202DRV:P1202DRV()P1202DRV:P1202DRV()P1202DRV:Init()int i;WORD wTotalBoard,wInitialCode;ErrorFlag=0;for(i=0; i32; i+) wChannelStatusi=0;wChannelConfigi=0; /wChannelStatus0=1; / Add Ch:0 to be scanfor(i=0;iNUMCHAN;i+)wChannelStatusi=1;buffindex=0;initflag=0;readcount=0;wInitialCode=P1202_DriverInit(&wTotalBoard); if( wInitialCode!=NoError )ErrorFlag=1;return 1;P1202_ActiveBoard( 0 );Ts

溫馨提示

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

評論

0/150

提交評論