Update – extra schematics and timing diagrams added (see below). Also TLP222G optofets are available in the shop here.
There has been discussion on Stompville here (in the comment section) and on diystompboxes.com about problems with audio clicks when using a relay for true bypass. The consensus seems to be that the answer is to use a photofet opto-isolator to mute the audio output while the relay is switching. Two components in particular have been discussed, the Toshiba TLP222G and the Fairchild H11F1M.
These devices are called photofet isolators and comprise an LED (the input or control side) optically isolated from a push-pull MOSFET (the output or detector side). There is no external gate connection to the detector and the output stage is switched on by the light coming from the LED. Our intention is to use the MOSFET to short the audio signal to ground (i.e. mute the signal), then switch the relay, then release the mute. The opto isolator function allows us to separate the control signal (from our micro-controller) and the audio signal (from our bypass relay) and in particular have separate (or managed) analogue and digital grounds.
Now, we could just switch the LED on when we want to mute and this will probably work adequately in most cases. However, it would be more elegant if we could have a soft mute so the sound would fade out over a period of time (say 20 ms) then we switch the relay, then un-mute over a further 20ms, giving a total switching time of 50 ms (allowing 10 ms for the relay to change-over).
To cut a long story short, the TLP222G is a better option all round than the H11F1M (more on this later), so I have been experimenting with the ‘222. The following circuit has been suggested as a way of providing soft mute:
Unfortunately, the switching characteristic of the ‘222 is such that the above circuit simply delays switching of the output stage and does not provide a soft muting function.
Another possible option would be to use PWM control of the LED current:
Unfortunately, the switching characteristic of the ‘222 does not lend itself to this solution because the maximum useable PWM frequency for the ‘222 is less than 5kHz (which is, of course, audible). We would need a PWM frequency of 40kHz or higher to make this circuit useable.
Here’s a timing diagram for the above with an LED current (set by R) of about 2mA:
However, there is a caveat here as well. I bought a batch of 25 TLP222G’s and after trying only about half a dozen of them it became clear that the resistor required to give the 20 ms mute period is a moveable feast and would need to be selected for the individual sample of TLP222G you have – which is OK if you have an oscilloscope handy.
So it seems the way forward is to forget trying to force a soft mute of the photofet for the time being – I will continue to tinker with any ideas which come to mind. We should set the value of R low enough to make sure that any sample of the TLP222G will fire reliably. That value would coincide with a If of 3mA and the resistance would be (5V – 1.15V)/3mA = 1.28k so 1.5k would be adequate. This gives us our timings as follows:
Note that if you want to muck about with the soft mute, I have left a 20 ms delay before operating the relay. R2 will need to be in the region of 3.6k – 5.6k. You might consider a 1.5k resistor with a 5k preset in series.
As previously noted, U1 could be LP2950-5V to save battery life; U2 could be ATtiny13 in lieu of ATtiny13A; and finally, U3 could be TLP222A. R1 may need to be reduced if your LED is too dim.
Here’s a link to firmware hex file with timings as per figure 142SV above. No fuse changes required.
TLP222G’s are available for sale in the Stompville Shop.
Update – Where should the Capacitor go?
I’ve received a few comments suggesting that the electrolytic capacitor should go before the resistor and this will make all the difference. In fact it makes no difference. We can’t escape from two facts we have discovered:
- The photofet has sharp turn-on and turn-off characteristics
- The actual characteristics vary significantly from sample to sample
This means that it is not practical to finesse the soft-muting function using a simple RC network. Here are schematics and timing diagrams for the three possible scenarios:
We can see from the timing diagrams that the addition of the capacitor has some effect on the ‘mute-on’ function, but no effect on the ‘mute-off’ function.
Appendix – Choosing a Photofet
The Toshiba TLP222 comes in two variants, the TLP222A and the TLP222G. The two significant differences which apply here are the on-state resistance of the output (Ron) and the off-state capacitance of the output (Coff). Here is a summary of the differences:
Notionally, we want the lowest possible Ron (to give optimal muting) and the lowest possible Coff (to give minimal filtering of the audio signal). However, in this case, lower Coff trumps lower Ron and TLP222G is the better choice (but it may not make much difference in practice).
The Fairchild alternative also comes in two variations, the H11F1M and the H11F3M. The datasheet also refers to the H11F2M, but this is an obsolete part. Here is a summary of the relevant differences:
Note that Coff is comparable with the TLP222G, but Ron is much higher. Clearly, we would want to choose the ‘F1 variant over the ‘F3 variant.
So it turns out that the Toshiba part is a better choice all round. Both parts have acceptably low capacitance – but the TLP222G has lower on-resistance, comes in a smaller package and is less expensive than the H11F1M.