Close
0%
0%

OP-Amps Gone Digital - A BCD to 7 Seg Converter

A proof of concept which demonstrates how analog op amps can perform digital logic functions.

Similar projects worth following
Imagine being stuck on a desert island with only op amps at your disposal.
Would you be limited to building analog circuits only? Surpisingly no, since it's possible to use them to build digital circuits. In fact you could construct the logic for an entire digital computer
with op amps alone (see NAND example below). Of course, this is not the best
way to produce logic circuits. For this purpose, op amps are overkill and have limited bandwidth, but it does work and it demonstrates just how amazingly versatile op amps are!

And who knows, perhaps someday you might be designing a circuit and realize you
need an extra logic gate and you only have a spare op amp remaining. In that case,
that lone op amp may just save the day!

Having said that, I believe my submission fits well in the "oddball" category. :)

To simulate logic gates, the op amps are configured as open loop (no feedback) and effectively act as comparators.  Each op amp "gate" is provided with an approriate Vref input via a resistor divider which causes it to swing to the high or low rail depending upon the value of the other input signal.  The input signal consists of a resistor network which averages the voltage all of its input and provides that to the op amp input.  The Vref voltages must be carefully chosen so as to ensure proper operation of the "gate".  For example, the "OR" gate must trigger on a low threshold when any one of its inputs is high, conversely an "AND" gate have a higher threshold so that the op amp does not trigger when one input is present, but only when both inputs are high.  

Further complicating the Vref determination is the fact that an LM324 can only reach approximately 3.6v (when powered by 5v), and so the gates must work properly with both 5v and 3.6v input voltages.  The reason for that is due to the fact that the input to some gates are wired directly to the 5v inputs whereas the input to other gates are wired to the output of another gate that produces 3.6v.  Yet another complication was the desire to use a single Vref for the variations of "OR" gates such that it works for the 2,3, and 4 input cases.  Since all inputs are averaged, when only a single input is high, the average value will be lower for the 4 input "OR" gate than the 2 input "OR" gate.

The gate designs shown below were initially tested with the "Falstad" simulator. and then further tested on a breadboard.

I have uploaded Falstad code for the simulations shown below in the "Files" section of this project. 

LM324 NAND gate.  Since a digital computer can be constructed from NAND gates, it should be possible to build one using op amps as the basic building block.  Therefore, op amps are capable of performing universal computation.

LM324 NOT gate (inverter)

LM324 AND gate:

 LM324 OR gates:

The logic design of the BCD to 7 segment converter:

BCD_FINAL.txt

Falstad code for the BCD to 7 segment logic circuit.

plain - 6.64 kB - 06/07/2023 at 19:50

Download

PaintPCB.png

PCB Artwork created with MS Paint

Portable Network Graphics (PNG) - 13.11 kB - 06/06/2023 at 11:34

Preview
Download

Portable Network Graphics (PNG) - 109.54 kB - 06/06/2023 at 03:53

Preview
Download

Inverter.txt

Falstad code for "NOT" gate (inverter)

plain - 503.00 bytes - 06/05/2023 at 22:12

Download

Nand.txt

Falstad code for "NAND" gate

plain - 673.00 bytes - 06/05/2023 at 22:12

Download

View all 7 files

  • 5 × LM324 Amplifier and Linear ICs / Operational Amplifiers
  • 48 × 10k Resistor
  • 1 × 15k Resistor
  • 1 × 2.2k Resistor
  • 5 × 0.1 uf ceramic disk capacitor

  • Lessons Learned

    gschmidt95806/05/2023 at 22:10 0 comments

    I simulated each gate using Falstad, then built up an example of each gate on a breadboard and connected them together.  This was very helpful, but...

    The real world often throws you a curve ball.  I discovered that for some inputs, a "logic low" was .6 or .7, not just a few millivolts which the LM324 is spec'd at.  The reason for this is that I used 10k resistors for the input averaging networks and that created some leakage current which added an offset to the op amp's output.  In retrospect, it would have been better to use some higher valued resistors, 100k or even 1M (although you don't want to go too high as that might make the circuit more susceptible to noise).

    The offset voltage was only a problem for the four input OR gate.  Fortunately, I was able to solve the problem by increasing the OR gate Vref (by replacing the 1k resistor with a 2.2k).

    Nearing the end of the build, I ran out of 10k resistors so I used 20k resistors instead.  This works fine as long as you are consistent and all inputs of a gate use the same resistor value. 

View project log

  • 1
    Design & Construction Details

    I used EasyEDA to layout the schematic.  Unfortunately, I was too close to the deadline to order a double sided board so I ended up making my own single sided board in "old school" fashion.

    This is the board artwork.  I used MS Paint to create this image!

    I used a laser printer to print the artwork onto magazine paper.  I then transferred the toner from the paper onto the copper with a hot iron and and then etched the board with a mix of  HCL (Muriatic acid) and Hydrogen Peroxide.  Here is the result after drilling:

    There are many more connection to be made that can be easily accomodated by a single sided board, so I designed it with pads so that I could solder (many) point to point wires.

    Here is the component side:

    And here is the "rats nest" of point to point wiring on the copper side.  I tested each chip with a multimeter after wiring it in order to find any errors early on and to avoid having to test it all at once.

    After completing the wiring, I was pleased and a bit surprised to see that it appeared to be working!

    I like to use salvaged components as much as possible in my builds.  The wiring is old telephone wire, and the LM324's were removed from old electronics about to be recycled.

    For the demo, the BCD inputs are being driven by a 74HC393 clocked by a 555 timer.  On the output side, I connected a common anode 7 segment LED display.

View all instructions

Enjoy this project?

Share

Discussions

Dan Maloney wrote 06/07/2023 at 00:06 point

Great project, Bob Widlar would be proud. I wrote this up for the blog, should publish soon.

Thanks for participating in the contest. Good luck!

  Are you sure? yes | no

gschmidt958 wrote 06/07/2023 at 01:44 point

Thank you!  We can only imagine what Bob's response would have been! :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates