signal processing - BER graph MATLAB calibration -
signal processing - BER graph MATLAB calibration -
i'm doing 16qam scheme (transmitter, channel , receiver), , ber , per curves of results. however, i'm having problems noise @ receiver. i'm running scheme within 2 loops: eb/no values , packets , sent 200 symbols , 1000 packets still happens. check whether result code right or not:
clear clc numpkts=1000; n = 200; % number of symbols m = 16; % constellation size k = log2(m); % bits per symbol pv=4; %prefix length % defining real , imaginary pam constellation % 16-qam alphare = [-(2*sqrt(m)/2-1):2:-1 1:2:2*sqrt(m)/2-1]; alphaim = [-(2*sqrt(m)/2-1):2:-1 1:2:2*sqrt(m)/2-1]; k_16qam = 1/sqrt(10); eb_n0_db = [0:15]; % multiple es/n0 values es_n0_db = eb_n0_db + 10*log10(k); ertot=zeros(1,length(eb_n0_db)); % mapping binary <--> grayness code conversion ref = [0:k-1]; map = bitxor(ref,floor(ref/2)); [tt ind] = sort(map); ii = 1:length(eb_n0_db) pktx=1:numpkts % symbol generation % ------------------ ipbit = rand(1,n*k,1)>0.5; % random 1's , 0's ipbitreshape = reshape(ipbit,k,n).'; bin2decmatrix = ones(n,1)*(2.^[(k/2-1):-1:0]) ; % conversion binary decimal % real ipbitre = ipbitreshape(:,[1:k/2]); ipdecre = sum(ipbitre.*bin2decmatrix,2); ipgraydecre = bitxor(ipdecre,floor(ipdecre/2)); % imaginary ipbitim = ipbitreshape(:,[k/2+1:k]); ipdecim = sum(ipbitim.*bin2decmatrix,2); ipgraydecim = bitxor(ipdecim,floor(ipdecim/2)); % mapping grayness coded symbols constellation modre = alphare(ipgraydecre+1); modim = alphaim(ipgraydecim+1); % complex constellation mod = modre + j*modim; s1 = k_16qam*mod; % normalization of transmit powerfulness 1 s=[s1(length(s1)-pv+1:end) s1]; %add prefix % noise % ----- esno=10^(es_n0_db(ii)/10); standevnoise=sqrt((1)/(2*esno)); n =standevnoise *[randn(1,length(s)) + j*randn(1,length(s))]; % white guassian noise, 0db variance h=(1/sqrt(2))*(randn+j*randn); y1= conv(s,h) + n; % additive white gaussian noise %removes prefix y1(1:pv) = []; y=y1/h; % demodulation % ------------ y_re = real(y)/k_16qam; % real part y_im = imag(y)/k_16qam; % imaginary part % rounding nearest alphabet iphatre = 2*floor(y_re/2)+1; iphatre(find(iphatre>max(alphare))) = max(alphare); iphatre(find(iphatre<min(alphare))) = min(alphare); iphatim = 2*floor(y_im/2)+1; iphatim(find(iphatim>max(alphaim))) = max(alphaim); iphatim(find(iphatim<min(alphaim))) = min(alphaim); % constellation decimal conversion ipdechatre = ind(floor((iphatre+4)/2+1))-1; % lut based ipdechatim = ind(floor((iphatim+4)/2+1))-1; % lut based % converting binary string ipbinhatre = dec2bin(ipdechatre,k/2); ipbinhatim = dec2bin(ipdechatim,k/2); % converting binary string number ipbinhatre = ipbinhatre.'; ipbinhatre = ipbinhatre(1:end).'; ipbinhatre = reshape(str2num(ipbinhatre).',k/2,n).' ; ipbinhatim = ipbinhatim.'; ipbinhatim = ipbinhatim(1:end).'; ipbinhatim = reshape(str2num(ipbinhatim).',k/2,n).' ; % counting errors real , imaginary nbiterr(pktx) = size(find([ipbitre- ipbinhatre]),1) + size(find([ipbitim - ipbinhatim]),1) ; end ertot(ii)=ertot(ii)+sum(nbiterr); %total errors in packets simber(ii)=(ertot(ii)/(n*k*numpkts)); %bit error rate totpkterrate(ii)=(ertot(ii)/(numpkts)); end theoryber = (1/k)*3/2*erfc(sqrt(k*0.1*(10.^(eb_n0_db/10)))); close all; figure semilogy(eb_n0_db,theoryber,'bs-','linewidth',2); hold on semilogy(eb_n0_db,simber,'mx-','linewidth',2); axis([0 15 10^-5 1]) grid on legend('theory', 'simulation'); xlabel('eb/no, db') ylabel('bit error rate') title('bit error probability curve 16-qam modulation')
thanks!
the code provided makes next assumptions:
16-qam modulation using gray-coding bit mapping a flat slow/block rayleigh fading channel model. coherent decoding under perfect channel state information estimationdue it's similarity additive-white-gaussian-noise (awgn) channel, logical first step in understanding , calibrating scheme performance under assumptions stated above evaluate performance without fading (i.e. substituting channel model awgn channel setting h=1
in provided code).
awgn channel
you may want verify calibration of symbol-error-rate (ser) performance can have big impact on (ber) performance, , ser curves readily available coherent decoding of uncoded 16-qam constellation (see e.g dsplog, these lecture slides, this book, etc.) references include next approximation ser of 16-qam:
1.5*erfc(sqrt(esn0/10))
where esn0 = 10.^(0.1*esn0_db)
.
note results may equivalently provided in terms of either es/n0 (the average energy per symbol) or eb/n0 (the average energy per bit). k-bits signal constellation (constellation size of 2k), relationship between es/n0 , eb/n0 given as
es/n0 = k*eb/n0
thus 16-qam, es/n0 = 4eb/n0 (or es/n0db = eb/n0db + 6db).
for grayness coded scheme, ber approximation sufficiently high eb/n0 can obtained fact symbol error translates 1 bit in error (out of k-bits in symbol) of time, ber ~ ser/k (or 1 time again 16-qam: ber ~ ser/4).
es/n0 (db) eb/n0 (db) ser ber approx 15 9 1.8e-2 4.5e-3 16 10 7.0e-3 1.8e-3 18 12 5.5e-4 1.4e-4 20 14 1.2e-5 3.0e-6 25 19 2.7e-15 6.7e-16
as side note, confidence interval of simulation results using 2,000,000 symbols @ sers below approximately 10-5 can start quite significant. illustration, next graph shows ser of 16-qam in blue, expected 95% confidence interval of 2,000,000 symbols simulation in red:
rayleigh block fading channel
once performance calibration has been established awgn channel, can rayleigh block fading channel used in posted code.
assuming perfect channel state info estimation @ receiver , if there no noise, possible scale received signal onto original transmitted symbols using transformation:
y = y1/h;
when noise present, transformation unfortunately scales noise. fortunately, noise remains white , gaussian such basic derivation of awgn channel equations can reused work. on independent packets, statistical distribution of scaling abs(h)
follows rayleigh distribution (with parameter sigma2=1/2). average effect of scaling on ser, possible compute weighted sum (where weight probability density function of rayleigh distribution) of effects on range of possible scaling values using integral:
this can done numerically matlab using:
function ser = awgnser(esn0) ser = 1.5*erfc(sqrt(0.1*esn0)); end function f = weightedawgnser(x) weight = 2*x.*exp(-x.*conj(x)); f = weight*awgnser(esn0*x.*conj(x)); end function ser = blockrayleighfadingser(esn0) ii=1:length(esn0) ser(ii) = quad(inline('weightedawgnser(esn0(ii),s)','s'), 0, inf); end end
a similar derivation can obtained ber:
function ber = awgnber(esn0) x = sqrt(0.1*esn0); q1 = 0.5*erfc(x); q3 = 0.5*erfc(3*x); q5 = 0.5*erfc(5*x); ber = (12*q1+8*q3-4*q5 - q1*(q1+q3-2*q5)+(q3-q5)*q5)/16; end function f = weightedawgnber(x) weight = 2*x.*exp(-x.*conj(x)); f = weight*awgnber(esn0*x.*conj(x)); end function ser = blockrayleighfadingber(esn0) ii=1:length(esn0) ser(ii) = quad(inline('weightedawgnber(esn0(ii),s)','s'), 0, inf); end end
note i've utilize exact formula ber since weighted average tends affected low signal-to-noise ratio approximation not good. not create huge difference on curve (~0.3db @ eb/n0=10db) not want worry when calibrating performance curves.
this yields next performance curves:
other considerations
decoding performance can affected number of other factors beyond scope of answer. next briefly touches on few mutual ones , links external references may used additional information.
the decoder in posted code uses explicit knowledge of fading effect (as evidenced line y=y1/h;
). not case, , fading must first estimated. estimation of channel effect @ receiver beyond scope of answer, imperfect estimation result in performance loss. performance curves of perfect knowledge used practical benchmark against compare performance under imperfect channel estimation.
channel coding done improve scheme performance. mutual benchmarks used coded modulation on awgn channel are:
shannon's channel capacity union upper bound (eg. these lectures notes), , multiple other bounds found in research literature uncoded modulation performance (which derived here)similarly coded modulation on flat block rayleigh fading channel, next benchmarks commonly used:
outage probability (see section 5.4.1 of this book) uncoded modulation performance (which derived here) matlab signal-processing telecommunication modulation
Comments
Post a Comment