DIYstompboxes.com

DIY Stompboxes => Building your own stompbox => Topic started by: bobindah on March 20, 2012, 06:35:53 PM

Title: uC Latching Relay True Bypass - nearly!
Post by: bobindah on March 20, 2012, 06:35:53 PM
Hi,
I have recently got into programming micro-controllers (I started with an Arduino Uno and moved onto ATTiny chips (which can be programmed using the arduino board and code which is nice :-) anyways I thought I would try and make one of those posh uC controlled latching relay true bypass circuits like the ones from De-Ville, AMZ etc  (ps sorry for the criss-cross schematic, I never seem to be able to avoid crossing lines. I chose a Panasonic 2 coil latching 5V relay and used an ATTiny45 chip as the controller. Unfortunately due to tiny45 can't quite put out the 40ma required to energise the relay coils so I used 2N7000's to buffer the relay switching.
(http://www.triggsamps.co.uk/images/uCschem.png)

The basic pseudo code for the uC is:
1. read switch status
2. debounce the switch status
3. If the status has changed after debouce then we need to change the relay:
If the current status is high (we want it to go low - bypass mode)
set the mute pin (connected to the J175) to low
set the LED pin to low
set the Reset pin to HIGH
Delay(10ms) - wait to ensure relay has switched
set the Reset pin to LOW (to avoid wasting power)
set the mute pin to high (un-muting the signal)
set the current status to low.

Do the same to set it into "effects" mode expect I set the set pin instead of the reset and set the LED pin to high.

Iv got this working quite nicely, it will toggle on and off turning on the LED and switching the signal nicely. I decided to add a P-Channel JFET (J175)  to mute signal whilst the relay is switching, I'm not 100% sure if I hooked that up right but it seems to work - all good so far.
My problem is when it is switched on or off I get a click/pop noise through the amp - (the relay itself makes a slight mechanical clicking sound) and was wondering if there is anything I can do about it? Is there something obvious I've missed? It's not a massive click but I'd like to be quieter if I can. I have tried increasing the delay so the mute JFET is on for longer but it still makes the noise. I thought it could be related to the LED but I have tried disabling the LED pin and the noise is still made so I don't think its that.
Any help would be greatly appreciated, many thanks Bob
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on March 20, 2012, 07:48:42 PM
I've done this several times. I put a batch of "postage stamp" PCBs into the unused spaces on my last PCB order.

I think you're running into issues with the speed over which the J175 is being switched. Hang a slow-down cap on its gate drive to slow down how fast it comes on and off, and adjust the timing of the mute/unmute in your code.

The code's pretty simple. I keep thinking I'll publish it, but keep going - nah, let 'em work it out. Good job - you're the first I've seen do this.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Gurner on March 20, 2012, 07:58:21 PM
+1

To prove the point, just have you uc gate the P fet (ie nothing else) - it'll probably click.

I was never able to eliminate the click with the jfet gate slow down technique (it seems a valid approach, but never got rid of my click),  but using a opto isolated fet cured it

You mght also be running into problems with the relay ground currents permeating into your signal ground...so this is another reason just to have the FET gate on/off temporarily....just see how of much your click (if any) is related to the relays energising
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: bobindah on March 21, 2012, 10:14:53 AM
Hi guys,
Thanks for the responses, I thought it might have something to do with the J175 switching, I'll try and stick a 0.1uF to ground on the gate drive and see if it helps. I will also try fiddling with the uC code and disabling the output pins so I just switching each component on and off one at a time (e.g. LED, J175, Relay) to see which ones effect the popping. I tried changed the LED resistor to see if the change in current caused by that switching on made much difference but I don't think its that - I used a 4.7k so my LED is basically using about 1ma ish now when driven by 5V. (total consumption when OFF is about 6.7ma - when on it jumps up to about 7.5ish when its ON - the 40ma spike from the relay being energised is too fast for my meter to measure)

Hmm I did think of some kind of opto-solution but couldn't find anything suitable that wasn't really expensive (e.g. several pounds each) - by opto-isolated fet is that like those 6pin DIP H11F1 packages? I wondered if one of those transistor opto-isolators like 4N25 but not sure that would be suitable in this situation?

Also looking at my test circuit (I have it connected to a Boss SD-1 at the mo but disabling the flip-flop of the circuit so it always (ON)) - I have the ground wire from this switching circuit connected to the output jack sleeve. Would it be better grounding it to the input jack (e.g. where the DC ground connects) or even to the circuit ground on the SD-1 board itself.

Quote from: R.G. on March 20, 2012, 07:48:42 PM
The code's pretty simple. I keep thinking I'll publish it, but keep going - nah, let 'em work it out. Good job - you're the first I've seen do this.
- TBH I found the process of learning how code and program the chips quite fun and learned a lot from doing it. I think it greatly helped fact that I could use C code which I have had some experience with but the Arduino stuff is a pretty good starting point. I might look into other uC solutions such as PIC too.
RG - It was actually a post of yours while ago about designing a uC relay switching board that gave me the idea to try it, so thanks again for the inspiration and excellent website.
When I've got the hang of this double coil switching version I might look at a single coil latching relay as I could probably get away without needing the two 2N7000 drive transistors as the relay current is less so reducing the board size / cost.
bob
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: MetalGuy on March 21, 2012, 05:51:14 PM
I've used this idea in pedals and in tube amps and it's pretty much noiseless. 10 msec might be short (including the bouncing) for some type of relays so I put at least 20 msec.
Using uC for switching is very practical so go for it!
By the way you can get the same muting effect without uC as well. Check out Engl's mute circuit for example.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: bobindah on March 22, 2012, 07:35:07 PM
Hi guys thanks for the ideas, I've had a bit of play...
Firstly I went step by step - as RG suspected the J175 turning on is making a pop - So I tried using different slow down caps - anything around 0.047 - 0.1uF seems to slow it down a bit and make the pop a lot shorted (its still there tho - I tried going up to even bigger caps but over 1uF i think it does more harm that good - lol 100uF means it doesn't really switch at all lol!

I then tried with just the relay without any muting - there is a slight pop coming from this too - which was greatly reduced by moving the grounding point for the switching circuit to the same lug as the battery ground (rather than grounding via the output jack)

The LED switching on and off doesn't seem to have much if any effect on the pop so some good news there :-)

I have also slightly altered the switching code so it now basically does the following:
set mute pin low (J175 comes on)
delay(10)
set relay pin high (relay switches)
delay(20)  (to ensure relay has fully switched
set relay pin low again
delay(10) - not sure if this delay achieves much
set mute pin high again (so the signal is now passed)

All of these changes have made some difference I think the "pop" is slightly less pronounced now so maybe I could live with it, but it would be nice to get rid of it all together!
Quote from: MetalGuy on March 21, 2012, 05:51:14 PM
By the way you can get the same muting effect without uC as welsol. Check out Engl's mute circuit for example.
Ah yeah iv seen that kind of thing before I think Mesa do something similar, my basic understanding of it is some magic is created when the relay coil collapses that causes a pulse to the J175 to mute for a bit of time that allows the switching, as the Fet is faster than the relay it kicks in first, very clever stuff!

So yeah not really sure where to go from here? I can try and fiddle with the program timings to see if there's an optimum delay time. Opto-Fet's do sound interesting but a H11F1 (the only opto-fet i know of) is like gold-dust here in the UK after RoHS decided they weren't very nice. Would using an N-channel Fet like at 2N7000 to mute be any better? I quite like the J175 cos it keeps everything at 0 volts. Also at the moment I have all the switching stuff including the regulator all set up on one board sharing one ground wire - would separating the "digital" ground from the signal help at all? E.g two wires one for the 5V ground stuff and one for the muted signal? Just a thought, i know from amp building that grounding can be a bit of mine field!

Cheers again for the help :-)
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Beo on March 22, 2012, 11:02:47 PM
I don't see the point. A single CD4013 gives you enough flip-flops to process a momentary switch input and drive a relay and LED. What advantage are you getting with a uC?
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on March 22, 2012, 11:51:50 PM
Quote from: Beo on March 22, 2012, 11:02:47 PM
I don't see the point. A single CD4013 gives you enough flip-flops to process a momentary switch input and drive a relay and LED. What advantage are you getting with a uC?
Flexibility. There are other things than driving the relay and LED that you can do. One doesn't even need a 4013 - Boss and Ibanez have been using a two-transistor flipflop since they started making pedals.

First, a 4013 costs $0.44. The cheapest PIC at Mouser is $0.49, but is SMD. The cheapest DIP PIC is $0.55. For the extra $0.11 you get an 8-pin DIP that will do anything you cant tell it to with 4 I/O pins.

That includes:
- doing latching relays, either single or double coil, easily; it's possible with flipflops and R-C time constants and such, but it's hard to not bring in another chip. I went through this with the design I put on geofex for a latching relay circuit driven by a hex inverter. It means that running a relay on a battery is feasible, where a non-latching relay isn't really.
- doing a separate mute, which is currently having some technical issues here, but can be made to make switching completely silent
There are others.

Quote from: bobindah on March 22, 2012, 07:35:07 PM
the J175 turning on is making a pop - So I tried using different slow down caps - anything around 0.047 - 0.1uF seems to slow it down a bit and make the pop a lot shorted (its still there tho -
Bummer. More than one problem.
Quote
I then tried with just the relay without any muting - there is a slight pop coming from this too - which was greatly reduced by moving the grounding point for the switching circuit to the same lug as the battery ground (rather than grounding via the output jack)
The reduction means that the transient on the ground line of the relay current is being heard. Moving the grounding wire to keep relay ground current off the signal ground wires is a big help in most things. Have you tried putting a 10uF to 100uF cap out very near the relay and the driver?

I suspect the slight pop you hear may be from capacitive coupling of coil voltage to the signal lines. This is what the muting is supposed to cover up.
Quote
So yeah not really sure where to go from here? I can try and fiddle with the program timings to see if there's an optimum delay time. Opto-Fet's do sound interesting but a H11F1 (the only opto-fet i know of) is like gold-dust here in the UK after RoHS decided they weren't very nice. Would using an N-channel Fet like at 2N7000 to mute be any better? I quite like the J175 cos it keeps everything at 0 volts. Also at the moment I have all the switching stuff including the regulator all set up on one board sharing one ground wire - would separating the "digital" ground from the signal help at all? E.g two wires one for the 5V ground stuff and one for the muted signal? Just a thought, i know from amp building that grounding can be a bit of mine field!
No H11Fx because of RoHS? Sigh.

You're at a bit of an impasse. There is reason to believe that ground noise is causing some of the pop. It would be a Good Thing to have the whole switching setup not share power or ground with the signal. The relays let you do this, but if you have to use a JFET for muting, it has to share the signal ground to mute. That means that the switching and signal grounds have to meet.

Some options are :
LED-LDR for muting, which will be very slow to mute and un-mute, but maybe OK. Does RoHS give you permission to have either LEDs or LDRs?
You don't really need a full mute; just going to low impedance (under 10K) might be enough to dissipate the coil capacitance coupling.
Maybe you could use one of the fancy LED-photovoltaic MOSFET drivers and the JFET. LED-PV modules use the LED light to make an isolated voltage. This could drive the JFET on and off and still isolate the two grounds. Assuming RoHS allows you to possess LED-PV modules.

Title: Re: uC Latching Relay True Bypass - nearly!
Post by: bobindah on March 23, 2012, 04:58:58 AM
Thanks again RG for the advice,

I think you are correct, I think my main concern should be isolating the grounding, I'll try and put a 100uF near the relay driving circuits and see if that filters it out. I'm optimistically hoping that if the relay circuit isolation is done well enough I could get away without needing the mute FET! I'll try re-breadboarding my design and powering it from a separate 5V supply see if I still get a pop.

The RoHS thing is more from the suppliers here really, I noticed Farnell have got back in the H11F1M which is RoHS compliant but its US stock so they wack on another £15.99 delivery! I'll keep looking around for them as I think it could be a good all in one solution. Pretty sure RoHS compliant versions of the LED-LDR couplers / LED-photovoltaic MOSFET exist also so that could be a thing to look into.

Yeah basically I chose to use the uC instead of the 4013 or similar chips because I wanted to have a flexible board that I could use in different places, one thing I have coded in is the ability for it to work with a momentary switch (like in Boss etc) or a fixed toggle (e.g. like the standard Crybaby switch) meaning I can (hopefully when its all working nicely) drop the same board into pretty much any pedal. I know there are probably simpler solutions out there but I wanted to learn more about uC programming so this gave me a good excuse to play with it :-)
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Gurner on March 23, 2012, 06:11:06 AM
They are only about 66p each inc VAT at RS UK (but you need to buy in 5s)....

http://uk.rs-online.com/web/p/optocoupler/0456383/?searchTerm=H11F1M&relevancy-data=636F3D3226696E3D4931384E4B6E6F776E41734D504E266C753D656E266D6D3D6D61746368616C6C7061727469616C26706D3D5E5C772B2426706F3D313326736E3D592673743D4D414E5F504152545F4E554D424552267573743D48313146314D2677633D424F544826

...top tip, register account with then & then postage is free. (I'm not a business & I was able to register an account without any issue).

so 5 x HF11Ms for £3.30 delivered seems bargain basement to me!

What with all the tree hugging ROHS stuff going down...this is for a stompbox not an industrial scale blockbuster rollout?!
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Perrow on March 23, 2012, 08:46:53 AM
You can usually find one or more of them (opto coupler) in PC power supplies, should you have any dead ones around.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on March 23, 2012, 09:54:08 AM
Quote from: Perrow on March 23, 2012, 08:46:53 AM
You can usually find one or more of them (opto coupler) in PC power supplies, should you have any dead ones around.

Wrong kind of optocoupler. This app needs a photo-FET or LDR. The optos in power supplies tend to be phototransistors, which do shunt signal, but introduce offset voltages and transients. This is what you're using an optocoupler to avoid.
Title: Re: Re: uC Latching Relay True Bypass - nearly!
Post by: Perrow on March 23, 2012, 10:29:40 AM
Doh :(
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: bobindah on March 23, 2012, 11:03:52 AM
Quote from: Gurner on March 23, 2012, 06:11:06 AM
They are only about 66p each inc VAT at RS UK (but you need to buy in 5s)....

http://uk.rs-online.com/web/p/optocoupler/0456383/?searchTerm=H11F1M&relevancy-data=636F3D3226696E3D4931384E4B6E6F776E41734D504E266C753D656E266D6D3D6D61746368616C6C7061727469616C26706D3D5E5C772B2426706F3D313326736E3D592673743D4D414E5F504152545F4E554D424552267573743D48313146314D2677633D424F544826

What with all the tree hugging ROHS stuff going down...this is for a stompbox not an industrial scale blockbuster rollout?!

Thanks for heads up, unfortunately the website says they won't be in stock 'til July :-( but worth keeping in mind for the future as its way cheaper than farnell etc. I'm not really fussed about whether I use RoHS stuff or not really its just I tend to buy from Farnell or Rapid and they seem to have pretty much phased out most things that aren't, or at least the bits I'm looking for any ways!
I wish I could use the 4N25 type opto's, they are pretty cheap these days but as RG confirms the transistor output isn't ideal for this application.

I did have a bit of an idea, been studying some boss and ibanez fet switching schematics - whilst they all use a N-Channel Fet and I'm using P-Channel so there are some differences, they all have a similar set of components on the gate - e.g. Diode - 1M resistor and 0.047uF cap to ground, I wonder if use these values I might get the magic slowdown in the FET switching iv been looking for. It's just a idea but I think I'll try it and see if it helps. I did also have a crazy idea of using the PWM pin of the chip through a low pass filter to slowing ramp up (and down) the FET voltage to slow it down that way.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: gritz on March 24, 2012, 07:50:53 PM
@bobindah: Doctor Tweek seems to have the H11F1M in stock in the UK if you still fancy trying 'em before July...

http://www.doctortweek.co.uk/shop/article_278/Optocoupler-Analog-FET-H11F1M.html?shop_param=cid%3D1%26aid%3D278%26 (http://www.doctortweek.co.uk/shop/article_278/Optocoupler-Analog-FET-H11F1M.html?shop_param=cid%3D1%26aid%3D278%26)

Hope this helps.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: bobindah on March 27, 2012, 03:28:59 AM
kool, I knew someone could find these H11F1M's somewhere in the UK! I think I might get a couple as they are always useful for testing. I am still convinced that I can get it working with the J145 I just need to go back to the breadboard and try various things. Thanks for the link, very useful  :)
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Hoffmann on June 04, 2012, 07:33:26 AM
I came across this project, maybe it'll be of an interest:
http://stompville.co.uk/?p=260
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: asatbluesboy on June 04, 2012, 08:03:12 AM
Reading it all and thinking I'm still a long way... Can't understand anything being said here.  ???

You guys are awesome.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: amptramp on June 04, 2012, 12:41:14 PM
You could use a low slew-rate switcher such as the Boss / Ibanez circuit shown here:

http://geofex.com/Article_Folders/bosstech.pdf

which suppresses switch popping by gradually transferring from one source to another.  You can add resistor / capacitor / diode networks at the flip-flop outputs to obtain the correct priority for switch actuation.  No need for programming.

You can also use vactrol (LED / photoresistive) switching, diode switching and CD4007 low slew-rate switching.  For the latter, check the following datasheet figure 1:

http://pdf1.alldatasheet.com/datasheet-pdf/view/11942/ONSEMI/MC14007.html

and eliminate the inverter connections to pins 6, 8 and 13 and drive pins 3 and 10 directly from a flip-flop as presented in the geofex article above.  Note that this site has some Boss pedal schematics scattered all over in various locations but a complete compendium is here:

http://www.generalguitargadgets.com/tech-pages/45-schematics/55-boss-schematics

so you even have the parts values.  Almost any small-signal NPN transistors will do for the flip-flop.  There is nothing critical in these circuits except that for the diode / JFET circuit used in the Boss pedals, the JFET must be low gate-to-source cutoff and the diode must have lower leakage current than the JFET gate.  (One more reason to like the CD4007 / MC14007 circuit.)
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: tempus on June 04, 2012, 01:39:09 PM
Keep us posted on how this one works out. I built a PIC based matrix (thread is here: http://www.diystompboxes.com/smfforum/index.php?topic=76715.0 (http://www.diystompboxes.com/smfforum/index.php?topic=76715.0)). I was never able to get it totally silent - I used a BS170 for muting though, and I changed all the in/out switching to JFETs instead of BS170s. I still get small pops when switching, and bigger pops when switching amp channels (which is weird because the remote footswitch that came with the amp switches pretty quietly). It'd be nice to see if there's a way to make totally silent switching.

Quick question on the H11F1M - am I reading the datasheet right? Is 1.75 v the maximum you can use to switch these things?

Thanks

Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on June 04, 2012, 02:17:03 PM
Quote from: tempus on June 04, 2012, 01:39:09 PM
Quick question on the H11F1M - am I reading the datasheet right? Is 1.75 v the maximum you can use to switch these things?
If you mean on the LED side, yes. That's the LED forward voltage. However, that's almost of no consequence at all, because what you want to do is to use a *current* through the LED to switch it. You want off to be zero current in the LED, and you get this by making the voltage into the LED much less than the 1.75V "on" voltage. You want the on state to be something like 3 to 10 milliamperes, which you get by putting a voltage larger than 1.75V through a resistor into the LED.

For a 5V drive, the voltage across the resistor is 5V -1.75V = 3.25V. You then pick a current you want; perhaps 8ma; then the resistor is R = 3.25V/0.008 = 406 ohms. This is not a standard value, but 390 ohms is, and that would give you a bit more current, which is OK.

Title: Re: uC Latching Relay True Bypass - nearly!
Post by: tempus on June 04, 2012, 05:55:23 PM
Ahh right - funny I wasn't even thinking about it like trying to light an LED, which is exactly what it is. So of course you use the proper sized resistor to control the current, just like in a normal LED. That makes sense now. I may have to order a few of these next time I place an order with Mouser and see if they can fix my popping problem.

Thanks RG
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Hoffmann on June 06, 2012, 05:29:24 AM
any progress?
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: bobindah on June 21, 2012, 08:54:30 AM
Hi,

my appologies for not replying sooner, my appendix decided to explode so I have been out of for a while! But I'm all fixed now so back on it!

I have made some progress, I gave up on the H11F1 cos it was a bit costly for my liking (I wanted to make a few as friends were interested) though I think it could be the ultimate answer - I decided to play with different FET's in the mute position - I found that the J175 has quite a resistance (RDSon) when compared to some other FET's, in my tests this meant that even when it was in mute mode I could still faintly here the pedal (it wasn't fully attenuating the signal) I decided to look in my parts bin and came up with the 2N7000 (which is N-channel rather than the P-channel) This seems to have silenced the pops better **There is still a faint pop, but compared to a 3PDT switch for example I think its pretty darn quiet.
Anyways I think I'm happy with the circuit and have fitted it to a few different pedals for a friend of mine and he's gigged them successfully (DS-1, SD-1, Tube Screamer etc) and it seems to have made them nice and true bypassy. My design is pretty similar to the one on SmudgerD's Stompville http://stompville.co.uk/?p=260 (http://stompville.co.uk/?p=260) site, mine just has a 2N7000 mute to ground on the output - I used a simple 0.1uF cap / 100k resistor slowdown circuit to reduce the pop from the actual FET.
I like the idea of replacing the 78L05 with a device that has a much lower QC too, that would make this circuit use hardly any current at all. I also settled on using the attiny13 as he as because it is quite affordable from taydar - I program it using my Arduino as an ISP.
I'm not sure if using an N-Channel Mosfet is ideal in this instance but it does seem to work well by my ears! thanks to everyone for all your help :)
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: merlinb on June 21, 2012, 09:22:29 AM
Quote from: bobindah on June 21, 2012, 08:54:30 AM
I found that the J175 has quite a resistance (RDSon) when compared to some other FET's, in my tests this meant that even when it was in mute mode I could still faintly here the pedal (it wasn't fully attenuating the signal) I decided to look in my parts bin and came up with the 2N7000

Don't forget you can connect multiple FETs directly in parallel to reduce Rds(on) and so get better offness...
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on June 21, 2012, 10:35:21 AM
A MOSFET as opposed to a JFET will do a better mute, all right; the on resistance is much lower. But it brings its own problems, in the form of a substrate diode from source to drain that cannot be avoided, only worked around. This means that as a shunt-to-ground, signals bigger than about 0.4V peak will start to be distorted and signals bigger than about 0.6V will be clipped. As a series device, it will block signals when off, but only up to about the same signal size, where the diode will start to conduct.

There are ways around this, but they add complexity and cost. But if it works for your setup, that's great!

As merlin notes, you can parallel JFETs for lower Rdson; you can also use a second JFET as a series switch element, turning the series JFET off and the shunt JFET on to block signal. This arrangement can give profound signal attenuation. Again, you have to make two gate control signals and they have to be out of phase.

I'm glad to hear that the setup is working for you and your friend, but even happier that the appendix was fixed successfully.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: tempus on June 21, 2012, 11:39:12 AM
Quote from: R.G. on June 21, 2012, 10:35:21 AM
A MOSFET as opposed to a JFET will do a better mute, all right; the on resistance is much lower. But it brings its own problems, in the form of a substrate diode from source to drain that cannot be avoided, only worked around. This means that as a shunt-to-ground, signals bigger than about 0.4V peak will start to be distorted and signals bigger than about 0.6V will be clipped.
R.G., do you mean that if a MOSFET is connected like this:

(http://i369.photobucket.com/albums/oo136/tempus1/PICJFETs-1.jpg)

(the BS170 shunt at the right) it will distort? I kind of figured that since it was only shunting to ground, it would basically be invisible when off since it's not in the signal path, but would shunt when turned on.

Thanks

PS Glad you got your setup working bob. I'm kind of in your boat; I can't quite get rid of the last bit of switching pop (more of a thump in my case). I'll be sure to post if I find a solution, especially since we're using similar circuits.

Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Hoffmann on July 18, 2012, 12:09:54 PM
Quote from: bobindah on June 21, 2012, 08:54:30 AM
Hi,

my appologies for not replying sooner, my appendix decided to explode so I have been out of for a while! But I'm all fixed now so back on it!

I have made some progress, I gave up on the H11F1 cos it was a bit costly for my liking (I wanted to make a few as friends were interested) though I think it could be the ultimate answer - I decided to play with different FET's in the mute position - I found that the J175 has quite a resistance (RDSon) when compared to some other FET's, in my tests this meant that even when it was in mute mode I could still faintly here the pedal (it wasn't fully attenuating the signal) I decided to look in my parts bin and came up with the 2N7000 (which is N-channel rather than the P-channel) This seems to have silenced the pops better **There is still a faint pop, but compared to a 3PDT switch for example I think its pretty darn quiet.
Anyways I think I'm happy with the circuit and have fitted it to a few different pedals for a friend of mine and he's gigged them successfully (DS-1, SD-1, Tube Screamer etc) and it seems to have made them nice and true bypassy. My design is pretty similar to the one on SmudgerD's Stompville http://stompville.co.uk/?p=260 (http://stompville.co.uk/?p=260) site, mine just has a 2N7000 mute to ground on the output - I used a simple 0.1uF cap / 100k resistor slowdown circuit to reduce the pop from the actual FET.
I like the idea of replacing the 78L05 with a device that has a much lower QC too, that would make this circuit use hardly any current at all. I also settled on using the attiny13 as he as because it is quite affordable from taydar - I program it using my Arduino as an ISP.
I'm not sure if using an N-Channel Mosfet is ideal in this instance but it does seem to work well by my ears! thanks to everyone for all your help :)
Any chance for posting schematics?
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: chris1001 on January 25, 2013, 10:25:17 AM
Hi Bobindah, I'm also experiencing relay clicks with an ATtiny/relay switching circuit. What do you mean exactly by "2N7000 mute to ground on the output " - how is this connected, and to where? Is your schematic similar to the Stompville one?

Cheers


Quote from: bobindah on June 21, 2012, 08:54:30 AM
Hi,

my appologies for not replying sooner, my appendix decided to explode so I have been out of for a while! But I'm all fixed now so back on it!

I have made some progress, I gave up on the H11F1 cos it was a bit costly for my liking (I wanted to make a few as friends were interested) though I think it could be the ultimate answer - I decided to play with different FET's in the mute position - I found that the J175 has quite a resistance (RDSon) when compared to some other FET's, in my tests this meant that even when it was in mute mode I could still faintly here the pedal (it wasn't fully attenuating the signal) I decided to look in my parts bin and came up with the 2N7000 (which is N-channel rather than the P-channel) This seems to have silenced the pops better **There is still a faint pop, but compared to a 3PDT switch for example I think its pretty darn quiet.
Anyways I think I'm happy with the circuit and have fitted it to a few different pedals for a friend of mine and he's gigged them successfully (DS-1, SD-1, Tube Screamer etc) and it seems to have made them nice and true bypassy. My design is pretty similar to the one on SmudgerD's Stompville http://stompville.co.uk/?p=260 (http://stompville.co.uk/?p=260) site, mine just has a 2N7000 mute to ground on the output - I used a simple 0.1uF cap / 100k resistor slowdown circuit to reduce the pop from the actual FET.
I like the idea of replacing the 78L05 with a device that has a much lower QC too, that would make this circuit use hardly any current at all. I also settled on using the attiny13 as he as because it is quite affordable from taydar - I program it using my Arduino as an ISP.
I'm not sure if using an N-Channel Mosfet is ideal in this instance but it does seem to work well by my ears! thanks to everyone for all your help :)
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on January 25, 2013, 03:32:02 PM
Quote from: tempus on June 21, 2012, 11:39:12 AM
R.G., do you mean that if a MOSFET is connected like this:
(the BS170 shunt at the right) it will distort? I kind of figured that since it was only shunting to ground, it would basically be invisible when off since it's not in the signal path, but would shunt when turned on.

Sorry, I missed this when it was originally posted.

Every MOSFET currently available, including the BS170, has a body diode from the source to the drain. For N-channels, the body diode anode is on the source and the cathode is on the drain. So any circuit that puts more than about 0.4V from source to drain on the source-drain in the reverse direction that it would be for amplifying will forward bias that diode.

There are schemes to cope with this, such as using two MOFETs source-to-source to get the diodes opposing, and then using floating gate drives in opposite directions to make the MOSFETs turn on at the same time, making a low resistance through them, but this gets complicated fast. For the simple case of shunt muting, a JFET is the only easy answer. Reverse-connected bipolars with large capacitors on the collector driven by ... well, that gets complicated too.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: defaced on January 25, 2013, 04:11:32 PM
Thinking out loud here...

If the MOSFET were connected as a follower could you turn it into a mute if you connected it as such:
input signal - coupling cap - MOSFET gate with control voltage imposed on it (two states, one for MOSFET on, one for mute), MOSFET source connected to output jack. 
The obvious problem would be the quality of the control signal because it would be coupled into the audio, but with regard to the body diode, would this function as expected? 
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on January 25, 2013, 05:28:44 PM
Quote from: defaced on January 25, 2013, 04:11:32 PM
Thinking out loud here...

If the MOSFET were connected as a follower could you turn it into a mute if you connected it as such:
input signal - coupling cap - MOSFET gate with control voltage imposed on it (two states, one for MOSFET on, one for mute), MOSFET source connected to output jack. 
The obvious problem would be the quality of the control signal because it would be coupled into the audio, but with regard to the body diode, would this function as expected? 
It would serve as a mute, but it brings along the same thing that plagues mute circuits of all kinds - control signal feedthrough. The control signal has to be a few volts to turn a MOSFET on and off, and the source follows the control signal, so the control signal comes through to the source almost 100%. Big pops and clicks.

Title: Re: uC Latching Relay True Bypass - nearly!
Post by: tempus on January 25, 2013, 08:48:26 PM
Thanks for your reply on this RG.

QuoteEvery MOSFET currently available, including the BS170, has a body diode from the source to the drain. For N-channels, the body diode anode is on the source and the cathode is on the drain. So any circuit that puts more than about 0.4V from source to drain on the source-drain in the reverse direction that it would be for amplifying will forward bias that diode.

OK that makes sense, but would this affect the signal? I'm kind of picturing the guitar signal, if it surpasses 400mV, forward biasing the drain-source junction which would cause the signal going to ground to be distorted. Is this accurate? Would there be any distorting of the signal on its way out to the amp (gtr out) as a result of this? Or would the mute circuit actually cause more popping rather than less?

Thanks again
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on January 25, 2013, 09:20:43 PM
Quote from: tempus on January 25, 2013, 08:48:26 PM
OK that makes sense, but would this affect the signal? I'm kind of picturing the guitar signal, if it surpasses 400mV, forward biasing the drain-source junction which would cause the signal going to ground to be distorted. Is this accurate? Would there be any distorting of the signal on its way out to the amp (gtr out) as a result of this? Or would the mute circuit actually cause more popping rather than less?
The signal being muted needs to be DC-free. If the signal has an overall DC level, then even a perfect muting circuit (if one of those existed) would still cause a pop by "muting" the DC level. So we'll presume that any DC has been removed by either careful amplification or DC blocking with a capacitor.

Given that, the signal sees the MOSFET as either a low resistance to ground in both positive and negative directions during muting, or a diode from ground when not muted. The polarity of the signal that reverse bias the diode have no issues. But the opposite polarity that tend to turn the diode on start being clipped when the signal peaks get large enough to start the diode conducting. For silicon, this is something like 0.4V at the first hints of conduction. Beyond that, the signal gets ever more clipped in one direction only.

As a result, a single MOSFET used to shunt-mute signals is limited to signals smaller than a couple of hundred millivolts peak when not muting before distortion becomes objectionable.

This behavior makes single MOSFET series or shunt muting not very practical.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: tempus on January 26, 2013, 01:42:19 PM
Thanks again for your reply RG.

I think I understand what you're saying, but I'm not sure how the signal gets clipped. Following the electrons, I'm seeing them going straight through unimpeded for signals below, say, 200mV. Beyond that, some of them are going to start to get diverted by the now forward biased MOSFET, which would reduce the output, but aren't they only being clipped as they are being diverted to ground anyway? In my design (above) the MOSFET is shunting the signal to ground, so the protection diode isn't actually in the signal path (or is it?). Would this actually affect the sound? I'm curious because I've been using this design for a couple years now and never really noticed any change in my sound (although I haven't been looking too close either).

Also, slightly off topic, would the 2007 suffer from the same problem? Fairchild calls it an N-Channel Enhancement Mode Field Effect Transistor, not a MOSFET, but it appears to have the same protection diode as a MOSFET on a JFET symbol.

Thanks
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on January 26, 2013, 04:41:58 PM
Quote from: tempus on January 26, 2013, 01:42:19 PM
I think I understand what you're saying, but I'm not sure how the signal gets clipped. Following the electrons, I'm seeing them going straight through unimpeded for signals below, say, 200mV. Beyond that, some of them are going to start to get diverted by the now forward biased MOSFET, which would reduce the output, but aren't they only being clipped as they are being diverted to ground anyway? In my design (above) the MOSFET is shunting the signal to ground, so the protection diode isn't actually in the signal path (or is it?). Would this actually affect the sound? I'm curious because I've been using this design for a couple years now and never really noticed any change in my sound (although I haven't been looking too close either).
Let's approach this another way. Imagine that the MOSFET is a perfect shunt-muting switch; that is, with 0V on the gate, it is an open circuit, and with several volts on the gate, it is a perfect short circuit. So far so good. Now put in an ordinary diode with its anode to ground and its cathode to the drain of the MOSFET.
And now, imagine that you have the MOSFET set to "don't mute", which means it's an open circuit, and can simply be removed from the schematic.

Now all you have is the diode, anode to ground and cathode to signal. Any signals more than minus 200-400mV will turn on the diode and be clipped by it. The positive-going excursions of the signal turn the diode more off, and are not affected.

This imaginary diode is always there in every MOSFET. It's an inherent part of the silicon process that makes MOSFETs as we know them today.

If you have used it and have not notices it in the sound, either you've been feeding it signals less than the size that starts to make the diode conduct, or you ear may like the slight single-sided distortion on peaks. That's possible.

QuoteAlso, slightly off topic, would the 2007 suffer from the same problem? Fairchild calls it an N-Channel Enhancement Mode Field Effect Transistor, not a MOSFET, but it appears to have the same protection diode as a MOSFET on a JFET symbol.
Got a link? A quick look at the Fairchild site didn't turn it up. I probably looked in the wrong places.

>> Did you mean 7002? If so, that's a MOSFET in the same line as I was discussing.

>> A better way to do this is to use a P-channel JFET like a J175. The control sense is reversed, as a high signal turns the JFET off and lets signal through, while a low control signal turns the JFET on and shunts signal to ground. It suffers from some issues, but has no parasitic reverse diode to muck things up. The control signal can be thought of as a "let my signal through" enabling signal.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: stirfoo on March 09, 2013, 04:46:41 AM
Could a photoresistor be used to mute? Attach to tip and sleeve then couple to an LED. Lower resistance = lower volume. Kind of like the tremolo circuit in the Radio Shack DIY thread.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on March 09, 2013, 09:46:42 AM
Yes, it can. This is subject to the limitations of the photoresistor, which has limited off-ness and also limited on-ness.

Most photo resistors can get to several megohms of dark resistance and between several hundred and a few thousand ohms of on-resistance. How well this works as a mute depends on the source impedance of the signal.

There was a guitar plug with an internal photoresistor set up to let you swell your guitar signal by covering or uncovering the opening that let in light. I believe it was set up in series, where covering the opening faded the signal out. That was patented, oddly enough. I can't think it would work all that well on stage, where the lighting is variable, and changes as you move around. But, hey, for some things might be OK.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: remmy on April 30, 2013, 05:04:19 PM
I have been giving this a go over the last couple of days using an Arduino to program an attiny85 and have it work with a optical MOSFET SSR for the muting, I have been using Mrki's comments on the Stompville site as a starting point http://stompville.co.uk/?p=260 (http://stompville.co.uk/?p=260)

QuoteThis 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

I'm happy enough with the code I have come up with though I will tinker with it more tomorrow I imagine after I have taken the circuit from my breadboard into a pedal.  One issue I have that has got me stomped is that I am getting pops with the circuit which is not down to the relay as they are there when I remove the relay.  They are also coming through the amp when I leave the mute active.  ???

I am hoping that getting the circuit off of the breadboard and into an enclosure will help.  The signal ground is isolated from the power ground, though I have noticed no difference when they are not isolated from each other.  I will post an update tomorrow once I have it boxed up.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: caldersm on May 22, 2013, 08:53:48 AM
Remmy,

Did you get his working with the optical mosfet...?  Did you figure out how to eliminate the popping...?

I have run into this same situation.....can you share your success or failure...?  Can you post the code you came up with...?

Thanks so much....looking forward to your reply.

Regards,
Steve
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: caldersm on May 22, 2013, 02:33:06 PM
R.G.

Could you use a TLP222A Optical MOSFET...?  It contains back to back diodes, so the issue with it conducting is gone....I believe.  It also has an ON resistance of only 2 ohms.  I believe you could use that one to go to ground to mute the signal, but do you think it would work to bypass the relay in parallel..?

Also....do you separate the audio common from the attiny common...?  If you separate them in say a Looper enclosure....would you use isolated jacks or use the enclosure as a common...?  Just some questions I am pondering as I try to improve my 4 channel programmable looper.

And thanks for all your insight....you appear to be extremely competent in this subject area.

Steve

(http://file1.dzsc.com/file/shop/168/330/000/0652019843s.jpg)
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: tempus on May 22, 2013, 05:41:01 PM
I would think that you could use the TLP222A, because although it contains the diodes, the only time the signal would ever see them is when the mute is on, when it wouldn't matter. I used a BS170 for a while, but realized that it was distorting the signal (after RG pointed it out) even when not in being used, because the signal was always presented to that diode. With the optical relay, you have the benefit of isolation, i.e., the signal is completely isolated from the relay when the relay is off.

As far as eliminating the popping, I'd like to point out that my BS170 mute didn't really improve my popping problems anyway. You can see in a previous post in this thread that I have a mute circuit similar to yours set up. It muted just fine, but for some reason didn't catch the pops. You may have to experiment with longer mute times to get rid of the pops altogether, which may interfere with the seamlessness of your patch changes.

Keep us posted; I'd love to hear if this works as a solution. I've been thinking about trying one of these SSRs myself.

Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on May 22, 2013, 08:07:08 PM
Quote from: caldersm on May 22, 2013, 02:33:06 PM
Could you use a TLP222A Optical MOSFET...?  It contains back to back diodes, so the issue with it conducting is gone....I believe.  It also has an ON resistance of only 2 ohms.  I believe you could use that one to go to ground to mute the signal, but do you think it would work to bypass the relay in parallel..?
If that's how the TLP222A is wired inside, I'd sure give it a try. That connection is how the body diode problem is solved in some MOSFET solid state relays. I'd sure like to see how this device works.
Quote
Also....do you separate the audio common from the attiny common...? 
Ideally, they'd be connected at one and only one point, perhaps even through a resistor. They need not to be completely floating, but not to have circulating currents from more than one connection.

QuoteIf you separate them in say a Looper enclosure....would you use isolated jacks or use the enclosure as a common...? 
The enclosure ought to be a **shield**, not a common. I would isolate the jacks, then take one and only one wire to the enclosure from audio ground for lowest noise. You might get lucky with non-isolated jacks, or you might not.
Quote
And thanks for all your insight....you appear to be extremely competent in this subject area.
You're welcome to any help I can provide. I've fought grounding and noise for a long time.   :icon_biggrin:
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: tempus on June 09, 2013, 09:27:11 PM
I've been thinking about ordering some of the TLP222A's the next time I place an order. There is one caveat to these - the turn on time is .8ms at an If of 5ma, moving up to about 70us at around 50 ma. I don't know how long a switch pop is or how long it takes to start after the switching action, but that seems a bit long to me. The switch pop may have come and gone before this thing even starts to turn on. I suppose that brings up another question - should you try to ramp up the voltage on a MOSFET like you would on a JFET? My understanding is that a MOSFET has more of a switching threshold than a JFET and doesn't really act like a variable resistor in the same way. As always, correct me if I'm wrong on that. Would you even have time to ramp up the voltage before the transient was over? These should work nicely for channel switching though.

Compare that spec to a H11F2M, which is 45us at 16ma.

Something else to think about...
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: gritz on June 10, 2013, 03:29:52 AM
Quote from: tempus on June 09, 2013, 09:27:11 PM
I've been thinking about ordering some of the TLP222A's the next time I place an order. There is one caveat to these - the turn on time is .8ms at an If of 5ma, moving up to about 70us at around 50 ma. I don't know how long a switch pop is or how long it takes to start after the switching action, but that seems a bit long to me. The switch pop may have come and gone before this thing even starts to turn on. I suppose that brings up another question - should you try to ramp up the voltage on a MOSFET like you would on a JFET? My understanding is that a MOSFET has more of a switching threshold than a JFET and doesn't really act like a variable resistor in the same way. As always, correct me if I'm wrong on that. Would you even have time to ramp up the voltage before the transient was over? These should work nicely for channel switching though.

Compare that spec to a H11F2M, which is 45us at 16ma.

Something else to think about...


JFET switching (as seen in pedals) can more accurately be thought of as crossfading between the effected and dry signals, because the fets themselves are not simple on / off switches, but operate as (crude) variable resistors over a limited gate / body voltage. The switch driving circuitry might have a time constant (a slope) in the order of 10 - 50 milliseconds (although the actual fade time will depend on the Vgs(gutoff) of the fets themselves. In digital audio we also use crossfading to switch between signals to prevent pops and clicks. The reason for the click is the same for software as hardware - switching instantly between two different signals can cause a sudden step in the output, because it's likely that the two signals will be at very different levels at any time. The faster the "switch", the greater the high frequency content of the "step", so it's a real problem in software and we use crossfades of around 5 - 20 milliseconds (or a bit more if there's a lot of low frequency content). With mechanical switches (including relays) it's not quite so disastrous, possibly because mechanical switches tend to "bounce" for a millisecond or five (very roughly!) before reliably making contact.

With solid state (electronic) switching, a few milliseconds of fade twixt one and the other is a good thing imo.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: caldersm on June 10, 2013, 11:19:26 AM
Ok....I got it working...!!  I have eliminated most all of the perceivable popping noises, when switching between effects.(Granted I only have two foot pedal effect, as I am not a music guy....just a hacked up EE type guy)  Also, I eliminated the noises when the LED's turned ON and OFF by having the Audio on a separate common, and by adding a 10uf Cap to the Load side of the +5V regulator.  Granted, I am not an Audiophile.....but I can't hear any tone difference with the TLP222A connected, but not turned on.

I went from my Attiny Output pin to a 100uf to ground with a series resistor to pin 1 of the TLP222A with pin 2 going to the power supply ground.  I then connected my output jack signal to pin 4, and the audio ground to pin 3.  Whenever I switch the relays, I run the MUTE code....Turning it ON then the Turning it OFF.  I found that a 5ms delay for ON and a 10ms delay for OFF is working great.

Snapshot of that part of the circuit from my 4 channel programmable looper.
http://imgur.com/eLQqwLz (http://imgur.com/eLQqwLz)

Snapshot of the PCB board.
http://imgur.com/ef5aVZF (http://imgur.com/ef5aVZF)

The code is pretty simple....turn it on before you doing anything....ie....turning on LED's or Relays.

if(time_delay >= 3 && time_delay <= 5 && Prg == 0) { //If switch is held >= 3secs and <= 5secs Then
     Prg = 1;  //Set Program Mode Bit to execute Program Mode Code when Switch is Released.
 Mute_ON(); //<<-------------MUTE
 PORTB &= 0b00001111; //Turn off
 Mute_OFF();  //<<-------------UNMUTE
   }


void Mute_ON() {
 bitSet(PORTA,1);
 delay(5);
}

void Mute_OFF() {
 delay(10);
 bitClear(PORTA,1);
}


Title: Re: uC Latching Relay True Bypass - nearly!
Post by: SmudgerD on June 13, 2013, 04:31:42 PM
I blogged about this issue and posted a schematic and code for ATtiny13A and TLP222G.

http://stompville.co.uk/?p=423

Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on June 13, 2013, 04:46:44 PM
It's worth noting that the problems with capacitively-induced clicks are largely a result of the high impedance of the signal line.

You don't have to mute the signal line - just making it low impedance for a few milliseconds to eat the transient will also make it clickless and won't subject the audio to such rough treatment. The treble fades out for an undetectible fraction of a second.

Ideally...  :)
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: caldersm on June 13, 2013, 04:51:54 PM
Great write up Smudger...!!  I actually saw the opto on Pedalsync's Relay Bypass circuit, but your blog has much more meaningful information.

I didn't even think about the Coff when I bought the A version.....I was just looking at the On State resistance.

I was considering using using the analog PWM on the pin, instead of the cap, but the cap seems to work really well, so I didnt pursue it.  Did you actually try doing an Analogwrite out of the pin...?  If so, could you hear the PWM signal...?

R.G.....so you are saying that adding series resistance between the audio common and the output through the switch would work as well.....or is the 2 ohm On state resistance the same thing...?

Again...thanks for the info....and the write up.




Steve
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on June 13, 2013, 06:42:51 PM
Quote from: caldersm on June 13, 2013, 04:51:54 PM
R.G.....so you are saying that adding series resistance between the audio common and the output through the switch would work as well.....or is the 2 ohm On state resistance the same thing...?
There is a fixed amount of energy to be transferred from the relay coil contacts through the leakage capacitors to the signal path. The leakage capacitors are in the few-pF range. We want that to transfer inefficiently to the signal path. The signal path is often held at 1M ohm or about, so the 5pf (just guessing) and 1M lowpass is 32 kHz. If we lower the impedance to 10K, the crossover point is 3.2MHz, so the energy is vastly attenuated in the audio range - the click signal does not couple well.

Two ohms might be better, but 10K may be enough.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: SmudgerD on June 14, 2013, 04:34:46 PM
Quote from: caldersm on June 13, 2013, 04:51:54 PM
Great write up Smudger...!!  I actually saw the opto on Pedalsync's Relay Bypass circuit, but your blog has much more meaningful information.

I didn't even think about the Coff when I bought the A version.....I was just looking at the On State resistance.

I was considering using using the analog PWM on the pin, instead of the cap, but the cap seems to work really well, so I didnt pursue it.  Did you actually try doing an Analogwrite out of the pin...?  If so, could you hear the PWM signal...?

R.G.....so you are saying that adding series resistance between the audio common and the output through the switch would work as well.....or is the 2 ohm On state resistance the same thing...?

Again...thanks for the info....and the write up.




Steve

Hey Steve, thanks for the kind words. Regarding PWM control of the LED current, the datasheet for the TLP222G allows for 300us turn-on time and 100us turn-off time, giving a theoretical minimum pulse width of 400us and therefore a maximum switching frequency of 2.5kHz. I did try it and the sample I was experimenting with was faster than the datasheet. I managed to get about 4.5kHz switching frequency.

To be honest, I didn't do any experimenting with audio at all. Personally, I don't have a problem with clicks on any of my pedal designs and I only investigated the optofet mute option out of interest. I'm sure that a 5kHz tone would be audible, since it couples directly to the audio. However, it would only be two bursts of 20ms or so.

Also, I don't think it is particularly desirable to have soft mute - after all, the relay itself (or stomp switch if you're doing it the old-fashioned way) doesn't have soft mute.

SmudgerD
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on June 14, 2013, 05:10:59 PM
Quote from: SmudgerD on June 14, 2013, 04:34:46 PM
To be honest, I didn't do any experimenting with audio at all.
That would be an important test to try.

QuoteAlso, I don't think it is particularly desirable to have soft mute - after all, the relay itself (or stomp switch if you're doing it the old-fashioned way) doesn't have soft mute.
A lot depends on the specifics of the relay or stomp switch. Stop switches are sometimes audible. Relays have an additional problem in that there is a 5V to 9V fast waveform running the coil only a few mm or less away from the signal-carrying contacts. Whether this is coupled over or not depends on the relay's construction and the circuit layout.

It is only particularly desirable to have soft mute if your relay or layout give you clicks. And then it becomes more desirable.

I've never had a house fire, but I do have both fire insurance and fire extinguishers. Probably just wasted money, since my house has never had a problem.

Title: Re: uC Latching Relay True Bypass - nearly!
Post by: SmudgerD on June 15, 2013, 06:40:26 AM
Quote from: R.G. on June 14, 2013, 05:10:59 PM
Quote from: SmudgerD on June 14, 2013, 04:34:46 PM
To be honest, I didn't do any experimenting with audio at all.
That would be an important test to try.

QuoteAlso, I don't think it is particularly desirable to have soft mute - after all, the relay itself (or stomp switch if you're doing it the old-fashioned way) doesn't have soft mute.
A lot depends on the specifics of the relay or stomp switch. Stop switches are sometimes audible. Relays have an additional problem in that there is a 5V to 9V fast waveform running the coil only a few mm or less away from the signal-carrying contacts. Whether this is coupled over or not depends on the relay's construction and the circuit layout.

It is only particularly desirable to have soft mute if your relay or layout give you clicks. And then it becomes more desirable.

I've never had a house fire, but I do have both fire insurance and fire extinguishers. Probably just wasted money, since my house has never had a problem.



LOL. OK, I'm not sure if you're pulling my chain a little. As I said, I don't have a problem with audible clicks because I design those problems out. It seems that some people do have a problem with clicks because their effects designs have high impedance signal paths and/or no discharge resistors - or they really want to keep authentic designs from way back when. I decided I wasn't going to create a 'bad' design just to prove I can cure it using a mute function - which is why I didn't test with audio.

I published my findings (including schematic and object code for an ATTiny13A) so people who have been pestering me to do so can build the design and let us know if it works. As I said in my blog, I left a 20ms delay between calling for mute and switching the relay so people can experiment with the soft-mute function if they want to.

SmudgerD
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Beo on June 15, 2013, 12:18:01 PM
Quote from: SmudgerD on June 15, 2013, 06:40:26 AM
I decided I wasn't going to create a 'bad' design just to prove I can cure it using a mute function - which is why I didn't test with audio.

Seems to me that most people will read your article with an interest towards applying it to audio. It wasn't clear to me in reading your article that you hadn't tested a switching audio signal. Probably my own presumption, since it was linked from a stompbox forum.

One thing I find curious is that most uC relay solutions I've seen out there do not have DC blocking/biasing on the relay channels. It's definitely quite a few more components to add. From my own recent testing of a uC relay solution (using H11F1 for mute), I'm getting very quite switching without adding DC blocking/biasing.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: SmudgerD on June 15, 2013, 03:45:13 PM
Quote from: Beo on June 15, 2013, 12:18:01 PM

Seems to me that most people will read your article with an interest towards applying it to audio. It wasn't clear to me in reading your article that you hadn't tested a switching audio signal. Probably my own presumption, since it was linked from a stompbox forum.


Others assert that optofets will effectively mute the signal (or get rid of the clicks, anyhow). For my part (as I have said) I have no need to test with audio because I don't have a problem with clicks and I can see from the test circuit whether or not (and when and how) the optofet is switching on and off.

The point of the exercise was to publish revised firmware for my true bypass relay circuit as requested of me by a number of people who want to experiment for themselves but are not in a position to write the code. I could have just added a mute signal with 20ms delay before switching the relay and not bothered to investigate at all, but I decided the pursuit of soft muting was worth a couple of hours tinkering.

If I had offered a PCB design, I would absolutely have tested it with audio before offering it to the world.

HTH
SmudgerD
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: remmy on September 18, 2014, 02:07:45 PM
I have come back to this after initially not having much luck getting no pop and there is still a pop, but I have narrowed it down.

I am using the below schematic and I have worked out that the pop is coming from when the mute is disabled after being active to mute any pops from the relay, I changed the C6 gradually up to a 220uF and the click slowly turned into thuds which are still noticeable.  Ideally I want to get that sorted and then get the mute down to as short as possible with the code.

I have a couple of questions, firstly why is there a pop when the mute disables and secondly is there a way to sort it?

(http://i61.tinypic.com/2lm8exk.jpg)
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: R.G. on September 18, 2014, 05:30:01 PM
Quote from: remmy on September 18, 2014, 02:07:45 PM
I have a couple of questions, firstly why is there a pop when the mute disables
Good question. Is the pop worse with or without the mute?

Clearly there is some path for the control signal to get into the audio path. One of those is through the MOSFET itself. I would first simply open the line from the controller and see if the pop is still there, or different.

Quoteand secondly is there a way to sort it?
Maybe. I would attack the edge rate on the control signal. With no resistance between the logic signal and C6, you're asking the controller output pin to go into current limiting while it tries to force the voltage on C6 to change instantly. I would either delete R4 or change it to maybe 1M or more, and then stick a 10K?47K?100K? in series from pin 3 to C6 and see what happens then.

Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Transmogrifox on September 18, 2014, 09:29:36 PM
Funny to see this post since I have just recently started thinking about this again.  I think it was somewhere in ... 2006 ... with a PIC12F683...where I last left off
http://www.diystompboxes.com/smfforum/index.php?topic=43400.0
Unfortunately my Geocities page died a long time ago, so the schematic is gone.  The computer with that schematic died so I still have to copy the page backup from the hard drive.  I never posted the assembly code that I developed from that original project, and have long lost it in the shuffle of deleting Windows forever.

I agree that the mute function should not be necessary.  If a plain DPDT mechanical switch works, then a latching relay should be the same if transient currents are properly handled and designed to stay out of the main audio circuitry.  As an aside, I wonder if the uC output pin could be used successfully for the mute function -- tri-state high-z mode for through-signal, logic-0 to mute, and AC coupled to the signal path.  Probably all depends if port protection diodes get driven too far...

Recently I wrote some code and tested it on a TI MSP430 (MSP430F2013, specifically).  The current design drives a resistor with the worst-case for the NEC 3.3V single coil latching relay.
The MSP430F2013 can supply the current needed to switch the relay as a package, but not for a single set of pins.  This design connects pins in parallel to get the current drive needed.
The main selling point is the switch debouncing and deglitching algorithm here.  It functions as a linear integrator for edge detection, then applies a timeout after a confident "on" state detection so that the caffeine-induced double-tap doesn't fool it.  It's still short enough that you can tap on/off pretty fast /on purpose/...it just aims to be immune to accidental double-taps or really bad or dirty momentary switches.

Here is yet-another-way-to-do-this.  In code below,
LATCH_DELAY
Is the only constant one may want to play with since this relates to how much time is actually needed to latch the relay.  It is more healthy than it needs to be in the current code, so chance of pops is greater.
//
//  Switch Debouncing and toggle latching relay state with LED indication
//

//
// Schematic
//                      MSP430F2013           N/C MOMENTARY
//                    -------------           SWITCH
//         <+3.6V>-++| 1         8 |++-<GND>---\___\-----<SW>
//      -----------++| 2         9 |++                 |
//      |  <RL_N>--++| 3        10 |++                 ----/\/\/\---<+3.6V>
//      |    <SW>--++| 4        11 |++                       10k   |
// R  C |----------++| 5        12 |++                             |
// E  O =  <RL_N>--++| 6        13 |++     <RL_N>----/\/\/\---|<;---
// L  I =          ++| 7        14 |++                470     LED
// A  L =             -------------
// Y    =
//      |
//      ---<RL_N>
//
//  Relay contacts not shown.  Nominal is a DPDT relay and true bypass switching
//  circuit without LED indicator since this is powered by the MSP430
//

#include <msp430x20x3.h>

//Port Output Register 'P1OUT, P2OUT':
#define P1OUT_INIT      0                       // Init Output data of port1
#define P2OUT_INIT      0                       // Init Output data of port2

//Port Direction Register 'P1DIR, P2DIR':
#define P1DIR_INIT      0xfb                    // Init of Port1 Data-Direction Reg (Out=1 / Inp=0)
#define P2DIR_INIT      0xff                    // Init of Port2 Data-Direction Reg (Out=1 / Inp=0)

//Selection of Port or Module -Function on the Pins 'P1SEL, P2SEL'
#define P1SEL_INIT      0                       // P1-Modules:
#define P2SEL_INIT      0                       // P2-Modules:

//Interrupt capabilities of P1 and P2
#define P1IE_INIT       0                       // Interrupt Enable (0=dis 1=enabled)
#define P2IE_INIT       0                       // Interrupt Enable (0=dis 1=enabled)
#define P1IES_INIT      0                       // Interrupt Edge Select (0=pos 1=neg)
#define P2IES_INIT      0                       // Interrupt Edge Select (0=pos 1=neg)

#define WDTCTL_INIT     WDTPW|WDTHOLD

//  
//  Timing Constants
//      These constants were experimentally tuned using an oscilloscope to watch
//      delay from input edge to state change.  This comes to something
//      between 10 ms to 15 ms, also depending on amount of switch bounce
//

#define POLL_RATE   0x002F
#define THRS        0x001F
#define HOLD_OFF    0x4FC2
#define LATCH_DELAY 0x0400

// OUTPUT pin states
#define LATCH_OFF   0x0009
#define OFF_STATE   0x0000
#define LATCH_ON    0x0012
#define ON_STATE    0x001B

// INPUT Pin
#define INPUT_MASK  0x0004

//
//  Delay function.
//  Sets crude basis for system tick and input polling
//

void delay(unsigned int d) {
   int i;
   for (i = 0; i<d; i++) {
       nop();
       nop();
       nop();
       nop();
   }
}

//
//  Toggle output states
//
//  Timing sequence to turn off:
//  P1OUT xxx11x11    <-Initial state when enters toggle function
//  P1OUT xxx01x01
//  delay
//  P1OUT xxx00x00
//  
//  Timing to turn on:
//  P1OUT xxx00x00    <-Initial state when enters toggle function
//  P1OUT xxx10x10
//  delay
//  P1OUT xxx11x11
//
unsigned int toggle(unsigned int on)
{
   if(on != 0)
   {
       P1OUT = LATCH_OFF;
       delay(LATCH_DELAY);
       P1OUT = OFF_STATE;
       return 0;
   } else {
       P1OUT = LATCH_ON;
       delay(LATCH_DELAY);
       P1OUT = ON_STATE;
       return 1;
   }
}

unsigned int run_poll_sequence()
{

   static volatile unsigned int onstate = 0;
   static volatile unsigned int edge = 1;
   static volatile unsigned int trgcnt = 1;
   static volatile unsigned int in_state = 0;
   
   //Start polling
   in_state = P1IN;    //copy it over where it can be
   in_state &= INPUT_MASK;   //manipulated without touching P1IN
                   
   // Switch bounce filtering
   // Ramp up or down.  Response time will be
   // determined by POLL_RATE and THRS
   if(in_state != 0) {
       trgcnt += 1;
   }
   else {
       trgcnt --;
   }
   
   //  This is the edge detection
   //  When trgcnt ramps up above 1, edge will be set to 1
   //  When trgcnt exceeds THRS, switch state will toggle
   //  then edge is reset so it doesn't toggle the switch
   //  for every cycle the input is high.  When input returns
   //  low and ramps to <1, then edge is reset
   if(trgcnt < 1) {
       trgcnt = 1;
       edge = 1;
   }
   else if (trgcnt > THRS) {
       if(edge == 1)
           onstate = toggle(onstate);
       edge = 0;
       trgcnt = THRS;
       delay(HOLD_OFF);  //don't do anything for a good bit
                       //so the jiggly foot doesn't retrigger
                       //immediately after positive state change
   }

   return 1;
}

//
//  System Initialization
//

void bootup_init()
{
   //Watchdog
   WDTCTL = WDTCTL_INIT;               //Init watchdog timer
   
   //Set up clock
DCOCTL = 0;
BCSCTL1 = CALBC1_1MHZ;
BCSCTL2 = 0x01;
DCOCTL  = CALDCO_1MHZ;

   //Initialize I/O
   P1OUT  = P1OUT_INIT;                //Init dataput data of port1
   P2OUT  = P2OUT_INIT;                //Init dataput data of port2

   P1SEL  = P1SEL_INIT;                //Select port function on port1
   P2SEL  = P2SEL_INIT;                //Select port function on port2

   P1DIR  = P1DIR_INIT;                //Init port direction register of port1
   P2DIR  = P2DIR_INIT;                //Init port direction register of port2

   //Interrupts
   P1IES  = P1IES_INIT;                //init port interrupts
   P2IES  = P2IES_INIT;
   P1IE   = P1IE_INIT;
   P2IE   = P2IE_INIT;

   //Initialize relay to known state
   P1OUT = 0x001B;
   toggle(1);
}

//
//  Main polling function
//

int main(void) {
   bootup_init();
   while(run_poll_sequence()) { //always returns 1, so this is forever loop
       // Crude loop timing
       delay(POLL_RATE);
   }
   
   //just to keep gcc happy
   return 0;
}



The ASCII schematic shows nothing about the 3.6V power supply other than it is there.  I suggest a tightly located 0.1uF cap for decoupling high frequency noise on the uC itself, then a good several 220uF bulk caps to supply relay switching current.  All of this can be fed by a 5.6V zener divided down to 3.6V since the MSP430 takes microamps current for normal operation, so the LED is the main power hog for the system.  Probably something clever could be done the power supply when the LED is turned on.  The output state generally follows this pattern:
<____> OFF
[Depress Switch]
<__--> LATCH ON
<----> ON
[Depress Switch]
<--__> LATCH OFF
<____> OFF  //LED on, so wire polarity on Relay so bypass state is consistent with relay.

The key elements to reducing pop are pretty well covered in this post.  I thought I'd just use the occasion to share the code in case anybody decides to try this with an MSP430.  

Other than specific initialization and device-specific references (like P1OUT) this would work on pretty much any uC.  I figure for those who want to figure it out for themselves, they will do it anyway, so I may as well share the code for somebody who wants to just copy/paste and do it.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: remmy on September 19, 2014, 03:00:43 PM
Thank you for the reply RG, any help on this is much appreciated.

Quote from: R.G. on September 18, 2014, 05:30:01 PM
I would first simply open the line from the controller and see if the pop is still there, or different.

The pop in this situation appears to be the same, it is high in frequency and quite abrupt when I raise the gain up.

I changed the R4 for 1M and it didn't seem to make a difference, I then added an inline resistor as suggested and the pop changed in the same way as when I upped C6 before, in that the higher the resistor the pop became more of a kick drum compared to the original snare, that's the best analogy I can think of  ;D

I have taken delivery of a oscilloscope today (about time I learnt how to use one) so once I have worked out how to measure the mute pop I will see if the findings help in trying to resolve the issue.  I will post what I find.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: remmy on September 19, 2014, 03:05:17 PM
Quote from: Transmogrifox on September 18, 2014, 09:29:36 PMI suggest a tightly located 0.1uF cap for decoupling high frequency noise on the uC itself, then a good several 220uF bulk caps to supply relay switching current.

Thank you for all the info, really helpful.

How are you connecting the 220uF caps?  Is it one on each of the two relay connections?
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: Transmogrifox on September 19, 2014, 06:17:07 PM
Quote from: remmy on September 19, 2014, 03:05:17 PM
Quote from: Transmogrifox on September 18, 2014, 09:29:36 PMI suggest a tightly located 0.1uF cap for decoupling high frequency noise on the uC itself, then a good several 220uF bulk caps to supply relay switching current.


How are you connecting the 220uF caps?  Is it one on each of the two relay connections?

The big caps go across the power supply to which you connect the relays.  In the context of the original post, if you are driving the relays with transistors, then you should have the power supply decoupled right at the places where the transistors connect to ground.  The idea is to reduce sudden switching currents from making waves further up the power supply system.  You supply charge locally to make most of the transient switching current come out of the caps and not drive current through your whole grounding system and/or bounce your 9V rail that supplies the audio circuits.  You may even want to put a resistor in series with your relay switching circuit that is as big as you can make it and still power the LED and uC.  Then a sudden change on the bulk capacitor discharging into the relay won't result in a very high magnitude surge current up the power supply.  It will only dip locally then trickle-charge for the next switching cycle.

This is only one of the ways a pop can get into the audio path.  Other things as mentioned by RG is transfer of charge from one part of the circuit to the other when switched in.  There as mentioned before you have to be careful all contact points are discharged to 0V so nothing jumps when you switch over.

Also the mute circuit adds another piece of complexity since the logic switching the muting element can couple through to the audio path and defeat the purpose of muting.

I hope that makes sense without a schematic.
Title: Re: uC Latching Relay True Bypass - nearly!
Post by: MetalGuy on September 27, 2014, 09:43:20 AM
Just to let you know that I tried the VO1400 (from Vishay, Ron 2.5Ohm) which is similar to TLP222 (but SMD) in another setup and it works fine. I tested it with 33V RMS sine wave and it showed no signs of clipping. My DMM couldn't measure the capacitance which means it's lower than 10pf.