Audio output circuit with -22dB volume switch - Page 1
Forum section: electronics / beginners

author: Saimoun
author_rank: Frequent Contributor
timestamp: June 30, 2021, 04:00:00 pm
content: EDIT: please ignore the first messages and read this instead:reply #5It will be clearerThank you!HiSo I have been working with the audio output circuit I presented here:https://www.eevblog.com/forum/beginners/audio-output-circuit-comments-specific-question/it works great, but Terry Bites was right and there is a tiny "click" because of charge injection when I open the S1 switch (the one changing the gain from 8dB to -22dB of the first opamp). Only when I open the switch, I see a little bump of about 50mV and 20us.The switch I used is this one:https://datasheet.lcsc.com/szlcsc/1908021732_Gainsil-GS4157-CR_C280709.pdfand it has a 3pC injection charge.It's barely hearable but just for the sake of learning I thought I would give it a go (at making it better)So my question is: is there a way to make a passive -22dB before the opamp, the same way Terry is doing here:BUT without using the 3rd opamp (the one for Vcc/2), just using an inverting opamp?

author: Saimoun
author_rank: Frequent Contributor
timestamp: June 30, 2021, 04:01:03 pm
content: I thought about it and maybe something like the attached circuit would work?(clearly the resistor values need to be changed to get exactly-22dB and +8dB)

author: Zero999
author_rank: Super Contributor
timestamp: June 30, 2021, 06:19:40 pm
content: Lower resistor values will lessen the effect of charge injection, because they reduce the impedance.Try adding a 470pF capacitor, at the point where R8, R11 & R12 join and 0V, on your first schematic. It will cut the bandwidth to just over 30kHz, but should absorb that 3pC of charge injection nicely.

author: Saimoun
author_rank: Frequent Contributor
timestamp: June 30, 2021, 09:32:50 pm
content: Sorry if I was not clear: the first schematic is not mine, and I have not tried it. My current circuit, the one with the problem, is the one attached here.What I want to do is doing like the diagram from Terry (i.e. reducing the signal with a passive resistor divider), but without using an extra opamp for the Vcc/2. My idea of how to do this is the LTSpice diagram and results attached in my previous post.

author: Zero999
author_rank: Super Contributor
timestamp: July 01, 2021, 07:30:44 am
content: Quote from: simonlasnier on June 30, 2021, 09:32:50 pmWhy create another thread? This has illustrated quite nicely why it's a good idea to keep it to one thread per project/circuit. Had you done that, we wouldn't have wasted time with the previous few replies.That looks reasonable. C15 should help to absorb the pulses due to charge injection.

author: Saimoun
author_rank: Frequent Contributor
timestamp: July 01, 2021, 08:31:59 am
content: Well I think continuing the old thread would be even more confusing, because there are many things in it and now I am asking about something specificLet me start over - this circuit:has an issue - I get a bump of 50mV for 20us on the output. Like you said C15 probably absorbs some of the charge, that's why it's low, but ideally I would like to reduce it even more.Question 1: would placing R7 on the other side of the switch make any difference? (just wondering)Question 2: any other ideas for how to reduce the injection?----In the old thread, Terry Bites mentioned using a passive attenuator instead, and he suggested this:So I was thinking maybe I could do that, but without using the extra opamp for Vcc/2, and I came with the following:Question 3: is there anything wrong with this circuit / do you think it would work? (I only tried simulating it not building it)

author: dmills
author_rank: Super Contributor
timestamp: July 01, 2021, 09:52:28 am
content: You are still going to get a charge injection glitch on switching, and might get a dc offset click as well, placing a 1M resistor from VMID to ground would solve the second one of those issues (Leakage in the caps and on the board).Doing this genuinely cleanly is **much** harder then it at first appears, and cmos switches are not really the way to do it, discrete jfets with controlled ramp rates on the gates are better because you can make the gain change slowly enough to avoid objectionable clicks. I have also had some reasonable luck with those photomos opto mosfets for audio switching.See Doug Selfs "Small signal audio design" for a whole chapter on switching audio.In general I find your resistor values rather high for audio, all of those could probably come down by a decade (and the caps go up by a decade) to get lower system noise (Johnson-Nyquist), as well as lower charge injection clicks.R4 wants a healthy amount of cap across it to reduce the noise from that source and improve PSRR.

author: Zero999
author_rank: Super Contributor
timestamp: July 01, 2021, 01:34:04 pm
content: Quote from: simonlasnier on July 01, 2021, 08:31:59 amWhy do you care? 1/20µs is a frequency of 50kHz, so I doubt you'll hear it.I don't see what difference moving R7 would make.Actually, moving R7 is probably a good idea, as the output of U2B is a low impedance node.You could try 3.3nF between pin 4 of U3 and 0V.QuoteWhat's Vmiddle? If it's a low impedance voltage node, all you're doing is shorting the input signal.

author: Saimoun
author_rank: Frequent Contributor
timestamp: July 02, 2021, 01:29:23 pm
content: Thank you both for your replies!@Zero999: very interesting point about the frequency! You are right, it should be out of the hearable range... Strange because I can hear it in the headphones (it's still low but there is a little high pitched "click" sound). There is really nothing else on the oscillo, and the timing fits (i.e. the bump appears on the oscillo and I hear the click right when I change the switch).My guess is the bump has some parts which are slightly lower frequency? For example the end slope is softer, I would guess this is about 30us half period, which would make it 16kHz (and therefore slightly hearable). I attached a picture of the bump.Regarding your question: Vmiddle is nothing, it was just to give that point a name so I could see it in the simulator.@dmills: fair point! Based on your comment I decided to stick with the circuit I had, just moved R7 as Zero999 suggested, and reduced the resistor values as your suggested. Thinking the click sound is barely hearable, if I can make it slightly less hearable then I'm ok with thatPS: yes there are decoupling caps on the halfVCC (R4)

author: Saimoun
author_rank: Frequent Contributor
timestamp: July 02, 2021, 01:35:08 pm
content: Just FYI - this is the circuit. I will test it and let you know if it is any better than the previous one.PS: @dmills I did not dare divide the resistor values by 10 since my input ("IN") is a DAC output and I think 5k is probably how much load it can take

author: fourfathom
author_rank: Super Contributor
timestamp: July 02, 2021, 03:47:34 pm
content: Quote from: simonlasnier on July 01, 2021, 08:31:59 amThat click you are hearing is likely from the instantaneous change in the audio signal that occurs when you change the gain (shown in the image when you reduce the gain). You may even be hearing a click when changing the gain near zero-crossing (as when you increase gain), since the signal slope is abruptly changing. As dmills suggests, you need a gradual gain transition.

author: Zero999
author_rank: Super Contributor
timestamp: July 02, 2021, 09:16:46 pm
content: Quote from: fourfathom on July 02, 2021, 03:47:34 pmYou're right. Looking at the waveform, it's unavoidable. The easiest way to do this is to use a digital potentiometer, but it still make a tiny noise, as the gain is stepped. A voltage controlled amplifier would be better.EDIT:How about only changing the gain, when the signal is zero crossing? That will avoid sudden transients from the voltage jumping from one level to another.

author: dmills
author_rank: Super Contributor
timestamp: July 03, 2021, 12:45:17 pm
content: Doesn't really work, you still get a glitch because dV/dt becomes non continuous when you switch the gain, and charge injection will still likely have you to some extent.Seriously, jellybean jfet with an RC ramp on the gate for this.Regards, Dan.

author: Saimoun
author_rank: Frequent Contributor
timestamp: August 12, 2021, 09:13:16 am
content: Quote from: simonlasnier on July 02, 2021, 01:29:23 pmSo I know this is an old thread - I just wanted to say I got new boards with the updated version (moved R7) and reduce all resistors (and increased the capacitors), and that actually worked *really well*!!! The pop was about 60mV, it is now reduced to about 10mV, that's like 15dB difference! Listening, I really cannot hear it anymore - beauty like Dave would say!PS: the slow ramp could be an option - but this is more than good enough for my project