Modulace ASK. Signály RC a RRC.
%% ASK
% Tomas Krejci, 11.4.2015
clc
close all
clear all
data = [1 1 0 1 0 0 0 1];
%% PAM - jedno rozmerna
fs = 1E9; % vzorkovaci frek, pro "udelani spojite s(t)", v prednskach jako fh=1/Tv
Ts = 1E-6; % symbolovy interval, (jak dlouho potrva jeden datovy syombol (1 nebo 0 z data) po modulaci jako s(t) ?)
nn = fs*Ts;
kMax = length(data); % kolik je symbolovych intervalu (pro jedno rozmernou odpovida datovych intervalu)
c_m = [0 1]; % dvou-stavová
M = length(c_m);
c_m_k = zeros(1, kMax);
for kk = 1:kMax
switch (data(kk))
case 0
c_m_k(kk) = c_m(1);
case 1
c_m_k(kk) = c_m(2);
otherwise
c_m_k(kk) = 0;
end
end
%% REC
h_xy = ones(1, nn);
%% BiP
h_xy = [ones(1, nn/2) -ones(1, nn/2)];
%% RC
trc = -1:1/(nn/2):1-1/(nn/2);
h_xy = sRC(0.5,trc,nn-1);
%% RRC
h_xy = sRRC(0.5,trc,nn-1);
%% PAM expanzni cast
s_PAM = zeros(1, nn * kMax);
for kk = 1:kMax
s_PAM( (kk-1)*nn+1 : kk*nn ) = c_m_k(kk) * h_xy(1,:);
end
%% ASK
f0 = 100E6;
w0 = 2*pi*f0;
t0 = 0:1/fs:kMax*Ts-1/fs;
% ASK
s_t = s_PAM .* cos(w0*t0);
% spektrum
S_PAM = 10*log10((abs(fftshift(fft(s_t)))).^2);% energetické spektrum signálu
fx = fs/2 * linspace(-1,1,length(s_t));
h_figure = figure; set(h_figure(:),'color',[1 1 1]);
subplot(211); hold all;
plot(t0, s_t, 'Color', 'red', 'LineWidth', 2);
ylim([min(s_t)*1.2 max(s_t)*1.2 ]); title(['ASK M=' num2str(M)]);
xlabel('Time [s]'); ylabel('A [V]'); %legend('PAM s(t)', 'c_m_(_k_)','Location','NorthEastOutside');
subplot(212); hold all;
plot(fx, S_PAM, 'Color', 'blue');
ylim([-40 max(S_PAM)*1.2 ]); title('Spektrum');
xlabel('f [Hz]'); ylabel('Se [dB]');
Signál RC
function s_RC = sRC(alfa, t, N)
s_RC = zeros(1,N+1);
for n = 1:N+1,
if abs(t(1,n))<= (1-alfa)/2,
s_RC(1,n) = 1;
end;
if abs(t(1,n))<= (1+alfa)/2,
if abs(t(1,n))>= (1-alfa)/2,
s_RC(1,n)=(cos((pi/4/alfa)*(2*abs(t(1,n))-1+alfa)))^2;
end;
end;
end;
Signál RRC
function s_RRC = sRRC(alfa, t, N)
s_RRC = zeros(1,N+1);
for n = 1:N+1,
if t(1,n) ==0, s_RRC(1,n) = 1-alfa+4*alfa/pi;
elseif abs(t(1,n))==1/4/alfa, s_RRC(1,n) = (alfa/pi/1.414)*((pi-2)*cos(pi/4/alfa)+(pi+2)*sin(pi/4/alfa));
else s_RRC(1,n) = ((sin((1-alfa)*pi*t(1,n)))/pi/t(1,n)+(4*alfa*cos((1+alfa)*pi*t(1,n)))/pi)/(1-16*alfa*alfa*t(1,n)*t(1,n));
end;
end;
Download
ASK
sRC sRRC