Mechatronics · Module 4 of 10

Data Acquisition and Conversion

A microcontroller cannot read a voltage directly; it reads numbers. Data acquisition samples the conditioned signal in time and quantizes it in amplitude, and a converter turns numbers back into voltage to drive the world.

01

Readiness check

This module digitizes the signal. Tick only what you can do closed-notes.

  • Evaluate a power of two such as 28.
  • Divide a voltage range into equal steps.
  • Recall that sampling reads a signal at intervals.
  • Recall that a digital code is a whole number.
  • Compute a fraction of a reference voltage.
0 or 1 weak itemsContinue with this module.
2 weak itemsRevisit conversion basics in Electrical Circuits, Module 10.
3 or more weak itemsRevisit conditioning in Module 3.
02

The core idea

An analog-to-digital converter splits a reference voltage into 2n levels, so its smallest step, the LSB, is the reference divided by 2n, and the worst quantization error is half an LSB. A digital-to-analog converter reverses this: its output is the code's fraction of the reference. Sampling must run faster than twice the highest signal frequency.

levels = 2nLSB = Vref / 2nDAC out = (code / 2n) × Vref

Digital systems work on numbers, so a signal must be discretised in two ways. Sampling discretises time: the signal is read at a fixed rate, and the Nyquist rule requires that rate to exceed twice the highest frequency present, or fast components alias into false slow ones. Quantization discretises amplitude: an n-bit converter divides the reference span into 2n equal levels, so one level, the least significant bit, is Vref/2n. Any real voltage is rounded to the nearest level, so the quantization error is at most half an LSB. More bits mean finer steps and smaller error, at the cost of speed and price. The digital-to-analog converter runs the process backwards, producing an output equal to its input code as a fraction of the reference, (code/2n) × Vref, which a microcontroller uses to command an analog actuator. Together these define the boundary between the analog world and the digital controller.

The skill works when: you compute 2n levels, an LSB, and a half-LSB error, and check sampling beats twice the signal band.
The skill breaks down when: the LSB is confused with the full range, or the sample rate falls below Nyquist and aliases.
The concept. Sampling reads the signal at intervals; quantization snaps each reading to the nearest level. The step height is the LSB, and rounding costs at most half an LSB.
03

The skills, taught in order

Five skills describe how a signal crosses into and out of the digital domain.

4.1 Sampling and Nyquist

Reading a signal at a fixed rate is sampling. The Nyquist rule says the sample rate must exceed twice the highest frequency present; otherwise higher frequencies alias into false low ones. The anti-alias filter of the previous module enforces this at the front end.

4.2 Quantization and the LSB

An n-bit converter has 2n levels across the reference, so one level is LSB = Vref/2n. Because each reading is rounded to the nearest level, the quantization error is bounded by half an LSB. Resolution is set entirely by the bit count and the reference.

Bits nLevels 2nLSB at Vref = 10 V
825639.1 mV
1010249.77 mV
1240962.44 mV

Each extra bit halves the LSB. Choosing the bit count is choosing the resolution.

4.3 The analog-to-digital converter

An ADC outputs the code nearest to input/LSB. Common types trade speed for resolution: successive-approximation converters are the general-purpose choice, while flash converters are fast and sigma-delta converters are high-resolution but slower.

4.4 The digital-to-analog converter

A DAC produces (code/2n) × Vref, turning a number back into a voltage. It lets a controller command an analog quantity, such as a motor drive reference, from digital logic.

4.5 Practical acquisition

A sample-and-hold freezes the input while the ADC converts; a multiplexer shares one converter among channels; and throughput is the product of channels and per-channel rate. These set what a real data-acquisition system can capture.

Engineering connection: a data logger reading eight thermocouples uses one ADC, a multiplexer, and a sample-and-hold, sampling each channel well above its slow thermal bandwidth.

04

Worked example 1: ADC resolution and error

An 8-bit ADC has a reference of 10 V. Find the number of levels, the LSB, and the worst-case quantization error.

Figure 1. With 256 levels across 10 V, each step is 39.1 mV, and rounding to the nearest step costs at most half a step, 19.5 mV.
  1. ProblemFind the levels, LSB, and worst-case error for the ADC in Figure 1.
  2. Given / findn = 8 bits, Vref = 10 V. Find levels, LSB, and error.
  3. AssumptionsIdeal uniform quantizer, input within the reference span.
  4. Modellevels = 2n; LSB = Vref/2n; error ≤ LSB/2.
  5. Equationslevels = 28 = 256LSB = 10 / 256
  6. Solve256 levels; LSB = 10/256 = 39.1 mV; error ≤ 39.1/2 = 19.5 mV.
  7. Check256 steps of 39.1 mV sum to 10.0 V, and half a step is 19.5 mV, as required.
  8. ConclusionAn 8-bit converter resolves this 10 V range to about 39 mV, with a worst rounding error near 20 mV; finer work needs more bits.
Result. 256 levels, LSB 39.1 mV, error up to 19.5 mV.
05

Worked example 2: a DAC output

An 8-bit DAC with a 10 V reference receives the code 200. Find its output voltage.

Figure 2. The DAC output is the code as a fraction of full scale times the reference. Code 200 of 256 gives about 78 percent of 10 V, namely 7.81 V.
  1. ProblemFind the DAC output for code 200 in Figure 2.
  2. Given / findn = 8 bits, Vref = 10 V, code = 200. Find Vout.
  3. AssumptionsIdeal linear DAC, no output loading error.
  4. ModelVout = (code/2n) × Vref.
  5. EquationsVout = (200 / 256) × 10
  6. SolveVout = 0.781 × 10 = 7.81 V.
  7. Check200 is a little under 80 percent of 256, and 78 percent of 10 V is 7.81 V, consistent.
  8. ConclusionThe controller commands 7.81 V by writing the code 200, the reverse of the ADC's job.
Result. DAC output 7.81 V for code 200.
06

Misconceptions and diagnostics

MistakeSymptomDiagnostic questionCorrection
Using n instead of 2nFar too few levels"Is it n or two to the n?"Levels are 2n, not n.
LSB set to the full rangeResolution wildly overstated"Did I divide by 2n?"LSB = Vref/2n.
Quantization error = LSBError doubled"Round to nearest or truncate?"Rounding gives at most half an LSB.
Sampling below NyquistFalse low-frequency content"Is fs above twice the signal?"Sample above twice the highest frequency.
07

Practice ladder

Level 1 · Direct skill

A 10-bit ADC has a 5 V reference. Find the number of levels and the LSB.

Show answer

Levels = 210 = 1024; LSB = 5/1024 = 4.88 mV.

Level 2 · Mixed concept

A 12-bit ADC has a 10 V reference. Find the LSB and the worst-case error.

Show answer

LSB = 10/4096 = 2.44 mV; error ≤ 1.22 mV.

Level 3 · Independent problem

An 8-bit DAC with a 5 V reference receives the code 64. Find its output.

Show answer

Vout = (64/256) × 5 = 0.25 × 5 = 1.25 V.

Transfer task | Real engineering

You must read a 0 to 10 V signal to within 5 mV. How many ADC bits are needed?

What good work looks like

Require LSB ≤ 5 mV, so 10/2n ≤ 0.005, giving 2n ≥ 2000, so n ≥ 11 bits (211 = 2048, LSB = 4.88 mV).

08

Working with AI, and proving it yourself

Use AI as an examiner, not a solver

"Check that I used 2n levels and a half-LSB error here."
"Give me three converters; I will compute each LSB and error."
"How many bits do I need?" Set the LSB target and solve it yourself.
"Is my sampling fine?" Compare fs to twice the band yourself.

Portfolio task

For one measurement, choose an ADC bit count and sample rate, and justify both from the required resolution and signal bandwidth.

Must include: an LSB, a half-LSB error, and a sample rate checked against Nyquist.
09

Retrieval and spaced review

Closed notes. Answer out loud, then reveal.

1. How many levels has an n-bit converter?

2n.

2. Write the LSB.

LSB = Vref/2n.

3. What is the worst quantization error?

Half an LSB, from rounding to the nearest level.

4. Write the DAC output.

(code/2n) × Vref.

5. State the Nyquist rule.

Sample faster than twice the highest frequency present.

TodayFinish this quiz and Levels 1 and 2 of the ladder.
+1 dayRe-derive an LSB and error for a new converter.
+3 daysPick bits and rate for one real measurement.
+7 daysMove on to hydraulic and pneumatic actuation in Module 5.
+30 daysReuse the 2n and half-LSB rules whenever you digitize.
10

Textbook mapping

This module follows William Bolton, Mechatronics, 6th edition. Use these references to read further.

Topic in this moduleWhere to read more
Sampling and digital signalsBolton, Chapter 4, Digital signals
Analog-to-digital conversionBolton, Chapter 4, Analogue-to-digital conversions
Digital-to-analog conversionBolton, Chapter 4, Digital-to-analogue conversions

Chapter numbers refer to Bolton's Mechatronics, 6th edition. Any edition with the same chapter titles is equivalent for study.