Lesson plan

ADCs, DACs and sampling lesson plan

What a converter really gives you: aliasing, resolution and the LSB, R-2R and PWM DACs, the ADS1115, MCP3008 and MCP4725, and a 16-bit voltmeter that checks itself.

7 chapters, 7 lessons, about 6 hours, no board. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • Sample below twice the signal and it lies.
  • Codes, steps, bits, references and clipping.
  • Binary weights from two resistor values, and why it needs a buffer.
  • A pin and an RC filter: level, ripple and step.
  • Sixteen bits and a gain amplifier against ten bits and speed.
  • A 12-bit DAC on I2C, read back and compared with PWM.
  • A 0 to 30 V meter with a divider, a self-test and a range you pick.

Materials for the whole unit

  • 8-resistor network
  • Arduino Uno R3
  • Bench power supply
  • Capacitor
  • DAC, MCP4725
  • Eight-channel ADC, MCP3008
  • Function generator
  • Multimeter
  • Oscilloscope
  • Resistor x 9
  • Sixteen-bit ADC, ADS1115
  • Slide switch x 5

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 55 min

Aliasing

Sample below twice the signal and it lies.

LessonTimeWhat students do
Aliasing: when a fast signal looks slowAn Uno samples a sine from a function generator at a rate you pick and counts the cycles it sees: right below half the sample rate, wrong above it, with the Nyquist rule and the anti-alias filter that real converters put first.55 min
  1. Run it: 10 Hz at 100 samples a second
  2. 40 Hz: still fine
  3. 70 Hz: a lie
  4. Predict: 95 Hz
  5. Sample faster
  6. The scope samples too

Materials

  • Arduino Uno R3
  • Function generator
  • Oscilloscope

Check for understanding

Each student finishes "Aliasing: when a fast signal looks slow" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "The scope samples too".

Chapter 2. About 55 min

Resolution and LSB

Codes, steps, bits, references and clipping.

LessonTimeWhat students do
Resolution and LSB: the smallest stepA bench supply on A0: the code and the volts, one LSB of 4.88 mV, a change too small to see, fewer bits and bigger steps, the 1.1 V reference for finer ones, and what happens past full scale.55 min
  1. Run it: a code, not a voltage
  2. Smaller than a step
  3. Fewer bits
  4. Predict: 4 bits
  5. A smaller reference
  6. Past full scale

Materials

  • Arduino Uno R3
  • Bench power supply

Check for understanding

Each student finishes "Resolution and LSB: the smallest step" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Past full scale".

Chapter 3. About 55 min

R-2R DAC

Binary weights from two resistor values, and why it needs a buffer.

LessonTimeWhat students do
R-2R DAC: bits into volts with two resistor valuesFour slide switches drive a 10k and 20k ladder: each bit worth half the one above it, the LSB, full scale one step short of 5 V, a predicted code, and why a ladder needs a buffer.55 min
  1. Run it: the top bit
  2. Each bit is half the last
  3. The LSB
  4. Full scale
  5. Predict: code 1010
  6. A load on the ladder

Materials

  • Bench power supply
  • Multimeter
  • Resistor x 9
  • Slide switch x 5

Check for understanding

Each student finishes "R-2R DAC: bits into volts with two resistor values" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A load on the ladder".

Chapter 4. About 55 min

PWM as a DAC

A pin and an RC filter: level, ripple and step.

LessonTimeWhat students do
PWM as a DAC: a pin and a filterPin 9's PWM through a 10k and 10 uF low-pass: the duty sets the voltage, the pin still switches, a smaller capacitor shows the ripple, a predicted level, and the 19.6 mV step of 8-bit PWM.55 min
  1. Run it: duty 128
  2. The pin still switches
  3. Predict: duty 64
  4. Ripple
  5. Predict: duty 200
  6. One step of PWM

Materials

  • Arduino Uno R3
  • Capacitor
  • Multimeter
  • Oscilloscope
  • Resistor

Check for understanding

Each student finishes "PWM as a DAC: a pin and a filter" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "One step of PWM".

Chapter 5. About 45 min

ADS1115 and MCP3008

Sixteen bits and a gain amplifier against ten bits and speed.

LessonTimeWhat students do
ADS1115 and MCP3008: buying more bitsA 16-bit ADS1115 on I2C and a 10-bit MCP3008 on SPI read the same input: a change only one of them sees, clipping past the range, a programmable gain that makes 0.1 V worth 12,800 counts, and the speed each trades.45 min
  1. Run it: two ADCs, one input
  2. A change only one can see
  3. Past the range
  4. A small signal, magnified
  5. Predict: the 1.024 V range

Materials

  • Arduino Uno R3
  • Bench power supply
  • DAC, MCP4725
  • Eight-channel ADC, MCP3008
  • Sixteen-bit ADC, ADS1115

Check for understanding

Each student finishes "ADS1115 and MCP3008: buying more bits" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Predict: the 1.024 V range".

Chapter 6. About 45 min

MCP4725

A 12-bit DAC on I2C, read back and compared with PWM.

LessonTimeWhat students do
MCP4725: a real DAC on I2CThe gallery's DAC sine: a 12-bit MCP4725 writes a 32-point sine, A0 reads it back, and pin 9 plays the same sine as PWM for comparison on the scope.45 min
  1. Run it: find the chip
  2. The top of the sine
  3. The bottom
  4. Read VOUT
  5. PWM beside it

Materials

  • Arduino Uno R3
  • DAC, MCP4725
  • Oscilloscope

Check for understanding

Each student finishes "MCP4725: a real DAC on I2C" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "PWM beside it".

Chapter 7. About 55 min

Boss build

A 0 to 30 V meter with a divider, a self-test and a range you pick.

LessonTimeWhat students do
Boss: a 16-bit voltmeterAn ADS1115 meter for 0 to 30 V: wire a bussed resistor network as an 8:1 divider, tell the sketch the ratio, check it against an MCP4725 self-test, and pick the range that fits.55 min
  1. Wire the divider
  2. Run it: 20 V in
  3. Tell it the ratio
  4. Self-test against the DAC
  5. Predict: 30 V
  6. Your change: a wider range

Materials

  • 8-resistor network
  • Arduino Uno R3
  • Bench power supply
  • DAC, MCP4725
  • Eight-channel ADC, MCP3008
  • Oscilloscope
  • Sixteen-bit ADC, ADS1115

Check for understanding

Each student finishes "Boss: a 16-bit voltmeter" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Your change: a wider range".

Your class

Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.