Lab Report-2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

LAB REPORT-2

Name: Penukonda Chandana


Roll Number: 2021102006
Group Number: 7
Objective:
● To get familiarized with Logic gates
● To understand De Morgan’s law
● To implement a full adder circuit using the gates

Part A: Logic levels


Aim:
● To familiarise with logic gates
● To find the logic levels of input and output voltages for HIGH and LOW
Electronic components used:
● Arduino UNO
● Breadboard
● NOT logic gate IC
● Potentiometer
● Multimeter
● 2 Resistors (1 kΩ)
● 2 Red LEDs
● Wires

Reference Circuit:
Procedure:
1) Open TinkerCAD on the browser and start a new project.
2) Find the required components in the TinkerCAD library and place them
in the workspace. NOT gate is available as 74hc04 IC.
3) Connect the 5V arduino pin to the positive and GND(ground) to the negative terminal
of the breadboard.
4) Connect pin 7(ground) of NOT gate to -ve terminal and power of NOT gate to +ve
terminal.
5) Connect an LED along with a resistor to the input 1 of the NOT gate and another LED
along with a resistor to the output of the NOT gate.
6) As per the reference circuit connect the potentiometer and voltmeters/multimeters.
7)Click on “Start Simulation”.
8) Turn the potentiometer shaft to one end until the input multimeter reads 0V. The output
LED must be glowing.
9) Now slowly rotate the potentiometer shaft to the other end. Now input LED must be
glowing.
10) Find the tipping voltages and voltage ranges for the IC which it considers to be HIGH
or LOW for both INPUT and OUTPUT.
11) Compare these voltages with the specifications for binary logic level for a 0-5 V
range.
0 ≤ VOL ≤ 0.4, 0 ≤ VIL ≤ 0.8, 2.0 ≤ VIH ≤ 5.0, 2.4 ≤ VOH ≤ 5.0

Conclusion:
As we keep turning the potentiometer shaft the LEDs keep glowing ON and OFF
simultaneously. When the input voltage is HIGH then the output LED is OFF. When the
input voltage is LOW then the output LED is ON.

Link of the TinkerCAD Simulation:


https://www.tinkercad.com/things/3mBsxWyMNgJ-lab-2-a/editel?sharecode=rG5bNx7cF
2cZ-PaEFym2Nk_IjCK_6md6dLcQVlhF9MY
Part B:Verifying the truth table of Logic Gates

Aim:
● To familiarise with logic gates.
● To verify the truth table of AND, OR, NAND, NOR, NOT, XOR logic gates

Electronic components used:


● Arduino UNO
● Breadboard
● AND, OR, NAND, NOR, NOT, XOR logic gates IC
● Resistor (1 kΩ)
● Red LED
● Wires

Reference Circuit:

Procedure:
1) Open TinkerCAD on the browser and start a new project.
2) Find the required components in the TinkerCAD library and place them
in the workspace. AND gate is available as 74hc08 IC.
3) Connect the 5V arduino pin to the positive and GND(ground) to the negative terminal
of the breadboard.
4) Connect pin 7(ground) of AND gate to -ve terminal and pin 14 of AND gate to +ve
terminal.
5) Connect an LED with a resistor to the output of the gate.
6) Take inputs from the Serial Monitor for values x & y and route them to the input pins
of the IC and type the code:

int A = 0 ;
int B = 0 ;

int pin2 = 2 ;
int pin3 = 3 ;

int x,y ;

void setup()
{
pinMode(pin2,OUTPUT) ;
pinMode(pin3,OUTPUT) ;
Serial.begin(9600) ;
}

void loop()
{
Serial.print("\n x = " );
while(Serial.available() == 0)
{
}
x = Serial.read() ;
x = x - '0' ;
Serial.println(x) ;
Serial.print("\n y = " );
while(Serial.available() == 0)
{
}
y = Serial.read() ;
y = y - '0' ;
Serial.println(y) ;
digitalWrite(pin2,x) ;
digitalWrite(pin3,y) ;
while(Serial.available() == 0)
{
}
A = Serial.read() ;
}

7) Click on “Start Simulation” and enter the input values in the serial monitor and note
the output observed in a truth table.
8) Note that LED turning OFF corresponds to 0 and turning ON corresponds to 1.
9) Repeat the same process with the other logic gates.

Conclusion:
We get the given truth table and we observe that it matches the truth table of the chosen
gate i.e. the logic gate behaves accordingly.

AND gate

x y x.y

0 0 0

0 1 0

1 0 0

1 1 1

Link of the TinkerCAD Simulation:


https://www.tinkercad.com/things/kwiY1ovtYN7-lab-2-b-and-gate/editel?sharecode=gFu
fr88mWjFOgV9Sk8CJ_4HVyqn6rtn3TRziIqaQkb8

OR gate

x y x+y

0 0 0

0 1 1

1 0 1

1 1 1
Link of the TinkerCAD Simulation:
https://www.tinkercad.com/things/fsSWZDW479f-lab-2-b-or-gate/editel?sharecod
e=M2JT7-tlRiiTdCxUDtvhSKhcItKppGINbKFbOZ18gAE

NOR gate

x y (x+y)’

0 0 1

0 1 0

1 0 0

1 1 0

Link of the TinkerCAD Simulation:


https://www.tinkercad.com/things/k6VE4s3gbIC-lab-2-b-nor-gate/editel?shar
ecode=oLX276YGkyJ4chadMgybKTIlzoLxDu325nfjd6tWyoo

NAND gate

x y (x.y)’

0 0 1

0 1 1

1 0 1

1 1 0

Link of the TinkerCAD Simulation:


https://www.tinkercad.com/things/0cpiAuqfxlh-lab-2-b-nand-gate/editel?shar
ecode=UyrcOA3g44jtjg-yGQhzMQvum0x_Z9XsBIY6s44D0rE

XOR gate

x y x.y’+x’.y

0 0 0
0 1 1

1 0 1

1 1 0

Link of the TinkerCAD Simulation:


https://www.tinkercad.com/things/lXVg1ARwR1o-lab-2-b-xor-gate/editel?sh
arecode=WAiG5NH_6q_IkY6N-kR-dBRbllkf2Lw5mnDZGgjYcq8

NOT gate

x x’

0 1

1 0

Link of the TinkerCAD Simulation:


https://www.tinkercad.com/things/hUhQ9UJFygB-lab-2-b-not-gate/editel?sharecod
e=_Gg_606XxMASnpamVBmSn0BKGEDXgehmU_XxUFVo1mc

Aim:
● To verify De Morgan’s theorems:
(A+B)’=A’.B’ & (A.B)’=A’+B’

Electronic components used:


● Arduino UNO
● Breadboard
● AND, OR, NOT logic gates IC
● 2 Resistors (1 kΩ)
● 2 Red LEDs
● Wires

Reference Circuit:
Procedure:
1) Open TinkerCAD on the browser and start a new project.
2) Find the required components in the TinkerCAD library and place them
in the workspace.
3) Connect the 5V arduino pin to the positive and GND(ground) to the negative terminal
of the breadboard.
4) Give pin 2 and pin 3 as input from arduino to the NOT gate.
5) Connect the outputs from the NOT gate as inputs to the AND gate and OR gate.
6) Connect the output from AND gate to an LED along with a resistor and the output
from OR gate to another LED along with resistor.
7) Enter the code:

int A = 0 ;
int B = 0 ;

int pin2 = 2 ;
int pin3 = 3 ;

int x,y ;

void setup()
{
pinMode(pin2,OUTPUT) ;
pinMode(pin3,OUTPUT) ;
Serial.begin(9600) ;
}
void loop()
{
Serial.print("\n x = " );
while(Serial.available() == 0)
{
}
x = Serial.read() ;
x = x - '0' ;
Serial.println(x) ;
Serial.print("\n y = " );
while(Serial.available() == 0)
{
}
y = Serial.read() ;
y = y - '0' ;
Serial.println(y) ;
digitalWrite(pin2,x) ;
digitalWrite(pin3,y) ;
while(Serial.available() == 0)
{
}
A = Serial.read() ;
}

8) Click on “Start Simulation”.


9) 2 NOT gates and an AND gate are used to perform the function X=A’.B’
Note down the truth tables of this function by observing the turning ON and OFF of the
LED 1 for different values of input given through the serial box and compare it with the
truth table of the NOR gate(obtained from part B of this experiment).
10) 2 NOT gates and an OR gate are used to perform the function Y=A’+B’
Note down the truth tables of this function by observing the turning ON and OFF of the
LED 2 for different values of input given through the serial box and compare it with the
truth table of the NAND gate(obtained from part B of this experiment).
11) Compare both the truth tables.
12) Note that LED turning OFF corresponds to 0 and turning ON corresponds to 1.

Conclusion:
We observe that the truth tables of A’.B’ & A’+B’ match with the truth tables of NOR and
NAND respectively .This verifies De Morgan's theorem.
A B A’.B’

0 0 1

0 1 0

1 0 0

1 1 0

A B A’+B’

0 0 1

0 1 1

1 0 1

1 1 0

Link of the TinkerCAD Simulation:


https://www.tinkercad.com/things/kpKFPc8l2WX-lab-2-c/editel?sharecode=I555hJRti8j6
kN-KeZjgpgehh275TWL5LnTIX0Ir7xw

QUESTION:
How would you realise the above circuit if you have only NAND gates
instead of NOT gates? i.e
How would you use NAND gates to perform function of NOT gates?

Aim:
● To verify De Morgan’s theorems using NAND gates instead of NOT gates:
(A+B)’=A’.B’ & (A.B)’=A’+B’

Electronic components used:


● Arduino UNO
● Breadboard
● AND, OR, NOT logic gates IC
● 2 Resistors (1 kΩ)
● 2 Red LEDs
● Wires
Reference Circuit:

Procedure:
Procedure:
1) Open TinkerCAD on the browser and start a new project.
2) Find the required components in the TinkerCAD library and place them
in the workspace.
3) Connect the 5V arduino pin to the positive and GND(ground) to the negative terminal
of the breadboard.
4) Give pin 2 and pin 3 as input from arduino to the NOT gate.
5) Connect the outputs from the NOT gate as inputs to the AND gate and OR gate.
6) Connect the output from AND gate to an LED along with a resistor and the output
from OR gate to another LED along with resistor.
7) Enter the code:

int A = 0 ;
int B = 0 ;

int pin2 = 2 ;
int pin3 = 3 ;

int x,y ;

void setup()
{
pinMode(pin2,OUTPUT) ;
pinMode(pin3,OUTPUT) ;
Serial.begin(9600) ;
}
void loop()
{
Serial.print("\n x = " );
while(Serial.available() == 0)
{
}
x = Serial.read() ;
x = x - '0' ;
Serial.println(x) ;
Serial.print("\n y = " );
while(Serial.available() == 0)
{
}
y = Serial.read() ;
y = y - '0' ;
Serial.println(y) ;
digitalWrite(pin2,x) ;
digitalWrite(pin3,y) ;
while(Serial.available() == 0)
{
}
A = Serial.read() ;
}

8) Click on “Start Simulation”.


9) 2 NAND gates and an AND gate are used to perform the function X=A’.B’
Note down the truth tables of this function by observing the turning ON and OFF of the
LED 1 for different values of input given through the serial box and compare it with the
truth table of the NOR gate(obtained from part B of this experiment).
10) 2 NAND gates and an OR gate are used to perform the function Y=A’+B’
Note down the truth tables of this function by observing the turning ON and OFF of the
LED 2 for different values of input given through the serial box and compare it with the
truth table of the NAND gate(obtained from part B of this experiment).
11) Compare both the truth tables.
12) Note that LED turning OFF corresponds to 0 and turning ON corresponds to 1.

Conclusion:
We observe that the truth tables of A’.B’ & A’+B’ match with the truth tables of NOR and
NAND respectively .This verifies De Morgan's theorem.
We can use NAND gates to perform function of NOT gates by replacing the 2 NOT gates
with NAND gates and giving 2 A’s as input to one NAND gate and 2 B’s as input to
another NAND gate. The NAND gate converts the 2 A’s to A’ and the 2 B’s to B’ as
(A.A)=(A)’ (since A.A=A)
(B.B)=(B)’ (since B.B=B)

A B A’.B’

0 0 1

0 1 0

1 0 0

1 1 0

A B A’+B’

0 0 1

0 1 1

1 0 1

1 1 0

Link of the TinkerCAD Simulation:


https://www.tinkercad.com/things/5oKRD6QQ29s-lab-2-c-nand-gate/editel?sharecode=sr
ZiN-iThbLaPKRCBgWx24GmyE-sN9FeqotDDTouE28

Part D:Binary Full Adder


Aim:
● To implement a binary full adder circuit using logic gates.

Electronic components used:


● Arduino UNO
● Breadboard
● AND, XOR logic gates IC
● 5 Resistors (1 kΩ)
● 5 Red LEDs
● Wires

Reference Circuit:

A binary full adder adds two bits A & B along with a carry C to get a FINAL SUM
& FINAL CARRY as output. The first step in this procedure is to set up a binary
half adder that adds 2 bits A & B and gives output as sum S1 and carry C1.This is
done as follows:

S1 = A.B’ + B.A’ = A XOR B C1 = A.B

Now another half adder is used to get the FINAL SUM & FINAL CARRY in the
following way:

FINAL SUM = S1 XOR C C2 = S1.C

FINAL CARRY = C1 XOR C2

(To get final carry we actually use C1 OR C2 but when we compare the truth tables
of XOR and OR we see that they differ only in the case where C1=1 & C2=1 but
this case doesn’t arise when we add single bit binary numbers and hence, we can
use XOR instead of OR here so as to avoid using an extra IC just for the FINAL
CARRY.)

Procedure:
1) Open TinkerCAD on the browser and start a new project.
2) Find the required components in the TinkerCAD library and place them
in the workspace.
3) Connect the 5V arduino pin to the positive and GND(ground) to the negative terminal
of the breadboard.
4) Set up the circuit of a Half Adder by taking 2 inputs A & B to get output S1 & C1 by
using a XOR and an AND gate respectively.
5) Connect the remaining components to set up another Half Adder by taking S1 and C as
inputs to get FINAL SUM and C2 as outputs by using another XOR and AND gates
respectively.
6) Now to generate the FINAL CARRY output from the intermediate carry outputs C1 &
C2 connect them as inputs to the unused XOR gate of the IC as shown in the reference
circuit.
7) Also connect the outputs S1, C1, C2, FINAL SUM, FINAL CARRY with LED’s
and 1kilo ohm resistors so as to observe the outputs.
8) Enter the code:

int A = 0 ;
int B = 0 ;
int C = 0 ;

int pin2 = 2 ;
int pin3 = 3 ;
int pin4 = 4 ;

int x,y,z ;

void setup()
{
pinMode(pin2,OUTPUT) ;
pinMode(pin3,OUTPUT) ;
pinMode(pin4,OUTPUT) ;
Serial.begin(9600) ;
}

void loop()
{
Serial.print("\n x = " );
while(Serial.available() == 0)
{
}
x = Serial.read() ;
x = x - '0' ;
Serial.println(x) ;
Serial.print("\n y = " );
while(Serial.available() == 0)
{
}
y = Serial.read() ;
y = y - '0' ;
Serial.println(y) ;
Serial.print("\n z = " );
while(Serial.available() == 0)
{
}
z = Serial.read() ;
z = z - '0' ;
Serial.println(z) ;

digitalWrite(pin2,x) ;
digitalWrite(pin3,y) ;
digitalWrite(pin4,z) ;
while(Serial.available() == 0)
{
}
A = Serial.read() ;
}
9) Click on START SIMULATION & enter different inputs for A, B, C using the serial
monitor and note down the behavior of the LED’s representing S1, C1, C2, FINAL SUM,
FINAL CARRY in a truth table and verify it.
10) Note that LED turning off corresponds to ‘0’ and turning on corresponds to ‘1’.

Conclusion:
We get the given truth table by which we can say that the binary full adder behaves
accordingly and that we have successfully implemented the full adder circuit using
the logic gates.

Truth Table:
A B C S1 C1 Final Sum C2 Final Carry

0 0 0 0 0 0 0 0

0 0 1 0 0 1 0 0

0 1 0 1 0 1 0 0

0 1 1 1 0 0 1 1

1 0 0 1 0 1 0 0

1 0 1 1 0 0 1 1

1 1 0 0 1 0 0 1

1 1 1 0 1 1 0 1

Link of the TinkerCAD Simulation:


https://www.tinkercad.com/things/hLbNM75TfcZ-lab-2-d/editel?sharecode=Z3_ziKZhm
Ty2vOkj8Q4xfu5A8Kq-JeQyZyGcArcKMVk

You might also like