Op Amp Basics for Arduino Hobbyists

Who Is This Written For?

Op Amps For the Rest of Us LogoI have struggled with the idea of writing this Op Amp article.   Indeed, I’ve started and stopped at least a dozen times.

You see, there’s already a bunch of excellent information (which you may ultimately want to read) offered by people who are far more knowledgeable about this component than I.

However,  most of those articles are directed at those of us who first learned about things like Common Mode Rejection and Thevenin’s Theorem in classrooms.

Therein lies the problem.

Arduino enthusiasts come from different backgrounds.  Some of us are hardcore hardware hacks,  some are code geeks,  some are gear heads and some are artistic.   Better yet,  some of us are an eclectic blend of everything with expertise in nothing.

While there are those classical purists who insist that learning about electricity and magnetism begin with a discussion of the make up of atoms,  I’m not one of them.    I think there are many paths to learning and ultimately to solving problems.  Therefore, my approach is a tad different.  That isn’t to say that you should never learn about valence electrons. You may wish to one day.

Instead,  I don’t think that B necessarily has to  follow A.

This is for the Arduino aficionado who isn’t classically educated.  Its for the person who tinkers first and studies second.

What this article sets out to do, is to make the reader aware that there is a really cool component called an Op Amp,  to very basically discuss how it functions,  and to show some of its commonly used configurations within circuits.

How you use this electronic Lego to complete your micro-controller masterpiece is entirely up to you.   In future articles,  I will introduce some Arduino examples that make use on an Op Amp.

Very Basic Op Amp Functionality

Two Inputs and One Output

Simply put…

  • It accepts two inputs.
  • It provides a single output

Op Amp Inputs and Output

What the Output Does

The output responds to an input by raising or lowering its voltage until the voltage at the inputs are equal.

This is done by connecting the op amp in such a way that feedback is provided to one of the inputs.  You’ll see some circuits with feedback a little further on.

In a sense, the device works to create a balance.

Inverting and Non-Inverting Inputs

The two inputs to the Op Amp each will affect the output differently.  Their names derive from how they affect the output.

The input with minus sign is known as the Inverting Input.   When it increases (or goes more positive),  the output decreases (or goes more negative).  Conversely,  if the inverting input goes more negative,  the output will go more positive.

The input with the plus sign is known as the Non-Inverting Input.   It causes to output to behave exactly the opposite of the inverting input.   If it goes more positive, the output will go more positive.   If it goes more negative,  the output will go more negative.

Op Amp Inverting and Non-Inverting Inputs

Op Amp circuits on the internet don’t always include a thorough functional explanation.  For you to make use of these circuits,  you will want to thoroughly grasp how these inputs affect the output.


Bi-Polar and Uni-Polar Op Amps

Op Amp PinsThe op amp comes in a variety of packages that include DIP,  Surface Mount, Cans and others.   Regardless of the package,  the Op Amp will at least five pins.

The inputs and outputs have been sufficiently discussed for now.  That said, it is useful to discuss the pins used to provide power.

While we apply to those pins clearly depends on the specs,  it is important to know that there are a couple basic flavors available.

One is known as a bi-polar op amp.   The other is known as a uni-polar op amp.

What you use will be application driven.    While you can use both with an Arduino,  I lean towards using the uni-polar variety in my circuits when I can.  It is a little less complex to use.

Bi-Polar Op Amp

Bipolar Op AmpThe Bi-Polar Op Amp is the style that is the most commonly featured in various sample schematics found on the internet.   For power, it is designed to receive both a positive and negative voltage.

It is extremely useful if you need to provide an output that indicates a difference that is less than zero volts.

With some thought,  it is possible to design a circuit that grounds the negative terminal.  In fact, there are tons out there that do just that.   However,  its not how it best operates.

Uni-Polar Op Amp

Unipolar Op AmpThe uni-polar op amp is one where there is a power input and a ground connection.   The power supply will be positive in most cases.

It’s my personal favorite when integrating into a micro-controller application.

In future articles, you will see me discussing the LM358.  That device is a unipolar op amp.


Common Op Amp Circuit Configurations

Here’s where we start getting to the cool stuff and reinforcing concepts we have already discussed.

Each of the circuits shown uses feedback.   Remember,  the op amp will work raise or lower its output until both inputs are equal.

Now, as you progress through these configurations it is important to keep in mind that these apply to the ideal op amp.

What I mean by that is that if you apply some of the formulas to crazy resistance values,  you could end of with infinite gain.  That ain’t happening.    Similarly, you might assume that your output will perfectly track your input.  It won’t.

In real life,  you’re going to figure out what you need and then try to find the op amp that gets you there.

The Op Amp Voltage Follower

The illustration below shows a voltage follower.   In this circuit, the output voltage will equal the input voltage.

The benefit here has to do with the input impedance of the op amp.  It has a very high input impedance and will not likely drag the output of the micro-controller (or other device down).

More, depending on the Op Amp selected,  the output of the Op Amp can have a much higher current handling capacity than the Arduino Output.

Notice how the output is connected to inverting input.   Thus,  the output will respond to change in voltage at the non-inverting input by raising or lowering the voltage until both inputs are equal.

Five volts in, gets you five volts out.


Op Amp Voltage Follower

The Op Amp Non Inverting Amplifier

With the non-inverting amplifier we introduce the gain and feedback resistors.   These resistors together determine the amount of amplification or attenuation we see at the output.

The image below is a non-inverting amplifier.  In this circuit,  the output is going to raise or lower its voltage until the inverting input is equal to the value present at Vin.

How much it has to raises or lower its voltage is determined by the voltage divider formed by RF and RG.

RF is referred to as a feedback resistor.  RG is the gain resistor.

When solving for this circuit,  you’re asking yourself what value at the output will cause the voltage at the inverting input to equal Vin.

The equation is:  Vout = Vin ( 1+ RF/RG)

Op Amp Non-Inverting Amplifier

The Op Amp Inverting Amplifier

As the name suggests, the inverting amplifier will provide an output that decreases when Vin goes more positive.

Conversely, the output will decrease as the input goes more positive.

The inverting amplifier also introduces us to gain and feedback resistors.   In the drawing below,  the gain resistor is identified as Rg and the feedback resistor is identified as Rf.

The values of these resistors set up circuit behavior.  In fact, these resistors set up a direct ratio.   Specifically:  -1 x (Rf/Rg) = Vout/Vin

Or put another way:  Vout = -1 x Vin x (Rf/Rg)

Op Amp Inverting Amplifier