Mudanças entre as edições de "CSF29008 2015-2"

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
Linha 156: Linha 156:
 
{{collapse bottom}}
 
{{collapse bottom}}
  
=== Modelo de Jakes ===
+
==== Modelo de Jakes ====
 
{{collapse top | Modelo de Clarke-Jakes (Canal Plano com Desvanecimento Rayleigh)}}
 
{{collapse top | Modelo de Clarke-Jakes (Canal Plano com Desvanecimento Rayleigh)}}
  

Edição das 22h59min de 4 de novembro de 2015

Plano de Ensino e Cronograma

Desenvolvimento Pedagógico - Andamento do Cronograma 2015/2

Suspensão do calendário acadêmico pela direção do Campus de 30 de Julho a 1 de Outubro;
Semestre 2015-2 - Prof. Bruno Fontana da Silva / ???
Aula Data Horas Conteúdo Recursos
1 5/10 2 Introdução às comunicações móveis: apresentação e motivação da componente curricular
2 8/10 2 Propagação em Larga Escala (Modelos Analíticos): Introdução, Espaço Livre, Dois Raios
3 15/10 2 Propagação em Larga Escala (Modelos Analíticos): 10 Raios, Múltiplos Raios Generalizado, Difração e Dispersão, Okumura
4 17/10 2 Dúvidas sobre exercícios com MATLAB (apenas um aluno compareceu)
5 19/10 2 Propagação em Larga Escala (Modelos Empíricos): Okumura, Hata, Cost231, Dual Slope, Atenuação Indoor, Modelo Simplificado (+30min.) MATLAB para simulação das curvas do modelo Hata e Cost231
6 22/10 2 Propagação em Pequena Escala: Introdução, Doppler e Canal Multipercurso MATLAB: superposição de fasores de campo elétrico
7 26/10 2 Propagação em Pequena Escala: Modelo de Banda Estreita, Autocorrelações, Clarke-Jakes e PSD (+30min.) MATLAB: simulação do canal rayleigh plano através do modelo Clarke-Jakes
8 29/10 2 Propagação em Pequena Escala: Simulação Rayleigh (Plano) – Método Rappaport x MATLAB rayleighchan(Ts,fd) + BPSK
TOTAL 80

Voltar para CSF-2015-2

Notas de Aula


Simulações

  • Dois raios
  • Hata e Cost231

Campo Eletromagnético

Campo eletromagnético
% 5.4.1 A Computer Experiment (Andreas Molisch, Wireless Communications)

clear all; close all; clc;

% Consider the following simple computer experiment. The signals from several IOs are incident
% onto an RX that moves over a small area. The IOs are distributed approximately uniformly around
% the receiving area. They are also assumed to be sufficiently far away so that all received waves
% are homogeneous plane waves, and that movements of the RX within the considered area do not
% change the amplitudes of these waves. The different distances and strength of the interactions are
% taken into account by assigning a random phase and a random amplitude to each wave. We are
% then creating eight constituting waves Ei with absolute amplitudes |a_i|, angle of incidence (with
% respect to the x-axis) φ_i and phase ϕ_i.

fc = 900e6; Tc = 1/fc;                      % frequência da portadora;
c = 3e8;                                    % speed of light
wl = c*Tc;                                  % comprimento de onda
k = 2*pi/wl;                                % número de onda

% Fasores
% a = [169 213 87 256 17 126 343 297 0];        % φ, azimuti
% e = [311 32 161 356 191 56  268 131 0];       % ϕ_i, elevação
% Ep = [1 .8 1.1 1.3 .9 .5 .7 .9 1000];            % |a_i|, amplitudes

a=0;
e=180;
Ep = 1;

L = 100;
x = linspace(0,5*wl,L);                     % Eixo 0 < x < 5*wl  (L pontos)
y = linspace(0,5*wl,L);                     % Eixo 0 < y < 5*wl  (L pontos)
    

En = zeros(L,L);                            % buffer
for xx=1:length(x)                          % índices de x
    for yy = 1:length(y)                    % índices de y
        for n = 1:length(a)                 % índices de componentes
            % E(x,y) = sum Ep*exp{-jk[x*cos(a) + y*sin(a)]}*exp{je}
            % fasores do campo elétrico(x,y) em t=0;
            % Ep*exp(-j [k d + d0/k])
            En(xx,yy) = En(xx,yy) + Ep(n)*exp(-1i*k*(x(xx)*cosd(a(n))+y(yy)*sind(a(n))))*exp(1i*e(n)*pi/180);
        end
    end
end



figure;
subplot(2,2,1);
 surf(x,y,real(En)); zlabel('Real');
 
 subplot(2,2,2);
 surf(x,y,imag(En)); zlabel('Imaginário');
 
  subplot(2,1,2);
 surf(x,y,abs(En)); zlabel('|E|');
 
 figure;
 hist(abs(En(:)),100)

Modelo de Jakes

Modelo de Clarke-Jakes (Canal Plano com Desvanecimento Rayleigh)
% Clarke-Jakes Narrowband Model
clear all; close all; clc; 

N = 4096;                           % frequency points
Nz = 1*2^16;                        % frequency zero-padding
fd = 300;                            % Doppler shift
fc = 900e6;                         % carrier frequency
delta = 0;                          % ignore infinity PSD values
Vz = zeros(1,Nz/2);                 % zero-padding vector
f = linspace(fc-fd+delta,fc+fd-delta,N); % frequency vector;
df = 2*fd/N;
B = 2*fd+Nz*df;                     % bandwidth
Ts = 1/B;                           % sample-time
T = (N+Nz)*Ts;                      % total time

%% Doppler PSD
Pr = 1/4;
A = Pr;           
D = 1-(abs((f-fc))/fd).^2;
Sf = A./pi/fd./sqrt(D);         % PSD
% Sf(1) = Sf(2); Sf(end) = Sf(end-1); % ignore infinity PSD values
% Sf(1) = 0; Sf(end) = 0; % ignore infinity PSD values
% Sf(1) = 0.5*(max(Sf)); Sf(end) = Sf(1); % ignore infinity PSD values
m1 = (Sf(2)-Sf(3))/(f(2)-f(3)); 
m2 = (Sf(end-1)-Sf(end-2))/(f(end-1)-f(end-2));
Sf(1) = m1*(f(1)-f(2))+Sf(2);
Sf(end) = m2*(f(end)-f(end-1))+Sf(end-1);



Sfz = [Vz Sf Vz];       % zero-padded PSD

%% Frequency Domain
Hp = sqrt(1/2)*(randn(1,N/2) +1i*randn(1,N/2));     % positive components
Hn = conj(Hp(end:-1:1));                % negative components
H = [Vz Hp Hn Vz];                      % zero-padded comp.
Hf = sqrt(Sfz).*H;                      % zero-padded equivalent spectrum

%% Time domain
ri = ((N+Nz)/2)*ifft(real(Hf),N+Nz);               % real components
rq = ((N+Nz)/2)*ifft(imag(Hf),N+Nz);               % imaginary components
hr = sqrt(abs(ri).^2+abs(rq).^2);             % rayleigh envelope
hrms = sqrt(var(hr)+mean(hr)^2);                % rms value
hnorm = hr/hrms;                                % normalizing fading
t = linspace(0,T-Ts,N+Nz);                 % time vector

%% MATLAB Rayleigh Channel
h2 = rayleighchan(Ts,fd);
h2.ResetBeforeFiltering = 0;    % do not reset
h2.StoreHistory = 1;            % save path gains after filter
h2.StorePathGains=1;
h2.NormalizePathGains = 0;      % do not normalize E[norm(h)]
y = filter(h2,[1 ones(1,N+Nz-1)]);


%% Plot Images
figure;
% plot(t, sqrt(hr),'k','linewidth',2);
plot(t, 20*log10(hnorm),'k','linewidth',2); hold;
plot(t, 20*log10(abs(h2.PathGains)),'--r','linewidth',1.2);
set(gca,'linewidth',3,'fontsize',30);
grid;
% axis([0 5 get(gca,'Ylim')])

%_________________________________________________________________________%
%% Histogram 1
figure;
Mh = 50;                                % bin numbers
[fn,bin] = hist(hnorm,Mh);           % get bins and cumulative frequencies
yhist = fn/trapz(bin,fn);               % calculate relative frequencies
xx = linspace(min(bin),max(bin),100);   % x vector in bins
yy = spline(bin,yhist,xx);              % interpolation of histogram envelope
set(gca,'linewidth',3,'fontsize',30); grid;

% sigr = 1/sqrt(2);
sigr = mean(hnorm)*sqrt(2/pi);
PDF_theor = bin.*exp(-bin.^2/(2*sigr^2))/(sigr^2);

bcor = [0.5 0.5 1];                                                         
bar(bin,yhist,'FaceColor',bcor,'edgecolor',bcor); hold on;                  % histogram bar plot
plot(xx,yy,':','color',[0 0 1],'linewidth',3);                              % envelope plot    
plot(bin,PDF_theor,'-ok','linewidth',3); grid on;                           % theoretical PDF
title('RMS-Normalized Rayleigh Amplitude Fading Histogram','fontsize',30);
ylabel('Estimated PDF','fontsize',30); xlabel('Amplitude Levels','fontsize',30);
legend('Normalized Histogram','Histogram Envelop','Theoretical Rayleigh PDF');
set(gca,'fontsize',30,'linestyleorder','-','linewidth',3);

%% Histogram 2 (MATLAB channel)
figure;
Mh = 50;                                % bin numbers
[fn,bin] = hist(abs(h2.PathGains),Mh);           % get bins and cumulative frequencies
yhist = fn/trapz(bin,fn);               % calculate relative frequencies
xx = linspace(min(bin),max(bin),100);   % x vector in bins
yy = spline(bin,yhist,xx);              % interpolation of histogram envelope
set(gca,'linewidth',3,'fontsize',30); grid;

% sigr = 1/sqrt(2);
sigr = mean(abs(h2.PathGains))*sqrt(2/pi);
PDF_theor = bin.*exp(-bin.^2/(2*sigr^2))/(sigr^2);

bcor = [0.5 0.5 1];                                                         
bar(bin,yhist,'FaceColor',bcor,'edgecolor',bcor); hold on;                  % histogram bar plot
plot(xx,yy,':','color',[0 0 1],'linewidth',3);                              % envelope plot    
plot(bin,PDF_theor,'-ok','linewidth',3); grid on;                           % theoretical PDF
title('MATLAB RMS-Normalized Rayleigh Amplitude Fading Histogram','fontsize',30);
ylabel('Estimated PDF','fontsize',30); xlabel('Amplitude Levels','fontsize',30);
legend('Normalized Histogram','Histogram Envelop','Theoretical Rayleigh PDF');
set(gca,'fontsize',30,'linestyleorder','-','linewidth',3);

Canal Plano Rayleigh

Rayleigh Plano (BPSK e AWGN)
% Simulaçao BPSK (2PSK) em Canal Rayleigh Plano
    
clear all; close all; clc;

Nb = 1e2;                                                                   % numero de bits
Bw = 100e3;                                                                 % largura de banda
Ts = 1/Bw;                                                                  % periodo de símbolo
fd = 0;                                                                     % doppler shift

SNRdBmin = 0;                                                               % mínimo valor de SNR (dB)
SNRdBmax = 30;                                                              % máximo valor de SNR (dB)
L = 10;                                                                     % número de pontos para simular

SNRdB = linspace(SNRdBmin,SNRdBmax,L);     
% razão sinal ruído em dB

BER.slow = zeros(1,L);                                                      % inicializa a memória da BER
PER.slow = BER.slow;

BER.fast = zeros(1,L);                                                      % inicializa a memória da BER
PER.fast = BER.fast;

errMin = 40;                                                               % critério mínimo de erros

tic;
tempo.inicial = clock;
%% Loop de Monte Carlo
for k = 1:L
    err.slow =0; err.fast=0; iter = 0; errP.slow = 0; errP.fast = 0;
    while errP.slow < errMin

%%  Imprimir Status da Simulação
     if(~mod(iter,50))       % múltiplos de 20
        clc;                 % apaga a tela
        tempo.run = toc;
        fprintf('### Início da simulação: %d/%d/%d às %d:%d ### \n',tempo.inicial(3),tempo.inicial(2),tempo.inicial(1),tempo.inicial(4),tempo.inicial(5));
        fprintf('# Ponto de Simulação ----------------------: %d / %d \n\n',k,L);    % iteração atual
        fprintf('# Erros de Bit (slow/block fading) ------- : %d / %d \n',err.slow,errMin); % erros atuais
        fprintf('# Erros de Pacote (slow/block fading) ---- : %d / %d \n',errP.slow,errMin); % erros atuais
        fprintf('# Erros de Bit (fast/sample fading) ------ : %d / %d \n',err.fast,errMin); % erros atuais
        fprintf('# Erros de Pacote (fast/sample fading) --- : %d / %d \n\n',errP.fast,errMin); % erros atuais
        fprintf('# Tempo de simulação: %.2f (s) / %.2f (h) \n',tempo.run,tempo.run/60/60);        
     end

%% Entradas da iteração     
iter = iter+1;
% SNRdB = 10*log10(SNR)
SNR = 10^(SNRdB(k)/10);        % SNR linear
P = 1;                      % potencia de sinal unitaria
% SNR = P / No
No = P/SNR;                 % variancia do ruido complexo

%% Mensagem Binária
msg = randi([0,1],1,Nb);
% msg2 = randsrc(1,Nb,[0 1]);

%% Modulação 
% 0 graus: bit 0
% 180 graus : bit 1
% 0 ------ +  x
% 1 ------ -  x

s = exp(1i*pi*msg);         % simbolos (sinal modulado)
Scst = [-1 1];              % constelação

%% Transmissão pelo canal
% y = s;        % transmissão ideal sem atenuação nem ruído
% y = s + z;    % transmissão por um canal com ruido aditivo
% y = h*s;      % transmissã sem ruído, com desvanecimento
% y = h*s + z;  % transmissão com desvanecimento e ruído aditivo

% obs: * representa a convolução; 
% obs2: se o canal for plano, representará multiplicação por constante
% obs3: para simular o Doppler, deve ser feita a convolução

z = sqrt(No/2)*(randn(1,Nb)+1i*randn(1,Nb));            % ruído AWGN

h_slow = rayleighchan(Ts,fd);                           % canal plano (slow fading)
h_slow.ResetBeforeFiltering = 0;                        % não altera o valor antes da filtragem
y_slow = filter(h_slow,s) + z;                          % convolução do sinal com o canal
% y = filter(h,s);                                        % sem ruído aditivo

h_fast = sqrt(1/2)*(randn(1,Nb)+1i*randn(1,Nb));        % canal plano (fast fading)
y_fast = h_fast.*s+z;                                   % transmissão pelo canal plano (fast fading)

%% Detecção 
% fonte com distribuição uniforme de símbolos:
% critério MAP (máximo a posteriori) é igual ao MLD
% (equivalente à menor distância para constelação)

%% Slow (Block) Fading Detection
% Levar em conta o canal plano para calcular a distancia
hg_slow = h_slow.PathGains;
% hg =h; 
d1 = abs(y_slow-hg_slow*Scst(1));     % d(y,s1) = d(y,-1)
d2 = abs(y_slow-hg_slow*Scst(2));     % d(y,s2) = d(y,+1)

[~,idmin] = min([d2;d1]);    
% encontra as distâncias mínimas e índices de linha da matriz

msg_dtct_slow = idmin-1;
% 

%% Fast (Sample) Fading Detection
% Levar em conta o canal plano para calcular a distancia
% hg =h; 
d1 = abs(y_fast-h_fast*Scst(1));     % d(y,s1) = d(y,-1)
d2 = abs(y_fast-h_fast*Scst(2));     % d(y,s2) = d(y,+1)

[~,idmin] = min([d2;d1]);    
% encontra as distâncias mínimas e índices de linha da matriz

msg_dtct_fast = idmin-1;
% 

%% Medidas de Desempenho (taxas de erro)
% erros de bit 
errAtual.slow = sum(xor(msg_dtct_slow,msg));
err.slow = err.slow + errAtual.slow;
% erros de pacote
errP.slow = errP.slow + and(errAtual.slow,1);

% erros de bit 
errAtual.fast = sum(xor(msg_dtct_fast,msg));
err.fast = err.fast + errAtual.fast;
% erros de pacote
errP.fast = errP.fast + and(errAtual.fast,1);

    end  % while err < x

%% Taxa de erro de bit
BER.slow(k) = err.slow/(iter*Nb);
PER.slow(k) = errP.slow/(iter);

%% Taxa de erro de pacote
BER.fast(k) = err.fast/(iter*Nb);
PER.fast(k) = errP.fast/(iter);

end         % for SNR

%% Plot

figure;
semilogy(SNRdB,PER.slow,'-ok','linewidth',3); hold on;
semilogy(SNRdB,PER.fast,'--xk','linewidth',3);
semilogy(SNRdB,BER.slow,'-sr','linewidth',3);
semilogy(SNRdB,BER.fast,'--dr','linewidth',3);

xlab = xlabel('SNR (dB)','fontsize',30);
ylab = ylabel('Taxa de Erro','fontsize',30);

set(gca,'fontsize',35,'linewidth',2);
axis([SNRdBmin SNRdBmax 1e-6 1e0]); grid;
hleg = legend('PER (slow fading)','PER (fast fading)', ...
              'BER (slow fading)', 'BER (fast fading)');
set(hleg,'fontsize',30,'location','southwest');


%% Trabalho sobre Desvanecimento de Pequena Escala Plano (Banda Estreita)

% (1). Complementar essa simulação com as curvas AWGN (sem desvanecimento)

% (2). Repetir (1) para uma modulação 4-PSK e acrescentar curvas de SER (Taxa de Erro de Símbolo)

% (3). Repetir (1) para uma modulação 16-QAM e acrescentar curvas de SER (Taxa de Erro de Símbolo)

Convolução e ISI

Convolução e Interferência Intersimbólica
% Convolution and ISI Effects: Wideband and Narrowband Signals 
% CSF29008 - 2015/2
% Prof. Bruno Fontana da Silva
clear all; close all; clc;

%% Inputs
%_________________________________________________________________________%
speed = 1e-9;
% speed = 0.1;

Nx = 50;               % período de símbolo: Nx amostras
Nh = 5;                % duração de uma componente multipercurso: Nh amostras
Nz = 2;                % nulls length (espaço entre componentes multipercurso)

null = zeros(1,Nz);    % sequência de amostras nulas


%% Sinal x[n]
%_________________________________________________________________________%
% x = sin(2*pi*(1:Nx)/Nx);                                                    % modelo do pulso senoidal
% x = sin(2*pi*(1:Nx)/Nx/2);                                                  % modelo do pulso meia-onda
x = [ones(1,Nx/2) -ones(1,Nx/2)];                                           % sequência +1 / -1

X = [x x x];                     % enviando vários símbolos

%% Canal Multipercurso (Sistema LTI) h[n]
%_________________________________________________________________________%

h =  sin(2*pi*(1:Nh)/Nh/2);         % modelo do pulso

%% Canais Multipercurso
%_________________________________________________________________________%
% H = [null h null h null h ]; Lchan=3*Nh+2*Nz;                               % 3 multipercursos esparsas
% H = [null h null h]; Lchan=2*Nh+1*Nz;                                       % 2 multipercursos esparsas
H = [null h null];  Lchan=1*Nh+0*Nz;                                        % 1 multipercurso


%% Critério Wideband/Narrowband
%_________________________________________________________________________%
if(Nx>=10*Lchan)                                % Ts >> Tm
    convleg = 'Narrowband Signal';
elseif (Nx<=0.1*Lchan)                          % Ts << Tm
    convleg = 'Wideband Signal (ISI effect)';
else
    convleg = 'Not so narrowband...';
end

%% Auxiliares
%_________________________________________________________________________%
Ndiff = abs( length(X)-length(H));
null_diff = zeros(1,Ndiff);
if(length(X)>length(H))
 Xplot = X;
 Hplot = [H null_diff];
else
 Xplot = [X null_diff];
 Hplot = H;
end
Xp2 = [X(end:-1:1) zeros(1,length(H))];
Nconv = length(X)+length(H);
XH = zeros(1,Nconv);

xleg = ['1 Symbol: ' num2str(Nx) ' samples'];
chanleg = ['Channel spread: ' num2str(Lchan) ' samples'];

%% Convolução x[n]*h[n]
%_________________________________________________________________________%
figure(1);
for n =1:Nconv
   for k = 1:length(H)
       ix = n-k;
       if ix >= 0
           if ix+1 <= length(X)               
               XH(n) = XH(n) +  H(k)*X(ix+1);
           else
               XH(n) = XH(n) +  0;
           end
       else
           XH(n) = XH(n) +  0; 
       end
   end
   

%% Animated Convolution Plot
%_________________________________________________________________________%
    if n==1||n==Nconv
    %     clf;   
        subplot(3,1,1);
        stem([-length(X)+1:0 1:length(H)],circshift(Xp2,n,2),'b','linewidth',2.5); 
%         plot([-length(X)+1:0 1:length(H)],circshift(Xp2,n,2),'b','linewidth',2.5); 
        
        grid on; set(gca,'linewidth',3,'fontsize',20); 
        ylabel('x[n-k]','fontsize',30);
        hleg1 = legend(xleg); set(hleg1,'fontsize',10);
        axis([-length(X)+1 Nconv -2 2]);
      
        
        subplot(3,1,2);
        stem(Hplot,'r','linewidth',2.5); 
%         plot(Hplot,'r','linewidth',2.5); 
        
        set(gca,'linewidth',3,'fontsize',20); grid on; 
        ylabel('h[n]','fontsize',30);  hleg2 = legend(chanleg); set(hleg2,'fontsize',10);
        axis([-length(X)+1 Nconv get(gca,'Ylim')])

        
        subplot(3,1,3); 
        stem(XH,'k','linewidth',2.5); grid on;
%         plot(XH,'k','linewidth',2.5); grid on;

        xlabel('n (sample index)','fontsize',30)
        ylabel('x[n]*h[n]','fontsize',30); 
        set(gca,'linewidth',3,'fontsize',20);  hleg3 = legend(convleg); set(hleg3,'fontsize',10);
        axis([-length(X)+1 Nconv -10 10])

    else % not so many plot settings, faster animation
        subplot(3,1,1);
        stem([-length(X)+1:0 1:length(H)],circshift(Xp2,n,2),'b','linewidth',2.5); 
        axis([-length(X)+1 Nconv -2 2]);
    %     grid on; set(gca,'linewidth',3); 
    %     ylabel('x[n-k]','fontsize',30);
    %     hleg1 = legend(xleg); set(hleg1,'fontsize',10);
    %     
        subplot(3,1,3); 
        stem(XH,'k','linewidth',2.5); grid on;
        axis([-length(X)+1 Nconv -10 10])
    %     xlabel('n (sample index)','fontsize',30)
    %     ylabel('x[n]*h[n]','fontsize',30); 
    %     set(gca,'linewidth',3); 
        drawnow;
        pause(speed)
    end


end
% 
% figure;
% subplot(3,1,1);
% stem(Xplot,'b','linewidth',2.5);  grid on;  hleg1 = legend(xleg); set(hleg1,'fontsize',10);
% ylabel('x[n]','fontsize',30); 
% subplot(3,1,2);
% stem(Hplot,'r','linewidth',2.5);  grid on; hleg2 = legend(chanleg); set(hleg1,'fontsize',10);
% ylabel('h[n]','fontsize',30); 
% subplot(3,1,3);
% % stem(XH,'k'); hold on; 
% stem(conv(X,H),'k','linewidth',2.5); hold on;  grid on;
% xlabel('n (sample index)','fontsize',30)
% ylabel('x[n]*h[n]','fontsize',30);  hleg3 = legend(convleg); set(hleg3,'fontsize',10);

Exercícios

Lista 01 - Telefonia Celular

Material Complementar On-line

Palestra da ANATEL "Sistema Móvel Pessoal no Brasil", 02/06/2015

GSMA - Estatísticas e análise de dados da indústria de comunicações móveis

TELECO - Portal sobre Telecomunicações criado por grupo de profissionais brasileiros

Vídeo sobre perspectivas do 5G para Internet tátil

Princípios de reuso de frequência em sistemas celulares de telefonia

Práticas de planejamento de sistemas celulares de telefonia

Calculadora Erlang B

Calculadora Erlang C

Simulador de Configuração do AP TP-Link TL-WDR4300

Convolução de Sinais: Aplicativo Java para Visualização

Voltar para CSF-EngTel_(página)