Advertisement

Blog

Simple μ C-Based A/D Converters, Part 2: Σ -Δ

Microcontrollers (μCs) often contain a comparator that can implement a precise analog-to-digital (A/D) converter (ADC) with the addition of only an external resistor and capacitor. It is a charge-balancing or Σ- Δ (or Δ -Σ) ADC. The basic scheme uses a comparator which outputs μC input bit IN and requires one μC output bit, OUT. The circuit is shown below.

In μC software, the ADC routine is best implemented as an interrupt routine, driven by a timer of period tINT , the interrupt period. In the circuit above, the ADC reference voltage is the μC supply (VR = VCC ). This assumes that the μC has CMOS output bits, so that the outputs for negligible current are near the rails:

If greater accuracy than VCC is required, instead of driving R directly from OUT, use it to switch accurate analog switches between reference ground (for 0) and an accurate VR (for 1). If the OUT-bit voltage levels are close enough to the rails and the μC is low in power use, then an accurate VCC can be supplied by the reference voltage source, VR .

Σ-Δ RC Constraint for n -Bit Accuracy

The charge-balance voltage waveform on the capacitor is a constant voltage with a small up-down exponential ripple riding on it at the frequency that OUT switches. If this varying voltage becomes too large, the ADC will not be linear enough for n -bit conversion. The larger the RC time constant, the smaller the ripple. How large must R x C be made to ensure n bits of linearity? Large enough so that the ripple voltage, ΔvC = vH vL vLSB = 2-n x VR . Then

where vH and vL are the maximum and minimum values of the vC ripple. At full-scale, vH = VR and

or solving for R x C and applying the approximation, ln(1 + x ) ≈ x for x << 1,

For tINT = 1 ms, and n = 8 bits, then R x C ≥ 256 ms. For n = 10, R x C ≥ 1.024 s. The allowable measurement rate is comparable to DMMs. Multiple conversion values of NX can be used in a running average so that the new averaged values occur at a higher rate once the initial set of values has been acquired.

Σ-Δ Algorithm

The ADC algorithm, coded as part of the interrupt routine, sets or clears OUT to keep vC = vX . In other words, charge balance is maintained on C so that Δ q = 0. This can be expressed using Δ q = i x Δ t = (v /R )· Δ t :

or

where N is the number of tINT cycles during the measurement. After N intervals, the measurement ends, and the NX accumulated during this measurement interval is related to vX by N and VR :

N is a software parameter and VR = VCC of the μC; VR /N is a constant that is computed once. For each interrupt, the following routine is executed:

0. n ← 0

1. If IN = 1: OUT ← 1; increment NX

Else if IN = 0: OUT ← 0

2. Increment n . If n < N , go to 1.

At the end of the measurement, after N interrupts (or intervals of tINT ), then execute the following routine:

3. NX (out) ← NX Reset NX ← 0

Because the algorithm is simple, it takes few μC cycles and can be iterated at a relatively high interrupt rate.

Unmatched RU and RL

A refinement that can be brought to the minimalist ADC is to account for different resistance values in series with the OUT switches. Let RU be the series resistance when OUT = 1 (high) and RL when it is 0 (low). Then

Given the two switch resistance values, the measured voltage, as a fraction of the reference voltage is

This equation presents the onerous μ C task of division, despite the pre-calculated constant, RL /RU . This refinement is best left for DSPs, which usually facilitate division. As μCs become like DSPs, this improvement becomes feasible to implement.

Auto-Calibration

A more elegant method of producing an accurate measurement without external reference switching can be applied to systems in which multiple channels are multiplexed into the ADC. If two additional MUX inputs are available and the ADC is linear, two-point calibration can be applied. Two reference voltages, which can be 0 V and VR are applied to the ADC, resulting in NX (0 V) = N0 and NX(VR ) = VR . A plot of NX versus vX will then have two known points on it, corresponding to the known input voltages. The equation for the linear calibration function – graphically, a line – is

where the expression in parentheses is the slope of the line. In general, the offset voltage, Vos , can be of either polarity, requiring negative NX . To get around this, two precision resistors forming a divider from VR can provide instead a known accurate voltage of α x VR , where α is the attenuation ratio of the divider. For this more general case, the equation of the line can be written by equating slope expressions:

Solving for vX ,

By making α= 1/2, then m must be divided by two, a right-shift instruction. To add 1/2 to it for a rounded division, increment m before right-shifting. The resulting number is the fraction of VR that is vX .

Inverting Σ-Δ ADC

An inverting Σ- Δ converter uses one additional resistor, as shown below.

The RC time constant must still be much greater than tINT . A low OUT is 0 V and a high level is VCC = α x VR . Charge balance on the capacitor is maintained by the ADC algorithm, keeping VC = VR . This results in ΔQ = 0 C, or

Solving for the ADC transfer function,

For RX = RR , and α = 2, then

The following chart summarizes the transfer function:

The interrupt routine for the ADC is

0. n ← 0

1. If IN = 1: OUT ← 0; increment NX

Else if IN = 0: OUT ← 1

2. Increment n . If n < N , go to 1.

At the end of the measurement, after N interrupts (N intervals of tINT ), then output NX and reset it:

3. NX (out) ← NX

Reset NX ← 0

Closure

These minimal-component ADCs are often adequate for slow, medium-precision, μC-based ADC requirements. Besides few components, other advantages of the Σ- Δ ADC is that it does not need an anti-aliasing filter or sample & hold circuit preceding its input. Its integrating function reduces noise bandwidth of the measurement. It is an optimal solution for many μC-based applications.

The inverting ADC input circuit could be extended to have a second-order, cascaded RC filter using the same software routine, with a total of 4 external resistors and 2 capacitors. This adumbration is left to the imagination of the reader. With sufficiently low tINT , which is achievable on faster μCs and DSPs, high precision can be attained with a medium-performance comparator. By replacing the RC integrator with an external op-amp integrator, precision can be extended further.

0 comments on “Simple μ C-Based A/D Converters, Part 2: Σ -Δ

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.