Sei sulla pagina 1di 56

BiT Error Control Coding 2017

ERROR CONTROL CODING BY USING HAMMING CODE


By
1. Dawit Girma
2. Dawit Mesfin
3. Dasalegn Amare
4. Feben Eshetu

SEMESTER PROJECT
Submitted in partial fulfillment of the requirements for the degree of
BACHELOR OF SCIENCE
In Electrical and Computer Engineering (electronics and communication
Stream)

BAHIRDAR UNIVERSITY –INSTITUTE OF TECHNOLOGY

February - 2017

Semester Project Documentation Page 1


BiT Error Control Coding 2017

Approval
This semester project has been approved in partial fulfillment of the requirements
for the degree of Bachelor of Science in electrical and computer engineering with
specialization in electronics and communication engineering.

Faculty of electrical and computer engineering

Project advisor: Mr.Fekadu.M ---------------------

Team Members:

1. Dawit Girma........0500775 --------------------


2. Dawit Mesfin......0500780 --------------------
3. Desalegn Amare.....0500831 --------------------
4. Feven Eshetu ........0501073 --------------------
-

Semester Project Documentation Page i


BiT Error Control Coding 2017

Acknowledgment
We would like to thank our advisor Mr. Fekadu Mihert (M.Sc) who advised us attentively in
time scheduled to make us successful and complete the project on time. We are also great full for
Mr. Fasile (M.Sc), who has helped by giving friendly advice for our project . We would like to
thank the Electrical Engineering staff’s who have been in the mid presentation of our project, for
their supportive idea in our progress. Finally to all Electrical Engineering staff members who
cooperated us in giving the necessary information and materials.

Semester Project Documentation Page ii


BiT Error Control Coding 2017

Abstract
The information revolution is in full swing, having matured over the last 30 years. Now a days
the reliable information transmission is very essential so, this paper deals on the basic techniques
of error detection and correction, that helps for reliable information transmission and also the
performance comparison of these different techniques of error control coding. Error control
coding is a set of techniques which contains the basic principles in detecting and correcting the
errors by identifying the error location in the received information. The design phase consists of
encoder design, decoder design and channel simulation for each error control techniques. After
accomplishing this tasks we also done the performance analyzing.

Semester Project Documentation Page iii


BiT Error Control Coding 2017

List of Acronyms

ARQ…………………………………………………. Automatic Repeat Request

AWGN……………………………………… …. Additive White Gaussian Noise

BCH…………………………………………… Boss Chaundhuri Hocquengha

CD ……………………………………………….... Compact Disk

FEC…………………………………………………. Forward Error Correction

GUI……………………………………………….. Graphical User Interface

IMDL………………………………………………… Intelligent Machines Design Lab

RAM……………………………………………….. Random Access Memory

RSC …………………………………………. Recursive systematic convolution

SNR................................................................................Signal to Noise Signal

Semester Project Documentation Page iv


BiT Error Control Coding 2017

List of Figure
Figure 1 a communication system (source and channel encoder) ................................................. 2
Figure 2 Block diagram of a FEC system ....................................................................................... 9
Figure 3 block diagram of an ARQ system .................................................................................. 10
Figure 4 a code word.................................................................................................................... 11
Figure 5 This figure shows the information bit and the parity bits .............................................. 11
Figure 6 Systematic Code ............................................................................................................ 13
Figure 7 Decoding Spheres of Radius t ........................................................................................ 16
Figure 8 Hamming code................................................................................................................ 23
Figure 9 coded condition for hamming error control coding techniques..................................... 26
Figure 10 uncoded conditions for hamming error control coding technique................................ 27
Figure 11 performance comparison between coded and uncoded conditions for Hamming....... 28
Figure 12 GUI for Hamming ECC Technique .............................................................................. 29

Semester Project Documentation Page v


BiT Error Control Coding 2017

Table of Contents
Approval ........................................................................................................................................................ i
Acknowledgment .......................................................................................................................................... ii
Abstract ........................................................................................................................................................ iii
List of Acronyms ......................................................................................................................................... iv
List of Figure................................................................................................................................................. v
CHAPTER ONE .......................................................................................................................................... 1
INTRODUCTION ........................................................................................................................................ 1
1.1 Background ........................................................................................................................................ 1
1.2 Statement of the problems................................................................................................................... 4
1.3 Objective of the project ....................................................................................................................... 5
1.3.1 General Objective ........................................................................................................................ 5
1.3.2 Specified Objective ...................................................................................................................... 5
1.4 Methodology ....................................................................................................................................... 5
1.5 Contribution of the Project.................................................................................................................. 5
1.6 Scope of the project ........................................................................................................................... 6
1.7 Organizations of the Project............................................................................................................... 6
CHAPTER TWO .......................................................................................................................................... 8
LITERATURES REVEID ............................................................................................................................ 8
2.1 Error control strategies[2] ..................................................................................................................... 8
CHAPTER THREE .................................................................................................................................... 19
SYSTEM DESING AND ANIYZING ...................................................................................................... 19
3.1 Different classes of block code ......................................................................................................... 19
3.2 Mathematical Modeling ................................................................................................................... 21
3.2 System Design and Analysis ............................................................................................................. 22
3.2.1 Design of encoder ...................................................................................................................... 22
3.2.2 Design of decoder ..................................................................................................................... 24
3.3 Implementation ................................................................................................................................ 24
3.4 Performance comparison ................................................................................................................. 24
CHAPTER FOUR....................................................................................................................................... 25
RESULT AND DISSICUTION .................................................................................................................. 25

Semester Project Documentation Page vi


BiT Error Control Coding 2017
CHAPTER FIVE ........................................................................................................................................ 30
CONCULSION AND RECOMMUNDITION ........................................................................................... 30
5.1 conclusion ........................................................................................................................................ 30
5.2 Summary ........................................................................................................................................... 30
5.3 Recommendation for futures........................................................................................................... 31
Reference .................................................................................................................................................... 32
Appendices.................................................................................................................................................. 33
Appendix A: code for encoder design (using hamming error control coding technique) ....................... 33
Appendix B code for channel simulation (using hamming error control coding technique) .................. 34
Appendix C code for decoder design (using hamming error control coding technique) ........................ 35
Appendix D: SNR Vs BER graph .......................................................................................................... 38
Appendix E: Graphical User interface (GIU) ......................................................................................... 39

Semester Project Documentation Page vii


BiT Error Control Coding 2017

CHAPTER ONE
INTRODUCTION

1.1 Background
In modern digital communication and storage systems design, information theory is
becoming increasingly important .In recent years; there has been an increasing demand for
efficient and reliable digital data transmission. This demand has been accelerated by the
emergence of large scale, high speed data networks for the exchange and processing of digital
information in the military, governmental and private spheres. A major concern is control of
errors, so that reliable reproduction of data can be obtained. Recent developments have
contributed toward achieving the reliability required by today’s high speed digital systems and
the use of coding for error control has become an integral part in the design of modern
communication systems and digital computers.
When we are watching TV, enjoying music on CD, talking with friend by cellular phone
etc., we encounter problem due to the impact of the noisy environment. A CD player includes
semiconductor memories, optical media, laser device, disk files, and so on. Each of them is
subject to various types of noise disturbance may come from switching impulse noise, thermal
noise, dust on disk surface, or even lightening. Error control coding (also referred to as channel
coding) is used to detect, and often correct, symbols which are received in error on digital
communications channels.
A typical digital communications system is shown below in Figure 1 The source
information is usually composed of binary or decimal digits or alphabetic information in either a
continuous waveform or a sequence of discrete symbols. The encoder transforms these messages
into a sequence of binary digits (bits) to the channel. The sequence enters the channel and is
perturbed by noise. The output enters the decoder, which makes a decision concerning which
message was sent and delivers this message to the sink.
A communication system can be represented by the following block diagram:

Semester Project Documentation Page 1


BiT Error Control Coding 2017
Source Source Encoder Channel Decoder

Channel

Sink Digital Sink Channel Decoder

Figure 1 a communication system (source and channel encoder)


Each part of the communication system is discussed below:
 source encoder: transforms the source out put into a sequence of binary digits
(bits) called the information/message sequence m .if the source is continuous it involves
conversion of analog into digital (A/D) conversion.
 channel encoder: transforms the information sequence m into a discrete encoded
sequence n called a code word. The channel encoders must be designed and implemented
in a way which combat the noisy environment (channel).
 Noisy channel: is a channel which is subjected to noise. A channel is always a
medium through which the information being transmitted can suffer from the effect of
noise, which produces errors, that is, changes of the values initially transmitted. In this
sense there will be a probability that a given transmitted symbol is converted into another
symbol. Most of the times when we say noise the first which come to our mind and also
the concern of this project is Additive White Gaussian Noise (AWGN) Channel. In
communications, the AWGN channel model is one in which the only impairment is the
linear addition of wideband or white noise with a constant spectral density (expressed as
watts per hertz of bandwidth) and a Gaussian distribution of amplitude. The model does
not account for the phenomena of fading, frequency selectivity, interference, nonlinearity
or dispersion. However, it produces simple, tractable mathematical models which are
useful for gaining insight into the underlying behavior of a system before these other
phenomena are considered. AWGN is commonly used to simulate background noise of
the channel under study.

Semester Project Documentation Page 2


BiT Error Control Coding 2017
 channel decoder: transforms the received sequence r into a binary sequence m
called the estimated sequence. The decoding strategy is based on the rules of channel
encoding and the noise characteristics of the channel.
 source decoder: transforms the estimated sequence into an estimate of the source
output and delivers this estimate to the destination. If the source is continuous, it involves
digital to analog (D/A) conversion.
The major error control coding problem is to design and implement the channel
encoder/decoder pair such that:
 Information can be transmitted (or recorded) in a noisy environment as fast as
Possible.
 Reliable reproduction of the information can be obtained at the output of the
channel decoder.
 The cost of implementing the encoder and decoder falls within acceptable limits.

The fundamental of error control coding is based on Shannon’s landmark paper published
in 1948. Shannon demonstrated that by proper encoding of the information, errors induced by a
noisy channel or storage medium can be reduced to any desired level without sacrificing the rate
of information transmission or storage. Since Shannon’s work, a great deal of effort has been
expended on the problem of devising efficient encoding and decoding methods for error control
in a noisy environment.
Recent developments have contributed toward achieving the reliability required by today’s high
speed digital systems, and the use of coding for error control has become an integral part in the
design of modern communication systems and digital computers with the dramatic decreasing of
the size and cost of semiconductor devices.
Types of errors
There are two types of errors that occur on digital communications channels:
I. Random errors
II. Burst error
Random errors :- Errors that occur independently on each bit of the transmitted sequence. That is,
an error occurs on a transmitted bit independent of errors that occurred in the vicinity of the bit.
The random error channel also called as memory less channel. Good examples of random-error

Semester Project Documentation Page 3


BiT Error Control Coding 2017
channels are the deep-space channel and many satellite channels. The codes devised for
correcting random errors are called random-error-correcting codes.
Burst errors:- Errors that occur intensively in a period .That is to say, if an error occurs on a bit,
several consecutive bits are likely to be in error. The number of bits in this erroneous period,
from the first bit in error to the last bit in error, is called the burst length. A burst-error channel is
also called as channel with memory. Examples of burst-error channels are radio channels, where
the error bursts are caused by signal fading due to multipath transmission, wire and cable
transmission, which is affected by impulsive switching noise and crosstalk, and magnetic
recording, which is subject to tape dropouts due to surface defects and dust particles. The codes
devised for correcting burst errors called burst-error-correcting codes. Actually, some channels
contain a combination of both random and burst errors. They are called compound channels, and
codes devised for correcting errors on these channels are called burst-and-random-error-
correcting codes.

1.2 Statement of the problems


In recent years, there has been an increasing demand for efficient and reliable data
transmission. This demand has been accelerated by the emergency of large scale, high speed
data networks for the exchange and processing of digital information in the military,
governmental and private spheres. A major concern is control of errors so that reliable
reproduction of data can be obtained. Now a day, the design of digital computers and
communication systems require efficient error control coding technique. It is fact that every
communication channel is vulnerable to noise unless we use proper error control
mechanisms; this initiated us to do our project on detecting and correcting this errors. The
error control coding encoder takes as input, the information symbols from the source and
adds redundant symbols to it, so that most of the errors introduced in the transmitting signal
during transmission over noisy channel. The decoder then receives the corrupted signal and
detects the error locations by which we can correct it. Error control coding has its own error
detecting techniques and is also has a means of correcting the errors happened on our source
information. Some of these techniques are Hamming, BCH, Reed Solomon, Turbo,
convolutional coding and etc. Among these techniques we basically focused on Hamming
coding technique for this semester.

Semester Project Documentation Page 4


BiT Error Control Coding 2017
1.3 Objective of the project
1.3.1 General Objective
The goal of this project is the detection and correction of errors in digital information
using Hamming coding techniques. Such Errors almost inevitably occur after the transmission,
storage or processing of information in Digital (mainly binary) form, because of noise and
interference in communication channels, or imperfections in storage media. Protecting digital
information with a suitable Error-control code enables the efficient detection and correction of
any errors that may have occurred. Because of this we initiated to do our project on
this area.

1.3.2 Specified Objective


This project is using different coding techniques to decrease communication errors that occur
during transmission and comparing the performance of each coding techniques subjected to
noise. Messages that are transmitted over a communication channel can be damaged their bits
can be masked or inverted by noise. Detecting and correcting these errors is important. .
This paper addresses a multiple error detecting and single bit correcting error control coding
technique called Hamming codes.

1.4 Methodology
To accomplish this project we have used two stages. these are:-
I. Mathematical Model : In this section we will implement different mathematical concepts
that are applicable for Hamming error control coding techniques.
II. Simulation : In conducting our project we are going to follow the following basic steps
1. Design of
 Encoder
 Decoder
2. Performance analyzing:- by using graphical user interface(GIU)

1.5 Contribution of the Project


This project is the detection and correction of errors in digital information.
Such errors almost inevitably occur after the transmission and processing of information in
digital (mainly binary) form, because of noise and interference in communication channels.

Semester Project Documentation Page 5


BiT Error Control Coding 2017
Protecting digital information with a suitable Error-control code enables the efficient detection
and correction of any errors that might occur. Error control codes are now used in almost the
entire range of information communication.

1.6 Scope of the project


We are basically intended to test error control coding using the Hamming coding
technique and we also try to demonstrate the performance of Hamming coding techniques
using the graphical user interface (GUI). We can look the overall scope of our project by looking
the experimental tool, basics and output of our project.
 Experimental tool: we will do our project using the mat lab software, for this purpose we
will use a large memory (hard disk) and RAM (for demonstration purpose) computer.
 Experimental basics: here we will perform the following tasks.
 First we will look the basic encoding and decoding techniques without the effect
of noise in the channel.
 Then, we demonstrate the effect of adding noise on the normal functioning of the
decoder.
 Expected output: the final remark of this project is minimizing the error happen in
transmission by which we can have a reliable and fast transmission system. We can
create error free transmission system this is done at the expense of bandwidth.
Finally we will arrive at the point where we can choose a particular soft decision
decoding algorithm which can give an estimate of the performance that is achievable over
certain channel.

1.7 Organizations of the Project


This project paper is consisted of totally five chapters. Chapter one introduces background
history and general over view. Chapter two of this paper is consisted of literature review.
The literature review is a section where the previously done projects on this area is revised
and their major work is described. Chapter three of this paper is system and model design of
the project. This section greatly describes the principle of operation of the newly designed
system and also the materials required to do the design of the project. Chapter four describes
the results obtained based on the simulation briefly discusses the result. The final chapter

Semester Project Documentation Page 6


BiT Error Control Coding 2017
this paper is the conclusion and recommendation part. It draws a conclusion from the
experiment and also give recommendation for other researchers interested in this area.

There is also future work expressed for those people who are interested in this area and
further advancement areas are also mentioned.

Semester Project Documentation Page 7


BiT Error Control Coding 2017

CHAPTER TWO
LITERATURES REVEID
The traditional role for error-control coding was to make a troublesome channel acceptable by
lowering the frequency of error events. The error events could be bit errors, message errors,
or undetected errors. Coding's role has expanded tremendously and today coding can do the
following:[2]
 Reduce the occurrence of undetected errors:- This was one of the first uses of error-
control coding. Today's error detection codes are so effective that the occurrence of
undetected errors is, for all practical purposes, eliminated.
 Reduce the cost of communications systems:- Transmitter power is expensive, especially
on satellite transponders. Coding can reduce the satellite's power needs because messages
received at close to the thermal noise level can still be recovered correctly.
 Overcome Jamming:- Error-control coding is one of the most effective techniques for
reducing the effects of the enemy's jamming.
 Eliminate Interference:-As the electromagnetic spectrum becomes more crowded with
man-made signals, error-control coding will mitigate the effects of unintentional
interference. Despite all the new uses of error control coding, there are limits to what
coding can do. On the Gaussian noise channel, for example, Shannon's capacity formula
sets a lower limit on the signal-to-noise ratio that we must achieve to maintain reliable
communications. Shannon’s lower limit depends on whether the channel is power-limited
or bandwidth-limited. The deep space channel is an example of a power limited channel
because bandwidth is an abundant resource compared to transmitter power.
2.1 Error control strategies[2]
There are two strategies of error control coding with respect to the direction of information
transmission, one-way (simplex) and two-way (duplex) system. These are:-
Forward error correction(FEC)
Automatic repeat request(ARQ)
Forward error correction (FEC):- This is an error control strategy used for a one way
transmission system. That is, by employing error correcting codes which automatically correct
errors detected at the receiver. Communication systems that use the FEC approach are not able to

Semester Project Documentation Page 8


BiT Error Control Coding 2017
request a repetition of the transmission of coded information. Due to this, all the capability of the
code is used for Error correction. Error control for a one-way system must be accomplished
using forward error correction (FEC) that is, by employing error correcting codes that
automatically correct errors detected at the receiver. One example is deep-space communication
systems. This can be shown diagrammatically as follows:
noise

Encoder Transmit Channel Receiver Decoder

Figure 2 Block diagram of a FEC system

Automatic repeat request (ARQ):- This is used for two ways transmission system that is
information can be sent in both directions and the transmitter also acts as a receiver (a
transceiver). ARQ communication systems are based on the detection of errors in a coded block
and on the retransmission of the block when errors have been detected. In this case a two-Way
channel is needed in order to request retransmissions. For a given code, the error-detection
Capability possible in an ARQ system is higher than the error-correction capability of its FEC
counterpart, because the error control capability of the code is spent only on detection, while the
correction requires not only the detection but also the localization of the errors. Error control for
a two-way system can be accomplished using error detection and retransmission, called
automatic repeat request (ARQ). In an ARQ system, when errors are detected at the receiver, a
request is sent for the transmitter to repeat the message, and this continues until the message is
received correctly.
There are two types of ARQ systems:
 stop-and-wait ARQ and
 continuous ARQ
Stop-and-wait ARQ:-The transmitter sends a code word to the receiver who has the error
detecting ability and waits for response from the receiver. If no errors detected, the transmitter
sends the next code word. If errors detected, it resends the preceding code word. In some case,
the same code word may be retransmitted several times before it is correctly received and
Semester Project Documentation Page 9
BiT Error Control Coding 2017
acknowledged.
Continuous ARQ:- The transmitter sends code words to the receiver continuously and receives
acknowledgements continuously. When an error detected, the transmitter begins a
retransmission. It may back up to the code word in error and resend that word plus the words that
follow it. This is called go-back N ARQ. Alternatively, the transmitter may simply resend only
those code words that are acknowledged negatively. This is known as selective-repeat ARQ.
Selective-repeat ARQ is more efficient that go-back-N ARQ, but requires more logic and
buffering. Continuous ARQ is more efficient than stop-and-wait ARQ, but it is also more
expensive. In a satellite communication system where the transmission rate is high and the
roundtrip delay is long, continuous ARQ is normally used.
The major advantage of ARQ over FEC is that error detection requires much simpler
decoding equipment that does error correction. Also, ARQ is adaptive in the sense that
information is retransmitted only when errors occur. On the other hand, when the channel
error rate is high, retransmissions must be sent too frequently, and the system throughput,
the rate at which newly generated messages are correctly received, is lowered by ARQ.
Hence, a combination of FEC for the most frequent error patterns, together with error detection
and retransmission for the less likely error patterns, is more efficient than ARQ alone.

Transmitter Receiver
Buffer buffer
Data Transmision

Encoder Two way Decoder


channel

positive and negative


Figure 3 block diagram of an ARQ system
All error correcting codes are based on the same basic principle: Redundancy is added to the
information in order to correct any errors that may occur in the process of storage or
transmission. In a basic (and practical) form, redundant symbols are appended to information
symbols to obtain a coded sequence or codeword. The information symbols always appear in the

Semester Project Documentation Page 10


BiT Error Control Coding 2017
first k positions of a Codeword. The remaining n - k symbols in a codeword are some function of
the information Symbols, and provide redundancy that can be used for error correction/detection
purposes.
n length Code Word
K information bits (n-k) redundancy bits

Figure 4 a code word


There are basically two mechanisms for adding redundancy, in relation to error-control
Coding techniques .These two basic mechanisms are block coding and convolutional coding.
Block code[4]:- Block codes process the information on a block-by-block basis, treating each
block of information bits independently from others. In other words, block coding is a memory
less operation, in the sense that code words are independent from each other. It should be noted
that block codes have in fact memory, when encoding is thought of as a bit-by-bit process and
within a codeword. The encoder for a block code divides the information sequence into message
blocks of K information bits each. A block code is a rule for converting a sequence of source bits
s, of length k, into a transmitted sequence t of length n bits, where, in order to add redundancy, n
will be greater than k. Block codes are not necessarily linear, but in general all block codes used
in practice are linear. Linear codes are divided into two categories: block and convolutional
codes. In a block code, the transmitted sequence is always a multiple of n long. This is because
information is transmitted in blocks of data that are n bits long (hence the name). For an (n,k)
code, C, the blocks have a length of n, k information bits encoded in them, and n-k parity bits.
n = bits in a block
k = message bit (I)
n - k = parity bits (P)

(I) (I P P)

(N,K) Encoder

Figure 5 This figure shows the information bit and the parity bits

Semester Project Documentation Page 11


BiT Error Control Coding 2017
n
If each block is n bits long, there are 2 possible combinations. However, linear block
codes consist of 2k possible code words. These 2k possibilities form a subset of the set. These
are called valid code words. An important feature of linear codes is that the zero codeword is
always a member of the [1] valid codeword’s. The minimum distance of a linear code is equal to
the lowest weight of a nonzero codeword (the minimum number of bits that must be changed to
end up with another codeword). Here t is the number of errors that can be corrected. s is the
number of errors that can be detected. Because a decoder must be able to detect an error before it
corrects an error, s is always more than or equal to t.

s>= t
dmin>= s+t+1

dmin>=2t+1(for error correction only code).......................(2.1)


A linear code maps k-bit messages ( 2k possible messages) to n-bit code words. Only 2k of
the 2n possibilities are used, leaving 2n -2k illegal bit sequences. The next step in error
correction is assigning each of these illegal bit sequences to their nearest codeword.A message
block is represented by the binary K tuples m= ( m1,m2,.....mk) called message
bits. There are a total of different possible messages. The encoder transforms each message m
independently into an n tuples n= (n1,n2...nn) of discrete symbols called a code word. Therefore,
corresponding to the 2different possible messages, there are different possible code words at the
encoder output. This set of code words of length n is called an (n, k) block code. The ratio R=K/n
is called the code rate and can be interpreted as the number of information bits entering the
encoder per transmitted symbol.
Cyclic property of block codes[3]:- Cyclic codes are an important class of linear block codes,
characterized by the fact of being easily implemented using sequential logic or shift registers. A
given linear block code is said to be cyclic if for each of its code vectors the cyclic rotation is
also a code vector of the same code. In a linear block code, the sum of any two code vectors of a
cyclic code is also a code vector. For every code word v of length n a polynomial v(x) is
associated,

V=(V0,V1,...............Vn-1)↔V(x)=V0+V1x+........+Vn-1Xn-1.................(2.2)

Semester Project Documentation Page 12


BiT Error Control Coding 2017
A linear block code c is cyclic if and only if every cyclic shift of a codeword is another
codeword.
V=(V0,V1..............Vn-1)∈ v1=(V0,V1...........Vn-1)∈ ............................(2.3)
The minimum distance is an important parameter of a code, especially for a block code.
The Hamming distance between any two vectors.
C1=C01+C11+...........+ Cn-11 AND C2=C02+C12+..........+Cn-12.............................................(2.4)
d ( ) is the number of component positions in which the two vectors differ. The number of non-
zero components ≠ 0 of a given vector c = + +…+ of size (1 × n) is called the weight, or
Hamming weight, w(c), of that vector .For a vector defined over the binary field, the weight is
the number of ‘1’s in the vector. It can be verified that d( ) = w( ) for a given code, the minimum
value of the distance between all possible pairs of code words can be calculated. This minimum
value of the distance evaluated over all the code words of the code is called the minimum
distance of the code dmin.
dmin ={min d(Ci,Cj);Ci,Cj∈ Cb;Ci=Cj}...................(2.5)
Therefore, the minimum distance of a linear block code (n, k) is the minimum value of the
weight of the non-zero code words of that code.
Generator and parity check matrix[1]:- The generator matrix for a linear block code is one of the
basis of the vector space of valid codeword’s. The generator matrix defines the length of each
codeword n, the number of information bits k in each codeword, and the type of redundancy that
is added; the code is completely defined by its generator matrix. The generator matrix is a k x n
matrix. Multiplying the k-bit information sequence u(x) by the (n, k) generator matrix gives the
n-bit codeword.
Redundancy or Parity Check bits Original message

n-k bit k bit


Figure 6 Systematic Code
We must remember that the generator matrix will always produce a codeword with the last k
bits being equal to the information sequence. When the information bits are passed into the
codeword unchanged and parity bits are added this is called a systematic code. If the information
bits are not directly represented then the code in called a nonsystematic code. Typically,

Semester Project Documentation Page 13


BiT Error Control Coding 2017
systematic codes have every advantage of their nonsystematic counterparts plus the encoder only
needs to produce (n-k) bits instead of the entire codeword.

Syndromes[1]:- The syndrome is the receive sequence multiplied by the transposed parity check
matrix H.
s(x) =r(x) H T.........................(2.6)
The syndrome is a (n-k) -tuple that has a one to one correspondence with the correctable error
patterns. The syndrome depends only on the error pattern and is independent of the transmitted
codeword. Most codes do not use all of the redundancy that has been added for error correction.
The only two codes known to do this are Hamming ( 2m- 1,2m - m - 1) .
Coding Theory[5]:- Coding theory is the study of methods for efficient and accurate transfer
of information from one place to another. The theory has been developed for such diverse
applications as the minimization of noise from compact disc recorders, the transmission of
financial information across telephone line, data transfer from one computer another or from
memory to the central processor, and information transmission from a distance source . The
physical medium through which the information is transmitted is called a channel. Undesirable
disturbances, called noise, may cause the information received to differ from what was
transmitted. Noise may be caused by sunspots, lightning, folds in a magnetic tape, competing.
telephone messages, random radio disturbance, or many other things. Coding theory deals with
the problem of detecting and correcting transmission errors caused by noise on the channel.
In practice, the control we have over this noise is the choice of a good channel to use for
transmission and the use of various noise filters to combat certain types of interference which
may be encountered. Once we have settled on the best mechanical system for solving these
problems, we can focus our attention on the construction of the encoder and the decoder.
Our desire is to construct these in such a way as to effect:
1. Fast encoding of information
2. Easy transmission of encoded messages
3. Fast decoding of received messages
4. Correction of errors introduced in the channel, and
5. Maximum transfer of information per unit time.

Semester Project Documentation Page 14


BiT Error Control Coding 2017
Error-Detecting Codes[2]:- Now we make precise the notion of when a code C will detect errors.
Recall that if v is in C is sent and w in is received, then u=v+w is the error pattern. Any word u
in can occur as an error pattern, and we wish to know which error patterns C will detect. We say
that code C detects the error pattern u if and only if v+u is not a codeword, for every v in C. In
other words, u is detected if for any transmitted codeword v, the decoder, upon receiving v+u
can recognize that it is not a codeword and hence that some error has occurred. The table
constructed for IMLD can be used to determine which error patterns a code C will detect. The
first column lists every word in . Hence the first column can be reinterpreted as all possible error
patterns, in which case the error pattern columns in the IMLD table then contain the sums v+u,
for all v in C. If in any particular row none of these sums are codeword’s in C, then C
detects the error pattern in the first column of that row.
An alternative and much faster method for finding the error patterns that code C can
detect is to first find all error patterns that C does not detect; then all remaining error patterns can
be detected by C. Clearly, for any pair of codeword’s v and w, if then e cannot be detected, since
, which is a codeword. So the set of all error patterns that cannot be detected by C is the set of
all words that can be written as the sum of two codeword’s. There is also a way of determining
some error patterns that code C will detect without any manual checking. Firs we have to
introduce another number associated with C. For a code C containing at least two words the
distance of the code C is the smallest of the numbers as v and w range over all pairs of
different codeword’s in C. Note that since the distance of the code is the smallest value of wt
(v+w) as v and w, v≠w range over all possible codeword’s. The distance of a code has many of
the properties of Euclidean distance; this correspondence may be useful to assist in
understanding the concept of the distance of a code. Now we can state a theorem which helps to
identify many of the error patterns a code will detect.
Error-Correcting Codes:- If a word v in a code C is transmitted over a BSC and if w is received
resulting in the error pattern u=v+w, then IMLD correctly concludes that v was sent provided w
is closer to v than to any other codeword. If this occurs every times the error pattern u occurs,
regardless of which codeword is transmitted, and then we say that C corrects the error pattern u.
That is, a code C corrects the error pattern u if, for all v in C, is closer to v than to any other word
in C. So a code is said to be a t error-correcting code if it corrects all error patterns of weight at
most t and does not correct at least one error pattern of weight t+1.

Semester Project Documentation Page 15


BiT Error Control Coding 2017
How error control codes work[3]:- The block encoder takes a block of k bits and replaces it with a
k
n-bit codeword (n is bigger than k). For a binary code, there are2 possible codeword’s in the
codebook. The channel introduces errors and the received word can be any one of 2n n-bit
words of which only 2k are valid codeword’s. The job of the decoder is to find the codeword that
is closest to the received n-bit word. The decoding spheres of the Figure below will be used to
illustrate the decoding process. In the Figure each valid codeword is represented by a point
surrounded by a sphere of radius t where t is the number of errors that the code can correct. Note
that codeword’s A and B of the Figure below are separated by a distance dmin called the minimum
distance of the code. The minimum distance of a code is defined as the smallest number of places
that any two codeword’s in the codebook differ. Usually, codes with large minimum distance are
preferred because they can detect and correct more errors. First

Figure 7 Decoding Spheres of Radius t


Error Detection[3]: The minimum distance of a code gives a measure of its error detection
capability. An error control code can be used to detect al l patterns of u errors in any
codeword as long as dmin = u + 1. The code may also detect many error patterns with more
than u errors, but it is guaranteed to detect all patterns of u errors or less. We'll assume that the
error detection decoder comprises a look-up table with all valid codeword’s stored. When an n-
bit word is received by the decoder, it checks the look-up table and if this word is one of the
allowable codeword’s, it flags the n-bit word as error-free and sends the corresponding
information bits to the user. The three error detection cases are:
Case # 1: No errors. Let's assume that the encoder sends codeword C (see Figure above)

Semester Project Documentation Page 16


BiT Error Control Coding 2017
and the channel introduces no errors. Then codeword C will also be received, the decoder will
find it in the look-up table, and decoding will be successful in the case of hamming error control
technique case.
Case #2: Detectable error pattern. This time we send codeword C and the channel
introduces errors such that the n-bit word Y is received. Because Y is not a valid codeword, the
decoder will not find it in the table and will therefore flag the received n-bit word as an
erroneous codeword. The decoder does not necessarily know the number or location of the
errors, but that's acceptable because we only asked the decoder to detect errors. Since the
decoder properly detected an erroneous codeword, decoding is successful.
Case #3: Undetectable error pattern. We send codeword C for the third time and this time
the channel introduces the unlikely (but certainly possible) error pattern that converts codeword
C into codeword D. The decoder can't know that codeword C was sent and must assume that
codeword D was sent instead. Because codeword D is a valid codeword, the decoder declares the
received n-bit word error-free and passes the corresponding information bits on to the user. This
is an example of decoder failure.
Error Correction[5]:-Comparing the spheres surrounding codeword’s A and B in Figure above, we
see that the error correcting capability of a code is given by dmin = 2t +1 (this is the minimum
separation that prevents overlapping spheres). Or in other words, a code with dmin= 3 can correct
all patterns of error, one with dmin = 5 can correct all patterns of 2 errors, and so on. A code
can be used to correct t errors and detect v additional errors as long as  2t + v + 1. Three
error decoding cases for the error correction decoder are: correct decoding, decoding failure, and
error detection without correction.
Case #1: Correct decoding. Assume that codeword C is sent and the n-bit word Y is
received. Because Y is inside C's sphere, the decoder will correct all errors and error correction
decoding will be successful.
Case #2: Decoding failure. This time we send codeword C and the channel gives us n bit
word Z. The decoder has no way of knowing that codeword C was sent and must decode to D
since Z is in D's sphere. This is an example of error correction decoder failure.
Case #3: Error detection without correction. This case shows one way that an error
correction code can be used to also detect errors. We send codeword C and receive n-bit word X.

Semester Project Documentation Page 17


BiT Error Control Coding 2017
Since X is not inside any sphere, we won't try to correct it. We do, however, recognize that it is
an erroneous codeword and report this information to the user

Semester Project Documentation Page 18


BiT Error Control Coding 2017

CHAPTER THREE
SYSTEM DESING AND ANIYZING

3.1 Different classes of block code


There are different classes of block codes. Some of them are:
 Hamming code
 BCH (Bose,Chaudhuri,Hocquenghem) codes
 Reed Solomon codes
 Turbo codes
 Convolutional code and etc.
Hamming code[3]:- A Hamming code is a linear error-correcting code named after its inventor,
Richard Hamming. Hamming codes can detect up to two simultaneous bit errors, and correct
single-bit errors; thus, reliable communication is possible when the Hamming distance between
the transmitted and received bit patterns is less than or equal to one. By contrast, the simple
parity code cannot correct errors, and can only detect an odd number of errors. In mathematical
terms, Hamming codes are a class of binary linear codes. For each integer
m > 2 there is a code with m parity bits and 2m - m - 1 data bits. The parity-check matrix of a
Hamming code is constructed by listing all columns of length m that are pair wise independent.
Hamming codes are an example of perfect codes, codes that exactly match the theoretical upper
bound on the number of distinct code words for a given number of bits and ability to correct
errors.
BCH code[3]:-The BCH abbreviation stands for the discovers, Bose and Chaughuri (1960), and
independently Hocquenghem (1959). These codes are multiple error correcting codes and a
generalization of the hamming codes. They are classes of linear and cyclic block codes that can
be designed for any value of the error-correction capability up to any size error tor less. That is
they provide a maximum of t error correction among the n length received information. All their
behavior is described above on the block codes definition.
Reed Solomon code[3]:- Reed–Solomon (RS) codes are a class of linear, non-binary, cyclic
block codes. They are very effective for correcting multiple bursts of errors. All the concepts and
properties verified for binary BCH codes are also valid for these non-binary codes. All their
behavior is described above on the block codes definition.

Semester Project Documentation Page 19


BiT Error Control Coding 2017

Turbo code[3]:- This coding technique consists essentially of a parallel concatenation of two
binary convolutional codes, decoded by an iterative decoding algorithm. These codes obtain an
excellent bit error rate (BER) performance by making use of three main components. They are
constructed using two systematic convolutional encoders known as recursive systematic
convolutional (RSC) encoders, which are concatenated in parallel. In this parallel concatenation,
a random inter leaver plays a very important role as the randomizing constituent part of the
coding technique. In the structure of a turbo code, two recursive convolutional encoders are
arranged in parallel concatenation, so that each input element is encoded twice, but the input to
the Second encoder passes through a random inter leaver. This coding scheme is decoded by
means of an iterative decoder that makes the resulting BER performance to be close to the
Shannon limit.
Interleaver:- Interleaving is a widely used technique in digital communication and storage
systems .An inter leaver takes a given sequence of symbols and permutes their positions,
arranging them in a different temporal order. The basic goal of an inter leaver is to randomize
the data sequence. When used against burst errors, inter leavers are designed to convert error
patterns that contain long sequences of serial erroneous data into a more random error pattern,
thus distributing errors among many code vectors. The difficulty in linear block codes is that in
an effort to approach the theoretical limit for Shannon’s channel capacity, we need to increase
the code word length of a linear block code, this in turn causes:
 Computational complexity of a maximum likelihood decoder to increase exponential that
is we reach a point where complexity of the decoder is so high that it becomes physically
unrealizable.
Turbo code is one of the approaches proposed with large “equivalent” block lengths structured in
such a way that the decoding can be split into a number of manageable steps.
Convolutional code. Binary convolution codes are the most popular form of binary error
correcting codes and have found numerous applications: Wireless communications, digital
terrestrial and satellite communication and broadcasting systems, and space communication
systems, just to cite a few. A Convolutional code is an error correcting code that processes
information serially, or continuously, in short block lengths. A convolutional encoder has
memory, in the sense that the output symbols depend not only on the input symbols, but also on
previous inputs and /or outputs. In other words, the encoder is a sequential circuit.

Semester Project Documentation Page 20


BiT Error Control Coding 2017
3.2 Mathematical Modeling
In this section we will implement different mathematical concepts that are applicable for
each error control coding techniques. These are very important to go through our project.
Hamming code:- The Hamming single-bit correction code is implemented by adding check bits
to the output message.
Hamming encoder[3]:- Hamming codes are the first class of linear codes devised for error
correction. These codes and their aviations have been widely used for error control in digital
communication and data storage systems. For any positive m≥3,there exist a hamming code with
the following parameters:
Code length: n=2m-1
Number of information symbols: k=2m-m-1
Number of parity –check symbols: n-k=m
Error-correcting capability : t=1 (dmin=3)
The parity-check matrix H of this code consists of all the non zero m-tuples as its columns. In
systematic form, the columns of H are arranged in the following form:
H=[ ImQ]............................(3.1)
Where is an m×m identity matrix and the sub matrix Q consists of columns which are the m-
tuples of weight 2 or more . In systematic form, the generator matrix(G) of the code is
G=[QTI2m-m-1]....................(3.2)
Where is the transpose of QT and I2m-m-1 is an (2m-m-1)X(2m-m-1) identity matrix.
And to find the code word(V) to be transmitted over the transmission channel can be calculated
by multiplying the message to be transmitted (M) by the corresponding generator matrix(G).
This can be represented mathematically as follows:
V=MG.............................(3.3)
while in transmission we encounter problems due to such interferences like noise hence our
transmitted information will corrupt due to the prevailing noise in the channel.
Hamming decoder:- Here the basic task is detecting and then correcting the error happen in the
transmitted information bits, this can be done first by calculating the syndrome(S) for each code
word transmitted and then matching it to a corresponding lookup table which helps us in
identification of the error location. Hence once the error locations are identified we simply

Semester Project Documentation Page 21


BiT Error Control Coding 2017
perform a modulo 2 addition between the error location polynomials and the corrupted received
information bits(R). This can be represented mathematically as follows:
S=RHT.............................(3.4)
Where S=syndrome ,R=received vectors ,H=parity check matrix
Then we prepare a corresponding error location lookup table for the possible syndrome values.
Then after calculating the syndrome we find their corresponding error location polynomial from
the look up table.
C= e⊕R....................................(3.5)
where c =correctly received information bit ,e=error location polynomial from the lookup table
Hamming codes can be used for correcting all error patterns of single error and simultaneously
detecting all error patterns of double errors. When a single error occurs during the transmission
of a code vector, the resultant syndrome is non zero and it contains an odd number of one’s.
However, when double errors occur, the syndrome is also non zero, but it contains even number
of one’s. Based on these facts, decoding can be accomplished in the following manner:
If the syndrome S is zero, we assume that no error occurred.
If S is non zero and it contains odd number of one’s, we assume that a single error occurred.
The error pattern of a single error that corresponds to S is added to the received vector for error
correction.
If S is non zero and it contains even number of one’s, an uncorrectable error pattern has been
detected.
3.2 System Design and Analysis
3.2.1 Design of encoder
In digital communication the information from analog or digital source is transmitted in the
form of groups of bits. Each of error control coding techniques has their own algorithm of
generating code word. Code word is the group of bits which includes both the source message
and redundancy bits. The encoder adds redundancy bits to make easy for the decoder to detect
and correct errors which occur during transmission.
The channel encoder is designed to perform error correction with the aim of converting an
unreliable channel into a reliable one. On the other hand, there also exists a source encoder that
is designed to make the source information rate approaches the channel capacity. Channel

Semester Project Documentation Page 22


BiT Error Control Coding 2017
capacity represents the maximum amount of information per symbol transferred through a given
channel.
Hamming encoder:- The Hamming single-bit correction code is implemented by adding check
bits to the output message according to the following pattern:
1) The message bits are numbered from left to right, starting at 1.
2) Every bit whose number is a power of 2 (bits 1, 2, 4, 8…) is a check bit.
3) The other output message bits (bits 3, 5, 6, 7, 9…) contain the data bits, in order.
Each check bit establishes even parity over itself and a group of data bits. A data bit is in a
check bit’s group if the binary representation of the data bit’s number contains a 1 in the position
of the check bit’s weight. For instance, the data bits associated with check bit 2 are all those with
a 1 in the 2’s position of their binary bit number—bits 2, 3, 6, 7, and so forth. Here the basic task
is generating a code word which is a combination of source message bits and
the redundant or parity check bits. This is the first step in implementing the error control coding
strategies. The following diagram, which is for an 8-bit data message, illustrates this. It shows
the assignment of data bits and check bits to the bits of a12-bit output message. The horizontal
lines below the output message box have dots to indicate the assignment of output bits to check
groups. Each check group has a ones count box, with a parity bit that is inserted into the output
message.

Figure 8 Hamming code

Semester Project Documentation Page 23


BiT Error Control Coding 2017
3.2.2 Design of decoder
The design of decoders is difficult relative to that the encoder design because it involves both
detecting and correcting of the error. Here the basic task is differentiating the source information
signal from the parity bits by detecting and correcting the error bits in the code word. Hence we
are going to design the decoder in such a way that it can detect the error source information and
correcting it as fast as possible by which the receiver can receive the valid code word of the
transmitted information . This is the basic stage in error control.
3.3 Implementation
This is done in two parts:
Without noisy channel
When we implement without using noisy channel we expect to have the same information as
transmitted at the receiving end i.e. the message source is extracted from the code word without
any error.
Noisy channel ; with the addition of additive white Gaussian noise (AWGN)
Implementation with addition of AWGN may cause misinformation at the receiver end
i.e. the information transmitted at the transmitter might be corrupted and we expect the
decoder to detect and correct the errors that appear due to the addition of AWGN.

3.4 Performance comparison


We accomplished our project using mat lab software by implementing each step in progress
until we get the overall error control code. We also use the graphical user interface (GUI) to
demonstrate the performance comparison. This interface is used to show the demonstration of the
error control code clearly. Here the basic task is having a better understanding of the algorithms
important for error control code.
The performance is evaluated of a communication system disturbed by additive white
Gaussian noise (AWGN) in the channel. The performance comparison will be done by
generating bit error rate (BER) Vs signal to noise ratio (SNR) curve using Mat lab.

Semester Project Documentation Page 24


BiT Error Control Coding 2017

CHAPTER FOUR
RESULT AND DISSICUTION
The results here under shows the hamming error control coding bit error rate (probability
of error) versus signal to noise ratio under the influence of AWGN channel. There are two cases
in error control coding, these are:
 Coded condition and
 Uncoded condition
Coded condition: it is the one which have been performed by using error control coding
techniques for reliable transmission.
Uncoded condition : it is the other case which didn’t use error control coding techniques
for reliable transmission. As we see from the graphical representation of the hamming code
performance we deduce the following remarks:
Coded condition:- Here as we see from our result as we go from left to right across the x-axis
(signal to noise ratio) the probability of error reduced dramatically than that of the uncoded one.
This indicates that the detection and correction capability of the hamming error control coding
technique increase as the signal to noise ratio increases. This means when the signal to noise
ratio is very high, the signal is very strong than the noise hence it can be reproduced easily.
Hamming code works perfect for one bit error and can detect and correct all the erroneous code
words, this also demonstrated in our project. But when we introduce two bit errors it can detect
but the correction capability is rare. In addition to this when we introduce more than two bit
errors we will get the proper detection and but not correction for the introduced errors. As a
result of this we can deduce that the hamming error control coding technique works perfectly that
means for one bit error it can detect and correct the entire erroneous bit completely. In this case
we can confidentially say that hamming error control coding technique is 100% efficient for one
bit error detection and correction. And for the other bit errors that means more than one bit we
can’t get the perfection of error control capability of the hamming code like the one bit error
capability. This can be shown graphically as follows:

Semester Project Documentation Page 25


BiT Error Control Coding 2017

Figure 9 coded condition for hamming error control coding techniques

Uncoded condition
As we can see from the graph below shown we can see that for the uncoded case the probability of error
large even during large signal to noise ratio. It works better when there is no noise that means when the
signal to noise ratio is very small

Semester Project Documentation Page 26


BiT Error Control Coding 2017

Figure 10 uncoded conditions for hamming error control coding technique


Performance comparison between coded and uncoded condition
As we see from the graphical result shown below it is easy to deduce that coding condition
works better than the uncoded condition, when the signal to noise ratio is very high (i.e. when the
signal is stronger than the noise). At small SNR we see that the uncoded condition has small
probability of error than the coded one but starting at some point i.e. at the two graphs (the coded
and uncoded) cross each other. After this the coded one will have a small probability of error
than the uncoded one, hence we can deduce that for high SNR it is advisable to use error control
coding to get erroneous bit corrected and receive the transmitted signal without corruption.

Semester Project Documentation Page 27


BiT Error Control Coding 2017

Index:

red color Coded graph

blue color UN Coded graph


Figure 11 performance comparison between coded and uncoded conditions for Hamming
For hamming code the GUI we developed displays:
 It asks the user to enter The number of message to be generated display them.
 It asks the user to enter the number of errors to be introduced display it.
 The message bits generated
 The codeword generated and The received codeword
 The corrected codeword
 The number of messages corrected
 also it display BER Vs SNR graph

Semester Project Documentation Page 28


BiT Error Control Coding 2017

Figure 12 GUI for Hamming ECC Technique

Semester Project Documentation Page 29


BiT Error Control Coding 2017

CHAPTER FIVE
CONCULSION AND RECOMMUNDITION

5.1 conclusion
Form what we have done we can deduce that error control coding techniques are very essential
for the proper transmission and storage of information. Here proper design and selection of
efficient error control coding technique allow us for the proper transmission of information
without being corrupted by noise. There are different error control coding technique and each of
them have their own error detecting and correcting capability based on the number of bit errors
that have been introduced in the transmitted code word. In our project we have seen that
hamming coding technique has a perfect error detecting and correcting capability for one bit
error but it cannot correct more than one bit error.
5.2 Summary
The traditional role for error-control coding was to make a troublesome channel acceptable by
lowering the frequency of error events. The error events could be bit errors, message errors,
or undetected errors. Coding's role has expanded tremendously and today coding can do the
following:
 Reduce the occurrence of undetected errors
 Reduce the cost of communications systems
 Eliminate Interference
 Overcome Jamming
There different type of error control coding techniques such as BCH, Hamming, turbo, Reed
Solomon, convolutional and so on. Among these for this semester we have developed proper
error control coding using hamming error control coding techniques.
The major error control coding problem is to design and implement the channel
encoder/decoder pair such that:
 Information can be transmitted (or recorded) in a noisy environment as fast as Possible.
 Reliable reproduction of the information can be obtained at the output of the channel decoder.
 The cost of implementing the encoder and decoder falls within acceptable limits.

Semester Project Documentation Page 30


BiT Error Control Coding 2017
5.3 Recommendation for futures
From the very beginning error control coding has its own advantage in our daily life; hence it
is advisable for every communication system especially long distance communication links to
use efficient error control coding technique for reliable transmission of information between the
transmitter and the receiver. Now a days, Error control coding is very essential due to the
emergency of digital communication so its application get wider than before. It application
includes on military communication, satellite communication, radio transmission and the like. So
efficient use of error control coding techniques will alleviate the communication problems
happen in such areas. Since noise is the basic problem in every communication channel it
corrupts the transmitted information signal hence proper error control coding technique should
be designed to alleviate such problems that has been occurred. Now a day's most developed
countries are using efficient error control coding technique for reliable communication.

Semester Project Documentation Page 31


BiT Error Control Coding 2017

Reference
[1] John G.Prokis Masoud Salehi,"Communication Systems Engineering" ,Second Eidition,2002.
[2]. Behrouz A.Forouzan,"Data Communictions and Networking",Alan R. Apt, Fourth
Edition,2007.
[3]. Daniel J.Costello,Jr"Error Control Coding Fundamentals and Application",University of
Hawail Texas A&M University,1983.
[4]. John Wiley and Sons" Essentials Of Error-Control Coding ",University of Mar del Plata,
Argentina", Second Editions ,2006
[5]. N. Babu Anne, U. Thirunavukkarasu, Dr. S.Latifi, , (2004),“Three and Four-dimensional
Parity-check Codes for Correction and Detectionof Multiple Errors”, International Conference
on Information Technology: Coding and Computing,Volume 2, pp. 837-842.

Semester Project Documentation Page 32


BiT Error Control Coding 2017

Appendices

Appendix A: code for encoder design (using hamming error control coding technique)
m=3 % a positive integer m=3
n=2^m-1
k=2^m-m-1
p=[ 1 1 0; 0 1 1;1 1 1;1 0 1]; %parity check matrix
H=[eye(n-k) p']
G =[p eye(k)] %generator matrix
b=4 %no of bits
e1=input('enter the number of message to be sent e1 = ')
M=randint(e1,k); % message to be generated
disp('THE RANDOMLY SELECTED MESSAGE TUPLES ARE')
disp(M) ;
v=M*G;
%algorith to change the code word into 1's&0's
[a,b]=size(v);
for i=1:a;
for j=1:b;
if v(i,j)==3| v(i,j)==5| v(i,j)==7| v(i,j)==9
v(i,j)=1;
elseif v(i,j)==1
v(i,j)=1;
else
v(i,j)=0;
end
end
end
%final output
disp('the code word is:')
disp(v)

Semester Project Documentation Page 33


BiT Error Control Coding 2017

Appendix B code for channel simulation (using hamming error control coding technique)
d2=randint(1,1,[1,n]);
e=zeros(e1,n);
i=1:e1;
e(i,d2)=1;
e;
r=e+v;
[a1,b1]=size(r);
for i=1:a1;
for j=1:b1;
if r(i,j)==1|r(i,j)==3|r(i,j)==5|r(i,j)==7
r(i,j)=1;
elseif r(i,j)==1
r(i,j)=1;
else
r(i,j)=0;
end
end
end
disp('THE RECEIVED WORD IS:')
disp(r)
r

Semester Project Documentation Page 34


BiT Error Control Coding 2017
Appendix C code for decoder design (using hamming error control coding technique)
r=e+v;
s=r*H';
[a,b]=size(s);
for x=1:a;
for y=1:b;
if s(x,y)==3|s(x,y)==5|s(x,y)==7|s(x,y)==9
s(x,y)=1;
elseif s(x,y)==1
s(x,y)=1;
else
s(x,y)=0;
end
end
end
disp('the syndrome is s=')
disp(s)
% ERROR LOCATION CAN BE DETECTED BY ADDING r&v
e=r+v;
[a,b]=size(e);
for i=1:a;
for j=1:b;
if e(i,j)==2
e(i,j)=0;
elseif e(i,j)==1
e(i,j)=1;
else
e(i,j)=0;
end
end
end

Semester Project Documentation Page 35


BiT Error Control Coding 2017
disp('the error vector is e= ')
disp(e);
E=zeros(1:e1,n);
[a,b]=size(s);
for j=1:a;
n=7;
if s(j,:)==[1 0 0]
E(j,:)=[1 0 0 0 0 0 0];
elseif s(j,:)== [0 1 0]
E(j,:)=[0 1 0 0 0 0 0];
elseif s(j,:)==[0 0 1]
E(j,:)=[0 0 1 0 0 0 0];
elseif s(j,:)==[1 1 0]
E(j,:)=[0 0 0 1 0 0 0];
elseif s(j,:)==[0 1 1]
E(j,:)=[0 0 0 0 1 0 0];
elseif s(j,:)==[1 1 1]
E(j,:)=[0 0 0 0 0 1 0];
elseif s(j,:)==[1 0 1]
E(j,:)=[0 0 0 0 0 0 1];
elseif s(j,:)==[0 0 0]
E(j,:)=[0 0 0 0 0 0 0];
end
end
disp('The Error Pattern :Lookup Table is E=')
disp(E)
C=E+r;
[a,b]=size(C);
for i=1:a;
for j=1:b;
if C(i,j)==2

Semester Project Documentation Page 36


BiT Error Control Coding 2017
C(i,j)=0;
elseif C(i,j)==1
C(i,j)=1;
else
C(i,j)=0;
end
end
end
disp('The corrected code word is C= E+r')
disp(C)
message=C(:,k:n);
disp ('THE EXTRACTED MESSAGE IS')
disp(message)
disp('TO PROOF THE MESSAGE IS DETECTED SUCCESFULLY')
xor(c,v)% the zeros position indicate the information is received

Semester Project Documentation Page 37


BiT Error Control Coding 2017
Appendix D: SNR Vs BER graph
x=0:0.1:10;
k=4;
n=7;
snr=10.^ (x ./ 10);
% for coded case
x2=sqrt(k/n*snr);
pbe=1.2247*(erfc(x2));
pbe=(pbe).^2;
semilogy (x,pbe,'red')% creates a plot using a base 10 logarithmic scale
for the y-axis and a linear scale for the x-axis.
grid on;
xlabel('SNR (dB)');
ylabel('Bit error rate')
title('BER vs SNR under AWGN channel')
hold on
% for uncoded case
pbe1=0.5*(erfc(sqrt(snr)));
semilogy (x,pbe1,'blue')
hold off

Semester Project Documentation Page 38


BiT Error Control Coding 2017
Appendix E: Graphical User interface (GIU)
function varargout = gui(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui_OpeningFcn, ...
'gui_OutputFcn', @gui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function gui_OpeningFcn(hObject, ~, handles, varargin)
handles.output = hObject;

% Update handles structure


guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = gui_OutputFcn(hObject, eventdata, handles)
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

Semester Project Documentation Page 39


BiT Error Control Coding 2017

function edit4_Callback(hObject, eventdata, handles)


function edit4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
function edit6_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
function edit7_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit10_Callback(hObject, eventdata, handles)
function edit10_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit9_Callback(hObject, eventdata, handles)
function edit9_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit11_Callback(hObject, eventdata, handles)
function edit11_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))

Semester Project Documentation Page 40


BiT Error Control Coding 2017
set(hObject,'BackgroundColor','white');
end
function edit12_Callback(hObject, eventdata, handles)
function edit12_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit13_Callback(hObject, eventdata, handles)
function edit13_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit14_Callback(hObject, eventdata, handles)
function edit14_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit15_Callback(hObject, eventdata, handles)
function edit15_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit17_Callback(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit18_Callback(hObject, eventdata, handles)
function edit18_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

Semester Project Documentation Page 41


BiT Error Control Coding 2017
function edit19_Callback(hObject, eventdata, handles)
function edit19_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function slider1_Callback(hObject, eventdata, handles)
function slider1_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function slider2_Callback(hObject, eventdata, handles)
function slider2_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function slider3_Callback(hObject, eventdata, handles)
function slider3_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function slider4_Callback(hObject, eventdata, handles)
function slider4_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function pushbutton1_Callback(hObject, eventdata, handles)
m=3 % a positive integer m=3
[H,G,n,k]=hammgen(m);
b=4 %no of bits
% e1=input('enter the number of message to be sent e1 = ');%%%%%.....1
messg=get(handles.edit6,'string');
e1=str2num(messg);

Semester Project Documentation Page 42


BiT Error Control Coding 2017
%%%===========Encoder side====================
M=randint(e1,k); % message to be generated
set(handles.edit9,'string',...
num2str(M));%%%%......................2
disp('THE RANDOMLY SELECTED MESSAGE TUPLES ARE');
disp(M) ;

v=M*G;
%algorith to change the code word into 1's&0's
[a,b]=size(v);
for i=1:a;
for j=1:b;
if v(i,j)==3| v(i,j)==5| v(i,j)==7| v(i,j)==9
v(i,j)=1;
elseif v(i,j)==1
v(i,j)=1;
else
v(i,j)=0;
end
end
end
%final output
set(handles.edit12,'string',...
num2str(v));%................3
disp('the code word is:');
disp(v);

%%%==========decoder side============
d2=randint(1,1,[1,n]);
e=zeros(e1,n);
i=1:e1;
e(i,d2)=1;
e;
v;
r=e+v;
Semester Project Documentation Page 43
BiT Error Control Coding 2017
[a1,b1]=size(r);
for i=1:a1;
for j=1:b1;
if r(i,j)==2|r(i,j)==4|r(i,j)==6|r(i,j)==8
r(i,j)=0;
elseif r(i,j)==0
r(i,j)=0;
else
r(i,j)=1;
end
end
end
set(handles.edit14,'string',...
num2str(r));%%...............4
disp('THE RECEIVED WORD IS:');
disp(r);

%%%==========decoder side part 2============


r=e+v;
s=r*H';
[a,b]=size(s);
for x=1:a;
for y=1:b;
if s(x,y)==3|s(x,y)==5|s(x,y)==7|s(x,y)==9
s(x,y)=1;
elseif s(x,y)==1
s(x,y)=1;
else
s(x,y)=0;
end
end

Semester Project Documentation Page 44


BiT Error Control Coding 2017
end
disp('the syndrome is s=')
disp(s)
% ERROR LOCATION CAN BE DETECTED BY ADDING r&v
e=r+v;
[a,b]=size(e);
for i=1:a;
for j=1:b;
if e(i,j)==2
e(i,j)=0;
elseif e(i,j)==1
e(i,j)=1;
else
e(i,j)=0;
end
end
end
disp('the error vector is e= ')
disp(e);
E=zeros(1:e1,n);
[a,b]=size(s);
for j=1:a;
n=7;
if s(j,:)==[1 0 0]
E(j,:)=[1 0 0 0 0 0 0];
elseif s(j,:)==[0 1 0]
E(j,:)=[0 1 0 0 0 0 0];
elseif s(j,:)==[0 0 1]
E(j,:)=[0 0 1 0 0 0 0];
elseif s(j,:)==[1 1 0]
E(j,:)=[0 0 0 1 0 0 0];

Semester Project Documentation Page 45


BiT Error Control Coding 2017
elseif s(j,:)==[0 1 1]
E(j,:)=[0 0 0 0 1 0 0];
elseif s(j,:)==[1 1 1]
E(j,:)=[0 0 0 0 0 1 0];
elseif s(j,:)==[1 0 1]
E(j,:)=[0 0 0 0 0 0 1];
elseif s(j,:)==[0 0 0]
E(j,:)=[0 0 0 0 0 0 0];
end
end
disp('The Error Pattern :Lookup Table is E=')
disp(E)
C=E+r;
[a,b]=size(C);
for i=1:a;
for j=1:b;
if C(i,j)==2
C(i,j)=0;
elseif C(i,j)==1
C(i,j)=1;
else
C(i,j)=0;
end
end
end
set(handles.edit17,'string',...
num2str(C));%%.........................5
disp('The corrected code word is C= E+r')
disp(C);
message=C(:,k:n);
set(handles.edit19,'string',...

Semester Project Documentation Page 46


BiT Error Control Coding 2017
num2str(C(:,k:n)));%%%...............6
disp ('THE EXTRACTED MESSAGE IS')
disp(message)
disp('TO PROOF THE MESSAGE IS DETECTED SUCCESFULLY')
diff(C-v)% the zeros position indicate the information is received
%%%===========graph SNR Vs BER==============
x=0:0.1:10;
k=4;
n=7;
snr=10.^ (x ./ 10);
% for coded case
x2=sqrt(k/n*snr);
pbe=1.2247*(erfc(x2));
pbe=(pbe).^2;

semilogy (x,pbe,'red')% creates a plot using a base 10 logarithmic scale for the y-axis and a
linear scale for the x-axis.
grid on;
xlabel('SNR (dB)');
ylabel('Bit error rate')
title('BER vs SNR under AWGN channel')
hold on
% for uncoded case
pbe1=0.5*(erfc(sqrt(snr)));
semilogy (x,pbe1,'blue')
surf(handles.axes1,semilogy (x,pbe,'red'),semilogy (x,pbe1,'blue'));
hold off

Semester Project Documentation Page 47


BiT Error Control Coding 2017

Semester Project Documentation Page 48

Potrebbero piacerti anche