Electronics School · Stage 6: Advanced Electronics and Engineering · Lesson 33

Analog Electronics and Op-Amps

Amplifying, scaling and cleaning up real-world signals.

The question

A sensor gives a voltage between 0 and 0.5 V, but your microcontroller reads 0 to 3.3 V. How do you make the most of it?

What you’ll discover: how operational amplifiers work, how feedback sets their gain, and how to condition a sensor signal for a microcontroller.

In simple terms

BeginnerThe op-amp

An operational amplifier, or op-amp, is an integrated circuit with two inputs, marked + and −, and one output. It amplifies the difference between its inputs by an enormous amount, often 100,000 times or more.

That much gain is too much to use directly, so we use negative feedback: some of the output is fed back to the − input. The op-amp then adjusts its output until its two inputs are at almost the same voltage. The result is an amplifier whose gain is set precisely by two resistors.

Two classic circuits

Non-inverting amplifier: the signal goes to the + input; resistor Rf runs from the output to the − input, and Rg from the − input to ground.

Gain = 1 + Rf ÷ Rg

With Rf = 47 kΩ and Rg = 10 kΩ, the gain is 5.7: a 0 to 0.5 V sensor becomes 0 to about 2.85 V, using most of a 3.3 V microcontroller’s input range.

Voltage follower (buffer): connect the output straight to the − input, and the signal to the + input. The gain is 1, but the op-amp can supply current without loading down a delicate source, like a high-resistance sensor divider.

Go deeper

IntermediateChoosing an op-amp

Op-amps differ in what supply voltage they need and how close to the supply rails their inputs and output can go. For a 3.3 V microcontroller project, look for a rail-to-rail op-amp rated for low voltage, such as the MCP6002 (1.8 to 6 V). The older LM358 is cheap and common but can’t swing its output all the way up to the positive supply, so check the datasheet before you rely on it at 3.3 V.

The inverting amplifier is the other basic circuit: the signal goes through Rin to the − input, the + input is held at a reference, and the gain is −Rf ÷ Rin (the minus sign means the output is upside-down).

AdvancedSignal conditioning

Signal conditioning means preparing a sensor’s signal before it’s measured: amplifying it, shifting its level, filtering noise (Lesson 34) and protecting the input. A good chain makes the signal fill the analog-to-digital converter’s range, because a 12-bit ADC has only 4,096 steps: a signal that uses one tenth of the range gets only about 400 of them.

Always protect the microcontroller: an op-amp powered from 5 V or more could drive a Pico input above 3.3 V. Power the op-amp from the same 3.3 V as the Pico, or add protection.

Quick check

What does negative feedback do in an op-amp circuit?

It makes the op-amp adjust its output so its inputs are nearly equal, giving a stable gain set by resistors.

What is the gain of a non-inverting amplifier with Rf = 47 kΩ and Rg = 10 kΩ?

1 + 47 ÷ 10 = 5.7.

Why use a rail-to-rail op-amp with a 3.3 V microcontroller?

So the output can swing close to 0 V and 3.3 V, using the full input range.

Words to know

Op-amp
An integrated circuit that amplifies the difference between two inputs.
Negative feedback
Feeding part of the output back to reduce and control gain.
Buffer
A gain-of-1 amplifier that isolates a source from a load.
Signal conditioning
Preparing a sensor signal for measurement.

Electronics School is part of the Discovery Zone. Every activity here runs on small batteries or a USB cable: never wall outlets. The one plug-in tool is the optional soldering iron, set up by an adult.

Was this page helpful?
Get all four of our sites in one free email every Friday: Prairie Signals
⇧Top
Hello! “It's easy to become a father. It's harder to become a man.”