2012년 6월 5일 화요일

매트랩을 사용한 부가백색잡음환경에서의 QAM 시스템 BER 계산

개인적으로 외적 환경 변화가 많았던 기간을 지냈기도 했고, 잠시 게임 폐인이 되기도 했다.

한동안 이동통신공부에 탄력받았었는데, 지금은 갈피를 잘 못 잡겠고 정체기인것 같다.

아~ 정말 공부할 양도 많고, 어렵기도 하다~ 또 어떤방향으로 해야하나~

그래도 강박증을 버리되, 호기심으로 조금씩 정리해 보기로 한다!


오늘은 주제는 'Compute BER for a QAM System with AWGN Using MATLAB' 이다

매트랩사이트의 예제문서의 내용을 요약해고, 나름대로 부연설명을 추가해서

전반적인 통신의 절차를 확인해 볼 생각이다.

먼저,,, 원문 링크주소는 http://www.mathworks.co.kr/help/toolbox/comm/gs/a1067963807.html

참고로, 매트랩버전의 차이로 일부 명령어가 다르기도 한데, 대략의 의미는 통할것으로 본다.





문제1.   기저대역의 변조, 채널, 복조로 구성된 통신시스템을 이용한 이진데이터 stream을 처리한다.  시스템의 bit error rate (BER)를 구하고, 또한 전송 및 수신한 신호를 scatter plot에 표시하라!


문제2   송신기와 수신기에 펄스파형성형 및 정합필터를 수행하는 한 쌍의 square root raised cosine filters 를 사용하는 그레이코드된 변조로 수정하라!


문제3   주어진 구속장(constraint lengths)과 생성다항식(constraint lengths and generator polynomials)가진 convolutional coding 과 decoding을 포함할 수 있게 수정하라!



%% Setup  :  Define parameters
% Modified Plot, With Gray Coding
M = 16; % Number of points in constellation
k = log2(M);           % Number of bits per symbol
n = 5e5;                % Number of bits to process
nsamp = 4;            % Oversampling rate 
hMod = modem.qammod('M',M,'SymbolOrder','Gray');   % Modulator object
mapping = hMod.SymbolMapping;                            % Symbol mapping vector
pt = hMod.Constellation;                                         % Vector of all points in constellation
scatterplot(pt);                                                       % Plot the constellation.

% Include text annotations that number the points.
text(real(pt)+0.1,imag(pt),dec2bin(mapping));
axis([-4 4 -4 4]); % Change axis so all labels fit in plot.



%% Signal Source  :  Create a binary data stream as a column vector.

x = randint(n,1); % Random binary data stream



%% Encoder  :  Define a convolutional coding trellis and use it to encode the binary data.

t = poly2trellis([5 4],[23 35 0; 0 5 13]); % Trellis

code = convenc(x,t); % Encode.

coderate = 2/3;



%% Bit-to-Symbol Mapping  :  Convert the bits in x into k-bit symbols.

% B. Do ordinary binary-to-decimal mapping.

xsym = bi2de(reshape(code,k,length(code)/k).','left-msb');



%% Modulation

y = modulate(modem.qammod(M),xsym); % Modulate using 16-QAM.



%% Filter Definition  :  Define filter-related parameters.

filtorder = 40; % Filter order

delay = filtorder/(nsamp*2); % Group delay (# of input samples)

rolloff = 0.25; % Rolloff factor of filter

% Create a square root raised cosine filter.

rrcfilter = rcosine(1,nsamp,'fir/sqrt',rolloff,delay);

% Plot impulse response.

figure; impz(rrcfilter,1);



%% Transmitted Signal  :  Upsample and apply square root raised cosine filter.

ytx = rcosflt(y,1,nsamp,'filter',rrcfilter);

% Create eye diagram for part of filtered signal.

eyediagram(ytx(1:2000),nsamp*2);



%% Channel  :  Send signal over an AWGN channel.

EbNo = 10; % In dB

snr = EbNo + 10*log10(k*coderate)-10*log10(nsamp);

ynoisy = awgn(ytx,snr,'measured');



%% Received Signal  :  Filter received signal using square root raised cosine filter.

yrx = rcosflt(ynoisy,1,nsamp,'Fs/filter',rrcfilter);

yrx = downsample(yrx,nsamp); % Downsample.

yrx = yrx(2*delay+1:end-2*delay); % Account for delay.



%% Scatter Plot  :  Create scatter plot of received signal before and after filtering.

h = scatterplot(sqrt(nsamp)*ynoisy(1:nsamp*5e3),nsamp,0,'g.');

hold on;

scatterplot(yrx(1:5e3),1,0,'kx',h);

title('Received Signal, Before and After Filtering');

legend('Before Filtering','After Filtering');

axis([-5 5 -5 5]); % Set axis ranges.



%% Demodulation  :  Demodulate signal using 16-QAM.

zsym = demodulate(modem.qamdemod(M),yrx);



%% Symbol-to-Bit Mapping  :  Undo the bit-to-symbol mapping performed earlier.

z = de2bi(zsym,'left-msb'); % Convert integers to bits.

% Convert z from a matrix to a vector.

z = reshape(z.',numel(z),1);



%% Decoder  :  Decode the convolutional code.

tb = 16; % Traceback length for decoding

z = vitdec(z,t,tb,'cont','hard'); % Decode.



%% BER Computation  :  Compare x and z to obtain the number of errors and the bit error rate. Take the decoding delay into account.

decdelay = 2*tb; % Decoder delay, in bits

[number_of_errors,bit_error_rate] = biterr(x(1:end-decdelay),z(decdelay+1:end))



awgn 의 함수의 검증은 아래와 같다.


SNR_input=30;
 
         % To specify the power of X to be 0 dBW and add noise to produce
         % an SNR of 10dB, use:
         N=2^10;
         X = sqrt(2)*sin(0:2*pi/N:2*pi-2*pi/N);
         Y = awgn(X,SNR_input,0);


X_pow=X*X'/N                 % =var(X)
Y_pow=Y*Y'/N                 % =var(Y)
plot(1:N, X, 1:N, Y)
noise_pow=sum((X-Y).^2)/N    % =var(X-Y)
SNR_dB=10*log10(X_pow/noise_pow)


먼저, 컨벌루션 코딩를 수행하는 하드웨어와 격자구조를 비교해 보자.

2개 입력에 3개 출력이 나오는 구조이다.



A Rate-2/3 Feedforward Encoder
(trel = poly2trellis([5 4],[23 35 0;0 5 13])


(The ratio of bit energy to noise power spectral density ) k * Eb/N0
= Es/N0 (the ratio of symbol energy to noise power spectral density)

(the signal-to-noise ratio) SNR = (Eb * k * coderate / nsamp) / N0


또한 각 단계별 정보의 변형(예시로 8bit )을 추적해 보자!




위 정보 가공의 과정을 요약하자면, 랜덤이진데이터x에서 채널코딩후 16-QAM변조 시키고

noise를 s/n비로 오염 후 업샘플하여 필터처리하여 송신한다.

수신단에서는 송신신호를 동일한 정합필터를 통하여 심볼을 검출하고 디코딩해서

원 랜덤이진데이터x와 비교하여 BER을 계산하면 끝~





덧붙여 Phase Noise(위상잡음)에 대해서도 알아보자!

'Compute BER for a QAM System with AWGN and Phase Noise Using Simulink' 이다.

원문 링크주소는,,, http://www.mathworks.co.kr/help/toolbox/comm/gs/fp8022.html









Carrier Frequency : 100MHz

Offset Frequency : 1KHz

Carrier/Offset Power : 60dBc 이면,


위상잡음은 -60dBc/KHz = -60-10log(1000) = -90dBc/Hz




중심주파수와 오프셋주파수에서의 전력차이가 클수록(Phase noise ↓)

BER이 우수하다는 것을 알 수 있다.

위상잡음의 영향은 Contellation 이 둥근패턴이 되어 검출의 정확성을 떨어뜨린다.

좀 더 자세한 실험은 원문링크주소를 참고하기 바란다.


이상,,, matlab의 '시작하기'  였다...  헐,,,  

그래도 시작이 반이다.^^





이번 주제에는 RF 주파수천이와 동기화 방법들이 생략되었다.

동기화방법은 짧게 정리하자면,,,




Carrier Recovery - 수신측에서 복조에 사용되는 반송파(local carrier)의 주파수는 물론 그 위상도 수신신호의 carrier 위상에 맞춰져야 한다는 것

Symbol Synchronization(Timeing Recovery) - 수신측의 복조기출력을 한 심볼구간(Ts)마다 샘플링해서 detector로 보내는데, 이 샘플링시점도 신호가 송신기로부터 수신기까지의 전송시간 만큼 지연시켜 심볼구간에 맞도록 동기화

Frame Synchronization - 사전에 약속된 일정 길이의 접두부호(Prefix)를 매 프레임이 시작할 때마다 전송함으로써, 수신측에서 어느 비트가 MSB(Most Significant Bit)이고, 어느 비트가 LSB(Least Significant Bit)인지 구별
 


다음에는 이런것들과 측정방식에 대해서도 정리를 해야겠다.

일단,,, 기말고사 준비나 해야겠다...

댓글 없음:

댓글 쓰기