3-bit folding flash ADC uses only 3 comparators

Started by earthtonesaudio, February 17, 2011, 09:30:05 AM

Previous topic - Next topic

earthtonesaudio

I've been posting my progress with this circuit in this thread but I thought it might be worthwhile to re-post here.



This circuit uses a TL074 for all the active sections, but 3 are used as comparators and one is used as a voltage follower.  If one were so inclined, it is possible to build the entire ADC using only 3 parts: one TL074, and two log pots as "coarse" and "fine" threshold adjustment settings, replacing R3/R4 and R1/R2 respectively.
My current, verified values are:
R1=10k
R2=220k
R3=56k
R4=1M
And this can be reduced to R2=22R1, and R4=17R3.

The interesting thing to me is that this configuration appears to violate the formula on Wikipedia for calculating the number of comparators used in a folding flash ADC:

QuoteIf a m-times folding circuit is used in an n-bit ADC, the actual number of comparator can be reduced from 2n-1 to 2n/m (there is always one needed to detect the range crossover).

By this formula, my circuit with 3 comparators and 3 bits must be folding 8/3 times, but to my eyes it only looks like it's folding twice.

cloudscapes

I'm trying to figure out how there can be 8 possible bit combinations on the 3 pads with such a circuit.  ???
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

earthtonesaudio

The way I figured this out was to assume I could generate all 8 words in order, then figure out what thresholds I would need at the comparator inputs to obtain each word.

To analyze, assume V+ is 9V, V- is 0V, and AGND is 4.5V.
The resistor ratios are as stated above, R2=22R1, R4=17R3
Assuming the IC1C output swings rail-rail for simplicity (with a TL07x they don't go to the rail, but close enough for analysis purposes), the junction of R4/R3, and therefore also the output of IC1D will either be 4.25V or 4.75V.
Since the output of IC1B also swings rail-rail, the voltage at the junction of R1/R2 will be one of four values:
4.07V
4.45V
4.54V
4.93V

So all the thresholds in order are:
4.07
4.25
4.45
4.5
4.54
4.75
4.93

For each threshold you get one word above and one below:
000
     4.07
100
     4.25
010
     4.45
110
     4.5
001
     4.54
101
     4.75
011
     4.93
111

earthtonesaudio

I'm not 100% sure but it seems plausible to assume this topology could be expanded to n bits using n comparators, (n-1) resistive dividers, and (n-2) voltage buffers:


PRR

I'll be snookered. It does work. Glitchlessly.

The buffer is not essential. Change 1Meg+56K to 1K+56 and replace buffer with a short. The <56 ohm node impedance is low enough to not upset the 220K+10K divider.

Without really understanding the tradeoffs, I would think you should use the spare opamp to increase the analog signal before going into the ADC, to reduce errors. Reduce resistor ratios, of course. Probably a few-to-one rather than over ten-to-one.
  • SUPPORTER

earthtonesaudio

Hi Paul, thanks for your comments.  I built this with a TL074, which (according to the datasheet) isn't happy driving loads less than 10k.  If I had a higher-current quad op-amp I would definitely try the smaller divider and use the remaining op-amp for something more interesting.

The big ratios are arbitrary, but they keep the thresholds near AGND, which I thought would be useful for the small signals coming from a passive guitar.  I also didn't want to get too close to the negative rail on the TL074, to avoid phase inversion problems.

I was doing some figuring and it seems like R2:R1 has to be at least about 5:1 or you lose output states 001 and 110.  But that could just be for a particular R4:R3 ratio.  It might actually be a ratio of the two ratios that matters, but I am too lazy to figure it out.

cloudscapes

#6
Forgive me but I'm really not getting this.  ???

I just don't see how (with just a few opamps and no logic) how you can get the following:

0.5v - only bit A is high
1.0v - only bit B is high
1.5v - both bits A and B are high
2.0v - bit A and B are low but bit C is high
2.5v - only bits A and C are high
3.0v - only bits B and C are high
3.5v - A B and C are high
4.0v - only bit D is high
4.5v - only bits A and D are high
and so on

I'm just not seeing how it's capable of that with so few circuitry.  ??? ??? I'd always thought a minimum of logic is required in order to "make decisions"
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

earthtonesaudio

To be fair, I don't know for sure if the 4-bit version works.  The 3 bit version is verified though, and contained inside it is a 2-bit version.  I think it's sufficient proof of concept to analyze just the two LSBs.

So if you look only at the circuitry immediately connected to A and B, you see that comparator B takes its reference voltage from a fixed source, and comparator A's reference is either higher or lower than B's reference, and depends on the output state of B.

So if the signal is fully low, both comparators are off (00).  As the input increases, it reaches a voltage which is higher than A's reference, but still lower than B's reference, and output A goes high (01).  As the input continues to increase it becomes higher than B's reference.  Here's where the trick happens:
B goes high, which immediately causes the reference for A to go higher than it was before.  This new reference for A is higher than the reference for B, and since the input is still just barely above B's reference, the output of A is low (10).
Finally the input goes higher than A's new threshold and both comparators are high (11).

The key to all of this is that the fixed reference is in the middle of the signal swing, and when the MSB changes state, it forces all the other voltage references to change.

JKowalski

Quote from: cloudscapes on February 23, 2011, 12:47:13 PM
I'm just not seeing how it's capable of that with so few circuitry.  ??? ??? I'd always thought a minimum of logic is required in order to "make decisions"

Ah, but this is multi-level logic. You can do much more complex things with fewer parts if you have more then two states to work with.

PRR

> I'm just not seeing how it's capable of that with so few circuitry.

Exactly what I thought.

But it does.



Signal grounded for simplicity, supplies are +/-5V. (This won't interface nice with some logic, but that can be fixed.)

Input V2 is a 0.5V peak sine wave. On the plot I multiply by 18 so it can be seen among the larger outputs: green line V(V2:+)*18

Bits A B C go up and down. I've offset a trice so they don't overlap.

The proof of our ADCs is a DAC: do we get back what we put in? The "V(BitC) + V(BitB)/2 + V(BitA)/4" is of course the function of a 3-bit binary DAC. Orange line.

The orange line "matches" the green line as good as possible with 3 bits, 8 steps. And there are no glitches at the transitions.

> TL074, which (according to the datasheet) isn't happy driving loads less than 10k.

?? Errors are near-zero for 2K load. I used 1K:56 cuz I'm too lazy for math, but (ummm) 2K and 112 or 2K2/123 is the same ratio and 112--123 is far less than the 230K divider.

> big ratios are arbitrary, but they keep the thresholds near AGND, which I thought would be useful for the small signals coming from a passive guitar.

In general, when doing decisions on small signals, you first bump them up to substantial level. Dwarfs offset errors, speeds switching response. Gain of 10 simple analog amplifier.

> to avoid phase inversion problems.

Simulated LF411 (granddaddy of TL07x) showed that effect. Turn it down a trace.

At 3 bits you probably DO have a compromise between no-output below -18dB, and whatever overload artifacts your chip has. You can clamp, you can use another chip.... leave that for later.

> It might actually be a ratio of the two ratios that matters

Oh, surely the two ratios must track. I suspect numbers like 2:1 and 1.5:1 work for large inputs, but I too am too lazy to work the numbers.
  • SUPPORTER

JKowalski

#10
This is a really interesting circuit. I was playing around with it on falstad's sim.

It works for N inputs. I tried it with 4 & 5 comparators, though I didn't bother to calculate the resistor values accurately (is there an easy formula?) I got CLOSE to linear.

Whats really neat about the circuit is the potential for waveshaping. I set it up with a simple 5-bit op-amp summer DAC on the output with lowpass and played around with weird resistor ratios. You can really, really screw around with the transfer function.

I'm picturing an 8-bit weird waveshaping box with two quad comparators and a bank of knobs on top to skew the dividers....  :icon_eek: Actually, why not scale up to 12-bits... You could even throw in some modulation of the waveshaping through the voltage reference...

The coolest thing is that it's really so simple, just slightly repetitive.

earthtonesaudio

Paul, thanks for the info and pics.  I don't know why I thought 10k, must have misread something.

Chris, thanks for simulating it with n-bits.  I thought it should work, but I haven't had the chance to sim or build with more than 3 bits.
I did redraw it so it's easier to visualize expanding it to n-bits:


I would expect physical limitations (switching speed, errors-especially near zero crossings) to become more of a concern as you increase the number of bits, but I do think the arbitrary transfer function idea is cool.  That's what Taylor had in mind with his Uncanny Valley circuit, and it does indeed work for that.

PRR

Yes, I think a basic "flaw" (a reason it is uninteresting to ADC scientists) is that speed falls with number of bits (and in the ADC racket, speed is money).

And that's why you don't want large divider ratios... speed will be better with small ratios (assuming general-purpose chips), and you can get your sensitivity with simple analog ampification in front.

Still, your uses are non-precision and often slow. Things like audio, and particularly pitch extraction, NEED low-speed (relative to some of the stuff on the bleeding edge).
  • SUPPORTER

slacker

I just stumbled across this via google. I was after a cheap and cheerful way to switch programs in the Spin FV-1, you're supposed to use a BCD rotary encoder, but they're relatively expensive, mostly designed to be PCB mounted and my usual suppliers don't stock them.  So I thought lets see if there's a simple way to make an ADC then I can just use a pot instead, happily this looks like it will do the job just fine.

If anyone's interested I changed the R2/R1 divider to 5:1 and R4:R3 to 2:1 which makes it work over an input range of about 7 or 8 volts, which works fine using a pot wired as a voltage divider across the supply as an input. There's a bit of dead space at the top and bottom ends of the travel but a couple of series resistors would take care of that. I haven't actually hooked it up to the FV-1 yet, but hanging LEDs off the outputs shows it's doing the right thing. 

Thanks for sharing it.

earthtonesaudio

That's a great use for this circuit, Ian.  Thanks for the resistor-scaling info as well.  I'm assuming you built a 3-bit version, correct?  I haven't built a real world version of the 4-bit circuit yet, to see if it works with general purpose op-amps.

slacker

Yeah I've built the 3 bit version, I only need to select 8 programs. I tried it with the FV-1 tonight and it works as I'd hoped, using an LM324 I was able to run it at the FV-1's 3.3 volts and directly connect the outputs to the relevant pins. It also worked fine running it at 9 volts and hooking it up to the FV-1 using pull up resistors on the pins with diodes to do the switching.
If the 4 bit version works that would be great as you could access all the FV-1's programs, I wonder if Paul's version without the buffer can be expanded to 4 bit, so you'd still only need a quad?

I can see a few cool uses for this in an analogue synth that I'll have to play with. If you hooked the outs up to a CD4051, similar to what you and Taylor were discussing in the other thread you could make a voltage controlled sequencer or simple quantiser type thing.

frequencycentral

I don't understand most of this thread, but I'm excited by it anyway.  :D
http://www.frequencycentral.co.uk/

Questo è il fiore del partigiano morto per la libertà!

PRR

> I don't understand

A 3-bit flash converter has eight comparators and a priority encoder. One cycle, or it could run asynchronously.

A 3-bit dumb converter has a 3-bit digital-to-analog converter, a 3-bit counter, a comparator, and logic to stop the count when the DAC crosses the input. Must start/stop. Can take 8 cycles.

A 3-bit sucessive-approximation converter has a 3-bit digital-to-analog converter, a comparator, and some logic to yes/no its way to the answer in shortest time. Must start/stop. Can take 3 cycles.

Alex's plan is just 3 comparators, a 3-bit digital-to-analog converter, and can run asynchronously (in fact has no way to start/stop), but the comparators must be fast.

It's a hardware minimization. Back when each comparator was a $50 plug-in, such tricks were of great interest. Now that we can buy a 8-bit ADC for $4 and they throw in a mini-CPU too (PIC), it is maybe more fun than profit.
  • SUPPORTER

Gurner

Quote from: PRR on May 06, 2011, 12:20:19 AMNow that we can buy a 8-bit ADC for $4 and they throw in a mini-CPU too (PIC), it is maybe more fun than profit.

+1 to that (though $4 is excessive ...$1.50 gets me what I need ....8CH of ADC, some hw comparators thrown in, a basic DAC, PWM modules, blah blah!)

This one looks like a 'mountaineering project' to me (ie.....why climb it? becuase it's there!)

earthtonesaudio

Quote from: Gurner on May 06, 2011, 04:52:31 AM
Quote from: PRR on May 06, 2011, 12:20:19 AMNow that we can buy a 8-bit ADC for $4 and they throw in a mini-CPU too (PIC), it is maybe more fun than profit.

+1 to that (though $4 is excessive ...$1.50 gets me what I need ....8CH of ADC, some hw comparators thrown in, a basic DAC, PWM modules, blah blah!)

This one looks like a 'mountaineering project' to me (ie.....why climb it? becuase it's there!)

Definitely true.  30 years ago this would have been quite an achievement.  Today it's a novelty, but that doesn't mean I'm not proud of myself for discovering it.   ;D