Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Building 4-Bit Magnitude Comparator Using 7485 IC

By Ashutosh Bhatt April 21, 2008

In a previous tutorial – Arithmetic Circuits, digital circuits for performing arithmetic operations were designed. Like Arithmetic operations, comparison of numbers is also an important mathematical operation. From computing perspective, the comparison of numbers plays vital role in decision making and logical operations.  In digital systems, the numbers are in the form of binary numbers. The comparison of two numbers determines whether one number is greater than, equal, or less than the other number. A digital comparator is widely used in combinational systems and is specially designed to compare the relative magnitudes of binary numbers.

For comparing two binary numbers, first their MSB (Most Significant Bits) are compared. If the MSB of one these numbers is 1 while of other is 0, then it is greater than the other and the process of comparison ceases. If their MSB are equal like both are 1 or 0, then the next significant bit is compared in both numbers. If the next significant bit of one of these numbers is 1 while of other is 0, then it is greater than the other and the process of comparison ceases there. Otherwise, it continues to less significant bits until it is determined which number is greater or both numbers are found equal after comparing LSB (Least Significant Bit) of the numbers. So, if two numbers A and B are compared then, the result of comparison is that either A > B, A < B or A = B.

In microcontrollers and microprocessors, digital comparators for comparison of binary numbers are in-built. A digital comparator can be 4-bit, 8-bit, 16-bit, 32-bit or 64-bit system depending upon it compares 4-bit, 8-bit, 16-bit, 32-bit or 64-bit numbers respectively. More than one comparator can also be connected in cascade arrangement to perform comparison of long numbers. Like two 4-bit comparators can be cascaded for comparison of 8-bit numbers. A comparator produces three outputs as L, E and G which corresponds to less than, equal and greater than results.

There are also discrete ICs available for comparison of binary numbers. In this project SN7485 IC is used which is a 4-bit magnitude comparator. The two 4-bit numbers are input to the IC through a DC supply via 8 position DIP switch. The result of the comparison is verified by connecting LEDs at the output pins of the IC.       

Components Required –

COMPONENTS

QUANTITY

SN74LS85N

1

8 POSITION DIP SWITCH

1

LED

3

CONNECTING WIRES

As Required

 

Circuit Diagram –

SN7485 4-Bit Magnitude Comparator Circuit

Circuit Connections –

For comparison of 4-bit numbers, SN7485 IC is used in this project. The IC is a 4-bit magnitude comparator which can be used for comparison of straight binary numbers and BCD coded numbers. The 16-pin IC has the following pin configuration –

Pin Number

Pin Name

Pin Function

1

B3

MSB of Binary Number B

2

A < Bin

Input for A < B on cascading

3

A = Bin

Input for A = B on cascading

4

A > Bin

Input for A > B on cascading

5

A > Bout

Comparator Output for A > B

6

A = Bout

Comparator Output for A = B

7

A < Bout

Comparator Output for A < B

8

GND

Ground

9

B0

LSB of Binary Number B

10

A0

LSB of Binary Number A

11

B1

Third MSB of Binary Number B

12

A1

Third MSB of Binary Number A

13

A2

Second MSB of Binary Number A

14

B2

Second MSB of Binary Number B

15

A3

MSB of Binary Number A

16

VCC

Supply Voltage

The IC has the following pin diagram –

 

It can be noted that the SN7485 have additional input terminals that allow more individual comparators to be “cascaded” together to compare words larger than 4-bits with magnitude comparators of “n”-bits being produced. These cascading inputs are connected directly to the corresponding outputs of the previous comparator to compare 8, 16 or even 32-bit words. In this project, simply two 4-bit numbers are compared, so there is no need f cascading.

The input binary numbers are passed to the IC to the respective input pins via an 8-position DIP switch. The result of comparison is verified by connecting LEDs at output pins 5, 6 and 7 of the IC.  

 

How the circuit works –

The circuit is based on the working of the SN7485 IC. When the two numbers are input through the DIP switch where switches are connected to regulated 5V DC supply, the IC performs comparison of the two 4-bit numbers and depending upon the result of the comparison, one of the three output pins is set to HIGH. The LEDs are connected at the output pins of the IC such that on HIGH output they start glowing. So, if number A is greater than number B, the LED connected at pin 5 will start glowing. If both numbers are equal, the LED connected at pin 6 will start glowing. If number A is less than number B, the LED connected at pin 7 will start glowing.

These type of digital comparators are used in the address decoding circuitry in computers and microprocessor based devices to select a specific input/output device for the storage of data.

They are also used in control applications in which the binary numbers representing physical variables such as temperature, position, etc. are compared with a reference value. Then the outputs from the comparator are used to drive the actuators so as to make the physical variables closest to the set or reference value. Like the digital comparators are used in applications like process controllers and servo motor control.

Testing the circuit –

The output of the circuit can be tested by passing different 4-bit binary numbers to the input pins of the 7485 IC. On comparison of the two binary numbers, either of three output pins will be HIGH and the respective LED will start glowing. The following observations were made on working with the 7485 IC

Input Number A

Input Number B

Output  Pin 5 (A > B)

Output Pin 6 (A = B)

Output Pin 7 (A < B)

0000

0000

0

1

0

1000

0000

1

0

0

0000

1000

0

0

1

 

In the next tutorial, learn about more combinational circuits like multiplexers and encoders. 

Project Source Code

###

//Program to 

###

 



Filed Under: Electronic Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Snooping Around is All
  • mosfet driver problem in regeneration mode
  • Industrial Relay Board Design for Motorcycle Use
  • connector model question
  • ADEM III ECM — No CAN Signal & Power Supply Issue

RSS Electro-Tech-Online.com Discussions

  • Sump pit water alarm - Kicad 9
  • Pic18f25q10 osccon1 settings swordfish basic
  • Anyone jumped from Easyeda std to Easyeda pro?
  • turbo jet fan - feedback appreciated.
  • More fun with ws2812 this time XC8 and CLC

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • How IoT network topologies work
  • The top five AI startups to watch in 2025
  • STMicroelectronics unveils SoC based on secure MCU
  • Nexperia’s 48 V ESD diodes support higher data rates with ultra-low capacitance design
  • Taoglas releases Patriot antenna with 18 integrated elements covering 600 to 6000 MHz

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe