You are on page 1of 33

ELE DIGITAL COMMUNICATION

PROJECT REPORT

0
Contents
Project Requirement: ...................................................................................... 2

1 Introduction ............................................................................................. 4

2 Components of Proposed Project............................................................ 5

3 Working ................................................................................................... 5

3.1 Input Voice Signal and it’s Fourier transform. ..................................... 5

3.2 Analogue To Digital Conversion........................................................... 6

3.3 Encoding of digital Signal/ Quantized.................................................. 7

3.4 CRC Error Addition ............................................................................... 8

3.5 Interleaver ........................................................................................... 9

3.6 Modulation + AWG Noise .................................................................... 9

3.7 Demodulation + Noise Removal ........................................................ 11

3.8 Deinterleaver ..................................................................................... 11

3.9 CRC Error Removal............................................................................. 12

3.10 Decoding + DAC ................................................................................. 12

4 SIMULINK PART:..................................................................................... 14

4.1 Audio:................................................................................................. 14

4.2 Spectrum analyzer ............................................................................. 15

4.3 PCM ENCODING: ................................................................................ 16

4.4 Chanel Encoding: ............................................................................... 21

4.5 Modulation: ....................................................................................... 22

4.6 Communication Chanel: .................................................................... 23

4.7 Demodulation: ................................................................................... 25

4.8 Channel Decoding: ............................................................................. 26

4.9 PCM Decoding: .................................................................................. 28

1
5 Conclusion ............................................................................................. 29

6 Reference............................................................................................... 29

7 FULL MATLAB CODE............................................................................... 30

FIGURE 1:BLOCK DIAGRAM OF A DIGITAL COMMUNICATION SYSTEM .......................................... 4


FIGURE 2:DIAGRAM OF SIMPLE TRANSMITTER AND RECEIVER. ................................................... 4
FIGURE 3:VOICE MESSAGE AND ITS FOURIER TRANSFORM. ....................................................... 6
FIGURE 4:DIGITAL SIGNAL AFTER QUANTIZATION. ................................................................... 7
FIGURE 5:: ENCODING USING DIFFERENTIAL MANCHESTER SCHEME ........................................... 8
FIGURE 6:SIGNAL BEFORE MODULATION AND AFTER MODULATION ......................................... 10
FIGURE 7:MODULATED SIGNAL AFTER ADDING NOISE ............................................................ 10
FIGURE 8:DEMODULATED SIGNAL AFTER REMOVING NOISE..................................................... 11
FIGURE 9:AFTER DECODING OF SIGNAL. .............................................................................. 13
FIGURE 10:DAC=¿CONVERTED SIGNAL ............................................................................... 13
FIGURE 11:FOURIER TRANSFORM OF SIGNAL. ....................................................................... 14
FIGURE 12:SIMULINK IMPLEMENTATION ............................................................................. 14
FIGURE 13:FROM MULTIMEDIA BLOCK FOR FILE UPLOADING .................................................... 15
FIGURE 14:AUDIO SIGNAL ................................................................................................ 15
FIGURE 15: SPECTRUM ANALYZER SCOPE ............................................................................ 15
FIGURE 16:PCM ENCODING .......................................................................................... 16
FIGURE 17: PCM ENCODING WITH BUFFER BLOCK. ............................................................... 16
FIGURE 18: BUFFER PARAMETERS ...................................................................................... 17
FIGURE 19:SAMPLE AND HOLD OUTPUT .............................................................................. 18
FIGURE 20:SAMPLE & HOLD BLOCK PARAMETER. .................................................................. 18
FIGURE 21:QUANTIZER INPUT SCOPE1 ................................................................................ 19
FIGURE 22:QUANTIZER BLOCK PARAMETERS ........................................................................ 19
FIGURE 23: UNIFORM ENCODING ...................................................................................... 20
FIGURE 24:UNIFORM ENCODER PARAMETERS ...................................................................... 20
FIGURE 25:CHANNEL CODING ........................................................................................... 21
FIGURE 26:BCH ENCODER PARAMETERS ............................................................................ 21
FIGURE 27:MODULATION................................................................................................. 22
FIGURE 28QPSK INPUT ................................................................................................... 22
FIGURE 29:QPSK MODULATOR BASEBAND PARAMETERS ...................................................... 23
FIGURE 30:COMMUNICATION CHANNEL USING AWGN BLOCK. .............................................. 23
FIGURE 31:AWGN PARAMETERS .................................................................................. 24
FIGURE 32:CONSTELLATION DIAGRAM AFTER THE SIGNAL OR WAVE MOVES FROM NOISE ............... 24
FIGURE 33:DEMODULATION USING QPSK DEMODULATOR BASEBAND BLOCK. ............................ 25
FIGURE 34:QPSK DEMODULATOR BASEBAND BLOCK PARAMETERS. .......................................... 25

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.

Figure 1:Block Diagram of a Digital Communication System

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.

Figure 2:Diagram of Simple Transmitter and Receiver.

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

• Input Voice Signal by file

• Encoding

• Channel codding

• Interleaver

• Modulation

• AWG Noise Addition


AT Receiver End
• Removing Noise

• Demodulation

• DeInterleaver

• CRC Detection and removal

• 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.

3.1 Input Voice Signal and it’s Fourier transform.


At runtime a voice signal was fed into program using record-blocking command
and then it’s plot and Fast Fourier transform of voice signal was taken and
plotted as shown.

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’)

Figure 3:Voice Message and Its Fourier Transform.

3.2 Analogue To Digital Conversion


as we can not transmit analogue Signal so to convert into digital Voice Signal was
sampled and Quantized(3 bits) as shown code and plot. As there were tomuch
values so only plot of some chunk is shown.

%% Converting Audio/ Analog signal into digital U=0.9; %


range signal from 0 to 10 n=3; % number of bits q=U/(2^n-
1); % quantization interval t=0:1:100; % your time vector
y=abs(A); % your signal

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’)
%-------------------------------------------------

Figure 4:Digital Signal after Quantization.

3.3 Encoding of digital Signal/ Quantized


After Quantization encoding is done by using Differential Manchester Encoding
Scheme. This Scheme is bipolar and have values of 1 and -1.

%% Encoding of signal using differential manchester scheme bits = yq; %


bitrate = 1; n = 1000;
T = length(bits)/bitrate; N =
n*length(bits); dt = T/N; t =
0:dt:T;
x = zeros(1,length(t)); % making an array for storing encoded signal lastbit = 1; for
i=1:length(bits)
if bits(i)==0

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’)

Figure 5:: Encoding using Differential Manchester Scheme

3.4 CRC Error Addition


CRC Error is a packet error, which occurs when network communications are
bad or go in and out. This creates vulnerability for invalid data to be placed into
the file. Error is generated and then appended in encoded signal.

%%GENERATING ERROR AND APENDING IN INPUT FILE


crcgenerator = comm.CRCGenerator(poly); crcdetector =
comm.CRCDetector(poly); numFrames = 20; frmError =
zeros(numFrames,1); for k = 1:numFrames
data = x %binary data after encoding encData =
crcgenerator(data);
end

8
3.5 Interleaver
Interleaving, a technique for making forward error correction more robust with
respect to burst errors.

%% interleaverst1 = 27221; st2 = 4831; % States for random number generator n =


7; k = 4; % Parameters for Hamming code msg = encData; % signal after adding
CRC code = encode(msg,n,k,’hamming/binary’); % Encoded data % Create a burst
error that will corrupt two adjacent codewords. errors = zeros(size(code));
errors(n-2:n+3) = [1 1 1 1 1 1];

% Interleaving
%-----------------inter = randintrlv(code,st2); % Interleave. x =
bitxor(inter,errors); % Include burst error.

3.6 Modulation + AWG Noise


Modulation is the process of varying one or more properties of a periodic
waveform, called the carrier signal, with a modulating signal that typically
contains information to be transmitted. in our project we used BPSK Modulation
scheme. Binary Phase Shift Keying (BPSK) is a two phase modulation scheme,
where the 0’s and 1’s in a binary message are represented by two different
phase states in the carrier signal: for binary 1 and. for binary 0. As we have used
differential Manchester encoding so two phases will be -1 and 1. after
modulation white noise is added in signal.

%% SIGNAL BEFORE MODULATION figure(1); plot(x); xlabel(’Time (seconds)-


->’) ylabel(’Amplitude (volts)-->’) title(’Input signal to be
transmitted(BEFORE MODULATION)’); xlim([5000,10005]) t=0:.1:(length(x) -
1)/10; %Frequency of the carrier f=5;
%Here we generate the modulated signal by multiplying it with
%carrier (basis function)
Modulated=x.*(sqrt(2/T)*cos(2*pi*f*t)) figure;
plot(Modulated); xlabel(’Time (seconds)-->’);
ylabel(’Amplitude (volts)-->’); title(’BPSK
Modulated signal’);
xlim([500,550]) % Showing chunk of output as there are 200000 values
% Adiinggausian noise in the input audioa signal figure;
%% ADDING NOISE IN MODULATED SIGNAL addingnoise
= awgn(Modulated,0.5)

9
plot( addingnoise)
legend(’Signal after noise NOISE(AWGN)’)
xlim([500,600]) % Showing chunk of output as there are 200000 values
y=[];

Figure 6:Signal Before Modulation and After Modulation

Figure 7:Modulated Signal After adding noise

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

%% DEMODULATION + REMOVING NOISE


M =0;
V=0.01;
Removingnoise = imnoise(addingnoise,’gaussian’,M,V); % removing noise
%We begin demodulation by multiplying the received signal again with
%the carrier (basis function) after removing noise
demodulated=Removingnoise.*(sqrt(2/T)*cos(2*pi*f*t)); figure;
plot(demodulated) title(’Demodulated signal’); xlabel(’Time
(seconds)-->’); ylabel(’Amplitude (volts)’)
xlim([5000,10005]) % Showing chunk of output as there are 200000 values

Figure 8:Demodulated signal after Removing Noise

3.8 Deinterleaver
deinterleaver uses the inverse mapping to restore the original sequence of
symbols.

%%Deinterleaving deinter = randdeintrlv(inter_err,st2); % Deinterleave.


decoded = decode(deinter,n,k,’hamming/binary’); % Decode.

11
3.9 CRC Error Removal
CRC error is first detected and then removed.

numFrames = 20; crcdetector =


comm.CRCDetector(poly); frmError =
zeros(numFrames,1);

for k = 1:numFrames
[~,frmError(k)] = crcdetector(demodData); % Detect CRC errors end

3.10 Decoding + DAC


After removing of error Next step is Decoding or back to analogue form of signal
and then Fourier Transform of received signal.

%% Decoding of differential manchestercounter


= 0; lastbit = 1; x=demodulated; 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’) xlabel(’time’)
%% converting back to analog analog=bin2dec(yd);
analogagain=fix(analog);
%% plotingFigure; plot(analogagain,’y’)
title(’AGAIN ANALOGE SIGNAL’)
xlabel(’time’) figure;
plot(fft(analogagain)) title(’AGAIN
Fourier Transform’)
xlabel(’time’)

12
Figure 9:After Decoding of signal.

Figure 10:DAC=¿converted signal


12

Figure 11:Fourier transform of signal.

4 SIMULINK PART:

Figure 12:Simulink Implementation

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

Figure 14:Audio Signal

4.2 Spectrum analyzer


scope used for analyzing the audio signal.

Figure 15: Spectrum Analyzer Scope

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.

Figure 16:PCM ENCODING

 Buffer Block:

Then inserted to buffer block for Buffering, input sequence to a smaller or larger frame size.

Figure 17: PCM Encoding with buffer block.

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.

 Sample and Hold block:


The block is present in DSP System Toolbox / Signal Operations. This block obtains input at signal port each

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

Figure 20:Sample & hold block parameter.

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.

Figure 21:Quantizer input scope1

Figure 22:Quantizer block parameters

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

Figure 24:Uniform Encoder Parameters

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:

Figure 25:Channel Coding

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.

Figure 26:BCH Encoder Parameters

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

Figure 28QPSK input

22
Figure 29:QPSK Modulator Baseband Parameters

Here input type is set to integer and constellation ordering to binary for better resulting.

4.6 Communication Chanel:


For communication channel AWGN channel block is added An AWGN channel adds white Gaussian noise
to signal which passes via it. You can produce an AWGN channel in a model using
the comm.AWGNChannel System object the AWGN Channel block, or the awgn function.

Figure 30:Communication Channel using AWGN Block.

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.

Figure 33:Demodulation using QPSK demodulator baseband block.

Figure 34:QPSK demodulator baseband block parameters.

Here output type is set to integer and constellation ordering to binary for better resulting.

25
Figure 35QPSK demodulation output.

4.8 Channel Decoding:


For channel decoding BCH decoder used. It recovers a binary message vector after a binary BCH codeword
vector.

Figure 36:Chanel decoding using BCH Decoder.

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

Figure 39:Parameters for Unbuffer block.

4.9 PCM Decoding:


In finally PCM decoding is done by using uniform decoder block after the unbuffer block.

Figure 40:Complete Model

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

7 FULL MATLAB CODE

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’)
%% Converting Audio/ Analog signal into digital
U=0.9; % range signal from 0 to 10 n=3; % number
of bits
q=U/(2^n-1); % quantization interval t=0:1:100;
% your time vector y=abs(A); % your signal
% -------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,605]) title(’DIGITAL SIGNAL ’)
xlabel(’time’) %------------------------------------------------%%
Encoding of signal using differential manchester scheme bits =
yq; % bitrate = 1; n = 1000;
T = length(bits)/bitrate; N = n*length(bits); dt = T/N; t = 0:dt:T; x =
zeros(1,length(t)); % making an array for storing encoded signal lastbit = 1;
for i=1:length(bits)
if bits(i)==0
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(5) plot(t, x,
’Linewidth’, 3);
title(’Encoding’)
xlim([500,515])
xlabel(’time’)
%% CRC ERROR
%crcgenerator = comm.CRCGenerator(poly);
%crcdetector = comm.CRCDetector(poly);
%numFrames = 20;
30
% frmError = zeros(numFrames,1);
% for k = 1:numFrames
% data = x %binary data after encoding
% encData = crcgenerator(data);
% end
%% interleaver
% st1 = 27221; st2 = 4831; % States for random number generator
% n = 7; k = 4; % Parameters for Hamming code
% msg = encData; % signal after adding CRC
% code = encode(msg,n,k,’hamming/binary’); % Encoded data
% % Create a burst error that will corrupt two adjacent codewords.
% errors = zeros(size(code)); errors(n-2:n+3) = [1 1 1 1 1 1];
%
% Interleaving
%------------------
% inter = randintrlv(code,st2); % Interleave.
% error = bitxor(inter,errors); % Include burst error.
%% modulation
T=1;%Bit rate is assumed to be 1 bit/s;
%bits to be transmitted
%% SIGNAL BEFORE MODULATION figure; plot(x); xlabel(’Time
(seconds)-->’) ylabel(’Amplitude (volts)-->’) title(’Input signal to
be transmitted(BEFORE MODULATION)’); xlim([5000,10005])
t=0:.1:(length(x) -1)/10; %Frequency of the carrier f=5;
%Here we generate the modulated signal by multiplying it with
%carrier (basis function)
Modulated=x.*(sqrt(2/T)*cos(2*pi*f*t
)) figure; plot(Modulated);
xlabel(’Time (seconds)-->’);
ylabel(’Amplitude (volts)-->’);
title(’BPSK Modulated signal’);
xlim([500,550]) % Showing chunk of output as there are 200000 values
% Adiinggausian noise in the input audioa signal figure;
%% ADDING NOISE IN MODULATED SIGNAL
addingnoise = awgn(Modulated,0.5)
plot( addingnoise)
legend(’Signal after noise NOISE(AWGN)’)
xlim([500,600]) % Showing chunk of output as there are 200000 values
y=[];
%% DEMODULATION + REMOVING NOISE
M =0;
V=0.01;
Removingnoise = imnoise(addingnoise,’gaussian’,M,V); % removing noise
%We begin demodulation by multiplying the received signal again with
%the carrier (basis function)
demodulated=Modulated.*(sqrt(2/T)*cos(2*pi*f*t));
figure; plot(demodulated) title(’Demodulated
signal’); xlabel(’Time (seconds)-->’);
ylabel(’Amplitude (volts)’)

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

You might also like