uC Latching Relay True Bypass - nearly!

Started by bobindah, March 20, 2012, 06:35:53 PM

Previous topic - Next topic

bobindah

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.


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
perfing with the alien

R.G.

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.
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.

Gurner

+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

bobindah

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
perfing with the alien

MetalGuy

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.

bobindah

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 :-)
perfing with the alien

Beo

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?

R.G.

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.

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.

bobindah

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 :-)
perfing with the alien

Gurner

#9
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?!

Perrow

You can usually find one or more of them (opto coupler) in PC power supplies, should you have any dead ones around.
My stompbox wiki -> http://rumbust.net

Keep this site live and ad free, donate a dollar or twenty (and add this link to your sig)

R.G.

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.
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.

Perrow

My stompbox wiki -> http://rumbust.net

Keep this site live and ad free, donate a dollar or twenty (and add this link to your sig)

bobindah

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.
perfing with the alien

gritz

@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

Hope this helps.

bobindah

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  :)
perfing with the alien

Hoffmann

I came across this project, maybe it'll be of an interest:
http://stompville.co.uk/?p=260

asatbluesboy

Reading it all and thinking I'm still a long way... Can't understand anything being said here.  ???

You guys are awesome.
...collectors together and emitter to base? You're such a darling...

ton.

amptramp

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.)

tempus

#19
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). 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