ACN Hardware
ACN Hardware
Outputs:
1b Plot Theortical BER Vs Practical BER for different values of Eb/No
% Simulation parameters
numBits = 100000;
modOrder = 16; % for 16-QAM
k = log2(modOrder); % Number of bits per symbol
% Create source bit sequence
srcBits = randi([0,1],numBits,1);
% Perfom 16 QAM Modulation
modOut = qammod(srcBits,modOrder,'bin','InputType','bit',
'UnitAveragePower',true);
% Plot the constellation before noise
scatterplot(modOut);
% ADD Noise
EbNo = 0:1:20;
berVec = zeros(length(EbNo),1);
for n = 1: length(EbNo)
chanOut = awgn(modOut,EbNo(n));
% Plot the constellation after noise addition
%scatterplot(chanOut);
% Demodulate the signal
demodOut=
qamdemod(chanOut,modOrder,'bin','OutputType','bit','UnitAveragePower',true);
% Calculate Practical BER
%isBitError = srcBits~=demodOut
%numBitErrors = nnz(isBitError)
%BER = numBitErrors/numBits
% Alternative calculation for Practical it Error
[numErrors,ber] = biterr(srcBits,demodOut);
berVec(n,1) = ber
end
%fprintf('\nThe practical bit error rate is %5.2e, based on %d errors.\n', ...
BER,numErrors)
%EbNo = 0:1:20
bertheo = berawgn(EbNo,'qam',modOrder)
%fprintf('\nThetheortical bit error rate is %5.2e', bertheo)
semilogy(EbNo,berVec,'*b');
hold on
semilogy(EbNo,bertheo);
grid on
legend('Practical','Theortical');
xlabel('EbNo');
ylabel('BER');
title('Theortical and Practical BER/EbNo for 16QAM');
Outputs:
2. Simulation of OFDM system using MATLAB software
2a OFDM Modulation with the Inverse FFT (Basic link)
numBits = 32768; % power of 2, to optimize performance of fft/ifft
modOrder = 16; % for 16-QAM
srcBits = randi([0,1],numBits,1);
qamModOut =
qammod(srcBits,modOrder,"InputType","bit","UnitAveragePower",true);
scatterplot(qamModOut)
title("16-QAM Signal")
%Perfrom OFDM
ofdmModOut = ifft(qamModOut)
%Apply AWGN
SNR = 15; % dB
chanOut = awgn(ofdmModOut,SNR,"measured");
% Perform Demodulation
ofdmDemodOut = fft(chanOut)
scatterplot(ofdmDemodOut)
CODE
%% Create OFDM Modulated Data .
mod = comm.OFDMModulator('NumGuardBandCarriers',[4;3],'PilotInputPort',true,
'PilotCarrierIndices',[12 11 8; 26 27 20; 40 39 30; 54 55 50],'NumSymbols',3,
'InsertDCNull',true);
disp(mod)
modDim = info(mod)
%%% Generate random data symbols for the OFDM modulator. The structure variable,
pilotIn = complex(rand(modDim.PilotInputSize),rand(modDim.PilotInputSize));
modData = step(mod,dataIn,pilotIn);
% Y = step(OBJ,x) processes the input data, x, to produce the output, Y,for System
object, OBJ.
showResourceMapping(mod)
%% % Use the OFDM modulator object to create the corresponding OFDM demodulator.
demod = comm.OFDMDemodulator(mod);
%%% Demodulate the OFDM signal and output the data and pilot signals.
%% % Verify that, within a tight tolerance, the input data and pilot symbols match the
output data and pilot symbols.
RESULTS
For 3 symbols
2b. SER Simulation for OFDM Link
Aim: To perform a symbol error rate (SER) simulation of an over-the-air OFDM communication link.
Code.
%Create QPSK modulator and demodulator objects.
qpskMod = comm.QPSKModulator;
qpskDemod = comm.QPSKDemodulator;
%Create a default OFDM modulator and demodulator pair.
ofdmMod = comm.OFDMModulator;
ofdmDemod = comm.OFDMDemodulator;
%Use the info function to determine the required input
dimensions for the OFDM modulator.
modDim = info(ofdmMod)
%Set the number of frames. Determine the number of OFDM
symbols per frame from the modDim.DataInputSize array.
numBits = 100;
nSymbolsPerFrame = modDim.DataInputSize(1);
%Create an error rate counter with a reset input port.
Initialize the symbol error rate vector, SER.
errRate = comm.ErrorRate('ResetInputPort',true);
SER = zeros(nSymbolsPerFrame,1);
for k = 1:nSymbolsPerFrame
% Generate random data for each OFDM frame
data = randi([0 3],nSymbolsPerFrame,1);
% Apply QPSK modulation
txQPSK = qpskMod(data);
% Apply OFDM modulation
txSig = ofdmMod(txQPSK);
% Pass OFDM signal through AWGN channel
rxSig = awgn(txSig,23);
% Demodulate OFDM data
rxQPSK = ofdmDemod(rxSig);
% Demodulate QPSK data
rxData = qpskDemod(rxQPSK);
% Compute BER
errors = errRate(data,rxData,1);
SER(k) = errors(1);
end
%Display the symbol error data for the first ten frames.
SER(1:10)
OUTPUTS:
BER:
3. Simulate and test various types of PN codes, chip rate, spreading factor
and processing gain on performance of DSSS in CDMA using MAT
LAB software
a. DSSS Transmitter and receiver
%System Parameters
d=randi([0,1],10,1)
Rb=10 ;%datarate,
Rc=20;%chiprate and
L=32;%oversamplingfactor
dataLen=length(d)*(Rc/Rb);%required PRBS length to cover
the data
%Spreading Sequence
pnSequence =
comm.PNSequence('Polynomial',[3,2,0],'SamplesPerFrame',data
Len,'InitialConditions',[0 0 1]);
prbs = pnSequence()
prbs=prbs(:);
d=d(:);%serialize
%Spread Spectrum Communication
d_t=kron(d,ones(L*Rc/Rb,1));%datawaveform
prbs_t=kron(prbs,ones(L,1));%spreadingsequencewaveform
sbb_t=2*xor(d_t,prbs_t)-1;%XORdataandPRBS,converttobipolar
n=(0:1:length(sbb_t)-1).';
carrier_ref=cos(2*pi*2*n/L);
s_t=sbb_t.*carrier_ref;%modulation,2cyclesperchip
%------------BPSK Demodulation---------
r_t = s_t; % Recieved signal
v_t=r_t.*carrier_ref;
x_t=conv(v_t,ones(1,L));%integrate for Tc duration
y=x_t(L:L:end);%sample at ever yLth sample (i.e,every Tc
instant);
z=(y>0).'; %Hard decision (gives demodulated bits)
%-----------De-Spreading---------------
y=xor(z,prbs.');%reverse the spreadin gprocess using PRBS
ref.
d_cap=y(Rc/Rb:Rc/Rb:end);%sample a tevery Rc/Rb th symbol
figure(1);%Plotwaveforms
subplot(4,1,1);plot(d_t);title('datasequence');
hold on;
subplot(4,1,2);plot(prbs_t);title('PRBSsequence');
hold on
subplot(4,1,3);plot(s_t);title('DS-SSsignal(baseband)');
hold on
subplot(4,1,4);plot(d_cap);
title('Demodulted and Despread signal');
OUTPUTS:
b Performance evaluation DSSS system
%---Inputdata,datarate,chiprate-----
N=10e3;%numberofdatabitstotransmit
d=randi([0,1],N,1)%randomdata
Rb=2e1;%datarate(bps)forthedatad
Rc=6e1;%chip-rate(Rc>>RbANDRcisintegralmultipleofRb)
L=8;%oversamplingfactorforwaveformgeneration
dataLen=length(d)*(Rc/Rb);%required PRBS length to cover
the data
SNR_dB=-4:0.5:10; %signaltonoiseratios(dB)
BER=zeros(1,length(SNR_dB));%placeholderforBERvalues
%Spreading Sequence
pnSequence =
comm.PNSequence('Polynomial',[3,2,0],'SamplesPerFrame',data
Len,'InitialConditions',[0 0 1]);
prbs = pnSequence()
prbs=prbs(:);
d=d(:);%serialize
for i=1:length(BER)
% Transmitter
OUTPUTS: