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.
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.
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) × VrefDigital 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 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 n | Levels 2n | LSB at Vref = 10 V |
|---|---|---|
| 8 | 256 | 39.1 mV |
| 10 | 1024 | 9.77 mV |
| 12 | 4096 | 2.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.
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.
- ProblemFind the levels, LSB, and worst-case error for the ADC in Figure 1.
- Given / findn = 8 bits, Vref = 10 V. Find levels, LSB, and error.
- AssumptionsIdeal uniform quantizer, input within the reference span.
- Modellevels = 2n; LSB = Vref/2n; error ≤ LSB/2.
- Equationslevels = 28 = 256LSB = 10 / 256
- Solve256 levels; LSB = 10/256 = 39.1 mV; error ≤ 39.1/2 = 19.5 mV.
- Check256 steps of 39.1 mV sum to 10.0 V, and half a step is 19.5 mV, as required.
- 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.
Worked example 2: a DAC output
An 8-bit DAC with a 10 V reference receives the code 200. Find its output voltage.
- ProblemFind the DAC output for code 200 in Figure 2.
- Given / findn = 8 bits, Vref = 10 V, code = 200. Find Vout.
- AssumptionsIdeal linear DAC, no output loading error.
- ModelVout = (code/2n) × Vref.
- EquationsVout = (200 / 256) × 10
- SolveVout = 0.781 × 10 = 7.81 V.
- Check200 is a little under 80 percent of 256, and 78 percent of 10 V is 7.81 V, consistent.
- ConclusionThe controller commands 7.81 V by writing the code 200, the reverse of the ADC's job.
Misconceptions and diagnostics
| Mistake | Symptom | Diagnostic question | Correction |
|---|---|---|---|
| Using n instead of 2n | Far too few levels | "Is it n or two to the n?" | Levels are 2n, not n. |
| LSB set to the full range | Resolution wildly overstated | "Did I divide by 2n?" | LSB = Vref/2n. |
| Quantization error = LSB | Error doubled | "Round to nearest or truncate?" | Rounding gives at most half an LSB. |
| Sampling below Nyquist | False low-frequency content | "Is fs above twice the signal?" | Sample above twice the highest frequency. |
Practice ladder
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.
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.
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.
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).
Working with AI, and proving it yourself
Use AI as an examiner, not a solver
Portfolio task
For one measurement, choose an ADC bit count and sample rate, and justify both from the required resolution and signal bandwidth.
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.
Textbook mapping
This module follows William Bolton, Mechatronics, 6th edition. Use these references to read further.
| Topic in this module | Where to read more |
|---|---|
| Sampling and digital signals | Bolton, Chapter 4, Digital signals |
| Analog-to-digital conversion | Bolton, Chapter 4, Analogue-to-digital conversions |
| Digital-to-analog conversion | Bolton, 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.