0% found this document useful (0 votes)
22 views5 pages

PLC Program To Implement 2-Bit Magnitude Comparator - Sanfoundry

The document describes a PLC program to implement a 2-bit magnitude comparator using Ladder Diagram programming. It includes a problem description, solution with truth tables, Karnaugh maps, and Boolean expressions for outputs, as well as a detailed program explanation and runtime test cases. The program compares two 2-bit inputs and determines if one is less than, equal to, or greater than the other.

Uploaded by

Dr. Swati Madhe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

PLC Program To Implement 2-Bit Magnitude Comparator - Sanfoundry

The document describes a PLC program to implement a 2-bit magnitude comparator using Ladder Diagram programming. It includes a problem description, solution with truth tables, Karnaugh maps, and Boolean expressions for outputs, as well as a detailed program explanation and runtime test cases. The program compares two 2-bit inputs and determines if one is less than, equal to, or greater than the other.

Uploaded by

Dr. Swati Madhe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

4/5/2017 PLC Program to Implement 2-bit Magnitude Comparator - Sanfoundry

PLC Program to Implement 2-bit Magnitude Comparator

This is a PLC Program to Implement 2-bit Magnitude Comparator.

Problem Description
Implementing 2-bit comparator in PLC using Ladder Diagram programming language.

Problem Solution
For a 2-bit comparator, each input word is 2 bit long.
Writing truth table showing the comparison of input words.
For each output AB, write Karnaugh-Map.
From the K-Map, obtaining a simplified expression for each output in terms of 2-bit inputs.
Realize the code converter using the Logic Gates.

By comparing both word inputs, Truth Table can be written as given below.

Decimals Inputs Outputs


A1 A0 B1 B0 A<B A=B A>B
0 0 0 0 0 0 1 0
1 0 0 0 1 1 0 0
2 0 0 1 1 1 0 0
3 0 0 1 0 1 0 0
4 0 1 1 0 0 0 1
5 0 1 1 1 0 1 0
6 0 1 0 1 1 0 0
7 0 1 0 0 1 0 0
8 1 1 0 0 0 0 1
9 1 1 0 1 0 0 1
10 1 1 1 1 0 1 0
11 1 1 1 0 1 0 0
12 1 0 1 0 0 0 1
13 1 0 1 1 0 0 1
14 1 0 0 1 0 0 1
15 1 0 0 0 0 1 0

Boolean expression for each output bit can be written as

A<B = m(1, 2, 3, 6, 7, 11)


A=B = m(0, 5, 10, 15)
http://www.sanfoundry.com/plc-program-implement-2-bit-magnitude-comparator/ 1/5
A>B = m(4, 8, 9, 12, 13, 14)
4/5/2017 PLC Program to Implement 2-bit Magnitude Comparator - Sanfoundry

Karnaugh-Map for each output

Realizing code conversion using Logic Gates

http://www.sanfoundry.com/plc-program-implement-2-bit-magnitude-comparator/ 2/5
4/5/2017 PLC Program to Implement 2-bit Magnitude Comparator - Sanfoundry

PLC Program
Here is PLC program to Implement 2-bit Magnitude Comparator, along with program explanation and run
time test cases.

List of Inputs and Outputs


A1 = I:1/0 (Input)
A0 = I:1/1 (Input)
B1 = I:1/2 (Input)
http://www.sanfoundry.com/plc-program-implement-2-bit-magnitude-comparator/ 3/5
4/5/2017 PLC Program to Implement 2-bit Magnitude Comparator - Sanfoundry

B0 = I:1/3 (Input)
A<B = O:2/0 (Output)
A=B = O:2/1 (Output)
A>B = O:2/2 (Output)

Ladder Diagram to obtain Binary output

Program Description
RUNG000 is used to detect if A is less than B. first compares A1 and B1 bits. If A1 is less than B1 then
O:2/0 is set otherwise it similarly compares A0 and B0.
RUNG001 is used to detect the condition when A=B are equal. ANDing of two EX-NOR gates ae
obtained by simplifying expression using De-Morgan’s Theorem.
O:2/1 is set only when A1A0=B1B0.
RUNG002 works similarly as RUNG000, it first compares A1 and B1, if A1 is greater than B1 then
output O:2/2 is set to 1 and if not, it compares A0 and B0.

Runtime Test Cases

Decimals Inputs Outputs


http://www.sanfoundry.com/plc-program-implement-2-bit-magnitude-comparator/ 4/5
4/5/2017 PLC Program to Implement 2-bit Magnitude Comparator - Sanfoundry

A1 A0 B1 B0 A<B A=B A>B


0 0 0 0 0 0 1 0
1 0 0 0 1 1 0 0
2 0 0 1 1 1 0 0
3 0 0 1 0 1 0 0
4 0 1 1 0 0 0 1
5 0 1 1 1 0 1 0
6 0 1 0 1 1 0 0
7 0 1 0 0 1 0 0
8 1 1 0 0 0 0 1
9 1 1 0 1 0 0 1
10 1 1 1 1 0 1 0
11 1 1 1 0 1 0 0
12 1 0 1 0 0 0 1
13 1 0 1 1 0 0 1
14 1 0 0 1 0 0 1
15 1 0 0 0 0 1 0

http://www.sanfoundry.com/plc-program-implement-2-bit-magnitude-comparator/ 5/5

You might also like