Lab Report-2
Lab Report-2
Lab Report-2
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.
Aim:
● To familiarise with logic gates.
● To verify the truth table of AND, OR, NAND, NOR, NOT, XOR logic gates
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
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
NAND gate
x y (x.y)’
0 0 1
0 1 1
1 0 1
1 1 0
XOR gate
x y x.y’+x’.y
0 0 0
0 1 1
1 0 1
1 1 0
NOT gate
x x’
0 1
1 0
Aim:
● To verify De Morgan’s theorems:
(A+B)’=A’.B’ & (A.B)’=A’+B’
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() ;
}
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
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’
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() ;
}
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
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:
Now another half adder is used to get the FINAL SUM & FINAL CARRY in the
following way:
(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