《DSP课程设计调制解调实验报告(共23页).doc》由会员分享,可在线阅读,更多相关《DSP课程设计调制解调实验报告(共23页).doc(23页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上DSP课程设计实 验 报 告信号的调制与解调院(系):电子信息工程学院 设计人员:朱炜玮 学号: 张斯奇 目 录一、设计任务书1二、设计内容5三、设计方案、算法原理说明10四、程序设计、调试与结果分析15 五、设计(安装)与调试的体会25 六、参考文献26一、设计任务书信号的调制和解调广泛应用于通讯及信息处理领域。调制就是用低频的调制信号去控制高频载波的某一个参数,使载波信号的参数按照调制信号的规律变化,可分为调幅、调频和调相信号调制;信号的解调是调制的逆过程,是从已调高频信号中取出调制信号,对应的分为调幅、调频和调相信号的解调。本设计要求采用DSP及其A/D、D/A
2、转换器实现信号的调制和解调功能。1.设计要求及目标基本部分:使用DSP产生调幅波和调频波。调制信号从MIC音频输入接口输入,频率小于1000HZ;载频由DSP程序内部产生,频率在40008000HZ之间,调幅信号的调制度为50%。发挥部分:使用DSP对所产生的调幅及调频信号进行解调,并通过SPEAKER音频输接口输出解调后的信号。2.设计思路 模拟模拟幅度调制(AM)的实质是频谱搬移,其模型如下: 输出已调调幅信号的时域一般表示式为:如果载波的瞬时频率偏移随调制信号f(t)成线性变化,则为频率调制。调频信号表示式: 其瞬时频率为,其中c是未调载波的标称角频率,f (t)是调制信号,系数KFM称
3、为频偏常数。由数字振荡器递归的差分方程:yn=A*yn-1-yn-2其中:A=2cos(x),x=FM/FS, FS为采样频率。就可以迭代计算出调频信号的每一个输出样点的值,经过D/A变换和滤波便可以得到模拟的调频信号。3要求完成的任务(1)编写C语言程序,并在CCS集成开发环境下调试通过。(2)实现设计所要求的各项功能。(3)按要求撰写设计报告。二、设计内容1.基本部分:使用DSP产生调幅波(AM)和调频波(FM)。调制信号m(t)从MIC音频输入接口(J5)输入,频率f小于1000HZ;载频c(t)由DSP程序内部产生,频率在40008000HZ之间,调幅信号的调制度(modulation
4、 degree)为50%。2.发挥部分:使用DSP对所产生的调幅(AM)及调频(FM)信号进行解调,并通过SPEAKER音频输出(J6)接口输出解调后的信号。三、设计方案、算法原理说明1.整体构思:由J5输入fmax=1000Hz的音频信号,经A/D转换后变为15bit的二进制数据,再经FIR滤波器滤出噪声及高频分量(避免因高频分量的存在而影响系统的处理效果),后对经FIR滤波器输出的信号进行调制,选用载波为Fc=6250Hz。信号流图如图5.1所示:2.具体实现: c(t)的产生: 有两种实现方法:查表法和计算法。其中,查表法速度快,可以产生频率较高的波形,并且不占用DSP的计算时间,但由于
5、它占用DSP的内部存储空间,尤其对采样频率比较大的输出波形,而DSP的内部存储空间毕竟是有限的,所以其应用受到一定程度的限制;相反,计算法不占用DSP的内部存储空间,因而它多用于查表法不太适用的场合,但由于它要占用DSP的计算时间,因而使得执行程序的时间开销变大,不适用于高速处理场合。由于调制系统的载波频率较高,所以本实验采用的实现方法是查表法。 m(t)实时采集由于系统设计的是调制解调,而非一般的信号处理程序,因此需要对信号进行实时采集和处理。考虑到dsk板的硬件资源,最终决定采用先经过A/D对模拟信号进行离散量化,再经mcbsp进行信号处理的整体方案。而在数据经mcbsp后,对其进行相关的
6、处理。考虑到dsk板上的codec(TLC320AD50C)内含抗混叠滤波器和重构滤波器,因此可以省略输入端低通滤波器和输出端的滤波器。 AM调制的实现由AM调制的原理框图可知,其基本的过程是先对输入的信号加入一直流分量,其中所加直流分量要大于输入信号以保证后续调制不会出现过调幅现象。而信号的调制则采用的是对抽样后的信号直接与对应的调制信号相乘。由于dsp产生周期信号的方法是通过查表产生的,所以本方案采用的是将抽样得到的离散信号直接与调制信号表里的对应项相乘得到。再经codec输出。四、程序设计、调试与结果分析程序清单:调幅:程序1:/*头文件定义*/#include #include #in
7、clude #include #include #include #include /*延迟子程序定义*/void delay(s16 period);#pragma DATA_SECTION(delaybuff,delay);short delaybuff16=0; short *delayptr = &(delaybuff0); short inp_buffer1;short out_buffer1;short *inp_ptr=inp_buffer;short *out_ptr=out_buffer;HANDLE hHandset;s16 data;s16 temp_buffer256;
8、/*利用查表法产生载波信号定义*/s16 SINE_TABLE= 0x00324,0x00647 ,0x0096A,0x00C8B ,0x00FAB,0x012C7 ,0x015E1,0x018F8 ,0x01C0B,0x01F19 ,0x02223,0x02527 ,0x02826,0x02B1E ,0x02E10,0x030FB ,0x033DE,0x036B9 ,0x0398C,0x03C56 ,0x03F16,0x041CD ,0x0447A,0x0471C ,0x049B3,0x04C3F ,0x04EBF,0x05133 ,0x0539A,0x055F4 ,0x05842,0x05
9、A81 ,0x05CB3,0x05ED6 ,0x060EB,0x062F1 ,0x064E7,0x066CE ,0x068A5,0x06A6C ,0x06C23,0x06DC9 ,0x06F5E,0x070E1 ,0x07254,0x073B5 ,0x07503,0x07640 ,0x0776B,0x07883 ,0x07989,0x07A7C ,0x07B5C,0x07C29 ,0x07CE2,0x07D89 ,0x07E1C,0x07E9C ,0x07F08,0x07F61 ,0x07FA6,0x07FD7 ,0x07FF5,0x07FFE ,0x07FF5,0x07FD7 ,0x07FA
10、6,0x07F61 ,0x07F08,0x07E9C ,0x07E1C,0x07D89 ,0x07CE2,0x07C29 ,0x07B5C,0x07A7C ,0x07989,0x07883 ,0x0776B,0x07640 ,0x07503,0x073B5 ,0x07254,0x070E1 ,0x06F5E,0x06DC9 ,0x06C23,0x06A6C ,0x068A5,0x066CE ,0x064E7,0x062F1 ,0x060EB,0x05ED6 ,0x05CB3,0x05A81 ,0x05842,0x055F5 ,0x0539A,0x05133 ,0x04EBF,0x04C3F ,
11、0x049B3,0x0471C ,0x0447A,0x041CD ,0x03F16,0x03C56 ,0x0398C,0x036B9 ,0x033DE,0x030FB ,0x02E10,0x02B1E ,0x02826,0x02527 ,0x02223,0x01F19 ,0x01C0B,0x018F8 ,0x015E1,0x012C7 ,0x00FAB,0x00C8B ,0x0096A,0x00647 ,0x00324,0x00000 ,0x0FCDC,0x0F9B9 ,0x0F696,0x0F375 ,0x0F056,0x0ED39 ,0x0EA1F,0x0E708 ,0x0E3F5,0x0
12、E0E7 ,0x0DDDD,0x0DAD9 ,0x0D7DA,0x0D4E2 ,0x0D1F0,0x0CF05 ,0x0CC22,0x0C947 ,0x0C674,0x0C3AA ,0x0C0EA,0x0BE33 ,0x0BB86,0x0B8E4 ,0x0B64D,0x0B3C1 ,0x0B141,0x0AECD ,0x0AC66,0x0AA0C ,0x0A7BE,0x0A57F ,0x0A34D,0x0A12A ,0x09F15,0x09D0F ,0x09B19,0x09932 ,0x0975B,0x09594 ,0x093DD,0x09237 ,0x090A2,0x08F1F ,0x08D
13、AC,0x08C4C ,0x08AFD,0x089C0 ,0x08895,0x0877D ,0x08677,0x08584 ,0x084A4,0x083D8 ,0x0831E,0x08277 ,0x081E4,0x08164 ,0x080F8,0x0809F ,0x0805A,0x08029 ,0x0800B,0x08002 ,0x0800B,0x08029 ,0x0805A,0x0809F ,0x080F8,0x08164 ,0x081E4,0x08277 ,0x0831E,0x083D7 ,0x084A4,0x08584 ,0x08677,0x0877D ,0x08895,0x089C0
14、,0x08AFD,0x08C4B ,0x08DAC,0x08F1F ,0x090A2,0x09237 ,0x093DD,0x09594 ,0x0975B,0x09932 ,0x09B19,0x09D0F ,0x09F15,0x0A12A ,0x0A34D,0x0A57F ,0x0A7BE,0x0AA0B ,0x0AC66,0x0AECD ,0x0B141,0x0B3C1 ,0x0B64D,0x0B8E4 ,0x0BB86,0x0BE33 ,0x0C0EA,0x0C3AA ,0x0C674,0x0C947 ,0x0CC22,0x0CF05 ,0x0D1F0,0x0D4E1 ,0x0D7DA,0x
15、0DAD9 ,0x0DDDD,0x0E0E7 ,0x0E3F5,0x0E708 ,0x0EA1E,0x0ED38 ,0x0F055,0x0F375 ,0x0F696,0x0F9B9 ,0x0FCDC,0x00000 ; /*主程序*/void main() s16 cnt=2;int i=0,j=0;s32 dat32;/*初始化5402DSK扳*/ if (brd_init(100) return;/*闪灯程序定义*/while ( cnt- )brd_led_toggle(BRD_LED0);/* brd_delay_msec(1000); */delay(1000);brd_led_to
16、ggle(BRD_LED1);/* brd_delay_msec(1000); */delay(1000);brd_led_toggle(BRD_LED2);/* brd_delay_msec(1000); */delay(1000); hHandset = codec_open(HANDSET_CODEC); /* 获取Codec的句柄 */ /* Set codec parameters */ codec_dac_mode(hHandset, CODEC_DAC_15BIT); /* DAC in 15-bit mode */ codec_adc_mode(hHandset, CODEC_
17、ADC_15BIT); /* ADC in 15-bit mode */ codec_ain_gain(hHandset, CODEC_AIN_6dB); /* 输入信号增益为6dB */ codec_aout_gain(hHandset, CODEC_AOUT_MINUS_6dB); /* 输出信号增益为-6 dB */ codec_sample_rate(hHandset,SR_16000); /* 取样频率为16KHz*/ /* Polling and digital loopback */ while (1) /* Wait for sample from handset */ whi
18、le (!MCBSP_RRDY(HANDSET_CODEC) ; /*数据处理开始*/ data = *(volatile u16*)DRR1_ADDR(HANDSET_CODEC); i=i+100;/产生一个频率为6250HZ的载波 i=i&0xff;/修正样点指针 temp_bufferj=data; j+; j=j&0xff; dat32 =(data+10)* SINE_TABLEi; *(volatile u32*)DXR1_ADDR(HANDSET_CODEC) = dat32; return;/*延迟子程序*/void delay(s16 period) int i, j; f
19、or(i=0; iperiod; i+) for(j=0; j1; j+); Cmd文件:MEMORY PAGE 0: VECS: origin = 0080h, length = 0080h /* Internal Program RAM */ PRAM: origin = 7600h, length = 8000h /* Internal Program RAM */ PAGE 1: SCRATCH: origin = 0060h, length = 0020h /* Scratch Pad Data RAM */ DMARAM: origin = 0C00h, length = 0300
20、h /* DMA buffer */ DATA: origin = 1100h, length = 0080h /* Internal Data RAM */ STACK: origin = 1180h, length = 0560h /* Stack Memory Space */ INRAM: origin = 1900h, length = 0100h /* Internal Data RAM */ HPRAM0: origin = 1A00h, length = 0002h /* HPI memory accessible by Host and DSP */ HPRAM1: orig
21、in = 1A02h, length = 0280h /* HPI memory accessible by Host and DSP */ HPRAM2: origin = 1C82h, length = 0280h /* HPI memory accessible by Host and DSP */ EXRAM: origin = 1F10h, length = 4000h /* External Data RAM */*/* DSP Memory Allocation */*/SECTIONS .cinit PRAM PAGE 0 .text PRAM PAGE 0 .vectors
22、VECS PAGE 0 init_var PRAM PAGE 0 detect PRAM PAGE 0 vrcprg PRAM PAGE 0 matprg PRAM PAGE 0 .stack STACK PAGE 1 .trap SCRATCH PAGE 1 .const EXRAM PAGE 1 .data EXRAM PAGE 1 .bss EXRAM PAGE 1 .cio EXRAM PAGE 1 .switch EXRAM PAGE 1 coefficients EXRAM PAGE 1,align 1024 delay EXRAM PAGE 1,align 1024 tables
23、 EXRAM PAGE 1 var EXRAM PAGE 1 svctab EXRAM PAGE 1 /* SS_V LSP table */ vctab EXRAM PAGE 1 /* V LSP table */ uvctab EXRAM PAGE 1 /* UV LSP table */ cuvtab EXRAM PAGE 1 /* Stochastic codebook */ cdbktab EXRAM PAGE 1 /* various codebook tables*/ logtab EXRAM PAGE 1 /* table for log2 */ powtab EXRAM PA
24、GE 1 /* table for pow2 */ hamtab EXRAM PAGE 1 /* table for hamming */ lgwtab EXRAM PAGE 1 /* table for lag window */ acostab EXRAM PAGE 1 /* table for arccos */ sqrtab EXRAM PAGE 1 /* table for square root */ acbtab EXRAM PAGE 1 /* table for thresholds in acb */ pm03tab EXRAM PAGE 1 /* table for x(-
25、0.3) computation */ costab EXRAM PAGE 1 /* table for cosine */ V23 INRAM PAGE 1 FSK INRAM PAGE 1 hpibuff0 HPRAM0 PAGE 1 hpibuff1 HPRAM1 PAGE 1 hpibuff2 HPRAM2 PAGE 1 dma_buff DMARAM PAGE 1以上就是我们调幅波的产生程序,这个程序基本上是按照任务书的要求设计的,但因为最后一天没借到板子,所以只用仿真器产生了载波的波形如图:因为第一个程序的音频接收部分我们借鉴的是语音压缩的程序,但我们发现在调制过程中我们该程序对调
26、制信号的接收很差,在多次调试失败的情况下,我们只能通过DSK板同时产生调制信号和载波,效果很好,程序如下:/*利用查表法取得调制信号,次程序只是利用查表法产生载波和输入信号,没有里利用语音输入作为输入信号*/#include #include #include #include void delay(s16 period);HANDLE hHandset;s16 data;u16 j=0;u16 n=0;u16 a=0;s32 out_buffer256;s32 out_buffer1256;s32 out_buffer2256;/定义s16 SINE_TABLE= 0x00324,0x006
27、47 ,0x0096A,0x00C8B ,0x00FAB,0x012C7 ,0x015E1,0x018F8 ,0x01C0B,0x01F19 ,0x02223,0x02527 ,0x02826,0x02B1E ,0x02E10,0x030FB ,0x033DE,0x036B9 ,0x0398C,0x03C56 ,0x03F16,0x041CD ,0x0447A,0x0471C ,0x049B3,0x04C3F ,0x04EBF,0x05133 ,0x0539A,0x055F4 ,0x05842,0x05A81 ,0x05CB3,0x05ED6 ,0x060EB,0x062F1 ,0x064E7
28、,0x066CE ,0x068A5,0x06A6C ,0x06C23,0x06DC9 ,0x06F5E,0x070E1 ,0x07254,0x073B5 ,0x07503,0x07640 ,0x0776B,0x07883 ,0x07989,0x07A7C ,0x07B5C,0x07C29 ,0x07CE2,0x07D89 ,0x07E1C,0x07E9C ,0x07F08,0x07F61 ,0x07FA6,0x07FD7 ,0x07FF5,0x07FFE ,0x07FF5,0x07FD7 ,0x07FA6,0x07F61 ,0x07F08,0x07E9C ,0x07E1C,0x07D89 ,0
29、x07CE2,0x07C29 ,0x07B5C,0x07A7C ,0x07989,0x07883 ,0x0776B,0x07640 ,0x07503,0x073B5 ,0x07254,0x070E1 ,0x06F5E,0x06DC9 ,0x06C23,0x06A6C ,0x068A5,0x066CE ,0x064E7,0x062F1 ,0x060EB,0x05ED6 ,0x05CB3,0x05A81 ,0x05842,0x055F5 ,0x0539A,0x05133 ,0x04EBF,0x04C3F ,0x049B3,0x0471C ,0x0447A,0x041CD ,0x03F16,0x03
30、C56 ,0x0398C,0x036B9 ,0x033DE,0x030FB ,0x02E10,0x02B1E ,0x02826,0x02527 ,0x02223,0x01F19 ,0x01C0B,0x018F8 ,0x015E1,0x012C7 ,0x00FAB,0x00C8B ,0x0096A,0x00647 ,0x00324,0x00000 ,0x0FCDC,0x0F9B9 ,0x0F696,0x0F375 ,0x0F056,0x0ED39 ,0x0EA1F,0x0E708 ,0x0E3F5,0x0E0E7 ,0x0DDDD,0x0DAD9 ,0x0D7DA,0x0D4E2 ,0x0D1F
31、0,0x0CF05 ,0x0CC22,0x0C947 ,0x0C674,0x0C3AA ,0x0C0EA,0x0BE33 ,0x0BB86,0x0B8E4 ,0x0B64D,0x0B3C1 ,0x0B141,0x0AECD ,0x0AC66,0x0AA0C ,0x0A7BE,0x0A57F ,0x0A34D,0x0A12A ,0x09F15,0x09D0F ,0x09B19,0x09932 ,0x0975B,0x09594 ,0x093DD,0x09237 ,0x090A2,0x08F1F ,0x08DAC,0x08C4C ,0x08AFD,0x089C0 ,0x08895,0x0877D ,
32、0x08677,0x08584 ,0x084A4,0x083D8 ,0x0831E,0x08277 ,0x081E4,0x08164 ,0x080F8,0x0809F ,0x0805A,0x08029 ,0x0800B,0x08002 ,0x0800B,0x08029 ,0x0805A,0x0809F ,0x080F8,0x08164 ,0x081E4,0x08277 ,0x0831E,0x083D7 ,0x084A4,0x08584 ,0x08677,0x0877D ,0x08895,0x089C0 ,0x08AFD,0x08C4B ,0x08DAC,0x08F1F ,0x090A2,0x0
33、9237 ,0x093DD,0x09594 ,0x0975B,0x09932 ,0x09B19,0x09D0F ,0x09F15,0x0A12A ,0x0A34D,0x0A57F ,0x0A7BE,0x0AA0B ,0x0AC66,0x0AECD ,0x0B141,0x0B3C1 ,0x0B64D,0x0B8E4 ,0x0BB86,0x0BE33 ,0x0C0EA,0x0C3AA ,0x0C674,0x0C947 ,0x0CC22,0x0CF05 ,0x0D1F0,0x0D4E1 ,0x0D7DA,0x0DAD9 ,0x0DDDD,0x0E0E7 ,0x0E3F5,0x0E708 ,0x0EA
34、1E,0x0ED38 ,0x0F055,0x0F375 ,0x0F696,0x0F9B9 ,0x0FCDC,0x00000 ; /*主程序*/void main() s16 amp=1;/定义幅度 s16 cnt=2; u16 i=0;u16 m=0; if (brd_init(100) return;/* 定义闪灯程序*/while ( cnt- )brd_led_toggle(BRD_LED0);/* brd_delay_msec(1000); */delay(1000);brd_led_toggle(BRD_LED1);/* brd_delay_msec(1000); */delay(1
35、000);brd_led_toggle(BRD_LED2);/* brd_delay_msec(1000); */delay(1000); while (1) i=i+1;/62.5HZ / i=i+10;/625HZ / i=i+100;/6250HZ i&=0x00ff; / 修正样点指针 out_buffer1j=amp*SINE_TABLEi;/利用查表法产生一个载波信号,并存放在数组out_buffer1中 /m=m+1;/62.5HZ m=m+10;/625HZ / m=m+100;/6250HZ m&=0x00ff; / 修正样点指针 out_buffer2j=amp*SINE_
36、TABLEm;/利用查表法产生一个输入信号,并存放在数组out_buffer2中 out_bufferj=(10+out_buffer1j)*out_buffer2j; j+; j&=0x00ff; /mod 255 /* 定义延迟程序*/ void delay(s16 period) int i, j; for(i=0; iperiod; i+) for(j=0; j1; j+); Cmd:MEMORY PAGE 0: VECS: origin = 0080h, length = 0080h /* Internal Program RAM */ PRAM: origin = 7600h, l
37、ength = 8000h /* Internal Program RAM */ PAGE 1: SCRATCH: origin = 0060h, length = 0020h /* Scratch Pad Data RAM */ DMARAM: origin = 0C00h, length = 0300h /* DMA buffer */ DATA: origin = 1100h, length = 0080h /* Internal Data RAM */ STACK: origin = 1180h, length = 0560h /* Stack Memory Space */ INRA
38、M: origin = 1900h, length = 0100h /* Internal Data RAM */ HPRAM0: origin = 1A00h, length = 0002h /* HPI memory accessible by Host and DSP */ HPRAM1: origin = 1A02h, length = 0280h /* HPI memory accessible by Host and DSP */ HPRAM2: origin = 1C82h, length = 0280h /* HPI memory accessible by Host and
39、DSP */ EXRAM: origin = 1F10h, length = 4000h /* External Data RAM */*/* DSP Memory Allocation */*/SECTIONS .cinit PRAM PAGE 0 .text PRAM PAGE 0 .vectors VECS PAGE 0 init_var PRAM PAGE 0 detect PRAM PAGE 0 vrcprg PRAM PAGE 0 matprg PRAM PAGE 0 .stack STACK PAGE 1 .trap SCRATCH PAGE 1 .const EXRAM PAGE 1 .data