Super simple inverter-based relay bypass

Started by matt_garman, January 20, 2024, 12:38:05 PM

Previous topic - Next topic

matt_garman

I've been on a bypass obsession for a while.  Here is the latest idea:
  • Momentary SPST switch controlled
  • Uses cheap, commodity, low-power, current-production Schmitt-trigger inverter (cd40106, 74hc14) to maintain state and respond to switch presses
  • Uses MOSFETs for relay coil and status LED current sinking (no loading of inverter)
  • Uses series capacitor on FET gates for current pulse to set/reset relay
  • Uses 5v LDO for power supply so can be generalized for 9-18v pedals (but could be simplified to use e.g. 9v directly with a 9v relay and inverter chip that can run on 9v)
  • Ultra-low power consumption suitable for battery use (draws 10s of mA during switching, otherwise should be single-digit micro Amp draw)

Schematic is attached.  It's using a Panasonic TQ2-L2-5V relay (dual coil latching).  I have bread-boarded this, and works as expected.  I didn't actually connect an audio signal, but just verified that the relay switches (easy to hear), and the status LED comes on in one mode.

As I was searching for similar schemes, I found RG's latching relay driver circuit, discussed in this thread Relay bypass mod to Ibanez and Boss pedals.  I believe it's conceptually the same idea, but my design is much simpler - and now I'm wondering if it's too simple?  I don't understand the need for using the extra four inverters outside of the two (leftmost) used for keeping state and responding to switch presses, and the series caps + pullup resistors between inverters.




Baran Ismen

May i ask Whats the benefit of relay based bypasses compared to True bypass or millenium one? Or are they even on the same pot?

R.G.

Quote from: matt_garman on January 20, 2024, 12:38:05 PMAs I was searching for similar schemes, I found RG's latching relay driver circuit, discussed in this thread Relay bypass mod to Ibanez and Boss pedals.  I believe it's conceptually the same idea, but my design is much simpler - and now I'm wondering if it's too simple?  I don't understand the need for using the extra four inverters outside of the two (leftmost) used for keeping state and responding to switch presses, and the series caps + pullup resistors between inverters.
There are a number of reasons for using the extra four inverters. Probably the biggest one is that the extra inverters are there in a 6-inverter IC, and something has to be done with them. Even not using them, their inputs should be tied to logic high or low to keep them static, as you have done. It's simpler on a board layout to attach one output to the next input on the sides of the dip layout.
Subsidiary reasons are that the series cap/pullups on the third inverter input do the half-monostable job of setting the length of the pulses to the relay coils. Your design does this with the capacitors to the gates of the MOSFETs, I think. The resistor/caps on the bipolar driver transistors are there to slow the rise/fall time of the drive to the relay coil. It helps with getting less feedthrough of the coil voltage to the audio path inside the relay. Finally (best I can remember from here) the outputs are bipolars because single MOSFETs were much less common back when this circuit was posted, and relatively more expensive.

If your circuit works for you, and doesn't have nagging "impolite" behavior, no reason to worry that it's too simple.
That design is quite old, probably about 20 years. At the time, small MOSFETs were not easily available and common in pedal designs, so it was set up to use bipolars.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

matt_garman

#3
Quote from: Baran Ismen on January 26, 2024, 04:35:55 AMMay i ask Whats the benefit of relay based bypasses compared to True bypass or millenium one? Or are they even on the same pot?

Relay bypass and true bypass are not mutually exclusive; relay bypass can be either true or buffered.  I'm less familiar with Millenium bypass, but my understanding is that it's a true bypass scheme using a DPDT switch for circuit switching, with some extra circuitry to activate the power-on LED (someone please correct me if I'm wrong).

The simplest bypass is arguably the 3PDT footswitch.  Two of the poles are used for circuit switching, and the third is used for status LED (de-)activation.  3PDT bypass can be either buffered bypass or true bypass.

The 3PDT footswitch is fine for a lot of folks - it's relatively cheap and hard to argue against it's simplicity.  The main argument against them is that are likely to fail at some point, as the common ones are typically rated for 30-50k cycles.

Relays are still mechanical switching devices, but they are activated by electrical current, rather than physical force (i.e. from your foot).  They are typically rated for millions of cycles.  And likewise, relay bypass can be true or buffered.

The common relay bypass implementations use a SPST momentary switch.  Most of these are "soft touch", meaning, there is no distinct "click" when you press them (as there is with the 3PDT switches).  Whether or not this is "better" is simply a matter of personal preference.

There needs to be some kind of circuitry between the SPST footswitch and the relay.  A common way to do this is with a microcontroller.  The microcontroller is programmed to respond to the footswitch, and in turn set or reset the relay, as well as turn the status LED on or off.  This works well, requires a very basic/cheap/low power microcontroller, and the programming isn't hard (here's mine).  The nice thing about a microcontroller, too, is that you can optionally program all kinds of fancier button-press schemes, like double-tap, momentary-on, press-and-hold, etc etc.

The circuit in my first post was to try and further simplify the circuit between the footswitch and the relay, if simple effect/bypass plus status LED control is all that's needed.

Edit: In addition to what I wrote above, see also the discussion here, where the meaning of "true bypass" is discussed.  The gist is, most folks equate "true" bypass with mechanically switched bypass, where the effect circuit is physically switched away from the input and output, such that it's impossible for the effect circuit to have any impact on the bypassed signal.  Though uncommon, it is possible to have a non-buffered electrical bypass: there are subtleties and nuances to doing this, and if done incorrectly, the bypassed signal could be affected in some way (e.g. from the effect or even from the electrical switching circuit).  Done right though (above my capability!) it is technically possible to achieve true bypass without buffers and careful electrical switch design (but some might not agree to call that scheme "true bypass").  Maybe we need extra qualifiers, like hard true bypass vs soft true bypass. ;)

R.G.

All correct.
For some historical perspective:
Quote from: matt_garman on January 26, 2024, 10:33:36 AMThe 3PDT footswitch is fine for a lot of folks - it's relatively cheap and hard to argue against it's simplicity.  The main argument against them is that are likely to fail at some point, as the common ones are typically rated for 30-50k cycles.
[...]
This works well, requires a very basic/cheap/low power microcontroller, and the programming isn't hard (here's mine).  The nice thing about a microcontroller, too, is that you can optionally program all kinds of fancier button-press schemes, like double-tap, momentary-on, press-and-hold, etc etc.
The 3PDT footswitch was not always cheap or available. At the start of the internet pedal making revolution in the late 1990s, 3PDTs were essentially unavailable to pedal builders through normal supply chains, and were quite expensive when they were found. That has changed over the past two decades until they are now, as you note, cheap and easy.

Something similar prevailed on microcontrollers. The microcontrollers of the late 1990s to early 2000s were cheap on a function per dollar basis, but still cost a few dollars each. The US$0.50 (now US$0.80 in the last two years) wonders were a recent addition. An even bigger stumbling block was that the pedal diy community contained far, far fewer people who had the skill and programmer equipment to program anything. I've become accustomed to getting replies complaining about this every time I mention controllers. Less now, but they still happen.
I'm with you - I love the flexibility and extendability of controllers.

Hey - have you run into the vertical adder debouncer code? Neat stuff, eight or more switches debounced simultaneously in parallel with very short/fast code execution.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

matt_garman

#5
(Edit: moved notes on "true bypass" definition to earlier post.)

Quote from: R.G. on January 26, 2024, 10:13:43 AMThere are a number of reasons for using the extra four inverters. Probably the biggest one is that the extra inverters are there in a 6-inverter IC, and something has to be done with them. Even not using them, their inputs should be tied to logic high or low to keep them static, as you have done. It's simpler on a board layout to attach one output to the next input on the sides of the dip layout.

That makes sense.  I looked at Mouser and Digi-Key, and ICs with only two Schmitt trigger inverters don't appear to exist in through-hole format, and even the SMD parts are decidedly less ubiquitous than Schmitt trigger hex inverters.

I've since revised this to use another inverter as a current sink for the LED (and thus remove a mosfet).  I specify high efficiency/ultra bright LEDs, so you can use a pretty big (10k+) current limiting resistor, so I figure this isn't asking the inverter to sink a lot of current (though I admit I haven't done the math!).

Speaking of current sourcing/sinking, either the cd40106 or 74hc14 (I forget which now) can source/sink 25mA per inverter.  So another option might be to parallel the inverters (for double current source/sink) and remove the need for the mosfets entirely.  Most of the 5v relays I looked at only require 40mA to set/reset.  I haven't tested this, just thinking out loud.

Another side perk of leaving some inverters free - you can control two (or three using the original design above) relays+switches.  So if building a two-button pedal (e.g. king of tone), there's some space and number-of-components efficiency gains there.


Quote from: R.G. on January 26, 2024, 10:13:43 AMFinally (best I can remember from here) the outputs are bipolars because single MOSFETs were much less common back when this circuit was posted, and relatively more expensive.

I might try to tweak this a bit for using BJTs instead of MOSFETS.  Even now, I wouldn't call MOSFETS expensive, but e.g. the 2n3904 is silly cheap.


Quote from: R.G. on January 26, 2024, 10:13:43 AMIf your circuit works for you, and doesn't have nagging "impolite" behavior, no reason to worry that it's too simple.

Thank you for clarifying, I appreciate it!  I've got some PCBs of this design inbound, we'll find out fairly soon.  I'll post results here.


Quote from: R.G. on January 26, 2024, 10:58:17 AMI've become accustomed to getting replies complaining about this every time I mention controllers. Less now, but they still happen.

If I'm being honest (this coming from a software guy!) I was initially hesitant to take on microcontroller programming.  I even like coding, but when it comes to pedals, I just wanted to solder and rock.  Once I finally took the plunge, I hoped making the code available would lower the bar for others.


Quote from: R.G. on January 26, 2024, 10:58:17 AMHey - have you run into the vertical adder debouncer code? Neat stuff, eight or more switches debounced simultaneously in parallel with very short/fast code execution.

I have, but I can't say that I've put in the effort to fully wrap my head around it.  I was kind of hoping others would use my code as a baseline to add fancier features like this.  ;)

R.G.

Quote from: matt_garman on January 26, 2024, 01:12:43 PMSpeaking of current sourcing/sinking, either the cd40106 or 74hc14 (I forget which now) can source/sink 25mA per inverter.  So another option might be to parallel the inverters (for double current source/sink) and remove the need for the mosfets entirely.  Most of the 5v relays I looked at only require 40mA to set/reset.  I haven't tested this, just thinking out loud.
It's always tempting to go to 5V relays given that controllers run on 5-ish. Or used to. The ability to get to a 9V world without power regulation and drivers is one really big advantage of CD4000.
There is a tradeoff to be made between powering a microcontroller and powering peripherals. Almost all uCs will need 5V if not 3.3V or even lower. The pedal world run on 9V or higher, so the power system has to figure out how to make 5V. That's what makes those digital-effect pedals so noisy - they include a sometimes-not-very-quiet power supply inside and don't understand and/or test very well the associated pedal environment. A uC that doesn't drive things directly can often run on a shunt regulator like a zener or string of a few diodes. If you want to start pushing LED current or relay coil current through the uC, then its power supply has to be able to supply those currents. That often needs a three terminal regulator and bypass caps, and that costs $0.60 to $1.00 or so. It's usually cheaper to go cheap on the uC power supply and add more cheap bipolars, although it may take up a few more TO-92s worth of PCB area. Think hard about every piece that goes into the circuit and why exactly it's there.

Quote from: matt_garman on January 26, 2024, 01:12:43 PMAnother side perk of leaving some inverters free - you can control two (or three using the original design above) relays+switches.  So if building a two-button pedal (e.g. king of tone), there's some space and number-of-components efficiency gains there.
Yeah. Did that in a few commercial designs. Works.

Re: vertical adder debouncing.
Quote from: matt_garman on January 26, 2024, 01:12:43 PMI have, but I can't say that I've put in the effort to fully wrap my head around it.
You wind up defining a few register/ram locations for the various states. One location is the new switch values, read in up to a full port wide.
A second location is the byte-wide 0/1 bit of a counter. A third location is the byte-wide 0/2's bit of the same counter. In this format, a two-bit number is a vertical slice; the LSB of the second and third locations is a number from 0 to 3; so is the MSB slice, and each vertical slice in between.
A "1" for instance in the new switch read means "increment the number in this bit position" and a "0" means "don't increment this position".

So you XOR the new switches read values with the LSB (second byte) in a single instruction. Where there is a 1, the counter gets incremented, where it is a 0, no increment happens. The increment operation is two instructions. The 2/0s location (8 bits wide, remember) gets the result of an XOR of its previous value and the 0/1s location, also 8 bits wide. The 0/1s location is then XORed with the result of the first XOR, which inverts the bit where there's an increment to happen.  When a count gets to 1,1, it's debounced.
There are a lot of side chains in looking at this, but the basic operation of the adder is on the order of five assembly instructions on all eight switch operations on the same clock cycle in the uC. You can add mask registers and so on to make switch operations look only for changes (our friend XOR helps here) or to make switches change only on make, or only on release or on both - that is, the switch is programmably momentary.

It takes some attention to detail, but boy is it amazing when you get the logic right. Debouncing a word wide array of switches in a countably small number of machine instructions (or BASIC code - I did it once in BASIC) without careful timing loops and needing only a regular "sample the switches" loop or interrupt is really really handy.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

ElectricDruid

Quote from: matt_garman on January 26, 2024, 01:12:43 PM
Quote from: R.G. on January 26, 2024, 10:58:17 AMHey - have you run into the vertical adder debouncer code? Neat stuff, eight or more switches debounced simultaneously in parallel with very short/fast code execution.

I have, but I can't say that I've put in the effort to fully wrap my head around it.  I was kind of hoping others would use my code as a baseline to add fancier features like this.  ;)

I'd recommend looking into this. It's totally worth the effort. I first learned about it from Scott Dattalo's (unfortunately now defunct) website, which included all sorts of extremely useful and hacky tricks for getting more out of less. Maybe there's a waybackmachine version out there somewhere?
I often use this technique even if I only need a couple of inputs, not eight, and the *way of thinking* that it opens up has given me other solutions to various different problems. Rather than seeing it horizontally, how would this look if we did it vertically, in parallel? That's an important shift in viewpoint, and definitely worth getting to grips with. It won't always help, but it's another tool in the toolbox.


R.G.

Yep, Scott D'attallo. Really smart guy, in a bunch of smart guys who worked out things like the fewest-clock-cycles stuff on the first generations of PICs. I really ought to see if his stuff has been saved somewhere and archive it. Wayback's a good idea.

My cutoff is two inputs. If I only need one debounced input, I use my code. If it's two or more, I go vertical adder.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

ElectricDruid

Quote from: R.G. on January 26, 2024, 04:47:05 PMMy cutoff is two inputs. If I only need one debounced input, I use my code. If it's two or more, I go vertical adder.

Lol, yes, probably the same for me, but I *may* have been known to get lazy on an occasion or two and just use what was there. ;)

PRR

#10
Quote from: R.G. on January 26, 2024, 04:47:05 PMScott D'attallo

https://web.archive.org/web/20120225045334/http://www.dattalo.com/technical/software/software.php
??

Apparently "Scott Dattalo" (no stray accent). In 2015 the URL is taken over by a fairly pointless and un-updated homeowner website.

Quotepic_debounce - Here's a routine that's designed to simultaneously debounce 8 inputs. I've used it in conjunction with a keyboard scanning routine and also as a generic parallel digital input port. It's currently set up such that four consecutive samples at the same logic level are required for the filter outputs to change states. BTW, there are no gotos and no counters.
  • SUPPORTER

R.G.

Thanks for doing the digging!

Apparently I was thinking of my third cousin twice-removed So'cot D'at'tal-lo, who had spelling and punctuation issues. 8-)
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

ElectricDruid

Quote from: PRR on January 26, 2024, 11:57:27 PMhttps://web.archive.org/web/20120225045334/http://www.dattalo.com/technical/software/software.php
??

Yep! Good find! That's the one. That website is/was a gold mine. Like it says, for really tweaked code, or equivalently, really tweaked programmers  :icon_lol: It's proper hacking.

matt_garman

My PCBs came in Friday, I soldered one up and swapped it in to a former pedal build.  It works great - delightfully boring.  :)

These PCBs use the circuit posted in the first post in this thread.  I have four left, if anyone wants one, PM me and I'll mail it to you.








Ben N

  • SUPPORTER

matt_garman

Quote from: Ben N on January 28, 2024, 01:04:31 PMIs there a way to trigger it externally?

What do you mean?  There are two solder holes labeled "F.SW" on the lower left.  Those are designed to be used with any kind of momentary switch.  You can't see it in the pics I posted, but directly below the PCB is the foot switch, which is bolted to the enclosure, and comes out on the exterior of the pedal.

I don't see any reason you couldn't use fairly long cables and run it to a switch farther away from the pedal, if that's what you mean by externally?

R.G.

#16
Yes, but it needs a floating switch, not a switch to ground or switch to some voltage. The need for a not-ground-referenced switch is the flaw that keeps this particular circuit from being more widely applied in my opinion.

One of the two floating wires goes directly to a CMOS gate input fed through a 47K resistor from the second gate. The "input impedance" there is thankfully only the 47K. The second wire goes to that 0.1uF cap to ground. If you get noise pulses on the gate-connected wire, it can flip the state. This isn't a huge problem, but in difficult situations it can require shielding the two floating wires.

One way to get around this is to use a MOSFET-output optocoupler or CMOS transmission gate to be the actual switch, and then get a switch-to-ground for the external switch wires that can be low impedance and noise filtered. Or just take the chances on the noise. It's usually not that bad.

Edit: I got curious as to what was available today. Mouser has the Toshiba TC4S66F/FU for $0.15. It's a single channel CMOS transmission gate that would trigger the inverter flipflop fine while using a ground-referenced external switch. About the only thing wrong with this is that it's SMD. Otherwise, it's a great replacement for series JFET switches. It can take a 3V to 18V power supply too.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

matt_garman

Quote from: R.G. on January 28, 2024, 01:56:11 PMIf you get noise pulses on the gate-connected wire, it can flip the state. This isn't a huge problem, but in difficult situations it can require shielding the two floating wires. [...] Or just take the chances on the noise. It's usually not that bad.

Just to make sure I understand, the risk here is that environmental EM noise could potentially cause random/unintended state changes, right?  I.e., the effect could switch to bypass or engaged without an explicit footswitch press?

I'm assuming that in practice, there is little risk of this due to relatively short wires to the switch, and also having them tucked away in an aluminum box?  Typical analog circuits I'm assuming generate very little EM noise.  Digital effects could possibly generate some EMI within the enclosure?

Don't we get some degree of protection from EMI-induced spurious state changes due to the inverters being Schmitt trigger input?


Quote from: R.G. on January 28, 2024, 01:56:11 PMEdit: I got curious as to what was available today. Mouser has the Toshiba TC4S66F/FU for $0.15. It's a single channel CMOS transmission gate that would trigger the inverter flipflop fine while using a ground-referenced external switch. About the only thing wrong with this is that it's SMD. Otherwise, it's a great replacement for series JFET switches. It can take a 3V to 18V power supply too.

Can we get away with using three of those as drop-in replacements for the relay?  Or do the same nuances exist as with JFET switching, as recently discussed here?

R.G.

Quote from: matt_garman on January 28, 2024, 02:47:12 PMJust to make sure I understand, the risk here is that environmental EM noise could potentially cause random/unintended state changes, right?  I.e., the effect could switch to bypass or engaged without an explicit footswitch press?
Yes.
QuoteI'm assuming that in practice, there is little risk of this due to relatively short wires to the switch, and also having them tucked away in an aluminum box?  Typical analog circuits I'm assuming generate very little EM noise.  Digital effects could possibly generate some EMI within the enclosure?

Don't we get some degree of protection from EMI-induced spurious state changes due to the inverters being Schmitt trigger input?
Yes, and yes. Inside a shielding box, you're not at much risk. The issue gets bigger whenever wires go outside the box, and the longer the wire, the bigger the risk. Yes, the Schmitt triggers help a lot, but the biggest issue is the impedance. 47K isn't too bad, but a 0.1uF cap between the two wires is better; but this circuit can't use a cap like that and still function, I don't think. It relies on the 0.1uF cap-to-ground between the two inverters overwhelming the positive feedback from the second inverter. If the charge on the cap-to-ground can ever force the input to the first inverter to change in spite of the feedback through the 47K, the first inverter output flips, this flips the second inverter, and now the positive feedback is forcing the first inverter where the switch wanted it to go. In two inverter propagation delay times, the two inverters reach their new state and the output of the first inverter starts charging the 0.1uf cap to ground to the new state to remember.
That is to say, a noise pulse that gets onto the wire connecting to the input of the first inverter only has to (1) be in the flip-me-now direction, (2) cause a change bigger than the inverter input hysteresis and (3) be able to overwhelm the 47K feedback resistor trying to hold the first inverter's input steady. Stray noise of 5V or more is trivial for loose wires in free air, but the impedance is high. So the shorter the wires (= antennae) and the smaller the feedback resistor, the more energy needed from the EMI to flip it. The 47K isn't bad. I used 100K in my designs, never had issues inside a metal box.

Re: the Toshiba transmission gate;
Quote from: matt_garman on January 28, 2024, 02:47:12 PMCan we get away with using three of those as drop-in replacements for the relay?  Or do the same nuances exist as with JFET switching, as [...] recently discussed here[/url]?
Yes, those would be a fine bypass ( I think... depends on their internal control signal cross coupling; I've used the CD4051/2/3 series in commercial pedals for years with no problems.) but it would have the same philosophical issues as the JFET switching. It's not "true bypass" in the way most people think of that term. CMOS switches have issues with control signal feedthrough (little "ticks") and DC shifts when switching (more pop-ish than "tick") unless you tinker with biasing the input and output pins and worry about signal impedances. I personally think a single CD4053 would make a great bypass replacement for a relay ;-)
But it really can't claim true bypass status for folks who don't understand the techie stuff and relay on word-of-mouth from others.
What makes it really good here is that the switch is floating within it's power supply range, so it could take the place of the "floating" need for the two-inverter flipflop, and it needs only a control signal switch from or to ground. One or two of your spare Schmitt inverters lets you choose whether to make the external momentary switch be ground-to-make or high-to-make.

As an aside, the two-inverter flipflop is actually a master-slave two-stage flipflop. One of the flops is the two inverters. The other is that capacitor to ground, fed through a high resistance. The cap always keeps the "next" state; when shorted to the first inverter input, it forces the inverter flop to "next" and then recharges through its high resistance to the next "next" state. Some recharge time for that cap is needed between switch presses, but that's generally small enough not to notice for humans.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Ben N

Quote from: matt_garman on January 28, 2024, 01:45:33 PM
Quote from: Ben N on January 28, 2024, 01:04:31 PMIs there a way to trigger it externally?

What do you mean?  There are two solder holes labeled "F.SW" on the lower left.  Those are designed to be used with any kind of momentary switch.  You can't see it in the pics I posted, but directly below the PCB is the foot switch, which is bolted to the enclosure, and comes out on the exterior of the pedal.

I don't see any reason you couldn't use fairly long cables and run it to a switch farther away from the pedal, if that's what you mean by externally?
Actually, I was more thinking MIDI.
  • SUPPORTER