[sdiy] Help, I'm Desperate! (Charge Injection with DG408)

Steve Lenham steve at bendentech.co.uk
Wed Dec 5 13:05:21 CET 2018

On 05/12/2018 06:55, David G Dixon wrote:

> Today, I thought deeply about the switching glitch problem, and I think I
> concur with Steve Lenham.

Go me! ;-)

> So, I now believe that the best approach is to use Gray code to drive the
> switches, so that only one bit ever has to change.  This consists of two
> things: 1) changing the logic circuit to generate Gray code from the CV
> signal, and 2) reconnecting the switch inputs to conform to Gray code.  The
> second part is trivially easy.  The first part is not so easy.
> However, I have discovered that 3-bit binary can be converted to 3-bit Gray
> code fairly directly, since the 1st Gray and binary bits are equivalent, the
> 2nd Gray bit is the XOR of the 1st and 2nd binary bits, and the 3rd Gray bit
> is the XOR of the 2nd and 3rd binary bits.  An analog XOR circuit like the
> one on Ian Fritz's website (inspired by Electronotes) would fulfill the XOR
> function from my existing 3-bit hack-job ADC.

Gray code will not help you unless you can generate it directly.

Taking a binary address that passes through multiple transitional states 
and converting it to Gray code will give you a Gray code sequence that 
does exactly the same.

If your binary address is supposed to be changing from 1 to 2, but also 
temporarily passes through 3, then passing this value through a Gray 
encoder will simply give you an address that goes from the Gray code for 
1 (001) to the Gray code for 2 (011) but also temporarily passing 
through the Gray code for 3 (010). Nothing will have been gained.

Also, Gray code is only beneficial when the encoded value is guaranteed 
to only increment or decrement by one unit at a time (for example in 
rotary encoders). Otherwise, the statement that "only one bit of a Gray 
code value changes at a time" does not hold!

The Gray code values corresponding to decimal 0-7 are:

000, 001, 011, 010, 110, 111, 101, 100

Clearly a change in the value greater than one often involves changing 
more than one bit of the Gray code.

> However, I am going to rethink this entire logic and switching circuit,
> because it is getting fairly complicated.  I believe that proper comparators
> with pullup resistors to 5V would be better than the opamps with zener
> diodes, and I'll figure out some other way to generate the threshold
> voltages.  With proper logic levels, I'll probably just use proper logic
> chips.

I can't help agreeing with Tom in that one of the 8-pin PICs with an 
onboard ADC would kill the problem stone dead very inexpensively, but I 
appreciate that not everyone has the facilities/experience/inclination 
to take that approach.

As an alternative I would offer the following:

- Generate a clock signal at a fairly high frequency.
- Use the rising edge of that clock to trigger a sample-and-hold circuit 
(could be just a CMOS analogue switch).
- Feed the sampled signal to your comparators.
- Take the comparator outputs to a D-type latch.
- Clock the latch with the falling edge of your sample clock.
- Control your analogue multiplexer with the outputs of the latch.

That is effectively what the PIC would be doing, just in discrete form. 
The comparators then have half the clock period to settle to their final 

Good luck!

Steve L.
Benden Sound Technology

More information about the Synth-diy mailing list