Professional Documents
Culture Documents
PROJECT REPORT
0
Contents
Project Requirement: ...................................................................................... 2
1 Introduction ............................................................................................. 4
3 Working ................................................................................................... 5
4 SIMULINK PART:..................................................................................... 14
4.1 Audio:................................................................................................. 14
1
5 Conclusion ............................................................................................. 29
6 Reference............................................................................................... 29
2
FIGURE 35QPSK DEMODULATION OUTPUT. ......................................................................... 26
FIGURE 36:CHANEL DECODING USING BCH DECODER. ........................................................... 26
FIGURE 37:PARAMETERS FOR BCH DECODER....................................................................... 27
FIGURE 38:MODEL WITH UNBUFFER BLOCK ......................................................................... 28
FIGURE 39:PARAMETERS FOR UNBUFFER BLOCK. .................................................................. 28
FIGURE 40:COMPLETE MODEL .......................................................................................... 28
FIGURE 41:PARAMETERS FOR UNIFORM DECODER. ................................................................ 29
3
Project Requirement:
Required to design, build, and simulate the digital communication system
shown below in MATLAB-SIMULINK.
1 Introduction
This project implements end to end transmitter on MATLAB. In this input voice
signal was fed into program from file and passed through different processes
before modulation & then modulated signal was transmitted after adding noise
and then received at receiver end which then processed through different
modes & then converted back into voice signal again.
4
2 Components of Proposed Project
In this project our voice signal will go through different process and then
transmitted and received. some of these processare AT transmitter side
• Encoding
• Channel codding
• Interleaver
• Modulation
• Demodulation
• DeInterleaver
• Decoding
• PCM decoding
3 Working
Proposed model of project as all the above modules attached (in software)
&implemented in MATLAB Simulink with coding and also on Simulink each step
is plotted.voice signal will be processed through all these steps and the received
at other end in hearable form. All above steps working, their MATLAB CODE&
Simulink & their plot is shown below. At the end of Report after conclusion you
can see full code but here code of each step is attached.
5
clear all; close all; clc; %% input voice signal and
its ploting
fs=1000; % setting sampling rate to 1000 sampling time =
obj = audiorecorder(fs,16,1); fprintf(’start speaking’) recordblocking(obj,2);
%recording input voice signal for 60s fprintf(’\n Thank you’) figure(1) subplot(2,1,1)
A = getaudiodata(obj); % get data and store in y plot(A)
title(’Voice message’) xlabel(’time’)
ylabel(’voice signal’)
%% taking fourier transform voice signal and plotingsubplot(2,1,2)
fourieranalysis =fft(A); stem(abs(fourieranalysis))
title(’Fourier Analysis’)
xlabel(’time’)
ylabel(’Magnitude’)
6
% -------convert to a digital signal yd----------a=fix(y/q);
yd=dec2bin(a,n);
% ------calculate the signal in Digital ---------yq=a*q; figure(2)
plot(yq,’g’)
xlim([500,1005])
title(’DIGITAL SIGNAL ’) xlabel(’time’)
%-------------------------------------------------
7
x((i-1)*n+1:(i-1)*n+n/2) = -lastbit; x((i-1)*n+n/2:i*n) =
lastbit;
else
x((i-1)*n+1:(i-1)*n+n/2) = lastbit; x((i-
1)*n+n/2:i*n) = -lastbit; lastbit = -lastbit; end end
figure;
plot(t,x, ’Linewidth’,3);
title(’Encoding’)
8
3.5 Interleaver
Interleaving, a technique for making forward error correction more robust with
respect to burst errors.
% Interleaving
%-----------------inter = randintrlv(code,st2); % Interleave. x =
bitxor(inter,errors); % Include burst error.
9
plot( addingnoise)
legend(’Signal after noise NOISE(AWGN)’)
xlim([500,600]) % Showing chunk of output as there are 200000 values
y=[];
10
3.7 Demodulation + Noise Removal
After recieving the sinal white noise is removed by using imnoise command and
then signal is demodulated by multiplying with carrier
3.8 Deinterleaver
deinterleaver uses the inverse mapping to restore the original sequence of
symbols.
11
3.9 CRC Error Removal
CRC error is first detected and then removed.
for k = 1:numFrames
[~,frmError(k)] = crcdetector(demodData); % Detect CRC errors end
12
Figure 9:After Decoding of signal.
4 SIMULINK PART:
4.1 Audio:
Audio file is inserted from file on device such as computer to be utilized for the further process use. This is
done by using “from multimedia file” block in Simulink. Below is shown:
14
Figure 13:From multimedia block for file uploading
15
4.3 PCM ENCODING:
PCM (Pulse coded modulation) done for representation of analog signal into a standard digital form of our
multimedia audio signal.
Buffer Block:
Then inserted to buffer block for Buffering, input sequence to a smaller or larger frame size.
16
Figure 18: Buffer Parameters
Buffer output size us set to 64 for per channel and overlap and initial conditions are set to zero for better
results.
time it receives a prompt event at the trigger port ( ). After that block holds the output at the obtained
input value while waiting for the next triggering event happens.
17
Figure 19:Sample and Hold output
Initial condition is set to zero and the trigger type is set to rising edge for better work.
18
Quantizer Block:
This block discretizes input signal applyingquantization algorithm. It uses a round-to-neartechnique to plot
signal values to quantized values at output which are defined by Quantization interval. Smooth input signal
could betake on a staircase-step shape as soon as quantization.
The discrete input at given interval with quantization interval set to0.5, also can check the treat as
gain when linearizing.
Uniform Encoder:
This block usually does 2 operations on each floating-point sample in input matrix. It quantizes value using
same precision, also quantized floating point value is encoded to integer value.
19
Figure 23: Uniform Encoding
Parameters chosen for uniform encoder as peak set to 1 and number of bits to 8 the output type required
was set to signed integer.
20
4.4 Chanel Encoding:
Channel coding, utilizing BCH encoder block for this purpose as this block creates codes with K message
lengths & N number of punctures.If encoder is handlingvarious codewords per frame, then similar puncture
model holds for all codewords. Input &output signal lengths are itemized in Input & Output Signal Length
in BCH Blocks.
21
Following parameters are used for BCH encoding here K value is set to 5 which is message length & and code
ward length which is N is set to be 15.
4.5 Modulation:
Figure 27:Modulation
For this QPSK modulator baseband is utilized for QPSK modulation, the method operates on quadrature
phase shift keying method
22
Figure 29:QPSK Modulator Baseband Parameters
Here input type is set to integer and constellation ordering to binary for better resulting.
23
Figure 31:AWGN PARAMETERS
Above shown parameters are utilized for Adding white gaussian noise signal. Initial speed set to 67,
Eb/No(dB) set to 10, number of bits per symbol to 1 and input signal power & referenced to 1ohm watts.
Figure 32:constellation diagram after the signal or wave moves from noise
24
4.7 Demodulation:
Demodulation is done by using QPSK demodulator baseband blockwhich demodulates a signal which was
modulated applying quadrature phase shift keying technique. Input is a baseband description of the
modulated signal.
Here output type is set to integer and constellation ordering to binary for better resulting.
25
Figure 35QPSK demodulation output.
Following below shown parameters are utilized for proper channel decoding.
26
Figure 37:Parameters for BCH Decoder
Unbuffer:
This block unbuffers Mi-by-N input into 1-by-N output. Which is, inputs are unbuffered row-wise so that every
matrix row turn into an independent time-sample in output. Rate at which block receives inputs is usually less
than rate at which the block generates outputs.
27
Figure 38:Model with unbuffer block
Uniform Decoder block works the inverse operation ofUniform Encoder block & reconstructs quantized
floating-point values from encoded integer input.
28
Figure 41:Parameters for uniform decoder.
Parameters chosen for uniform decoder as peak set to 1 and number of bits to 8 the output type required
was set to signed integer.
5Conclusion
we have implemented the project with all desired specification given by teacher and it is working fine. Output
and code of each step is attached with each section in report also Simulink model built and each part and
block is explained full MATLAB code without section is at the end of report after references.
6 Reference
http://drmoazzam.com/matlab-code-bpsk-modulation-and-demodulation-with-explanation
https://www.mathworks.com/help/comm/ug/interleaving.htmlhttps://in.
mathworks.com/help/5g/ref/nrcrcdecode.htmlhttps://www.mathworks.com/
help/comm/ref/comm.crcgenerator-system-
object.htmlhttps://www.mathworks.com/help/comm/ref/awgn.html
https://www.mathworks.com/help/matlab/
ref/fft.htmlhttps://in.mathworks.com/matlabcentral/answers/160915-how-to-remove-gaussian-
29
no https://manikarea.home.blog/2019/09/15/manchester-line-coding-with-matlab-code-for-
encoding
31
xlim([5000,10005]) % Showing chunk of output as there are 200000 values x=demodulated;
%% deinterleaver
% deinter = randdeintrlv(inter_err,st2); % Deinterleave.
% decoded = decode(deinter,n,k,’hamming/binary’); % Decode.
%% error correction
% numFrames = 20;
% crcdetector = comm.CRCDetector(poly);
% frmError = zeros(numFrames,1);
%
% for k = 1:numFrames
% [~,frmError(k)] = crcdetector(demodData); % Detect CRC errors
% end
%% Decoding of differential
manchestercounter = 0; lastbit = 1; for
i = 1:length(t)
if t(i)>counter
counter = counter
+ 1; if x(i)==lastbit
result(counter) = 1;
lastbit = -lastbit;
else result(counter) =
0; end end
end disp(’Differential Manchester
Decoding:’); figure(4) plot(result);
title(’Decoding’) % xlim([500,605])
xlabel(’time’)
%% converting back to
analog
analog=bin2dec(yd);
analogagain=fix(analog);
%% plotingfigure;
plot(analogagain,’y’) %
xlim([500,605])
title(’AGAIN ANALOGE
SIGNAL’) xlabel(’time’)
figure;
plot(abs(fft(analogagain))) title(’AGAIN
Fourier Transform’)
xlabel(’time’)
32