注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Mr.Right

不顾一切的去想,于是我们有了梦想。脚踏实地的去做,于是梦想成了现实。

 
 
 

日志

 
 
关于我

人生一年又一年,只要每年都有所积累,有所成长,都有那么一次自己认为满意的花开时刻就好。即使一时不顺,也要敞开胸怀。生命的荣枯并不是简单的重复,一时的得失不是成败的尺度。花开不是荣耀,而是一个美丽的结束,花谢也不是耻辱,而是一个低调的开始。

网易考拉推荐

AM调制解调matlab  

2013-03-17 17:54:19|  分类: 学习 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
信号处理基础和基本功!贴出来希望对大家有帮助!南无阿弥陀佛

% This m-file simulates the operation of the heterodyne section and
% demodulating section of a garden variety AM receiver. An array is created
% that represents the superposition of three separate RF carriers, each
% modulated at a different audio frequency. This is the kind of signal that
% could be expected at the output of the LNA. This signal is multiplied by
% a local oscillator, passed though an IF filter, and demodulated using a
% simple envelope detector (half-wave rectifier and single pole LPF). Some
% plots are created at the end to show the signal at various locations in
% the receiver.


%% Start %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all; close all;       % Clear memory and close figures, files, etc.

%% RF section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Fc = [700 750 800]*1e3;     % Carrier frequencies (Hz), [700 750 800] KHz
Ac = [1.00 1.25 1.50];      % Carrier amplitudes

Fm = [1 2 3]*1e3;           % Modulation frequencies (Hz)
Dm = [0.25 0.25 0.25];      % Modulation depths

Fs = 20*max(Fc);            % Sample rate, 20 times the highest RF (Hz), 16MHz
Ts = 1/Fs;                  % Sample period (s)

L = 10/min(Fm);             % Duration of signal, 10 times the period of the lowest modulation frequency

t = Ts*(0:ceil(L/Ts) - 1);    % Array of sample times (s), (0:ceil(L/Ts) - 1) means sampling points indices

% Carrier signals. A three row array with each row representing a single RF carrier
Sc = diag(Ac)*cos(2*pi*Fc'*t);  

% Sm is the message signal, A0 = 1 is the additional DC component in amplitude modulation
Sm = 1 + diag(Dm)*cos(2*pi*Fm'*t);  % Modulating signals. A three row array
                                    % with each row representing the
                                    % modulation for a single carrier.

Stx = sum(Sm.*Sc, 1);   % RF signal. The superposition of three separately
                        % modulated carriers. This is the type of signal
                        % that could be expected at the output of the LNA
                        % (or input to the mixer).
% Fm + Fc = [701000      752000      803000]; Fc - Fm = [699000      748000      797000];
% plot((0:length(Stx) - 1).*Fs/length(Stx), abs(fft(Stx))) % note: the higher peak values are carrier components

%% Mixer section(coherent demodulation) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

FLO = 300e3;                % Local oscillator frequency (Hz), 300kHz
ALO = 1;                    % Local oscillator amplitude
SLO = ALO*cos(2*pi*FLO*t);  % Local oscillator signal

Smix = Stx.*SLO;            % Signal at the output of the mixer
% Fm + Fc + FLO = [1001000     1052000     1103000]; Fc - Fm + FLO = [999000     1048000     1097000];
% Fm + Fc - FLO = [401000      452000      503000]; Fc - Fm - FLO = [399000      448000      497000];
% stem((0:length(Stx) - 1).*Fs/length(Stx), abs(fft(Smix)))% 6 carrier components

%% Envelope detector section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% There is probably a slicker way to write this in MATLAB, but I am an
% analog guy and don't really have a good handle on the nuances of digital
% filtering. So I just generated a continous time transfer function for a
% Butterworth bandpass filter and then coverted that to its discrete
% equivalent.

[NUM, DEN] = butter(5, [2*pi*430e3 2*pi*470e3], 's'); % Filter coefficients
                                                      % for a 10th order
                                                      % Butterworth
                                                      % bandpass centered
                                                      % at 450 KHz
                                                      
Hd = c2d(tf(NUM, DEN), Ts);     % Discrete equivalent derived from previous
                                % continuous time filter coefficients

Sfilt = filter(Hd.num{1}, Hd.den{1}, Smix);     % Signal at the output of the IF filter
% plot((0:length(Stx) - 1).*Fs/length(Stx), abs(fft(Sfilt))) % filter out the signal coresponding to 448000Hz and 452000Hz
%% Envelope detector section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% half-wave rectifier, a diode
Srect = Sfilt; Srect(Srect < 0) = 0;  % Half-wave rectified IF signal, plot(Srect)
% plot((0:length(Stx) - 1).*Fs/length(Stx), abs(fft(Srect))) 

tau = 0.1e-3; % Filter time constant (s), tau = RC, 1/tau = 10e3
a = Ts/tau; % simulate 1st order RC passive low pass filter
Srect_low = filter(a, [1, a - 1], Srect);  % Low pass filtering to recover the modulating signal, plot(Srect_low)
% stem((0:length(Stx) - 1).*Fs/length(Stx), abs(fft(Srect_low))) % check the 2kHz sinusoidal signal
%% Plotting section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                        
                                        
% The plots display numerical data from somewhere in middle of the arrays
% so that the transient responses from the filters have had a chance to
% ring out. Each figure contains three plots: the RF signal, the IF filter
% output, and the demodulated audio signal. The first figure plots a longer
% segment of time so the demodulated audio signal can be distinguished.
% The second figure plots a much shorter segment of time to show the detail
% in the RF signal.

figure;
min_index = ceil(length(t)/2); % index * Ts = analog_time, analog_time / Ts = index
max_index = min_index + ceil(2/min(Fm)/Ts); % 1/min(Fm) is the period of the lowest modulation frequency, 2 periods here

subplot(3,1,1);
plot(t(min_index:max_index), Stx((min_index:max_index)));
xlim([t(min_index) t(max_index)]); xlabel('Time (s)');
title('all 3 AM signals');

subplot(3,1,2);
plot(t(min_index:max_index), Sfilt((min_index:max_index)));
xlim([t(min_index) t(max_index)]); xlabel('Time (s)');
title('the 2nd signal(2KHz) at the output of the mixer');

subplot(3,1,3);
plot(t(min_index:max_index), Srect_low((min_index:max_index)));
xlim([t(min_index) t(max_index)]); xlabel('Time (s)');
title('the 2nd signal(2KHz) after envelope detector');

figure;
min_index = ceil(length(t)/2);
max_index = min_index + ceil(150/min(Fc)/Ts); % 1/min(Fc) is the period of the lowest carrier frequency

subplot(3,1,1);
plot(t(min_index:max_index), Stx((min_index:max_index)));
xlim([t(min_index) t(max_index)]); xlabel('Time (s)');
title('all 3 AM signals');

subplot(3,1,2);
plot(t(min_index:max_index), Sfilt((min_index:max_index)));
xlim([t(min_index) t(max_index)]); xlabel('Time (s)');
title('the 2nd signal(2KHz) at the output of the mixer');

subplot(3,1,3);
plot(t(min_index:max_index), Srect_low((min_index:max_index)));
xlim([t(min_index) t(max_index)]); xlabel('Time (s)');
title('the 2nd signal(2KHz) after envelope detector');
  评论这张
 
阅读(1005)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016