1、第五章 调制与解调,第五章 调制与解调,5.1 调制与解调基本知识 5.2 通带模拟调制与解调 5.3 数字调制与解调,5.1 调制与解调基本知识,5.1.1 调制在通信系统中的作用 5.1.2 调制的基本特性和分类 5.1.3 通带仿真与基带仿真,5.1.1 调制在通信系统中的作用, 调制为了容易辐射 调制为了频率分配 调制为了多路复用 调制为了减少噪声和干扰的影响 调制可以克服设备的限制,5.1.2 调制的基本特性和分类(1),1.两个基本特性 仍然携带有消息 适合于信道传输 2.分类,5.1.2 调制的基本特性和分类(2),1 根据x(t)的不同可以分为:模拟调制、数字调制 2 根据c(
2、t)的不同分为:连续载波调制、脉冲载波调制 3 根据调制器功能不同分为:幅度调制、频率调制等。 4 根据调制器频谱搬移特性的不同可以分为:线性调制:Xc(t)与x(t)呈线性搬移,如AM和SSB。非线性调制:输出已调信号Xc(t)的频谱和调制信号x(t)的频谱之间没有线性对应关系,如FM FSK等。,5.1.3 通带仿真与基带仿真,通带仿真的载波信号包含在模型的发射部分,载波频率通常都远远高于信号的最高频率。由Nyquist抽样定理可知,为了能正确恢复出信息信号,仿真中的抽样频率应至少为载波频率最大值的两倍。如果信号频率很高,则仿真会变得非常慢,并且效率很低。为了加快仿真速度,当调制/解调技术
3、的参数选择或性能要求不是设计的关键时,通常使用基带仿真来代替通带仿真。 基带仿真一般被成为低通等效法仿真,它使用的是通带信号的复包络(complex envelope)。,5.2 通带模拟调制与解调,振幅调制(AM) DSB-SC 双边带抑制载波振幅调制 DSB-TC 双边带载波振幅调制 SSB QAM 频率调制(FM) 相位调制(PM),5.2.1 调制与解调函数介绍,1 通信工具箱提供的有关调制解调函数ammod 功能:模拟信号幅度调制 语法:Y = ammod(X, Fc, Fs) ; Y = ammod(X,Fc,Fs,INI_PHASE) Y = ammod (X,Fc,Fs,INI
4、_PHASE,CARRAMP) Fs must satisfy Fs 2*(Fc + BW),5.2.1 调制与解调函数介绍,1 通信工具箱提供的有关调制解调函数 Fs = 8000; % Sampling rate is 8000 samples per second. Fc = 300; % Carrier frequency in Hz t=0:.1*Fs/Fs; % Sampling times for .1 second x = sin(20*pi*t); % Representation of the signal y = ammod(x,Fc,Fs); % Modulate x
5、to produce y. figure; subplot(2,1,1); plot(t,x); % Plot x on top. subplot(2,1,2); plot(t,y)% Plot y below.,5.2.1 调制与解调函数介绍,5.2.1 调制与解调函数介绍,1 通信工具箱提供的有关调制解调函数 ssbmod pmmod fmmod,5.2.1 调制与解调函数介绍,1 通信工具箱提供的有关调制解调函数 amdemod 功能:模拟幅度解调。 语法:z = amdemod(y,Fc,Fs) z = amdemod(y,Fc,Fs,ini_phase) z = amdemod(y,
6、Fc,Fs,ini_phase,carramp) z = amdemod(y,Fc,Fs,ini_phase,carramp,num,den) num,den = butter(5,Fc*2/Fs),5.2.1 调制与解调函数介绍,2 解调过程中低通滤波器的使用butter 功能:数字巴特沃斯滤波器与模拟巴特沃斯滤波器设计 语法:B,A=butter(N,Wn) 说明:设计一个N阶低通巴特沃斯滤波器,返回滤波器的系数,A为分母的系数,B为分子的系数。A和B为长度为N+1的向量。系数按照Z的降幂排列。 The cut-off frequency Wn must be 0.0 Wn 1.0, wi
7、th 1.0 corresponding to half the sample rate.,t = .01; Fc = 10000; Fs = 80000; t = 0:1/Fs:0.01; s = sin(2*pi*300*t)+2*sin(2*pi*600*t); % Original signal num,den = butter(10,Fc*2/Fs); % Lowpass filter y1 = ammod(s,Fc,Fs); % Modulate. s1 = amdemod(y1,Fc,Fs,0,0,num,den); % Demodulate. subplot(3,1,1); p
8、lot(t,s) subplot(3,1,2); plot(t,y1) subplot(3,1,3); plot(t,s1),5.2.2 单边带抑制载波振幅调制与解调,1 原理分析,上边带调幅波的频谱图,下边带调幅波的频谱图,5.2.2 单边带抑制载波振幅调制与解调,1 原理分析,单边带调幅方式的时域表达式比较复杂,有上边带 (USB)和下边带(LSB)两种方式,表达式分别如下:,其中 为 的希尔伯特变换,5.2.2 单边带抑制载波振幅调制与解调,调制y = ssbmod(x,Fc,Fs)y = ssbmod(x,Fc,Fs,ini_phase)y = ssbmod(x,fc,fs,ini_p
9、hase,upper)解调z = ssbdemod(y,Fc,Fs)z = ssbdemod(y,Fc,Fs,ini_phase)z = ssbdemod(y,Fc,Fs,ini_phase,num,den),5.2.3 角度调制与解调,角度调制信号的一般表示式为,相位调制,频率调制,5.2.3.1 相位调制与解调,调制 y = pmmod(x,Fc,Fs,phasedev) y = pmmod(x,Fc,Fs,phasedev,ini_phase)解调 z = pmdemod(y,Fc,Fs,phasedev) z = pmdemod(y,Fc,Fs,phasedev,ini_phase),
10、5.2.3.2 频率调制与解调,调制 y = fmmod(x,Fc,Fs,freqdev) y = fmmod(x,Fc,Fs,freqdev,ini_phase)解调z = fmdemod(y,Fc,Fs,freqdev) z = fmdemod(y,Fc,Fs,freqdev,ini_phase),% Prepare to sample a signal for two seconds, % at a rate of 100 samples per second. Fs = 100; % Sampling rate t = 0:2*Fs+1/Fs; % Time points for sa
11、mpling % Create the signal, a sum of sinusoids. x = sin(2*pi*t) + sin(4*pi*t); Fc = 10; % Carrier frequency in modulation phasedev = pi/2; % Phase deviation for phase modulation y = pmmod(x,Fc,Fs,phasedev); % Modulate. y = awgn(y,10,measured,103); % Add noise. z = pmdemod(y,Fc,Fs,phasedev); % Demodu
12、late. % Plot the original and recovered signals. figure; plot(t,x,k-,t,z,g-); legend(Original signal,Recovered signal);,加性高斯白噪声函数,y = awgn(x,snr)y = awgn(x,snr,sigpower) sigpower is the power of x in dBW . y = awgn(x,snr,measured) measures the power of x before adding noise. y = awgn(x,snr,sigpower,
13、state) y = awgn(x,snr,measured,state),5.2.3 模拟幅度调制模块仿真,5.3.1 幅度键控(ASK),MATLAB函数 pammod y = pammod(x,M) (X中所有元素的值要小于M1) y = pammod(x,M,ini_phase) pamdemod z = pamdemod(y,M) z = pamdemod(y,M,ini_phase),5.3.1 幅度键控(ASK),x=1 0 0 1 1 0 1 y=pammod(x,2) y =1 -1 -1 1 1 -1 1x=1 0 3 1 1 2 1 y=pammod(x,4) y =-1
14、 -3 3 -1 -1 1 -1,5.3.1 幅度键控(ASK),x=1 2 3 1 2 3 0 4 3 y=pammod(x,5) y =-2 0 2 -2 0 2 -4 4 2,5.3.1 幅度键控(ASK),5.3.2 频移键控(FSK),将数字信号调制在载波的频率上的调制方法称为频移键控(FSK),它也包括二电平频移键控(BFSK)和多电平频移键控(MFSK)。 频移键控的原理与调频类似,只是使用数字信号而已。,5.3.2 频移键控(FSK),对上例的二元序列10110010,画出2FSK的波形, x=0:0.01:8; t=ones(1,100),zeros(1,100),ones(
15、1,100),ones(1,100),zeros(1,100),zeros(1,100),ones(1,100),zeros(1,101) y=sin(x.*(2*pi+2*t); plot(x,y),5.3.2 频移键控(FSK),可以看出,载频有所改变,由于调频同时必然带来了相位的改变,所以有相位的突变。,FSK波形,5.3.2 频移键控(FSK),调制 y = fskmod(x,M,freq_sep,nsamp)outputs the complex envelope y of the modulation of the message signal x using frequency
16、shift keying modulation. M is the alphabet size and must be an integer power of 2. The message signal must consist of integers between 0 and M-1. freq_sep is the desired separation between successive frequencies in Hz. nsamp denotes the number of samples per symbol in y and must be a positive intege
17、r greater than 1. The sampling rate of y is 1 Hz. By the Nyquist sampling theorem, freq_sep and M must satisfy (M-1)*freq_sep = 1. If x is a matrix with multiple rows and columns, the function processes the columns independently.,5.3.2 频移键控(FSK),调制 y = fskmod(x,M,freq_sep,nsamp,Fs)specifies the samp
18、ling rate of y in Hz. Because the Nyquist sampling theorem implies that the maximum frequency must be no larger than Fs/2, the inputs must satisfy (M-1)*freq_sep = Fs. 解调 z = fskdemod(y,M,freq_sep,nsamp) z = fskdemod(y,M,freq_sep,nsamp,Fs),5.3.2 频移键控(FSK),M = 4; freqsep = 8; nsamp = 8; Fs = 32; x =
19、randint(6,1,M) % Random signal y = fskmod(x,M,freqsep,nsamp,Fs); % Modulate. t=0:1:47; plot(t,y),5.3.2 频移键控(FSK),5.3.3 相移键控(PSK),1 简介 将信道发送的信息调制在载波的相位上,所以通过数字相位调制,数字信号的载波相位是 , m=0,1,M-1。对二进制调制,两个载波的相位分别是0, 。对于M进制的相位调制,一组M个载波调相信号的波形的一般表达式为:m=0,1,M-1 其中 为发射端的滤波脉冲,决定了信号的频谱特征,A是信号振幅。,5.3.3 相移键控(PSK),2 m
20、atlab函数 调制y = pskmod(x,M) M is the alphabet size and must be an integer power of 2. The message signal must consist of integers between 0 and M-1. The initial phase of the modulation is zero. y = pskmod(x,M,ini_phase) 解调 z = pskdemod(y,M) z = pskdemod(y,M,ini_phase),5.3.3 相移键控(PSK),len = 10000; % Nu
21、mber of symbols M = 16; % Size of alphabet msg = randint(len,1,M); % Original signal% Modulate using both PSK and PAM, % to compare the two methods. txpsk = pskmod(msg,M); txpam = pammod(msg,M);% Perturb the phase of the modulated signals. phasenoise = randn(len,1)*.015; rxpsk = txpsk.*exp(j*2*pi*ph
22、asenoise); rxpam = txpam.*exp(j*2*pi*phasenoise);,an n-by-n matrix containing pseudorandom values drawn from the standard normal distribution,5.3.3 相移键控(PSK),% Create a scatter plot of the received signals. scatterplot(rxpsk); title(Noisy PSK Scatter Plot) scatterplot(rxpam); title(Noisy PAM Scatter
23、 Plot)% Demodulate the received signals. recovpsk = pskdemod(rxpsk,M); recovpam = pamdemod(rxpam,M);% Compute number of symbol errors in each case. numerrs_psk = symerr(msg,recovpsk) numerrs_pam = symerr(msg,recovpam),5.3.3 相移键控(PSK),5.3.3 相移键控(PSK),N=7; K=4; row_num=100; g=1 1 0;0 1 1;1 1 1;1 0 1,e
24、ye(4); l=2K;%k比特传输信道 t=0:row_num-1*pi/50; sig=sin(t);%一个完整周期的正弦信号 p,codebook,partition=dpcmopt(sig,1,l); indx=dpcmenco(sig,codebook,partition,p); indx=indx; %可省略,msg=de2bi(indx);msg1=reshape(msg,row_num*K,1);code=encode(msg1,N,K,linear,g); nois=randerr(row_num,N,1); code=rem(code(:)+nois(:),2);rcv=d
25、ecode(code,N,K,linear,g);rcv1=reshape(rcv,K,row_num);rcv2=rcv1; rcv_indx=bi2de(rcv2);symerr(indx,rcv_indx);,rcv_indx=rcv_indx; quant=dpcmdeco(rcv_indx,codebook,p);MSE_err=(sig-quant).2; figure(1) plot(0:row_num-1,10*log10(MSE_err);%画出均方误差图形 figure(2) plot(t,sig,t,quant);,N=7; K=4; row_num=100; g=1 1
26、 0;0 1 1;1 1 1;1 0 1,eye(4); msg1=randint(K*row_num,1,2);code=encode(msg1,N,K,linear,g);code1=reshape(code,N,row_num);code2=code1;code3=bi2de(code2);M = 27; freqsep = 28; nsamp = 28; Fs = M *freqsep;y=fskmod(code3,M,freqsep,nsamp,Fs);,y = awgn(y,10,measured,103);y = fskdemod(y,M,freqsep,nsamp,Fs);y=de2bi(y);y1=reshape(y,N*row_num,1);rcv=decode(y1,N,K,linear,g);err=biterr(rcv,msg1),