DIYstompboxes.com

DIY Stompboxes => Digital & DSP => Topic started by: earthtonesaudio on February 17, 2011, 09:30:05 AM

Title: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on February 17, 2011, 09:30:05 AM
I've been posting my progress with this circuit in this thread (http://www.diystompboxes.com/smfforum/index.php?topic=89353.msg763438#msg763438) but I thought it might be worthwhile to re-post here.

(http://www.aronnelson.com/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=44588&g2_serialNumber=1)

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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: cloudscapes on February 17, 2011, 09:33:30 AM
I'm trying to figure out how there can be 8 possible bit combinations on the 3 pads with such a circuit.  ???
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on February 17, 2011, 11:51:12 AM
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
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on February 17, 2011, 03:55:14 PM
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:

(http://www.aronnelson.com/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=44613&g2_serialNumber=1)
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: PRR on February 22, 2011, 10:27:15 PM
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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on February 22, 2011, 11:52:24 PM
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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: cloudscapes on February 23, 2011, 12:47:13 PM
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"
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on February 23, 2011, 02:26:35 PM
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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: JKowalski on February 23, 2011, 05:47:20 PM
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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: PRR on February 23, 2011, 09:48:44 PM
> I'm just not seeing how it's capable of that with so few circuitry.

Exactly what I thought.

But it does.

(http://i.imgur.com/onAza.gif)

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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: JKowalski on February 24, 2011, 01:00:29 AM
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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on February 24, 2011, 08:16:24 AM
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:
(http://www.aronnelson.com/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=44666&g2_serialNumber=1)

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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: PRR on February 25, 2011, 10:32:15 PM
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).
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: slacker on April 25, 2011, 03:46:37 PM
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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on April 25, 2011, 06:00:12 PM
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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: slacker on April 26, 2011, 01:11:03 PM
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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: frequencycentral on May 01, 2011, 07:40:01 AM
I don't understand most of this thread, but I'm excited by it anyway.  :D
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: PRR on May 06, 2011, 12:20:19 AM
> 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.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: 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!)
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on May 06, 2011, 08:53:06 AM
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
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on June 24, 2011, 09:14:59 AM
I wanted to work on my PCB skillz so I made this in Eagle.  It's unverified and I'm sure I'll be making some revisions now that I've had a chance to look at it after a good night's sleep.  So take with a grain of salt, but here's a preliminary layout for an ADC/DAC "fuzz" with a volume control.

Schematic:
(http://www.aronnelson.com/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=45494&g2_serialNumber=1)

Layout:
(http://www.aronnelson.com/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=45495&g2_serialNumber=1)
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Hides-His-Eyes on June 25, 2011, 01:54:03 PM
I'd use bigger pads than that, especially if those are the GM defaults
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on June 25, 2011, 02:18:54 PM
Good call.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: oskar on July 09, 2011, 10:52:50 PM
Alex. This is just soo clever...   :o
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on July 11, 2011, 03:01:40 PM
Thanks Oskar!

I simulated a 4-bit version using just resistive dividers (no buffers). It does the job in the sim, albeit with some glitches.

Link (http://www.falstad.com/circuit/#%24+1+5.0E-6+3.5993318835628396+59+5.0+43%0Aa+672+336+752+336+0+15.0+-15.0+1000000.0%0Aa+672+400+752+400+0+15.0+-15.0+1000000.0%0Aa+672+464+752+464+0+15.0+-15.0+1000000.0%0Aa+672+528+752+528+0+15.0+-15.0+1000000.0%0Aw+672+352+640+352+0%0Aw+640+352+640+416+0%0Aw+640+416+672+416+0%0Aw+640+416+640+480+0%0Aw+640+480+672+480+0%0Aw+640+480+640+544+0%0Aw+640+544+672+544+0%0Aw+544+512+560+512+0%0Aw+560+512+672+512+0%0Ag+544+576+544+608+0%0Av+544+576+640+576+0+3+52.0+2.3+0.0+0.0+0.5%0Aw+640+544+640+576+0%0Aw+752+336+896+336+0%0Aw+784+400+896+400+0%0Aw+816+464+896+464+0%0Aw+832+528+896+528+0%0Ar+896+336+992+336+0+8000.0%0Ar+896+400+992+400+0+4000.0%0Ar+896+464+992+464+0+2000.0%0Ar+896+528+992+528+0+1000.0%0Aw+992+464+992+528+0%0Aw+992+464+992+400+0%0Ar+992+528+992+608+0+100.0%0Ag+992+608+992+640+0%0Aw+544+512+544+576+0%0Ar+560+512+560+448+0+100.0%0Ar+560+448+560+240+0+1000.0%0Aw+560+240+832+240+0%0Aw+832+528+832+240+0%0Aw+560+448+576+448+0%0Aw+576+448+672+448+0%0Ar+576+448+576+384+0+2000.0%0Ar+576+384+576+256+0+50000.0%0Aw+576+256+816+256+0%0Aw+816+256+816+464+0%0Aw+576+384+624+384+0%0Aw+624+384+672+384+0%0Ar+624+384+624+320+0+100000.0%0Ar+624+320+624+272+0+5000000.0%0Aw+624+320+672+320+0%0Aw+624+272+784+272+0%0Aw+784+272+784+400+0%0Aw+992+336+992+400+0%0Ar+752+400+784+400+0+25.0%0Ar+752+464+816+464+0+25.0%0Ar+752+528+832+528+0+25.0%0Ao+24+4+0+34+2.5+0.0125+0+-1%0A)
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Hides-His-Eyes on July 11, 2011, 07:30:01 PM
4 bits with a quad?

brrrrilliant!
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on July 11, 2011, 07:58:29 PM
Adding a cap seems to tame some of the glitches.  Link (http://www.falstad.com/circuit/#%24+1+5.0E-6+3.5993318835628396+59+5.0+43%0Aa+240+128+320+128+0+15.0+-15.0+1000000.0%0Aa+240+192+320+192+0+15.0+-15.0+1000000.0%0Aa+240+256+320+256+0+15.0+-15.0+1000000.0%0Aa+240+320+320+320+0+15.0+-15.0+1000000.0%0Aw+240+144+208+144+0%0Aw+208+144+208+208+0%0Aw+208+208+240+208+0%0Aw+208+208+208+272+0%0Aw+208+272+240+272+0%0Aw+208+272+208+336+0%0Aw+208+336+240+336+0%0Aw+128+304+240+304+0%0Ag+112+368+112+400+0%0Av+112+368+208+368+0+3+80.0+2.3+0.0+0.0+0.5%0Aw+208+336+208+368+0%0Aw+352+192+464+192+0%0Aw+384+256+464+256+0%0Aw+400+320+464+320+0%0Ar+464+128+560+128+0+8000.0%0Ar+464+192+560+192+0+4000.0%0Ar+464+256+560+256+0+2000.0%0Ar+464+320+560+320+0+1000.0%0Aw+560+256+560+320+0%0Aw+560+256+560+192+0%0Ar+560+320+560+400+0+1000.0%0Ag+560+400+560+432+0%0Ar+128+304+128+240+0+100.0%0Ar+128+240+128+32+0+1000.0%0Aw+128+32+400+32+0%0Aw+400+320+400+32+0%0Aw+128+240+144+240+0%0Aw+144+240+240+240+0%0Ar+144+240+144+176+0+2000.0%0Ar+144+176+144+48+0+50000.0%0Aw+144+48+384+48+0%0Aw+384+48+384+256+0%0Aw+144+176+192+176+0%0Aw+192+176+240+176+0%0Ar+192+176+192+112+0+100000.0%0Ar+192+112+192+64+0+5000000.0%0Aw+192+112+240+112+0%0Aw+192+64+352+64+0%0Aw+352+64+352+192+0%0Aw+560+128+560+192+0%0Ar+320+192+352+192+0+25.0%0Ar+320+256+384+256+0+25.0%0Ar+320+320+400+320+0+25.0%0Aw+560+128+608+128+0%0Ac+608+128+608+224+0+1.0000000000000001E-7+4.39974694433937%0Aw+608+224+608+400+0%0Aw+608+400+560+400+0%0Ar+320+128+368+128+0+25.0%0Aw+368+128+464+128+0%0Aw+112+368+112+304+0%0Aw+128+304+112+304+0%0Ao+22+4+0+34+10.0+0.0125+0+-1%0A)
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Taylor on July 12, 2011, 12:02:41 AM
Did it occur to anybody before that you can get multiple octaves up with this kind of thing? Maybe I'm looking at this wrong, but if you take the output of, I guess it would be the least significant bit, it has 16 cycles per input cycle, so 3 octaves up. The next LSB would be 2 octaves up, and the second-to-MSB would be an octave up.

If so, you could do the multi-octave drawbar kind of thing, without a PLL for the up octaves, which is responsible for a lot of the glitching in something like the Harmony Generator circuit.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on July 12, 2011, 08:28:36 AM
 ;D

Still a bit of work to get it to sound like a harmony note, though.  The bit transitions are level-sensitive, so you'd want to compress the input to be able to use all the bits.  But then you run into a problem, because a compressed or hard-limited input signal has steeper slopes, which means it can be represented with fewer bits, so you lose the frequency "multiplication" effect as the input becomes more square. 
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Hides-His-Eyes on July 12, 2011, 08:52:15 AM
You could do it with a VCA to always get the same peak level though right?
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Taylor on July 12, 2011, 02:49:28 PM
Also, by adding a switch for each bit, you can get some fun wave shaping stuff happening. Turning off the MSB gives you an octave up sawtooth wave that flips its phase every couple of cycles. That plus the next MSB gives 2 octaves up sawtooth that flips phase every 4 cycles or so.

As you say it will be tricky to get this to work with a real guitar signal. My approach would be more in just amplifying the signal enough before the ADC to get it to light up all the stages, but I'm a bit of a caveperson. It won't act the same with soft notes as loud, but that's true of most forms of harmonic processing.

I've got to build this! I went the "brute force" path, making a bit crusher/sample rate reducer with the FV1 chip, but your way is light-years more clever.

Have you built this in real life yet, ETA?
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: oskar on July 12, 2011, 05:17:01 PM
QuoteAlso, by adding a switch for each bit, you can get some fun wave shaping stuff happening.
Well, once you've got it in the digital domain there is no end to the fun... Gating with a Quad And or ringmodulating with Xor's.
Hard to tell tell what that would sound like...  But it's gonna be noisy!
I'm thinking envelopes à la Blue Box.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on July 12, 2011, 08:28:25 PM
Quote from: Taylor on July 12, 2011, 02:49:28 PM
Have you built this in real life yet, ETA?
I'm sorry to say I haven't.  Most of the rooms in my place, including the door to my "workshop" (a coat closet, lol) have been taped shut for the past two weeks while serious renovations have been going on in my apartment.  Mold growth due to landlord negligence, moving the bare necessities to a temporary apartment, etc.
The plus side is I've been getting more familiar with Eagle, and Falstad's circuit simulator.

I like the ideas everyone is suggesting.  I have no idea how to implement some of them, but they sound cool!  :)
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: toneman on July 13, 2011, 04:55:02 PM
have U seen this??

http://www.paia.com/ProdArticles/ek7.htm

:icon_cool:
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on July 13, 2011, 09:53:16 PM
Wow, very interesting.  Simonton's approach makes so much sense, I doubt I would have tried to reinvent the wheel if I had seen it before now.  Thanks for the link!
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: PRR on July 14, 2011, 06:18:18 PM
> the least significant bit, it has 16 cycles per input cycle

ONLY if the input is Full Scale.

As a note fades, there will be fewer transistions per input cycle.

What you have discovered/observed is digitizing distortion, not a a harmonic system. In fact the non-harmonic nature is why digital converters sound nasty all out of proportion to they THD numbers.

> Simonton's approach makes so much sense

Sorry, I assumed you were familiar with basic ADCs because your approach is so elegant. Simonton's ADC is ancient, textbook, except he gives specific values and parts which wil work for PAiA-quality audio. (Alternative FLASH converters can be VERY much faster, deeper, more precise... and costly.)
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Taylor on July 14, 2011, 10:21:39 PM
Alex, I think I can build this soon - was wondering if the values in the sim, especially resistors on the comparator outputs, are legitimate for a real life build? I can usually substitute successfully, but since the resistor values in this seem to make up a complex interactive "eco-system" I'm not sure about changing anything.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: toneman on July 14, 2011, 10:24:38 PM
Glad U found the link interesting.

The complete article was in Polyphony LabNotes long time ago.

As far as "range", I believe the EK7 was for a 0-5V signal uses for preset saving on the Paia Proteus.
The knobs/pots on the proteus were grouped into banks and one 8bit word was created with
TWO EK7 circuits.  btw, I have and original Proteus.

U could easilly "re-range" the input to be 0-2.5V by adding a x2 amplifier in front.
Or, 0-1.25V range by adding a x4 amplifier in front.
Then, U could always "fold" the bits by feeding some bits back thru XOR, OR and/or(pun) other gates.
It's all gonna come out square waves just by the digital nature of the signal.
Run the squares thru lowpassfilters (LPFs) to squeeze out the sines  :icon_smile:

Keep breadboarding....
8)
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Taylor on July 15, 2011, 01:04:23 AM
Quote from: PRR on July 14, 2011, 06:18:18 PM
> the least significant bit, it has 16 cycles per input cycle

ONLY if the input is Full Scale.

As a note fades, there will be fewer transistions per input cycle.

What you have discovered/observed is digitizing distortion, not a a harmonic system. In fact the non-harmonic nature is why digital converters sound nasty all out of proportion to they THD numbers.

Right, we discussed that above. I'm familiar with this kind of aliasing - I designed a commercial DSP bit crusher and sample rate reducer. But even without compressing the input, I think plenty of fun can be had with an effect that creates a multi-octave-up square wave, whose number of octaves up is envelope-controlled.

I played with volume in the sim and got some weird results - might just have been an error but at some input volumes I was getting 9 output cycles per input cycle...  ??? :o
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Quackzed on July 15, 2011, 12:55:06 PM
QuoteAdding a cap seems to tame some of the glitches.  Link
upping the 10n cap at the end to 1uf (heavy handed lpf-ing) cleans it up nicely... (i know:obviously :P)
probably a trade off for high frequency signals, but seems to do the job.
granted at 80hz the output is @9v, at 4khz it's @ 800mv... so some post amp/hp filtering would be in order. (again probably obvious)
still i had to try it...
-btw really brilliant! it takes a few large cognative leaps to get here. bravo (dignified golf clap) ;D
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Taylor on July 15, 2011, 01:21:26 PM
Quote from: Quackzed on July 15, 2011, 12:55:06 PM
QuoteAdding a cap seems to tame some of the glitches.  Link
upping the 10n cap at the end to 1uf (heavy handed lpf-ing) cleans it up nicely... (i know:obviously :P)

But a cap that big completely removes the digital artifacts that ETA worked so hard to get!  ;) So what would be the point of this circuit then?
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Quackzed on July 15, 2011, 02:42:38 PM
true. it would be pointless to 'un-digitize' it at this point, but after waveshaping,  manipulating , folding etc while its in the digital domain ... you could 'then' heavy lpf the signal...to er-'un-digitize' it...
i just figured that was one of the possibilities, rather than a/d being the end point.
you know a/d - digital fun -d/a(low pass filter)...
i was just surprised how effective low passing a digital signal is...well, to a point...
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Taylor on July 15, 2011, 02:51:19 PM
Ah, you're right. Lots of potential in here! Somebody needs to build this thing...
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on July 15, 2011, 10:57:24 PM
@PRR: I have a layman's understanding of the generic different ADC/DAC types, maybe just a little more than what can be gleaned from Wikipedia.  While I was working on this I did look up what patent drawings I could find regarding folding flash ADCs but they were mostly for stuff that would be fabricated on a single slab of silicon, way out of my comfort zone.  I'm not really surprised that this ground has been covered before, but I am pleased that I was able to discover it independently. 

@Taylor: There are a couple things to watch out for when going from simulation to real parts with this build.  First, if you use an op-amp it has to tolerate whatever differential voltages may appear at its inputs.  For a small full-scale input range, this differential can be negligible.  For a large full-scale input range, it might be better to use comparators that can handle such conditions gracefully.
Second, the simulation assumes the output can swing from zero to nine volts exactly.  A rail-rail op-amp will be close enough but a general purpose one will at best swing to within a volt or two of the supplies.  This makes the voltage at the resistive divider different so you get a deviation from the expected values; the result is some bits do not appear in the sequence.  I'm still working on a way to calculate these values reliably.  With rail-rail outputs it's just ratios, but with not-quite rail-rail outputs I think there might be actual math involved. 
What I did was use DC input voltage that I could sweep manually (a pot across the rails), and LEDs on the op-amp outputs to monitor the binary output.  Then I subbed resistor values until I got all the binary combinations.  Now, I would start with the values in the sim and tweak with trimpots as needed.

@Quackzed:  ;D

@toneman: I may just have to buy a copy of that issue from PAIA, but I don't know which issue... ???

@all: thanks for the kind words.  :)

I think there is a lot of potential in this thing as an audio mangler or noisemaker, but also as a way for folks to dabble with digital processing in a very raw and intimate way with discrete XOR/AND/OR chips as toneman suggested.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: toneman on July 17, 2011, 01:21:06 PM
Quote@toneman: I may just have to buy a copy of that issue from PAIA, but I don't know which issue... Huh

Possibly the july/august 1979 issue  :icon_question: .....

"Digitizer Projects and Software"

http://www.paia.com/Articles/polyphny.htm

suggestion: e-mail PAiA and see how many pages the article is.
And IF it is, in fact, the complete article (more than one page)  :icon_confused:
I have an ACTUAL EK7 but am looking for the documentation   :icon_redface:
afn
:icon_cool:
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: loss1234 on July 18, 2011, 11:22:35 AM
I hope this is not a stupid question...would it be possible to convert this circuit to have LESS bits instead of more? ( a 2 bit flash ADC )
for controlling CMOS chips that only have an A and B input like the 4052?


any info greatly appreciated!

thanks
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Hides-His-Eyes on July 18, 2011, 11:28:43 AM
You can indeed... Take the 2 most significant bits, get rid of the other two and then work out which op-amps have nothing connected to their outputs; delete those. Then see if any of the resistor divider pairs are left unconnected and get rid of those too.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: loss1234 on July 18, 2011, 11:34:27 AM
"get rid of the other two"

Sorry for the confusion...if there are only three bits (A, B and C) how can I take the two most significant bits and then remove the other two?

Did you mean just remove the third one?

thanks!
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: earthtonesaudio on July 18, 2011, 06:31:34 PM
@loss1234:
Referring to the schematic from post #1 of this thread, you can get rid of IC1a, R1 and R2 to make it into a 2-bit ADC.  Also, since no current is drawn into the inverting input of IC1B, you can also omit IC1D and do the whole thing with a dual op-amp or comparator package.

I think Hides-His-Eyes was talking about removing the other two sections from the 4-bit version, the most recently linked schematic.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: toneman on July 19, 2011, 12:08:56 AM
taylor:
try using real comparators in place of the opamps for the bit conversions. 
Comparators have "built-in snap", whereas opamps need positive feedback to get "snap". 
An LM339 is a quad comparator, same pinout as the MC3302. 

earthtonesaudio:
I FOUND the EK-7 article  :icon_exclaim: ...scanning now.....
If anyone wants a copy send me a PM with your email. 

A further note, I built he EK-7 out to 5bits with 1% resistors and it works fine.  The EK-7 was mainly invented/used for the Paia Proteus, a monophonic synth with saveable presets.  The EK-7, or actually TWO of them, were used to digitize the pot settings of the synth to make an 8bit word to be stored in memory, WITHOUT using any type of processor. It was cool  :icon_cool:

:icon_cool:
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: PRR on July 20, 2011, 12:02:59 AM
> Comparators have "built-in snap", whereas opamps need positive feedback to get "snap".

General-purpose comparators (like '339) don't "snap". Hysteresis and positive feedback is left to the user.

Comparators are often (not always) rated for large differential inputs; but so are most common op-amps (such as '074) (and yes, I've blown '709 opamps with excess input diff).

Comparators are generally faster to switch. An op-amp's speed must be controlled so it will be stable under negative feedback. 

What is stunningly elegant about earthtonesaudio's plan is that the "point" of hysteresis is accomplished another way, with threshold shifts. Once any stage switches, all other stages get new thresholds. It is unlikely to "chatter" around a near-threshold level, sweet.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: toneman on July 20, 2011, 11:24:39 PM

QuoteWhat is stunningly elegant about earthtonesaudio's plan is that the "point" of hysteresis is accomplished another way, with threshold shifts. Once any stage switches, all other stages get new thresholds

That's the way the PAIA 4bit digitizer worked.  Each stage fed previous/further stages, setting the biases for a new shift point. I think that is one of the reasons it's called a "folded" A2D.  The output bits are "folded back" to set the new thresholds for the inputs. Simonton used all comparators.  I found that there was still a little chattering just at the thresholds.  It worked OK for the Proteus.  I've included the digitizer page from the Proteus in the scans. I have scanned the EK-7 article and converted to pdf.  It's 6M.

check this article out:
http://www.analog.com/static/imported-files/application_notes/46875282066493AN_849.pdf

:icon_cool:
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Andon on October 27, 2023, 08:07:14 AM
Apologies for reviving a rather old thread, but I've been trying this circuit out over the last couple of days with what seems like random success. I'm trying to use this in a similar way as user slacker did in response #15 on page 1 - that is, using a pot to control the voltages to be able to spell out all eight words in sequence as you turn the knob (000, 001, etc.), which would then feed into the A, B, C pins of a 4051 and be able to select one of eight inputs. When I implement it, I seem to get some words, but not all, and not in order. There are also a lot of images missing from the thread as servers have moved over the years, but here's what I think is the initial schematic:

(https://www.diyschematics.com/schematics/galleries/Schematics-etc/earthtonesgallery/3bits.png)

AGND in the above schematic is 4.5V as user earthtonesaudio points out. PRR says that the buffer is not necessary, but what else can I be doing to ensure that this works? For the input I've tried a variety of pots across 9V-0V with the wiper feeding into the non-inverting inputs of each comparator, and it seems like B10K is the most reliable value. I have tried a variety of values as suggested in this thread, including the 4-bit simulation posted (parred down to 3-bit).

I've also found that standard op amps at least seem to work better than comparators here, contrary to what has been stated here.

So, any advice? Again, I'd be using this to send eight binary words to a 4051 to be able to select from eight inputs. Thanks!
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: PRR on October 29, 2023, 06:41:10 PM
Quote from: Andon on October 27, 2023, 08:07:14 AMpots across 9V-0V with the wiper feeding into the non-inverting inputs of each comparator,

Through C1?
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Andon on October 30, 2023, 11:19:31 AM
I've tried that, but I feel like I've had better luck replacing R5 with a pot to vary the voltage for the non-inverting inputs.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: ElectricDruid on October 30, 2023, 01:45:17 PM
Definitely get rid of the C1/R5 combo on the input. Your input voltage from the pot wiper needs to go straight in, not via a HPF - it's DC, so that's not going to work.

As you said "I've had better luck replacing R5 with a pot to vary the voltage". Well, yes! Not surprised!
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Andon on October 30, 2023, 01:55:49 PM
Oh yeah, I never even considered it until PRR posted that which made me second guess myself ha. I did some more digging around, and found another implementation of the 3-bit folding flash ADC from Alex (earthtonesaudio) over at the other forum:

(https://i.imgur.com/QCERVic.png)

The ADC is at the top left. I was happy to see this, because this is exactly how I have been mostly trying to implement it, but issues still persist between different values, using op amps or actual comparators, etc. The notation is a little confusing, however, because that schematic I just posted mentions VREF1 and VREF2 , but no mention of how VREF2 is created - given the other schematics I would assume it's the same, but I could always be wrong.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: ElectricDruid on October 30, 2023, 06:54:32 PM
The circuit seems to be tested and working in plenty of cases, so if it's not working, I'd suspect that it's a question of voltage levels. Especially given the symptoms you mention.

Its correct operation completely depends on the various thresholds and how those change when the outputs switch, and that in turn depends on what those output levels are. So the circuit will *only* work with specific resistor values if they are matched to the hard-to-the-rails output levels of the specific op-amp you're working with.
If the resistor ratios are assuming a op-amp that goes closer to the rails than yours does, it probably won't work the same, and the result of that could well be missing codes.
I was doing a sim to see what happens this afternoon, but LTSpice flaked out on me, so I didn't get anywhere. I'll post again if I get something more useful.

Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: PRR on October 30, 2023, 11:34:57 PM
Quote from: Andon on October 30, 2023, 01:55:49 PMissues still persist between different values, using op amps or actual comparators

There's no hysteresis. It will be incredibly sensitive to layout and chip speed. In that case a smooth roll-off opamp *MAY* be better behaved than a high-strung many-stage comparator.

Can't use a thumb switch? They were hip in the 1970s.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: ElectricDruid on October 31, 2023, 09:15:50 AM
I can only get this "close", rather than working, at least in the sim.

I've used a 9V single supply and TL072 op-amps. I copied values from PRRs sim on page 1 of the thread. The TL072 model, siginificantly, doesn't go to the rails - output is about 1.6V to 7.4V. This seemed more like a "practical" circuit than using ideal op-amps.
Note also that the input voltage is a sine wave of 0.8Vpp around Vref (4.5V), so all the transitions happen in a fairly small range in the centre. Also the output does show some glitches.

How realistic this is I'm not sure, but the part that strikes me as realistic is that the circuit is fussy. Change anything and everything else changes, because it's all linked together!

(https://i.postimg.cc/YjJpHFfQ/ADCCircuit.png) (https://postimg.cc/YjJpHFfQ)

(https://i.postimg.cc/XrY11HGL/ADCOutput.png) (https://postimg.cc/XrY11HGL)


Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Andon on October 31, 2023, 09:55:57 AM
Thanks for that, Tom. Your last post before the most-recent one also brought it into perspective, insofar as the circuit being tailored to the IC - good points! I know that user slacker (reply #15 on page 1) was able to get it working with an LM324, and even then they mentioned that there were some dead zones at the extremes of the pot turn, which I also noticed. I also tried taking the initial voltage values that user earthtonesaudio mentioned for each word (4.07-4.93V) and tried voltage dividers on each side of the pot to really narrow it down, with limited success.

As I said, I can get some of the words (four or five, depending) and they all see to be "major" words, just not all of them inbetween.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: slacker on October 31, 2023, 02:13:04 PM
Hi

This is what I built. The pot is connected across 9 volts (or whatever the opamp supply voltage is) and ground. AGND is half the supply voltage. Pot was 10k but the value probably isn't that important
R1 = 10k
R2 = 50k
R3 = 470k
R4 = 1Meg

I used an LM324, I think to work this needs an opamp whose inputs can go to the negative supply.

(https://i.postimg.cc/NLGsmwzc/3bits.png) (https://postimg.cc/NLGsmwzc)
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: ElectricDruid on October 31, 2023, 03:21:12 PM
Thanks Slacker. I wonder if my LTSpice has the LM324 op-amp. It'd be good to try it if so.

It *should* be doable to get it running even with something hopeless (for this application!) like the TL07x that goes nowhere near the rails too, though, right? Tweaks the thresholds to compensate, off we go?!?
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: slacker on October 31, 2023, 07:17:31 PM
Yeah it should work with a TL074 so long as you keep the inputs in it's range. I'd forgotten that the reason I used an LM324 was so I could run it on 3.3 volts.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Andon on November 02, 2023, 12:37:48 PM
Posting an update to say that I was able to get this working when I tried it again on an LM324 - thanks y'all! Now to figure out how to limit/spread the sweep of the pot, as all of the words/numbers occur in the middle third of the pot's rotation.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: ElectricDruid on November 02, 2023, 02:09:52 PM
Quote from: Andon on November 02, 2023, 12:37:48 PMPosting an update to say that I was able to get this working when I tried it again on an LM324 - thanks y'all! Now to figure out how to limit/spread the sweep of the pot, as all of the words/numbers occur in the middle third of the pot's rotation.
That shouldn't be too hard. A resistor above and below the pot equal to the pot's value will limit you to the middle third. In practice, you'll probably have to tweak them a bit, and the annoying thing is that it's all interactive. Altering one changes the other end too.
Still, it'll get you much closer.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Andon on November 02, 2023, 02:18:38 PM
Quote from: ElectricDruid on November 02, 2023, 02:09:52 PM
Quote from: Andon on November 02, 2023, 12:37:48 PMPosting an update to say that I was able to get this working when I tried it again on an LM324 - thanks y'all! Now to figure out how to limit/spread the sweep of the pot, as all of the words/numbers occur in the middle third of the pot's rotation.
That shouldn't be too hard. A resistor above and below the pot equal to the pot's value will limit you to the middle third. In practice, you'll probably have to tweak them a bit, and the annoying thing is that it's all interactive. Altering one changes the other end too.
Still, it'll get you much closer.

Yup. I've found that around 5K on either side of the pot gives a pretty even spread across the entire sweep, save for numbers 5 and 6 which are pretty close together. Tweaking, indeed.
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: PRR on November 02, 2023, 09:07:07 PM
https://www.jameco.com/z/GTF311221-R-Jameco-ValuePro-Switch-Thumbwheel-Binary-Coded-Decimal-BCD-10-Position-28-Volt-DC-15-Amp-End-Plate-Part-26771-_26818.html
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: ElectricDruid on November 03, 2023, 06:07:40 AM
Quote from: PRR on November 02, 2023, 09:07:07 PMhttps://www.jameco.com/z/GTF311221-R-Jameco-ValuePro-Switch-Thumbwheel-Binary-Coded-Decimal-BCD-10-Position-28-Volt-DC-15-Amp-End-Plate-Part-26771-_26818.html

Awww! Where's the fun in that?!?

This whole thing is an exercise. Even if we stick with the pot-to-binary outline, a $0.50 processor is cheaper and easier, and could even be done on a 6-pin device. But you've got to try and keep your braincells fit, a little bit!
Title: Re: 3-bit folding flash ADC uses only 3 comparators
Post by: Andon on November 14, 2023, 10:33:39 AM
A final thought/question on this for now: would tying the outputs to a cap to VREF (as in reply #26 on page 2 (https://www.diystompboxes.com/smfforum/index.php?msg=793307)) - using say 1uF - also work if using this as an insert for a 4051 to smooth the transitions between words/outputs?