A/D and D/A Converters, Microprocessors and Microcontrollers
CSIR NET electronics: weighted and R-2R DACs, flash, SAR and dual-slope ADCs, sampling and quantisation, 8085 and 8051 basics, with practice.
- 16 min
On this page · 13 sections
Prerequisites
- Operational Amplifiers: the summing amplifier (every DAC), the integrator (dual-slope ADC) and the voltage comparator (every ADC).
- Digital Techniques: Logic, Registers, Counters and Comparators: registers, counters, binary and hexadecimal arithmetic.
- Fourier analysis for the sampling theorem, from Linear ODEs and Special Functions and your mathematical-methods course.
The Hook: Where the Analogue World Ends
D/A Converters
An \( n \)-bit DAC converts a code \( b_{n-1}\ldots b_1b_0 \) into a voltage proportional to its value \( D = \sum b_i2^i \):
$$\boxed{V_o = V_{ref}\,\frac{D}{2^n}} \quad (\text{magnitude; many circuits also invert the sign})$$| Term | Meaning | 8-bit, \( V_{ref} = 10 \) V |
|---|---|---|
| Resolution (step, 1 LSB) | \( V_{ref}/2^n \) | 39.06 mV |
| Full-scale output | \( V_{ref}(1 - 2^{-n}) \) | 9.961 V |
| MSB alone (\( 1000\,0000 \)) | \( V_{ref}/2 \) | 5.000 V |
| Percentage resolution | \( 1/(2^n - 1) \times 100\% \) (step over full scale) | 0.39% |
Some books define resolution as \( V_{FS}/(2^n - 1) \) with \( V_{FS} \) the full-scale output; read the question’s definition.
Binary-weighted resistor DAC
Each bit switches \( V_{ref} \) through a resistor \( R, 2R, 4R, \ldots, 2^{n-1}R \) (MSB to LSB) into the virtual ground of an inverting summing amplifier with feedback \( R_f \):
$$V_o = -V_{ref}\frac{R_f}{R}\left(b_{n-1} + \frac{b_{n-2}}{2} + \cdots + \frac{b_0}{2^{n-1}}\right)$$Simple, but the resistor values span a ratio of \( 2^{n-1} \) (128 for 8 bits), and the MSB resistor must be accurate to better than 1 part in \( 2^n \). Hard to make for large \( n \).
R-2R ladder DAC
Only two resistor values. At every node of the ladder the resistance looking towards the termination is \( 2R \) in parallel with \( 2R \), so the current halves at each node going down the ladder. Bit \( i \) contributes a current proportional to \( 2^{i-n} \). Output into a virtual ground:
$$V_o = -V_{ref}\frac{R_f}{R}\sum_{i=0}^{n-1}\frac{b_i}{2^{n-i}} \qquad (\text{for } R_f = R:\ V_o = -V_{ref}D/2^n)$$Matching two values is easy on a chip, which is why R-2R ladders are standard.
Specifications: resolution, settling time (time to reach within ½ LSB of the final value), linearity and monotonicity (output never decreases as code increases), offset and gain errors.
A/D Converters
Sampling and quantisation
- Sampling theorem (Nyquist): a signal containing no frequencies above \( f_{\max} \) is fully recoverable from samples taken at \( f_s > 2f_{\max} \). A component at \( f > f_s/2 \) aliases to \( \lvert f - kf_s\rvert \) for the integer \( k \) that brings it into \( [0, f_s/2] \). An analogue anti-aliasing filter precedes the ADC.
- Sample-and-hold: freezes the input while the converter works.
- Quantisation: an ideal \( n \)-bit ADC over range \( V_{FS} \) has step \( Q = V_{FS}/2^n \) and maximum quantisation error \( \pm Q/2 \). For a full-scale sine wave,
so each extra bit buys about 6 dB.
Converter types
| Type | How it works | Conversion time | Strengths | Weaknesses |
|---|---|---|---|---|
| Flash (parallel) | \( 2^n - 1 \) comparators against a resistor-divider ladder; priority encoder gives the code | one step (fastest) | GHz-rate sampling | comparator count doubles per bit: 255 for 8 bits |
| Counter (ramp / staircase) | counter drives a DAC until DAC output exceeds input | up to \( 2^n \) clocks, depends on input | simple | slow, variable time |
| Tracking | up/down counter follows the input | fast for slow signals | continuous | slews slowly on steps |
| Successive approximation (SAR) | binary search: try each bit from MSB, keep it if DAC output \( \leq \) input | \( n \) clocks, fixed | good speed–resolution compromise; most common | needs sample-and-hold |
| Dual-slope (integrating) | integrate input for fixed time \( T_1 \), then de-integrate with \( -V_{ref} \) and time the return to zero | long (ms) | high accuracy, rejects noise; insensitive to \( R \), \( C \), clock drift | slow |
| Sigma-delta | 1-bit converter heavily oversampled, digital filter | moderate | very high resolution | latency |
The dual-slope equation
Phase 1: integrate \( V_{in} \) for a fixed time \( T_1 \) (a fixed count \( N_1 \)); the integrator output reaches \( -V_{in}T_1/RC \). Phase 2: switch to a reference of opposite polarity; the output returns to zero in time \( T_2 \):
$$\frac{V_{in}T_1}{RC} = \frac{V_{ref}T_2}{RC} \quad\Rightarrow\quad \boxed{V_{in} = V_{ref}\frac{T_2}{T_1} = V_{ref}\frac{N_2}{N_1}}$$\( R \), \( C \) and the clock frequency cancel. If \( T_1 \) is a whole number of mains periods (20 ms for 50 Hz), any mains hum integrates to zero. This is why bench digital multimeters use integrating converters.
Tracing a SAR conversion
Microprocessor Basics
A microprocessor is a CPU on one chip: an arithmetic logic unit (ALU), registers, and a control unit that fetches, decodes and executes instructions from external memory over a set of buses:
- Address bus: one-directional, from CPU; \( n \) address lines select \( 2^n \) locations.
- Data bus: bidirectional; its width (8, 16, 32, 64 bits) is the “word size”.
- Control bus: read, write, interrupt, clock and other signals.
The 8085 as the standard example
| Feature | 8085 |
|---|---|
| Data bus | 8 bits (multiplexed with the low address byte as AD0–AD7; ALE latches the address) |
| Address bus | 16 bits → \( 2^{16} = 65\,536 \) locations (64 KB) |
| General registers | B, C, D, E, H, L (8 bits), usable as pairs BC, DE, HL |
| Accumulator | A: one operand and the destination of arithmetic and logic results |
| Special registers | program counter (PC, 16-bit), stack pointer (SP, 16-bit) |
| Flags | S (sign, bit 7 of result), Z (zero), AC (auxiliary carry, out of bit 3), P (parity, set for even parity), CY (carry/borrow) |
| Interrupts | TRAP (non-maskable, highest priority), RST 7.5, RST 6.5, RST 5.5, INTR |
Instruction cycle: fetch (opcode read from memory at PC; PC increments), decode, execute. Each instruction takes one or more machine cycles (opcode fetch, memory read, memory write, I/O read, I/O write), each made of T-states (clock periods).
Addressing modes with examples:
| Mode | Example | Meaning |
|---|---|---|
| Immediate | MVI A, 32H | load the constant 32H into A |
| Register | MOV B, C | copy C into B |
| Direct | LDA 2050H | load A from memory address 2050H |
| Register indirect | MOV A, M | load A from the address held in HL |
| Implied | CMA | complement A (operand implicit) |
The stack is a last-in first-out area in RAM. PUSH decrements SP by 2 and stores a register pair (high byte at SP−1, low byte at SP−2); POP reverses this. CALL pushes the return address; RET pops it.
Memory arithmetic
A memory chip of \( 2^k \) locations × \( m \) bits needs \( k \) address lines and \( m \) data lines. The remaining high-order address lines feed a decoder that selects which chip responds (memory mapping).
| Chip | Address lines | Chips for 32 KB (8-bit words) |
|---|---|---|
| 1K × 8 | 10 | 32 |
| 2K × 8 | 11 | 16 |
| 4K × 8 | 12 | 8 |
Microcontrollers
A microcontroller puts the CPU together with program memory (ROM/flash), data memory (RAM), I/O ports, timers/counters, serial interface and interrupt controller on one chip. It is designed for dedicated control tasks (instruments, appliances, data loggers) rather than general computing.
| Feature | Microprocessor (e.g. 8085) | Microcontroller (e.g. 8051) |
|---|---|---|
| On chip | CPU only | CPU, ROM, RAM, I/O, timers, serial port |
| Memory | external | mostly internal |
| Typical architecture | von Neumann (one memory space for code and data) | Harvard (separate code and data spaces) in the 8051 |
| Instruction set | rich data handling | bit manipulation, I/O control |
| System cost and size | larger | compact, low power |
| Use | general computing | embedded control |
The classic 8051 has an 8-bit CPU, 4 KB on-chip program ROM, 128 bytes of on-chip RAM, four 8-bit I/O ports (32 lines), two 16-bit timer/counters, one full-duplex serial port and five interrupt sources, with 16-bit addressing (64 KB each) for external program and data memory.
graph LR
S[Sensor] --> A[Amplifier and anti-alias filter]
A --> H[Sample and hold]
H --> ADC[ADC]
ADC --> MCU[Microcontroller: CPU, memory, timers]
MCU --> DAC[DAC]
DAC --> ACT[Actuator]
MCU --> COM[Serial port to computer]Memory Tricks
Don’t Confuse
| This | With this | The difference |
|---|---|---|
| Resolution | Accuracy | smallest step the converter can represent; closeness to the true value, including offset, gain and linearity errors |
| Weighted-resistor DAC | R-2R ladder | \( n \) different resistor values; only two values |
| Flash ADC | SAR ADC | \( 2^n - 1 \) comparators, one step; one comparator and a DAC, \( n \) steps |
| Sampling rate | Conversion time | how often samples are taken; how long one conversion takes |
| Microprocessor | Microcontroller | CPU only, external memory and I/O; CPU with memory and peripherals on chip |
| Von Neumann | Harvard | one memory for code and data; separate code and data memories and buses |
| Carry (CY) | Auxiliary carry (AC) | out of bit 7; out of bit 3 (used for BCD adjustment) |
Common Mistakes
Practice
All questions below are original practice questions written for this page. They are not from any CSIR NET paper.
Level 1: Foundation
- How many comparators does a 4-bit flash ADC need?
- How many memory locations can 16 address lines select?
- How many clock cycles (one per bit) does a 10-bit SAR ADC need for one conversion?
Answers
- 15 (\( 2^4 - 1 \)).
- 65 536 (64 K).
- 10.
Level 2: Part B Style
Practice Q1. An 8-bit R-2R DAC with \( V_{ref} = 10 \) V and \( R_f = R \) receives the code 0110 0100. The magnitude of its output is:
(a) 3.91 V (b) 3.92 V (c) 6.40 V (d) 9.96 V
Answer: (a) 3.91 V
\( D = 0110\,0100_2 = 100 \). \( V_o = 10 \times 100/256 = 3.906 \) V. (b) uses \( 100/255 \), the full-scale-over-\( (2^n - 1) \) convention, which does not apply to this circuit; (c) reads the code as BCD (64) out of 100; (d) is the full-scale output.
Practice Q2. A 12-bit ADC has an input range of 0 to 5 V. Its maximum quantisation error and ideal SQNR for a full-scale sine are about:
(a) ±1.22 mV, 72 dB (b) ±0.61 mV, 74 dB (c) ±0.61 mV, 72 dB (d) ±1.22 mV, 74 dB
Answer: (b) ±0.61 mV, 74 dB
Step \( = 5/4096 = 1.22 \) mV; maximum error half a step, 0.61 mV. SQNR \( = 6.02 \times 12 + 1.76 = 74.0 \) dB. (a) and (d) confuse step with error; 72 dB omits the 1.76 dB.
Practice Q3. A 15 kHz sine is sampled at 20 kHz without an anti-aliasing filter. The reconstructed signal appears at:
(a) 15 kHz (b) 10 kHz (c) 5 kHz (d) 35 kHz
Answer: (c) 5 kHz
\( f > f_s/2 = 10 \) kHz, so it aliases to \( \lvert15 - 20\rvert = 5 \) kHz.
Practice Q4. After MVI A, 32H; MVI B, 47H; ADD B on an 8085, the accumulator and the carry and parity flags are:
(a) A = 79H, CY = 0, P = 0 (b) A = 79H, CY = 0, P = 1 (c) A = 7AH, CY = 1, P = 0 (d) A = 15H, CY = 0, P = 1
Answer: (a) A = 79H, CY = 0, P = 0
\( 32\text{H} + 47\text{H} = 79\text{H} = 0111\,1001 \): five 1s, odd parity, so P = 0. No carry out of bit 7. (b) inverts the parity convention; (d) subtracts.
Level 3: Part C Style
Practice Q5. A dual-slope ADC integrates the input for a fixed 20 ms, then de-integrates with a 2.000 V reference. The de-integration takes 12 ms. Consider:
- The input voltage is 1.200 V.
- If the integrator capacitor were 10% larger, the reading would change by 10%.
- A 50 Hz interference on the input is strongly rejected.
- A larger input would take longer to convert.
Which are correct?
(a) 1 and 3 only (b) 1, 3 and 4 only (c) 1, 2 and 3 only (d) 1, 2, 3 and 4
Answer: (b) 1, 3 and 4 only
- \( V_{in} = V_{ref}T_2/T_1 = 2 \times 12/20 = 1.2 \) V. True.
- \( RC \) cancels between the two phases. False.
- 20 ms is exactly one period of 50 Hz, whose integral over a whole period is zero. True.
- \( T_2 \propto V_{in} \), so total conversion time \( T_1 + T_2 \) grows with input. True.
Practice Q6. An 8-bit SAR ADC with \( V_{ref} = 10 \) V (step 39.0625 mV) converts 3.70 V. Consider:
- The first trial code 1000 0000 is rejected.
- The final code is 0101 1110 (decimal 94).
- Bit 0 is rejected because 0101 1111 corresponds to 3.711 V.
- The conversion time would be shorter for an input of 0.1 V.
Which are correct?
(a) 1 and 2 only (b) 1, 2 and 3 only (c) 2, 3 and 4 only (d) 1, 2, 3 and 4
Answer: (b) 1, 2 and 3 only
- 1000 0000 gives 5.000 V > 3.70 V: rejected. True.
- The full trace (in the worked example above) ends at 0101 1110 = 94, which is \( \lfloor3.70/0.0390625\rfloor = \lfloor94.72\rfloor \). True.
- \( 95 \times 0.0390625 = 3.711 \) V > 3.70 V. True.
- A SAR always tries all \( n \) bits: conversion time is fixed. False.
Practice Q7. An 8085 executes:
MVI A, 00H
MVI C, 05H
LOOP: ADD C
DCR C
JNZ LOOP
HLT
Consider:
- The loop body runs five times.
- At HLT, A = 0FH.
- At HLT, C = 00H and the zero flag is set.
- Replacing MVI C, 05H by MVI C, 00H makes the loop run 256 times.
Which are correct?
(a) 1 and 2 only (b) 1, 2 and 3 only (c) 2 and 4 only (d) 1, 2, 3 and 4
Answer: (d) 1, 2, 3 and 4
1–2. A accumulates \( 5 + 4 + 3 + 2 + 1 = 15 = 0\text{FH} \); C counts 5, 4, 3, 2, 1, 0 and the loop exits when DCR C sets Z. True. 3. The last DCR C gave 00H and set Z; JNZ does not alter flags. True. 4. Starting at 00H, the first DCR gives FFH (non-zero), so the loop continues until C returns to 0 after 256 decrements. True.
Quick Revision Table
| Idea | Formula or fact |
|---|---|
| DAC output | \( V_{ref}D/2^n \) |
| Step (1 LSB) | \( V_{ref}/2^n \) |
| Full scale | \( V_{ref}(1 - 2^{-n}) \) |
| Weighted resistor | values \( R \) to \( 2^{n-1}R \) |
| R-2R | two values; current halves per node |
| Nyquist | \( f_s > 2f_{\max} \); alias at \( \lvert f - kf_s\rvert \) |
| Quantisation | error \( \pm Q/2 \); SQNR \( 6.02n + 1.76 \) dB |
| Flash | \( 2^n - 1 \) comparators, fastest |
| SAR | \( n \) clocks, fixed time |
| Counter type | up to \( 2^n \) clocks |
| Dual slope | \( V_{in} = V_{ref}T_2/T_1 \); \( T_1 \) = mains period rejects hum |
| 8085 | 8-bit data, 16-bit address (64 KB); A, B–L, PC, SP; flags S Z AC P CY |
| Stack | PUSH: SP − 2; LIFO |
| 8051 | 4 KB ROM, 128 B RAM, 4 ports, 2 timers, serial port, 5 interrupts |
Key Takeaways
What’s Next
- Data Interpretation, Error Analysis and Least-Squares Fitting: what to do with the numbers once they are digitised.
- Digital Techniques: Logic, Registers, Counters and Comparators: the counters and registers inside every converter.
- Electronics and Experimental Methods (Core) overview.
- Sampling and estimation in a statistical sense: Experimental Design, Sampling and Data.