Skip to content

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 read
  • Updated
On this page · 13 sections
  1. Prerequisites
  2. The Hook: Where the Analogue World Ends
  3. D/A Converters
  4. A/D Converters
  5. Microprocessor Basics
  6. Microcontrollers
  7. Memory Tricks
  8. Don’t Confuse
  9. Common Mistakes
  10. Practice
  11. Quick Revision Table
  12. Key Takeaways
  13. What’s Next

Prerequisites

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})$$
TermMeaning8-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,
$$\boxed{\text{SQNR} \approx 6.02n + 1.76\ \text{dB}}$$

so each extra bit buys about 6 dB.

Converter types

TypeHow it worksConversion timeStrengthsWeaknesses
Flash (parallel)\( 2^n - 1 \) comparators against a resistor-divider ladder; priority encoder gives the codeone step (fastest)GHz-rate samplingcomparator count doubles per bit: 255 for 8 bits
Counter (ramp / staircase)counter drives a DAC until DAC output exceeds inputup to \( 2^n \) clocks, depends on inputsimpleslow, variable time
Trackingup/down counter follows the inputfast for slow signalscontinuousslews slowly on steps
Successive approximation (SAR)binary search: try each bit from MSB, keep it if DAC output \( \leq \) input\( n \) clocks, fixedgood speed–resolution compromise; most commonneeds sample-and-hold
Dual-slope (integrating)integrate input for fixed time \( T_1 \), then de-integrate with \( -V_{ref} \) and time the return to zerolong (ms)high accuracy, rejects noise; insensitive to \( R \), \( C \), clock driftslow
Sigma-delta1-bit converter heavily oversampled, digital filtermoderatevery high resolutionlatency

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

Feature8085
Data bus8 bits (multiplexed with the low address byte as AD0–AD7; ALE latches the address)
Address bus16 bits → \( 2^{16} = 65\,536 \) locations (64 KB)
General registersB, C, D, E, H, L (8 bits), usable as pairs BC, DE, HL
AccumulatorA: one operand and the destination of arithmetic and logic results
Special registersprogram counter (PC, 16-bit), stack pointer (SP, 16-bit)
FlagsS (sign, bit 7 of result), Z (zero), AC (auxiliary carry, out of bit 3), P (parity, set for even parity), CY (carry/borrow)
InterruptsTRAP (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:

ModeExampleMeaning
ImmediateMVI A, 32Hload the constant 32H into A
RegisterMOV B, Ccopy C into B
DirectLDA 2050Hload A from memory address 2050H
Register indirectMOV A, Mload A from the address held in HL
ImpliedCMAcomplement 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).

ChipAddress linesChips for 32 KB (8-bit words)
1K × 81032
2K × 81116
4K × 8128

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.

FeatureMicroprocessor (e.g. 8085)Microcontroller (e.g. 8051)
On chipCPU onlyCPU, ROM, RAM, I/O, timers, serial port
Memoryexternalmostly internal
Typical architecturevon Neumann (one memory space for code and data)Harvard (separate code and data spaces) in the 8051
Instruction setrich data handlingbit manipulation, I/O control
System cost and sizelargercompact, low power
Usegeneral computingembedded 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

ThisWith thisThe difference
ResolutionAccuracysmallest step the converter can represent; closeness to the true value, including offset, gain and linearity errors
Weighted-resistor DACR-2R ladder\( n \) different resistor values; only two values
Flash ADCSAR ADC\( 2^n - 1 \) comparators, one step; one comparator and a DAC, \( n \) steps
Sampling rateConversion timehow often samples are taken; how long one conversion takes
MicroprocessorMicrocontrollerCPU only, external memory and I/O; CPU with memory and peripherals on chip
Von NeumannHarvardone 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

  1. How many comparators does a 4-bit flash ADC need?
  2. How many memory locations can 16 address lines select?
  3. How many clock cycles (one per bit) does a 10-bit SAR ADC need for one conversion?
Answers
  1. 15 (\( 2^4 - 1 \)).
  2. 65 536 (64 K).
  3. 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:

  1. The input voltage is 1.200 V.
  2. If the integrator capacitor were 10% larger, the reading would change by 10%.
  3. A 50 Hz interference on the input is strongly rejected.
  4. 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
  1. \( V_{in} = V_{ref}T_2/T_1 = 2 \times 12/20 = 1.2 \) V. True.
  2. \( RC \) cancels between the two phases. False.
  3. 20 ms is exactly one period of 50 Hz, whose integral over a whole period is zero. True.
  4. \( 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:

  1. The first trial code 1000 0000 is rejected.
  2. The final code is 0101 1110 (decimal 94).
  3. Bit 0 is rejected because 0101 1111 corresponds to 3.711 V.
  4. 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
  1. 1000 0000 gives 5.000 V > 3.70 V: rejected. True.
  2. The full trace (in the worked example above) ends at 0101 1110 = 94, which is \( \lfloor3.70/0.0390625\rfloor = \lfloor94.72\rfloor \). True.
  3. \( 95 \times 0.0390625 = 3.711 \) V > 3.70 V. True.
  4. 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:

  1. The loop body runs five times.
  2. At HLT, A = 0FH.
  3. At HLT, C = 00H and the zero flag is set.
  4. 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

IdeaFormula or fact
DAC output\( V_{ref}D/2^n \)
Step (1 LSB)\( V_{ref}/2^n \)
Full scale\( V_{ref}(1 - 2^{-n}) \)
Weighted resistorvalues \( R \) to \( 2^{n-1}R \)
R-2Rtwo values; current halves per node
Nyquist\( f_s > 2f_{\max} \); alias at \( \lvert f - kf_s\rvert \)
Quantisationerror \( \pm Q/2 \); SQNR \( 6.02n + 1.76 \) dB
Flash\( 2^n - 1 \) comparators, fastest
SAR\( n \) clocks, fixed time
Counter typeup to \( 2^n \) clocks
Dual slope\( V_{in} = V_{ref}T_2/T_1 \); \( T_1 \) = mains period rejects hum
80858-bit data, 16-bit address (64 KB); A, B–L, PC, SP; flags S Z AC P CY
StackPUSH: SP − 2; LIFO
80514 KB ROM, 128 B RAM, 4 ports, 2 timers, serial port, 5 interrupts

Key Takeaways

What’s Next