You are on page 1of 15

Experiment 1

Objective: To design a two-way traffic light control system.


Software Required: PROTEUS DESIGN SUITE.
Theory: A two-way traffic light model is basically traffic signal controller that is designed
for two directions traffic. It controls 6 lights (2 red, 2 yellow and 2 green) for 2-way traffic.
Here, in this experiment we use AT89C51 8-bit micro-controller from Atmel family for
controlling the traffic lights. AT89C51 is based on 8051 microcontroller architecture is a 40
pin IC package with 4Kb flash memory and 128 bytes RAM. It has four ports each 8 bits and
all together they provide 32 programmable GPIO pins. The operating temperature range of
this microcontroller varies between -55°C to 125°C.
Proteus: The Proteus Design Suite is a proprietary software tool suite used primarily
for electronic design automation, creating schematics and electronic prints. It was developed
in Yorkshire, England by Labcenter Electronics Ltd. Schematic capture in the Proteus Design
Suite is used for both the simulation of designs and as the design phase of a PCB layout
project.
Source Code:
#include <reg51.h> // 8051 Architecture Header file.
#include <stdio.h> // Standard Input Output Header file.
#define t1 P1 // Definition of whole Port of micro-controller as GPIO.
#define t2 P3
void d(unsigned int itime) // Creating Delay function.
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
void main(void) // Main program.
{
while (1) // Infinite loop.
{
t1=0x94; t2=0x01; d(150);
t1=0x84; t2=0x11; d(150);

Department of ECE, MRSPTU Bathinda 1


t1=0x74; t2=0x21; d(150);
t1=0x64; t2=0x31; d(150);
t1=0x54; t2=0x41; d(150);
t1=0x44; t2=0x51; d(150);
t1=0x32; t2=0x61; d(150);
t1=0x22; t2=0x72; d(150);
t1=0x12; t2=0x82; d(150);
t1=0x01; t2=0x92; d(150);
t1=0x11; t2=0x04; d(150);
t1=0x21; t2=0x94; d(150);
t1=0x31; t2=0x84; d(150);
t1=0x41; t2=0x74; d(150);
t1=0x51; t2=0x64; d(150);
t1=0x61; t2=0x54; d(150);
t1=0x71; t2=0x44; d(150);
t1=0x82; t2=0x32; d(150);
t1=0x92; t2=0x22; d(150);
t1=0x04; t2=0x12; d(150);
t1=0x04; t2=0x01; d(150);
t1=0x00; t2=0x00; d(150);
}
}

Conclusion: The two-way traffic light system is designed using Proteus Design Suite and
it can be seen that both channels open one after another following a specific period of time.

Department of ECE, MRSPTU Bathinda 2


Experiment 2
Objective: To study the encoding and decoding of data using Huffman Coding.
Software Used: MATLAB 2018a.
Theory: The information theory is related to the concepts of statistical properties of
messages or sources, channels, noise interference etc. The information theory is used for
mathematical modelling and analysis of the communication systems, following two main
points are resolved:
i. The irreducible complexity below which the signal cannot be compressed.
ii. The transmission rate for reliable communication over a noisy channel.

Huffman coding also uses the same principle. This type of coding makes average number of
binary digits per message nearly equal to Entropy (average bits of information per message).
This is a variable length and prefix free coding. So there are different length code words and
no code words are prefix of others. It gives the advantages of variable length and prefix free
coding like - required less bandwidth. The main application of Huffman coding arises in
image compression.

Program:
clear all;
close all;
symbol = [1:6];% Create a vector of data symbols.
p = [0.05 0.10 0.10 0.15 0.25 0.35]; % Assign a probability to each vector
of data symbols.
[dict,avglen] = huffmandict(symbol,p) % Generates a binary Huffman code
dictionary using maximum variance algorithm.
dict{1,:}%Displaying Huffman code dictionary for 1st data symbol.
dict{2,:}%Displaying Huffman code dictionary for 2nd data symbol.
dict{3,:}%Displaying Huffman code dictionary for 3rd data symbol.
dict{4,:}%Displaying Huffman code dictionary for 4th data symbol.
dict{5,:}%Displaying Huffman code dictionary for 5th data symbol.
dict{6,:}%Displaying Huffman code dictionary for 6th data symbol.
hcode = huffmanenco(symbol,dict);% Encodes the signal using the Huffman
codes described by the code dictionary.
dhsig = huffmandeco(hcode,dict);% Decodes the numeric Huffman code vector
using the code dictionary.
disp('Encoded Message:');

Department of ECE, MRSPTU Bathinda 3


disp(hcode);% Displaying Encoded Message.
disp('Decoded Message:');
disp(dhsig);% Displaying Decoded Message.
Hx=0;
code_length = length(hcode)%Finding the length of Encoded Message.
for m = 1:6
H = Hx+(p(m)*log2(1/p(m)));% Formulae for Entropy Calculation.
Hx=H;
end
disp('Hx=');
disp(H);%Displaying Entropy.
Efficiency=(Hx/avglen)*100;%Calculating Efficiency.
disp('Efficiency=');
disp(Efficiency);%Displaying Efficiency.

Conclusion: From the study of Huffman Encoding and Decoding on two code-word it is
found that the symbol having minimum probability gets the code with more number of bits
and symbol having higher probability gets the code with less number of bits.

Department of ECE, MRSPTU Bathinda 4


Experiment 3
Objective: To study the effect of BER and SNR on M-PSK modulation scheme over
AWGN channel.
Software Used: Simulink in MATLAB 2018a.
Theory:
Bit Error Rate(BER): The bit error rate is the number of bit errors per unit time. The
number of bit errors is the number of received bits of a data stream over a communication
channel that have been altered due to noise, interference, distortion or bit synchronization
errors.
Signal-to-noise ratio(SNR): Signal-to-noise ratio is a measure used in science and
engineering that compares the level of a desired signal to the level of background noise. SNR
is defined as the ratio of signal power to the noise power, often expressed in decibels.
AWGN: Additive white Gaussian noise is a basic noise model used in Information theory to
mimic the effect of many random processes that occur in nature. Additive means the noise is
superimposed or added to the signal, White means the spectrum of the noise is flat for all
frequencies and Gaussian means the values of the noise follow the Gaussian probability
distribution function.
BPSK: Binary Phase Shift Keying is the simplest form of phase shift keying (PSK). It uses
two phases which are separated by 180° and so can also be termed 2-PSK. This modulation is
the most robust of all the PSKs since it takes the highest level of noise or distortion to make
the demodulator reach an incorrect decision.
QPSK: Quadrature phase shift keying is another extension of the PSK digital modulation
technique is the division of the phase of the carrier signal designed by allotting four equally
spaced values for the phase angle 0, 90, 180 and 270 degrees. The QPSK has four message
points in the constellation diagram and so it becomes a highly bandwidth efficient digital
modulation technique.
8PSK: A 8-PSK scheme would utilize a symbol containing three data bits to shift the phase
of a Carrier by 8 distinct amounts.
16PSK: A 16-PSK scheme would utilize a symbol containing four data bits to shift the phase
of a carrier by 16 distinct amounts. As value of M increases, the error probability also
increases over AWGN channel.

Department of ECE, MRSPTU Bathinda 5


Parameters Table:

S.No. Name of the Block Name of the M-PSK


parameter
1 Bernoulli Binary Probability of a zero 0.5
Generator
Initial Seed 61
Sample Time 1
Output Datatype double
2 M-PSK Modulator M-ary Number 2,4,8,16,32
Baseband Phase Offset (rad) Pi/8
Input Type Integer
Output Datatype Double
3 AWGN Channel Initial Seed 67
Mode Signal to noise ratio
(Eb/No)
Eb/No (dB) 2-20
Number of bits per 1
symbol
Input Signal Power 1W
Symbol Period (s) 1
4 M-PSK Demodulator M-ary Number 2,4,8,16,32
Baseband Phase Offset (rad) Pi/8
Output Type Integer
Output Datatype Double
5 Error Rate calculation Receive delay 0
Computational Delay 0
Computation Mode Entire Frame
Output Data Port
6 Display Format Short
Decimation 1

Conclusion: From the obtained result we conclude that the Bit Error Rate for the M-ary
PSK modulation techniques decrease monotonically with increasing values of SNR(Eb/N0).
It is clearly observed from the simulation curves that as the number of signals or number of
M increases, the error probability also increases over AWGN channel. Thus higher-order
modulations exhibit higher error-rates.

Department of ECE, MRSPTU Bathinda 6


Experiment 4
Objective: To design a Fuzzy Inference System for deciding the waiter tip.
Software Used: MATLAB 2018a.
Theory: Fuzzy logic is an approach to computing based on "degrees of truth" rather than the
usual "true or false" (1 or 0) Boolean logic on which the modern computer is based. The truth
values of variables may be any real number between 0 and 1 both inclusive. It is employed to
handle the concept of partial truth, where the truth value may range between completely true
and completely false. Here, in this experiment we use three input parameters (Ambiance,
Quality of Service, Quality of Food) and Waiter-Tip as output.
Rule Base:

S.No. Ambiance QoS QoF Tip


1 Bad Slow Bad Very Low
2 Bad Slow Normal Very Low
3 Bad Slow Good Low
4 Bad Normal Bad Very Low
5 Bad Normal Normal Medium
6 Bad Normal Good Medium
7 Bad Satisfactory Bad Medium
8 Bad Satisfactory Normal Medium
9 Bad Satisfactory Good High
10 Normal Slow Bad Very Low
11 Normal Slow Normal Low
12 Normal Slow Good Medium
13 Normal Normal Bad Low
14 Normal Normal Normal Medium
15 Normal Normal Good High
16 Normal Satisfactory Bad Medium
17 Normal Satisfactory Normal Medium
18 Normal Satisfactory Good High
19 Good Slow Bad Very Low
20 Good Slow Normal Low
21 Good Slow Good Medium
22 Good Normal Bad Low
23 Good Normal Normal Medium
24 Good Normal Good High
25 Good Satisfactory Bad Medium
26 Good Satisfactory Normal High
27 Good Satisfactory Good Very High

Department of ECE, MRSPTU Bathinda 7


De-fuzzification: De-fuzzification may be defined as the process of reducing a fuzzy set into
a crisp set or to convert a fuzzy member into a crisp member. The different methods of
Defuzzification are
1. Max-Membership Method
2. Centroid Method
3. Weighted Average Method
4. Mean-Max Membership

The most commonly used de-fuzzification method is the centre of area method (COA), also
commonly referred to as the centroid method. This method determines the center of area of
fuzzy set and returns the corresponding crisp value.

Conclusion: The FIS is designed for deciding the waiter tip using parameters ambiance,
quality of service, quality of food.

Department of ECE, MRSPTU Bathinda 8


Experiment 5

Objective: To study various functions of Contrast Adjustment in Image Processing Toolbox


in MATLAB.
Software Used: MATLAB 2018a.
Theory: Image enhancement techniques are used to improve an image, where “improve” is
sometimes defined objectively (e.g., increase the signal-to-noise ratio), and sometimes
subjectively (e.g., make certain features easier to see by modifying the colours or intensities).
Intensity adjustment is an image enhancement technique that maps an image’s intensity
values to a new range.
Contrast is the difference in luminance or colour that makes an object (or its
representation in an image or display) distinguishable. In visual perception of the real world,
contrast is determined by the difference in the colour and brightness of the object and other
objects within the same field of view. An image lacks contrast when there are no sharp
differences between black and white. Brightness refers to the overall lightness or darkness of
an image. To change the contrast or brightness of an image, the Adjust Contrast tool performs
contrast stretching. In this process, pixel values below a specified value are mapped to black
and pixel values above a specified value are mapped to white. The result is a linear mapping
of a subset of pixel values to the entire range of display intensities (dynamic range). This
produces an image of higher contrast by darkening pixels whose value is below a specified
value and lightening pixels whose value is above a specified value. The Adjust Contrast tools
adjust brightness by moving this window over the display range, without changing its size. In
this way, the pixel values map to lighter or darker intensities.
The process of adjusting intensity values can be done automatically using histogram
equalization. Histogram equalization involves transforming the intensity values so that the
histogram of the output image approximately matches a specified histogram. By default, the
histogram equalization function, histeq, tries to match a flat histogram with 64 bins, but we
can specify a different histogram instead
Coding:
I=imread('baby.jpg');%Reads the image from the file specified
by filename.
figure('color','white');%Sets the background color to white.
subplot(1,2,1);imshow(I);

Department of ECE, MRSPTU Bathinda 9


a=rgb2gray(I);%Converts RGB image into Grayscale image.
subplot(1,2,2);imshow(a);
figure('color','white');
subplot(1,2,1);imshow(a);
subplot(1,2,2);imhist(a);%Shows histogram
b=imadjust(a,[0.001 0.99],[.1 .9]);%Adjust image intensity
values.
figure('color','white');
subplot(1,2,1);imshow(b);
subplot(1,2,2);imhist(b);
c=histeq(b);%Enhance contrast using histogram equalization.
figure('color','white');
subplot(1,2,1);imshow(c);
subplot(1,2,2);imhist(c);

Conclusion: From the study of various functions of Contrast Adjustment in the input
image baby.jpg it can be concluded that the original image has low contrast and most of the
pixel values in middle of the intensity range. Histogram equalisation produces an output
image with pixel values evenly distributed throughout the range.

Department of ECE, MRSPTU Bathinda 10


Experiment 6
Objective: To study the working of a ripple counter using Multisim software.
Software Used: Multisim 14.1
Theory: A ripple counter is an asynchronous counter where only the first flip-flop is
clocked by an external clock. All subsequent flip-flops are clocked by the output of the
preceding flip-flop. Asynchronous counters are also called ripple-counters because of the way
the clock pulse ripples it way through the flip-flops.
The MOD of the ripple counter or asynchronous counter is 2n if n flip-flops are used. For a 4-
bit counter, the range of the count is 0000 to 1111 (24-1). A counter may count up or count
down or count up and down depending on the input control. The count sequence usually
repeats itself. When counting up, the count sequence goes from 0000, 0001, 0010, ... 1110,
1111, 0000, 0001, ... etc. When counting down the count sequence goes in the opposite
manner: 1111, 1110, ... 0010, 0001, 0000, 1111, 1110, ... etc.
The complement of the count sequence counts in reverse direction. If the un-complemented
output counts up, the complemented output counts down. If the un-complemented output
counts down, the complemented output counts up.
There are many ways to implement the ripple counter depending on the characteristics of the
flip flops used and the requirements of the count sequence.
1. Clock Trigger: Positive edged or Negative edged
2. JK or D flip-flops
3. Count Direction: Up, Down, or Up/Down
Asynchronous counters are slower than synchronous counters because of the delay in the
transmission of the pulses from flip-flop to flip-flop.

Conclusion: The 4-bit ripple counter circuit is designed and simulated in multisim
software and it is able to count from 0 to F.

Department of ECE, MRSPTU Bathinda 11


Experiment 7
Objective: To study the working of an up-down counter using Multisim software.
Software Used: Multisim 14.1
Theory: In asynchronous counter, a clock pulse drives FF0. Output of FF0 drives FF1
which then drives the FF2 flip flop. All J and K inputs are connected to Logic 1. Therefore,
each flip flop will toggle with negative transition at its clock input.
The 3-bit MOD-8 asynchronous counter consists of 3 JK flip flops. Overall propagation delay
time is the sum of individual delays. Initially all flip flops are reset to produce 0. The output
condition is Q2Q1Q0 = 000.

When the first clock pulse is applied, the FF0 changes state on its negative edge. Therefore,
Q2Q1Q0 = 001. On the negative edge of second clock pulse flip flop FF0 toggles. Its output
changes from 1 to 0. This being negative change, FF1 changes state. Therefore, Q2Q1Q0 =
010. Similarly, the output of flip-flop FF2 changes only when there is negative transition at
its input when fourth clock pulse is applied.

The output of the flip flops is a binary number equivalent to the number of clock pulses
received. On the negative edge of eighth pulse, counter is reset.

The counter acts as a frequency divider. FF0 divides clock frequency by 2, FF1 divides clock
frequency by 4, FF2 divides clock frequency by 8. If n flip flops are cascaded, we get 2 n
output conditions. The largest binary number counted by n cascaded flip flops has a decimal
equivalent of 2n-1. MOD-8 counter has count of the largest binary number 111 which has
decimal equivalent of 23-1=7

Conclusion: The 3-bit up down counter circuit is designed and simulated in Multisim and
it is clear from the output result shown in fig. 7.2 that the circuit is able to count up and down
simultaneously up to 7.

Department of ECE, MRSPTU Bathinda 12


Experiment 8

Objective: To study the impact of Low Frequency and High Frequency components on
quality of image using different wavelets.
Software Used: MATLAB 2018a.
Theory: Images contain large amounts of information that requires much storage space,
large transmission bandwidths and long transmission times. Therefore, it is advantageous to
compress the image by storing only the essential information needed to reconstruct the image.
Wavelet analysis can be used to divide the information of an image into approximation and
detail sub-signals. The approximation sub-signal shows the general trend of pixel values, and
three detail sub-signals show the vertical, horizontal and diagonal details or changes in the
image. For a two dimensional images, the approach of the 2D implementation of the discrete
wavelet transform(DWT) is to perform the one dimensional DWT in row direction and it is
followed by a one dimensional DWT in column direction as shown in fig 7.1. LL is a coarser
version of the original image and it contains the approximation information which is low
frequency, LH, HL, and HH are the high frequency sub-band containing the detail
information.

Fig. 8.1(b) 2D row and column computation of DWT.

Wavelet: Wavelets are mathematical functions that cut up data into different frequency
components, and then study each component with a resolution matched to its scale. These
basis functions are short waves with limited duration, thus the name 'wavelets' is used. The
basic functions of the Wavelet Transform are scaled with respect to frequency. Several
families of wavelets that have proven to be especially useful are:
1. Haar: The Haar wavelet is discontinuous, and resembles a step function. It represents the
same wavelet as Daubechies db1.

2. Daubechies: Ingrid Daubechies, one of the brightest stars in the world of wavelet
research, invented what are called compactly supported orthonormal wavelets — thus
making discrete wavelet analysis practicable. The names of the Daubechies family
wavelets are written dbN, where N is the order, and db the “surname” of the wavelet. The
db1 wavelet, as mentioned above, is the same as Haar wavelet.

Department of ECE, MRSPTU Bathinda 13


Biorthogonal: This family of wavelets exhibits the property of linear phase, which is
needed for signal and image reconstruction. By using two wavelets, one for
decomposition (on the left side) and the other for reconstruction (on the right side) instead
of the same single one, interesting properties are derived.

3. Coiflets: Built by I. Daubechies at the request of R. Coifman. The wavelet function has
2N moments equal to 0 and the scaling function has 2N-1 moments equal to 0. The two
functions have a support of length 6N-1.

4. Symlets: The symlets are nearly symmetrical wavelets proposed by Daubechies as


modifications to the db family. The properties of the two wavelet families are similar.

Mean Square Error(MSE): It is the cumulative squared error between the original image
and the noise added image. The lower the level of MSE, lower the error.

Here M and N are the number of rows and columns in the input image respectively. Hence, to
evaluate PSNR firstly MSE value should be calculated.

Peak Signal to Noise Ratio(PSNR) and signal to noise ratio(SNR) are mathematical
measure for image quality assessment between original image and noise added image. It
shows the measure of peak error.

Here MAX is maximum fluctuation in input image data type. PSNR measures the peak error.

Program for PSNR and MSE calculation:


InputImage=imread(‘cameraman.tif’);
SynthesizedImage=imread(‘synthesizedimage.jpg’);
n=size(InputImage);
M=n(1);
N=n(2);
MSE=sum(sum((InputImage-SynthesizedImage).^2))/(M*N);
PSNR=10*log10(256*256/MSE);

Department of ECE, MRSPTU Bathinda 14


fprintf(‘\nMSE: %7.2f’,MSE);
fprintf(‘\nPSNR: %9.7f dB’,PSNR);
Observation table:
1. PSNR and MSE calculation using Level 1 db wavelet for given input image.

Image Level 1 & db Wavelet PSNR(dB) MSE Size (KB)


Cameraman.tif A1 = 100% D1 = 100% 40.42 5.94 11.2
(256 x 256) A1 = 50% D1 = 100% 29.45 74.31 15.1
Size = 63.7KB
A1 = 0% D1 = 100% 25.15 200.00 15.3
A1 = 100% D1 = 50% 39.85 6.77 11.2
A1 = 100% D1 = 0% 37.35 12.06 10.6

2. PSNR and MSE calculation using Level 1 sym wavelet for given input image.

Image Level 1 & sym Wavelet PSNR(dB) MSE Size (KB)


Cameraman.tif A1 = 100% D1 = 100% 40.42 5.94 11.2
(256 x 256) A1 = 50% D1 = 100% 29.79 68.75 15.2
Size = 63.7KB
A1 = 0% D1 = 100% 25.22 196.93 14.9
A1 = 100% D1 = 50% 40.38 5.99 11.2
A1 = 100% D1 = 0% 37.42 11.85 10.4

3. PSNR and MSE calculation using Level 1 bior wavelet for given input image.

Image Level 1 & biorWavelet PSNR(dB) MSE Size (KB)


Cameraman.tif A1 = 100% D1 = 100% 40.42 5.94 11.2
(256 x 256) A1 = 50% D1 = 100% 31.38 47.42 15.8
Size = 63.7KB
A1 = 0% D1 = 100% 25.38 189.65 16.1
A1 = 100% D1 = 50% 40.43 5.93 11.2
A1 = 100% D1 = 0% 38.17 9.98 10.6

Conclusion: From the above obtained results it can be concluded that most of the
significant information of an image is stored in its low frequency component and the bior
wavelet gives better PSNR and MSE values for the input image ‘ cameraman.tif ’ than db and
sym wavelet.

Department of ECE, MRSPTU Bathinda 15

You might also like