True bypass with latching relay

By | April 20, 2012

Update: Remote controlling the True Bypass here.

Update: SMD version here.

Update: True Bypass Relay with muting here.

Update: True Bypass kits are available to buy in the shop here.

I have used Arduino over the last twelve months or so for a couple of projects and I have been looking for an excuse to go to play with the AVR ATTiny embedded microcontroller range.  I came across Jack Orman’s true bypass project and initially thought that controlling a relay with a microcontroller was a little over-the-top.  Whilst researching another project I came across Jack Gannsle’s excellent article on switch debouncing where it becomes clear that custom chips for debouncing switches are basically non-existent and if you’re going to debounce a momentary switch and drive a bipolar (latching) relay, you’re going to end up with quite a few components.  So maybe using a microcontroller is not such a bad idea.  Let’s try it!

Here’s the schematic:

ATRelay schematic

As you can see, once you get the voltage regulator out of the way, the whole thing is only five components.  ATTiny outputs can sink or source 40mA and the relay coil requires about 20mA so that’s OK.  When we power up PB3 and PB4 are made low.  To set the relay, we make PB3 high for a few milliseconds then low again.  To reset the relay, we make PB4 high for a few ms then low again.  Thus the power consumption of the circuit is very low (a continuous 1mA instead of 20mA if we used a non-latching relay).  I used an LP2950-5 in lieu of the 78L05 shown on the schematic to reduce quiescent current from around 4mA to 1mA ( see below).

Here’s the finished item:

ATRelay pcb assembly

The PCB dimensions are 30mm x 25mm.  Here’s another picture with the development board and a couple of half-finished PCB’s:

ATRelay development

The software is interrupt-driven and uses Dr Marty’s best-switch-debounce-routine-ever… and it works very well (but see the last paragraph here).  I toyed with using a jumper to determine whether the unit should power-up with the effect active or bypassed but I decided there was no downside to detecting if the stomp switch was pressed at the time the unit powers up and, if so,  toggling the power up status.  The power-up status is held in EEPROM.

Whilst the 78L05 is less expensive than the LP2950-5 (about half price)  neither are going to break the bank.  Furthermore, looking at the specs,  the 78L05 has a quiescent current of 3mA and a minimum load current of 1mA whereas the LP2950 has a quiescent current of 0.1mA and a minimum load current of 0.1mA to maintain regulation.  So it seems like a no-brainer to choose the LP2950-5 and get much better battery life.  The ATTiny is currently running at a clock frequency of 9.6MHz and if I rewrote the software to run it at 128kHZ the power consumption of the ATTiny13A would fall further but as the idle current is already less than 1mA, I may not get a round tuit.

All in all, an interesting my-first-ATTiny project. 

14 thoughts on “True bypass with latching relay

  1. mictester

    I have a different (and much cheaper) way of using a latching relay. The one I use has a 5V coil, but doesn’t need a regulator because all I’m doing is discharging a small electrolytic capacitor into it. The relay I use is the Takamisawa AL5WN-K which has a single coil and DPDT contacts.
    The control circuit uses one NPN and one PNP transistor and two silicon diodes, a few resistors and a capacitor.
    The quiescent current draw is zero when bypassed and <100µA when active – the predominant current draw is any LED you choose to use for indication.
    It needs a mechanically latching switch, but it was originally designed to use up all the SPST Carling switches I'd taken out of Cry Baby pedals when converting them for proper bypassing.
    If you want details, I'll email you them.

  2. chris

    Hi,

    Nice use of an AVR, had a go at building this however found that your choice of relays maybe isnt the best, the Panasonic TQ2-L-5V is almost microphonic, inducing a resonant ‘click’ into the signal path – tried an Axicom and its much better. Also noticed that you get a faint click as the momentary switch is depressed, and again when released – as though when the AVR shorts to ground its adding the noise. (Same result when just shorting the wire ends to eliminate a switch problem.)

    Cheers – and keep us updated as to any improvements!

    1. SmudgerD Post author

      Hey Chris, thanks for your comments. I have had a few people email me about this issue, so apologies for the long reply – it’s not just aimed at you…

      Firstly, I would say that I have not had a problem with the true bypass relay design that didn’t occur as a result of problems elsewhere. Such problems may include poor supply filtering, poor ground layout, bad coupling capacitors, assumption that a “breadboard” bench arrangement is going to perform as well as the final product, neatly wired and fitted in a shielding enclosure and effects design topology which is not suited to switching with a relay.

      Regarding the choice of relay, the Panasonic TQ2-L-5V and the Axicom FP2-D3043 are essentially the same relay. Both have gold-clad bifurcated (crossbar) contacts, similar initial contact resistance, similar operating/release time, etc, so there should not be a significant audio difference. I tried the Axicom and the Panasonic and also the Fujitsu/Takamisawa AL-5-W-K and the NEC EA2-5SNJ. I couldn’t tell them apart. Nor could I tell them apart from the similar Axicom FX2 form-factor design (also from several vendors). This is not to say that there are not subtle differences – your hearing may be better than mine.

      What is significant is that switching the effect signal with a miniature relay is not the same as switching with a stomp switch. A stomp switch will (in all likelihood) have heavy-duty contact plating (i.e. not gold) and will therefore have a higher initial contact resistance. The stomp switch will likely be slower to switch and have a significantly longer bounce-time than a relay.

      Any click you hear when switching with a relay that you didn’t hear when using a stomp switch will be due to the fact that the relay has lower contact resistance and faster swithcing time than a stomp switch.

      When you a.c. couple the input and output of an effects pedal, you generally do so using relatively high values of capacitor. These capacitors store charge and this charge may cause a switching “thump” when you switch the effect in and out. Usually, bleed resistors are incorporated into the design to discharge the coupling capacitors to ground.

      Unfortunately, when you switch with a relay (as opposed to a stomp switch) the capacitor is able to discharge much faster and may therefore make a noticably louder “thump”.

      So, the problem is not a problem with the relay as such, it’s a problem with the effects circuit – which is masked by the stomp switch and revealed by the relay.

      However, with some designs (as in the case of my experience with the Hollis Zombie chorus see: http://stompville.co.uk/?p=236), it is nigh-on impossible to get rid of switching clicks without significantly altering the circuit topology – so you either have to make your own version of an effect or put up with a switching click/thump.

      Finally, if you used my firmware for the ATtiny13 then I can’t see any reason why you would get any switching noise unless you have inadequate power supply bypassing filtering or a poor grounding topology. Send some photo’s of what you’re doing and I’ll see if I can spot anything.

      HTH,
      SmudgerD

  3. chris

    Hello again,

    In addition to the above, I’ve found the cause of the clicking noise thats induced into the audio signal. Its the electrical operation of the relay. You can test this if you just use a relay connected momentarily to 5V [common ground] with the audio signal passing through the relay – no other pedal/circuit in place. Need a way of filtering the noise from the relay as its coil is energised.

  4. chris

    As a further test I isolated the relay circuit from the audio path, totally separate ground – only the hot passing through the relay contacts. Very surprised to hear a distinctive click again, so the common ground is not the cause of the problem as I first thought. As the 2 circuits are totally separate now I can only assume that the relay itself is generating some sort of EMF interference, something that can’t be removed as its inherent to the relay. Tried 4 different relays now, some are better than others, but all have this problem. Its not a huge ‘click’, but if you run a delay pedal after the ‘relay bypassed’ pedal then its very evident.

    1. SmudgerD Post author

      The only scenario I can imagine where the relay coil could couple with the audio signal would be when your audio circuit is very high impedance. Can you lower the impedance of your audio circuit and see if this makes a difference?

    2. SmudgerD Post author

      You might consider adding a resistor in series with the relay coil. This would limit the current in the coil and therefore reduce the magnetic field strength in the vicinity of the coil.

      Start with (say) 10 Ohms. The d.c. resistance of the relay coil is 250 Ohms and the minimum set/reset voltage is 3.75 V, so you could experiment with values up to 82 Ohms. The operate time is 3-4 ms and the pulse width from the ATtiny13 is 10 ms, so there is plenty of margin for slowing the operation of the relay down.

  5. chris

    Cheers will give it a try. Various posts on Diystompbox forum indicate that several other people have experienced this relay click, one very clever ‘fix’ was to mute the signal for 20 or 30 m/s whilst the relay triggers. I’ll have to start learning how to program an AVR!

    1. SmudgerD Post author

      Yerbut, you would need a second relay to do that (to short the o/p to ground), wouldn’t you?

      Actually, you could probably get away with a JFET or a transistor. I’ll give it some thought – there is a spare output on the ATtiny13 which could be used to drive a mute signal.

  6. Mrki

    This should be a proper routine when the switch change is detected:
    1. trigger the mute ( spare MCU pin – 100uF parallel to GND – series 1K resistor – optical MOSFET SSR (Toshiba TLP222G e.g.))
    2. delay 2ms (to allow mute to take place)
    3. set / reset relay
    4. set LED low / high
    5. delay 10ms (to ensure the relay has finished switching)
    6. disable the mute

  7. electrosonic

    If the pedal loses power unexpectedly, does it remain in the last position? Any ideas on how to configure it so it reverts to bypass?

    1. SmudgerD Post author

      If power is unexpectedly lost, the unit will power up in fx-on or fx-bypass depending on how you have it set up. It does not remember the ‘last’ state. If you hold the stomp-switch down whilst powering up, the default behavior will change from fx-on to bypass or vice versa.

Leave a Reply