main content

design and evaluate successive approximation adc using stateflow -凯发k8网页登录

this example shows a 12 bit successive approximation register (sar) adc with a circuit-level dac model.

successive approximation adcs typically have 12 to 16 bit resolution, and their sampling rates range from 10 ksamples/sec to 10 msamples/sec. they tend to cost less and draw less power than subranging adcs.

model

open the system msadcsuccessiveapproximation.

model = 'msadcsuccessiveapproximation';
open_system(model)

set the switches to their default positions, selecting the two-tone source and the ideal dac model.

set_param([model '/source'],'sw','1');
set_param([model '/dac'],'sw','0');

the top-level model consists ofa testbench and the device under test. the testbench includes the test signal generators and the time domain scopes and spectrum analyzer for measurement purposes. the device under test, highlighted in blue in the model, contains a track and hold:, a comparator, control logic, and charge scaled dac.

the test signal is either a two-tone sine wave or a constant dc level input. this test signal is sampled and held at the adc's output word rate of 10 mhz. the output of the sampler serves as one input to a comparator. the second comparator input is the dac output which is an incrementally stepped reference level. if the output of the sampler is greater than or equal to the dac output, then the comparator outputs a logical 1. when this happens, the corresponding bit of the output is set to logical 1. otherwise, the comparator outputs a logical 0 which does not increment the adc output word. this single comparator is only place in the successive approximation converter where analog is converted to digital.

sim(model);

define the number of bits ( nbits ) and adc conversion rate ( fs ) in the matlab® workspace. the adc operating clock rate is determined from nbits and fs .

nbits = 12;
fs = 1e7;
adc_clock = fs*(nbits 2);

successive approximation control logic

this model uses stateflow to model the successive approximation control logic. the state-machine serves as a sequencer that starts by outputting a count corresponding to midscale which in this case is 0 volts. the state-machine then performs a binary search of one bit position at a time to find the count corresponding to the closest approximation to the sampled input signal within 12 bits of resolution. the init state prevents an end of conversion (eoc) signal from being sent prior to the first conversion.

open_system([model '/successive approximation logic'],'force')

on a particular bit, if the comparator outputs a 1, then that bit is set. otherwise that bit position is cleared. because there are 12 bits, it takes 12 clock cycles at the bit rate clock to complete the conversion for a given input sample.

in this model, the bit rate clock denoted by block labeled adc internal clock runs at 140 mhz. this clock is 14 times faster than the sample rate clock denoted by the block labeled conversion clock in the upper left corner of the model. after the control logic sequences from bit 11 down to bit 0 the end-of-conversion (eoc) line goes high, telling the dac circuitry to reset.

dac circuit-level implementation

the circuit-level dac uses a multi-stage charge-scaled array of capacitors in a split-array format. this architecture provides several advantages including reduced area or parts count, a built-in sample and hold, low power dissipation, and a relatively small range of capacitance values as would be required without a split-array.

there are two versions of a digital to analog converter (dac) in this model, one at the circuit-level and the second representing ideal dac behavior. the ideal dac block takes the input count and multiplies it by

$$\frac{v_{ref}}{2^{n_{bits}}} = \frac{2\sqrt{2}}{2^{12}} \left[\frac{volts}{count}\right]$$

to generate the output comparison voltage [1].

set the switch to enable the circuit-level dac model. run the model.

set_param([model '/dac'],'sw','1');
sim(model);

this particular charge-scaled array uses $n_{caps} = 3$ binary-weighted capacitors per stage with a total of $k = 4$ stages providing a total of $n_{caps} * k = 12$ bits of dac resolution. the binary-weighted capacitors per stage have a value of $1 c$, $2 c$, and $4 c$. the larger the capacitance corresponds to a higher bit position within a particular stage. for example, setting the low side of the $4 c$ capacitor high has 4 times the output voltage impact relative to setting the low side of the $1 c$ capacitor high.

if you change the value of the variable nbits, the physical number of bits of the converter, you need to modify the circuit level implementation of the dac. the ideal dac implementation and the control logic are parametrized with respect to the number of bits.

open_system([model '/circuit level 12 bit dac'],'force')

each stage is separated by a scaling capacitor with value $\frac{8}{7}c$. the scaling capacitor serves the purpose of attenuating the output voltage of each stage's output voltage. the further the stage is from the dac output node, the more it is attenuated. the attenuation is 8x per scaling capacitor which corresponds to $2^{n_{caps}}$.

the three msbs are closest to the output, bits 0, 1, and 2 while there lsbs, bits 10, 11, and 12 are furthest away. at any given time, the dac is in one of two modes. it is either generating an output voltage based on a particular input count or it is being reset when the eoc line goes high. when eoc goes high, the low side of each capacitor in the dac is switched to ground rather than data, thus draining the capacitors of charge in preparation for the next approximation. this effectively drains the capacitive network of charge preparing it for the next input sample.

measurement testbench

the adc testbench block from the mixed-signal blockset™ can provide a performance analysis of the adc.

in dc mode, the adc testbench tests the linearity of the adc. the test result is used to generate offset and gain error measurements which are displayed on the block mask. the full test results are available for export or visualization via the buttons on the adc testbench block mask.

bdclose(model);
model = 'msadcsar_dc';
open_system(model);
sim(model);

the ac mode of the adc testbench provides insight into the frequency performance of the adc, including measurements like the enob (effective number of bits), the maximum measured conversion delay, and the noise floor of the converter. these measurements are displayed on the block icon after simulation and are available for export via a button on the block mask.

model = 'msadcsar_ac';
open_system(model);
set_param([model '/dac'],'sw','1');

references

  1. haideh khorramabadi uc berkeley, department of electrical engineering and computer sciences, lecture 15, page 38

| |

related topics

    网站地图