《一、软件仿真部分:数字频带传输通信系统仿真.doc》由会员分享,可在线阅读,更多相关《一、软件仿真部分:数字频带传输通信系统仿真.doc(27页珍藏版)》请在三一办公上搜索。
1、内蒙古工业大学课程设计任务书参考格式学院(系): 信息工程学院 课程名称: 专业综合设计 指导教师(签名): 专业班级: 通信04-1班 学生姓名: 王兵 学号: 040204011 一、课程设计题目数字基带/频带通信系统的设计二、课程设计的目的“数字基带/频带通信系统的设计”是针对通信工程专业学生的实践教学环节。通过综合设计,要求学生利用所学专业知识和软件、硬件工具,掌握通信系统的分析、设计、仿真和调试技能,深入理解通信系统的基本组成,扩展专业背景知识,培养工程技能和实际操作能力。 三、课程设计的主要内容和要求(包括原始数据、技术参数、设计要求、工作量要求等) 1、 系统硬件设计2、 系统软
2、件仿真3、 系统硬件调试4、 设计报告的完成四、工作进度安排 专业综合设计为期二周,具体分5个阶段进行:1、查阅资料:利用1-2天,去图书馆或上网查阅资料,熟悉通信系统的相关内容;2、系统设计:根据设计要求,提出设计方案; 3、系统仿真:利用MATLAB语言进行系统仿真; 4、系统调试:利用通信原理实验箱,合理选择电路板;5、报告整理考核:最后1-2天进行设计报告的整理和考核。五、主要参考文献1、通信原理樊昌信编著2、通信系统仿真技术黎玉玲编著(内部学习资料)审核批准意见系(教研室)主任(签字) 仿真部分:一、设计内容:数字频带传输系统的MATLAB仿真实现1个人单独完成部分:A/D转换(60
3、分)(一)基本任务:单频正弦波模拟信号的简单数字化。即对一个单频正弦波模拟信号进行抽样、均匀量化、PCM二进制自然编码。1、 A/D转换部分的要求输入的信号幅度A 、频率F、相位P、量化电平D可变;仿真时间是02/F,抽样频率20F;输出信号要求是平顶正弦波;给出量化输出信号、抽样信号在同一图形窗口的波形;按照量化序号给出PCM二进制自然编码,在转换成数字序列;2、 A/D转换部分的步骤单频正弦波模拟信号的抽样对其进行均匀量化进行消顶处理二进制自然编码3、 程序代码说明function sampl,quant,pcm=a_d_1(A,F,P,D)%输入变量A、F、P、D;%输出变量:samp1
4、为抽样后的输入信号;quant为均匀量化后输出信号;%pcm为编码后的二进制自然编码数字序列;4、A/D转换程序代码function sampl,quant,pcm,pcm2=a_d_1(A,F,P,D)t=0:1/(20*F):2/F;x=A*sin(2*pi*F*t+P);sampl=x/max(x) % 归一化后的抽样信号subplot(3,1,1)plot(t,x,m*); %粉色为原始抽样后信号hold onplot(t,sampl,m.) ; %归一化后的信号partition=-1:2/D:1codebook=-1-1/D:2/D:1indx,quant=quantiz(samp
5、l,partition,codebook);m=min(quant);for i=1:length(quant) if quant(i)=m; quant(i)=quant(i)+2/D; end i=i+1;endhold onplot(t,quant,g*-) %绿色为处理后的平顶正弦波信号index=indx-1pcm=zeros(length(index)-1);i=1;while i=length(index) if index(i,1)=-1 index(i,1)=0; end i=i+1;endn=ceil(log2(D);pcm=dec2bin(index,n); %pcm为编
6、码后输出m1=length(pcm);pcm1=pcm;pcm2=reshape(pcm1,1,m1*n); %将二进制转换为行矢量5、测试程序的结果(基本任务)测试信号:sampl,quant,pcm,pcm2=a_d_1(4,32000,0,14)%输入信号波形和归一化后量化后波形(进行消尖处理后)%samp1为抽样后值sampl = Columns 1 through 7 0 0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 Columns 8 through 14 0.8090 0.5878 0.3090 0.0000 -0.3090 -0.5878
7、-0.8090 Columns 15 through 21 -0.9511 -1.0000 -0.9511 -0.8090 -0.5878 -0.3090 -0.0000 Columns 22 through 28 0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 0.8090 Columns 29 through 35 0.5878 0.3090 0.0000 -0.3090 -0.5878 -0.8090 -0.9511 Columns 36 through 41 -1.0000 -0.9511 -0.8090 -0.5878 -0.3090 -0.000
8、0量化后值(基本任务)quant = Columns 1 through 7 -0.0714 0.3571 0.6429 0.7857 0.9286 0.9286 0.9286 Columns 8 through 14 0.7857 0.6429 0.3571 0.0714 -0.3571 -0.6429 -0.7857 Columns 15 through 21 -0.9286 -0.9286 -0.9286 -0.7857 -0.6429 -0.3571 -0.0714 Columns 22 through 28 0.3571 0.6429 0.7857 0.9286 0.9286 0.9
9、286 0.7857 Columns 29 through 35 0.6429 0.3571 0.0714 -0.3571 -0.6429 -0.7857 -0.9286 Columns 36 through 41 -0.9286 -0.9286 -0.7857 -0.6429 -0.3571 -0.0714二进制编码:(基本任务)pcm =01101001101111001101110111011100101110010111010000100001000000000000000100100100011010011011110011011101110111001011100101110100
10、001000010000000000000001001001000110将PCM转换为数字序列(基本任务)pcm2 = Columns 1 through 12 0 1 1 0 1 0 0 1 1 0 1 1 Columns 13 through 24 1 1 0 0 1 1 0 1 1 1 0 1 Columns 25 through 36 1 1 0 1 1 1 0 0 1 0 1 1 Columns 37 through 48 1 0 0 1 0 1 1 1 0 1 0 0 Columns 49 through 60 0 0 1 0 0 0 0 1 0 0 0 0 Columns 61
11、through 72 0 0 0 0 0 0 0 0 0 0 0 1 Columns 73 through 84 0 0 1 0 0 1 0 0 0 1 1 0 Columns 85 through 96 1 0 0 1 1 0 1 1 1 1 0 0 Columns 97 through 108 1 1 0 1 1 1 0 1 1 1 0 1 Columns 109 through 120 1 1 0 0 1 0 1 1 1 0 0 1 Columns 121 through 132 0 1 1 1 0 1 0 0 0 0 1 0 Columns 133 through 144 0 0 0
12、1 0 0 0 0 0 0 0 0 Columns 145 through 156 0 0 0 0 0 0 0 1 0 0 1 0 Columns 157 through 164 0 1 0 0 0 1 1 0(二)选做任务:单频正弦波模拟信号的特殊数字化。按给定要求对一个单频正弦波模拟信号进行数字化。(10分)1、主要要求输入的信号幅度A 、频率F、相位P、量化电平D可变;仿真时间是02/F,抽样频率20F;杜输入正弦波信号进行非均匀量化实现,进行A,U率压缩;且A,U参数可变;输出信号要求是平顶正弦波;给出量化输出信号、抽样信号在同一图形窗口的波形;按照量化序号给出PCM二进制折叠编码,在
13、转换成数字序列;2、 A/D转换部分的步骤单频正弦波模拟信号的抽样对其进行A,U率压缩并进行均匀量化进行消顶处理二进制折叠编码数字序列3、程序代码说明function samp1,quant1,quant2,pcm1,pcm2=a_d_2(A,F,P,D,a,u)%输入变量:A,F,P,D,a,u;%输出变量:samp1为抽样后的输入信号、quant1为A率压缩非均匀量化后的输出信号、quant2为U率压缩非均匀量化后的输出信号;%pcm1,pcm2为进行二进制折叠编码后输出;4、 A/D转换程序代码function samp1,quant1,quant2,pcm1,pcm2=a_d_6(A,
14、F,P,D,a,u)t=0:1/(20*F):2/F;x=A*sin(2*pi*F*t+P);samp1=x/max(x); % 归一化后的抽样信号y=compand(samp1,a,1,a/compressor); %A率压缩后波形subplot(2,1,1);plot(t,samp1,m) ; %粉色为归一化后波形hold onplot(t,y,m*-) ; %压缩后的波形partition=-1:2/D:1;codebook=-1-1/D:2/D:1;indx1,quant1=quantiz(y,partition,codebook);m=min(quant1);for i=1:leng
15、th(quant1) if quant1(i)=m; quant1(i)=m+2/D; end i=i+1;endhold onplot(t,quant1,b*); %量化后波形index1=indx1-1; % 量化序号pcm1=zeros(length(index1)-1);i=1;while i=length(index1) if index1(i,1)=-1; index1(i,1)=0; end i=i+1;endn=ceil(log2(D);for j=1:length(index1); %对量化序号进行调整 if index1(j,:)=2(n-1) index1(j,:)=2n
16、/2-1-index1(j,:); else index1(j,:)=(2n)/2+(index1(j,:)-ceil(D/2); end i=i+1; endpcm1=dec2bin(index1,n); %pcm1为折叠二进制编码输出pcm11=pcm1;m1=length(pcm1);pcm111=reshape(pcm11,1,m1*n);%进行U率压缩z=compand(samp1,u,1,mu/compressor); %U率压缩后波形subplot(2,1,2)plot(t,samp1,m);hold onplot(t,z,m*-);partition=-1:2/D:1;code
17、book=-1-1/D:2/D:1;indx2,quant2=quantiz(z,partition,codebook);c=min(quant2);for i=1:length(quant2) if quant2(i)=c; quant2(i)=c+2/D; end i=i+1;endhold onplot(t,quant2,g*); index2=indx2-1;pcm=zeros(length(index2)-1);i=1;while i=length(index2) if index2(i,1)=-1 index2(i,1)=0; end i=i+1;endn=ceil(log2(D)
18、; for j=1:length(index2); if index2(j,:)=2(n-1) index2(j,:)=2n/2-1-index2(j,:); else index2(j,:)=(2n)/2+(index2(j,:)-ceil(D/2); end i=i+1; endpcm2=dec2bin(index2,n); %pcm2为折叠二进制编码后输出pcm22=pcm2;m1=length(pcm2);pcm222=reshape(pcm22,1,m1*n); %序列5、 测试结果samp1,quant1,quant2,pcm1,pcm2=a_d_6(4,32000,0,14,87
19、.6,255) samp1 = Columns 1 through 7 0 0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 Columns 8 through 14 0.8090 0.5878 0.3090 0.0000 -0.3090 -0.5878 -0.8090 Columns 15 through 21 -0.9511 -1.0000 -0.9511 -0.8090 -0.5878 -0.3090 -0.0000 Columns 22 through 28 0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 0.809
20、0 Columns 29 through 35 0.5878 0.3090 0.0000 -0.3090 -0.5878 -0.8090 -0.9511 Columns 36 through 41 -1.0000 -0.9511 -0.8090 -0.5878 -0.3090 -0.0000quant1 = Columns 1 through 7 -0.0714 0.7857 0.9286 0.9286 0.9286 0.9286 0.9286 Columns 8 through 14 0.9286 0.9286 0.7857 0.0714 -0.7857 -0.9286 -0.9286 Co
21、lumns 15 through 21 -0.9286 -0.9286 -0.9286 -0.9286 -0.9286 -0.7857 -0.0714 Columns 22 through 28 0.7857 0.9286 0.9286 0.9286 0.9286 0.9286 0.9286 Columns 29 through 35 0.9286 0.7857 0.0714 -0.7857 -0.9286 -0.9286 -0.9286 Columns 36 through 41 -0.9286 -0.9286 -0.9286 -0.9286 -0.7857 -0.0714quant2 =
22、Columns 1 through 7 -0.0714 0.7857 0.9286 0.9286 0.9286 0.9286 0.9286 Columns 8 through 14 0.9286 0.9286 0.7857 0.0714 -0.7857 -0.9286 -0.9286 Columns 15 through 21 -0.9286 -0.9286 -0.9286 -0.9286 -0.9286 -0.7857 -0.0714 Columns 22 through 28 0.7857 0.9286 0.9286 0.9286 0.9286 0.9286 0.9286 Columns
23、29 through 35 0.9286 0.7857 0.0714 -0.7857 -0.9286 -0.9286 -0.9286 Columns 36 through 41 -0.9286 -0.9286 -0.9286 -0.9286 -0.7857 -0.0714pcm1 =00011101111011101110111011101110111011010000011001110111011101110111011101110110000111011110111011101110111011101110110100000110011101110111011101110111011101
24、100001 pcm2 =00011101111011101110111011101110111011010000011001110111011101110111011101110110000111011110111011101110111011101110110100000110011101110111011101110111011101100001 2合作完成部分:通信系统的建模和传输质量分析(一)基本任务:数字基带传输系统的MATLAB仿真实现。(20分)1、主要步骤和要求:数字基带传输系统的MATLAB仿真包括以下内容:单频正弦波模拟信号经过抽样(要求仿真时间从0到2/F,抽样频率为F
25、s=20F)、均匀量化(量化电平数D可变)、PCM二进制自然编码、AMI码型变换后,发送到信噪比snr可变的AWGN信道,然后经过抽样判决、AMI码型反变换、D/A转换(内插点数N可变)后恢复出单频正弦波模拟信号。要求给出抽样后的输入信号sampl和恢复出的输入信号re_sampl的波形图。2、程序代码及说明:function sampl,re_sampl=system_1(A,F,P,D,snr,N)%输入变量A ,F,P分别为输入信号的幅度、频率和相位,D为量化电平数,snr%为信道信噪比,N为D/A转换时的内插点数;输出变量sampl为抽样后的输入%信号,re_sampl为恢复出的输入信
26、号。3、 数字频带传输通信系统仿真程序代码 function sampl,re_sampl=system_5(A,F,P,D,snr,fc,fd,fs,N)sampl,quant,pcm2=a_d_1(A,F,P,D);for i=1:length(pcm2); % 判断是数字还是字符 if ischar(pcm2(i)=1 pcm2(i)=str2num(pcm2(i); end i=i+1;endpsk_sig=modulat_1(pcm2,fc,fd,fs);psk_after_channel=channel_1(psk_sig,snr);adjudge_psk=adjudg_1(psk
27、_after_channel);re_pcm=demodul_1(adjudge_psk,fc,fd,fs);re_voltag,re_sampl=d_a_1(re_pcm,D,N)% A/D*functionsampl,quant,pcm2=a_d_1(A,F,P,D) t=0:1/(20*F):2/F;sampl=A*sin(2*pi*F*t+P); c=sampl/max(sampl);partition=-1:2/D:1;codebook=-1-1/D:2/D:1;indx,quant=quantiz(c,partition,codebook);indx=indx-1;ind=zero
28、s(length(indx),1);i=1;while i=length(indx) if indx(i,1)=-1 indx(i,1)=0 end i=i+1;enda=min(quant); %对信号消顶i=1;while i=length(quant) if quant(1,i)=a quant(1,i)=quant(1,i)+2/D end i=i+1;endsubplot(3,1,1);plot(t,c,g*-);pcm=dec2bin(indx,ceil(log2(D); %对量化后信号编码pcm1=reshape(pcm,1,length(pcm)*ceil(log2(D);fo
29、r i=1:length(pcm1) pcm2(i)=str2num(pcm1(i) i=i+1;end%调制*function psk_sig=modulat_1(pcm2,fc,fd,fs)a=pcm2;psk_sig=dmod(a,fc,fd,fs,psk); %进入信道*function psk_after_channel=channel_1(psk_sig,snr);n1=length(psk_sig);psk_sig=psk_sig(:);psk_sig_a=zeros(n1,1);psk_sig_a=psk_sig_a(:); %产生列向量for i=1:n1 if ischar
30、(psk_sig(i)=1 psk_sig_a(i)=str2num(psk_sig(i); else psk_sig(i)=psk_sig(i); endendpsk_after_channel=awgn(psk_sig,snr);%抽样判决*function adjudge_psk=adjudg_1(psk_after_channel)n2=length(psk_after_channel);adjudge_psk=zeros(1,n2);for i=1:n2 if ischar(psk_after_channel)=1 psk_after_channel(i)=str2num(psk_a
31、fter_channel); endendfor i=1:n2 if round(psk_after_channel(i)=1 adjudge_psk(i)=1; elseif round(psk_after_channel(i)=0 adjudge_psk(i)=0; else adjudge_psk(i)=-1; end end%解调*function re_pcm=demodul_1(adjudge_psk,fc,fd,fs) for i=1:length(adjudge_psk) if ischar(adjudge_psk(i)=1 adjudge_psk=str2num(adjudg
32、e_psk(i); end endre_pcm=ddemod(adjudge_psk,fc,fd,fs,psk,2);% d/a*function re_voltag,re_sampl=d_a_1(re_pcm,D,N)for i=1:length(re_pcm) if ischar(re_pcm(i)=1; re_pcm(i)=str2num(re_pcm(i); endendn=ceil(log2(D); for i=2:n if rem(length(re_pcm),n); k=rem(length(re_pcm),n); B=zeros(1,(n-k); re_pcm1=re_pcm,
33、B; else re_pcm1=re_pcm; endendre_pcm1=re_pcm1(:);m=ceil(length(re_pcm1)/n); for i=1:m A=re_pcm1(i-1)*n+1:(i-1)*n+n); C=reshape(A,1,n); E=fliplr(C); sum=0; for j=1:n sum=sum+E(j)*2(j-1); V(i)=sum; endends=2/D;for i=1:m re_voltag(i)=(V(i)*s+s/2-1); endfor i=1:length(re_voltag) re_sampl(i-1)*(N+1)+1)=r
34、e_voltag(i); for k=2:N re_sampl(i-1)*(N+1)+k)=0; endend h1=zeros(1,N);for j=1:N h1(j)=j/(N+1);endh=0,h1,1,fliplr(h1),0; h=h(:);re_sampl=conv(h,re_sampl);subplot(3,1,2);plot( re_voltag,m-*);subplot(3,1,3)plot(re_sampl,k*);4、 测试信号: sampl,re_sampl=system_5(4,32000,0,15,30,3200,1600,12800,8)sampl = Colu
35、mns 1 through 7 0 1.2361 2.3511 3.2361 3.8042 4.0000 3.8042 Columns 8 through 14 3.2361 2.3511 1.2361 0.0000 -1.2361 -2.3511 -3.2361 Columns 15 through 21 -3.8042 -4.0000 -3.8042 -3.2361 -2.3511 -1.2361 -0.0000 Columns 22 through 28 1.2361 2.3511 3.2361 3.8042 4.0000 3.8042 3.2361 Columns 29 through
36、 35 2.3511 1.2361 0.0000 -1.2361 -2.3511 -3.2361 -3.8042 Columns 36 through 41 -4.0000 -3.8042 -3.2361 -2.3511 -1.2361 -0.0000re_sampl = Columns 1 through 7 0 0 0 0 0 0 0 Columns 8 through 14 0 0 0 0.0296 0.0593 0.0889 0.1185 Columns 15 through 21 0.1481 0.1778 0.2074 0.2370 0.2667 0.2963 0.3259 Columns 22 through 28 0.3556 0.3852 0.4148 0.4444 0.4741 0.5037 0.5333 Columns 29 through 35 0.