Optimising shift registers / transistors / relays choice for current draw

Hi, this is my first foray into the world of Arduino and electronics bar basic soldering / desoldering skills and swapping out capacitors in a guitar effects pedal, so I'm trying to get my head around which components to buy for the project I'm working on. I'll start with a broad sketch of what the project is trying to achieve to provide some context for the circuit design, then I'll ask my questions, which all relate to what I put as the topic. I apologise in advance if I'm misusing terms, please do correct me.

So the project is a programmable guitar effects switching system. It will have two main sections: the control module to choose which effects get turned on by which foot switches (and the foot switches themselves- a bit like this); and the switching modules consisting of relays set up to do true bypass (here is an explanation of true bypass if you're not a guitar gear nerd). I want as many of these true bypass switches as I can because I have a stupid amount of effects. I want to make it myself rather than buying the G2 primarily because it sounds fun to me, and also because I have no intention of gigging so can't justify spending over $1000 on something that robust.

First I want to work out the switching module, as for me the electronics seem the hardest part. On a breadboard I have built this relay driving circuit (third graphic down) - note the extra capacitors to slow the transistor switching down as I'll come back to it. I've successfully got my Arduino Mega to switch it by setting a digital pin high or low sending to the base of the transistor. So far so good, and if I only wanted a few loops and to use the Mega in the final version this would probably be fine, I would just repeat this circuit. But I want to make this as scalable as possible, and preferably use a Nano or similar in the final version.

It seems using shift registers such as the 74HC595 would be the way to go, but before I get too carried away and buy a whole bunch I thought it wise to stop and really plan this circuit. I've attached a rough schematic of what I have so far (please excuse the erroneous symbols, I drew it with the first schematic tool I could find on SourceForge and only spent fifteen minutes on it using the closest symbols I could find). Currently I'm planning on using the 74HC595 chip for the shift register, and the 2N3904 for the transistor. I'm still deciding on the relay, but candidates from the following telecom/small signal relay series:

From my limited understanding of electronics, it seems like the main limit on the number of relays I can control from an Arduino is the current draw for all the components. Now, I will power the relays and shift registers with a separate power supply from the Arduino so I don't fry that part of the circuit, but most power supplies seem to have about 1A available. Also the pins from the 74HC595 only allow for 6mA, so the transistors need to be able to switch with something less than that.

So, my questions:

  • Other factors aside (such as price and quality), will the best choice of relay be the one with the highest coil resistance to switching voltage ratio, or have I completely misunderstood Ohm's Law?
  • Is the 2N3904 a good choice here, particularly for minimising current draw rather than because I have 100 of the things, or does someone have a better recommendation? I know there are ICs available with internal Darlington arrangements, but would these allow for the slowing down of the switching via capacitors as in my current circuit, or some other arrangement?
  • Is the 74HC595 the best chip here?
  • How many of these shift registers can I sensibly chain together so the operate off the same Arduino pins? Is there a point at which the communication between the Arduino and the shift registers at the end of a long chain slows down?
  • Am I missing some other important factor that might limit how many relays I'm able to control from the one micro controller?

I may not want to have the maximum number of relays in the end, but I'd like to be able to work out what that is before I get to far into planning. If you need clarification or more details for any of this in order to help me, please ask. However I only have an hour or two a day when I will get a chance to reply.

I've attached a rough schematic of what I have so far

Did you perhaps forget something?

Haha, no, I didn't forget, but it had a problem when I clicked post and then wouldn't let me edit the post because I'd used my ten minute posting quota, hopefully it works this time, otherwise i'll post it Tommy tumblr and provide a link...

Grr, stupid iPad, it turns my PNG into a JPEG... and autocorrectS "to my" to "Tommy"... I've tried one last time to attach but also posted it on my Tumblr here just in case (I hope that's allowed): Zatoichi No. 9: The Adventures of Zatoichi — Quick circuit design for Arduino powered effects...

Zatoichi9:
Grr, stupid iPad, it turns my PNG into a JPEG... and autocorrectS "to my" to "Tommy"... I've tried one last time to attach but also posted it on my Tumblr here just in case (I hope that's allowed): Zatoichi No. 9: The Adventures of Zatoichi — Quick circuit design for Arduino powered effects...

What's wrong with *.jpg? It's actually easier to view. A *.png defaults to "Save" when clicked on, rather than "Open".
If I don't remember to manually select "Open", it ends up on the Desktop.

And there's a button in the edit window for attaching inline images that are hosted on another site:-

Edit: Your link was wrong, so I had to track down the correct one. It looks like this:-

Now, why exactly do you want all of that junk attached to the base of the transistor? You said you'd come back to it, then neglected to do so.
If you can really justify the existence of those resistors and caps, you need to show their values, too.
(And by the way, that symbol is for a PNP transistor, not an NPN, which is what you really need.) You would have been better off hand-drawing the schematic and scanning it. They don't have to be software images.
And a 2N3904 is fine, by the way.

I've got nothing against *.jpg, but apparently Apple does as I was posting from my iPad directly from my camera roll and it turned the picture into a *.jpeg file, which apparently the forum software doesn't accept, but rather than let me return to my original post and change it, it just posted it without the attachment and then because I'm new (I assume) it wouldn't let me edit it for ten minutes. In the end I managed to attach the original *.png created by the free software (it only gave the option of png or its own format) via another app. I'll try taking a photo of my hand drawn schematics next time then, provided I can find a way to upload it without the extra "e"… Anyway, got there in the end!

Thanks for letting my know about the transistor symbol, NPN is the type I intended.

OK, yes, you're right I forgot to come back with a full explanation for all the extra bits around the transistor, or indeed the values for the components. That whole part of the circuit is a direct copy of the one I linked to (A Remote Indicating Effects Bypass System - that site is one of the most well-regarded amongst DIY guitar effects enthusiasts which is the route that has brought me to Arduino) minus the LED and LED resistor . The two resistors in series from the IC would be 4K7, the cap to ground is 4.7uF, the cap across the transistor is 0.1uF, both diodes are 1N4148 and the resistor to ground is one my mind seems to have invented for no good reason so can be ignored. Oh, and it looks like I forgot to draw in the connectors to the diode above the first resistor, it should be wired parallel to it. All in all a bit of a fail, sorry about that. I can post a corrected one tonight if it will make things clearer (I'm at work right now).

The reason for it is explained much better on that site, but to summarise the transients caused by the relay switching as fast as it does causes an audible pop in the audio signal chain. This is particularly unpleasant when that signal chain is running into an amp turned up to eleven (as all amps should be). The capacitors slow down the speed that the transistor turns on, which in turn slows the speed that the relay switches, which hopefully reduces or eliminates the pop. I imagine that the values of the resistors can be changed if required to optimise the current, as I understand it from the Geofex site it is the caps which are the important features for the pop reduction.

Zatoichi9:
I've got nothing against *.jpg, but apparently Apple does as I was posting from my iPad directly from my camera roll and it turned the picture into a *.jpeg file,

Right, you did say jpeg, not jpg.
A thought - jpg and jpeg are both effectively JPEG format. Have you ever tried simply renaming a *.jpeg file to *.jpg?
(I just saved a file from 'Ultimate Paint' as *.jpeg, then renamed it *.jpg, and it still opened and viewed correctly in 'Paint'.)

OK, yes, you're right I forgot to come back with a full explanation for all the extra bits around the transistor, or indeed the values for the components. That whole part of the circuit is a direct copy of the one I linked to (A Remote Indicating Effects Bypass System - that site is one of the most well-regarded amongst DIY guitar effects enthusiasts which is the route that has brought me to Arduino) minus the LED and LED resistor . The two resistors in series from the IC would be 4K7, the cap to ground is 4.7uF, the cap across the transistor is 0.1uF, both diodes are 1N4148 and the resistor to ground is one my mind seems to have invented for no good reason so can be ignored.

Definitely leave out that extra resistor to ground.

Oh, and it looks like I forgot to draw in the connectors to the diode above the first resistor, it should be wired parallel to it. All in all a bit of a fail, sorry about that. I can post a corrected one tonight if it will make things clearer (I'm at work right now).
The reason for it is explained much better on that site, but to summarise the transients caused by the relay switching as fast as it does causes an audible pop in the audio signal chain. This is particularly unpleasant when that signal chain is running into an amp turned up to eleven (as all amps should be). The capacitors slow down the speed that the transistor turns on, which in turn slows the speed that the relay switches, which hopefully reduces or eliminates the pop. I imagine that the values of the resistors can be changed if required to optimise the current, as I understand it from the Geofex site it is the caps which are the important features for the pop reduction.

Actually, I always thought that the 'pop' was caused by the relay contacts themselves, rather than the coil being energised too quickly, and that circuit won't change that. ie If the relay is replaced by a manual switch, doesn't it still 'pop'?
Anyway, I'll bow to those that are more expert at audio, it's not my field.

Are they the same people that say you need oxygen-free copper in the speaker wires and gold in the HDMI connectors?

Making a relay switch "slower" will be bad for the relay and bad for the electronics attached to the relay. When the contacts make contact,they don't start with a high resistance and slowly phase-in the new signal - as soon as the electron field of the first atom makes contact with its neighbour, current will flow. THEN it bounces. If you aren't driving the relay hard enough, it will bounce some more.

There are better methods than relays but a relay is conceptually simple and easy to wire up. Have you ever considered the path that the music signal has to take when it goes through a relay? A MOSFET has a much better chance of getting a "clean" signal.

MorganS:
Are they the same people that say you need oxygen-free copper in the speaker wires and gold in the HDMI connectors?

Making a relay switch "slower" will be bad for the relay and bad for the electronics attached to the relay. When the contacts make contact,they don't start with a high resistance and slowly phase-in the new signal - as soon as the electron field of the first atom makes contact with its neighbour, current will flow. THEN it bounces. If you aren't driving the relay hard enough, it will bounce some more.

There are better methods than relays but a relay is conceptually simple and easy to wire up. Have you ever considered the path that the music signal has to take when it goes through a relay? A MOSFET has a much better chance of getting a "clean" signal.

Good points. I've always wanted my relays to be switched as fast as possible. And I still feel that the 'pop' is more likely to originate from the contacts themselves, rather than the coil. Just my opinion though. Maybe it is the coil being energised that does it. Depending on signal level, CMOS switching is probably a better alternative.

There may be some minor differences between *.jpg and *.jpeg files, but the forum software has clearly been locked down to only allow a very limited number of file extensions (sensibly, to reduce the possibility of spreading virus etc.). And yes, on a proper computer I could simply rename the file, unfortunately I was posting from an iPad which is much more limited. You can actually rename any file to any extension and it will still usually open in a program that can open the original file type if you drag and drop it into it rather than double clicking. I've had to do that at work where a system had helpfully renamed all files in the records system to *.1, *.2 etc. Turns out most are *.tif images so you can just tell Picture Viewer to open *.1 files and it works fine. Anyway, this is a bit of a digression, the main lesson is that if I want to post images I should either host them elsewhere or use my desktop to attach them in this forum.

Regarding the 'pop', I don't believe that it is the contacts themselves which cause the 'pop' as I have a number (far too many!) of effects pedals, most with mechanical true bypass switches and most don't have a pop, a few do. In those that do it is apparently due to capacitors in the effect circuit discharging, or something like that, or with the indicator LED also being turned on / off with the same switch. There are other ways to eliminate those pops (pull down resistors and so on) but they would not be on the audio signal circuit and therefore not affect the current draw of the relay switching. In fact I have a couple of pedals with uses relay switching themselves internally, and they don't pop.

In addition to the article I linked to before where I got the initial circuit from, here are a couple more on the causes and solutions to the 'pop' when switching effects:
http://www.geofex.com/Article_Folders/box_pop.htm

And here is the justification for the slowing down:

Even though there is no physical connection between the coil of the relay and the signal switching contacts, there is always a little bit of capacitance between any two conductors. This is true inside the relay. There is a tiny capacitance, maybe a fraction of a pico-farad coupling the coil and the signal lines.
This wouldn't normally be as much of a problem, except that changing voltages on inductors cause some very fast, sharp edged transients, especially when the current in the inductor is turned off. These fast edges can couple through the tiny parasitic capacitances and cause audible clicks in the signal path.

The neat way to defeat the clicks is to slow down the change in voltage across the inductor. The circuit at left does that. An on/off signal is applied to a resistor/diode/capacitor network on the base of a common 2N3904 transistor. The capacitor to ground slows the on/off transition down on the rising (turn on) edge of the input signal, and the diode lets it turn off fairly quickly.

The capacitor between the collector and base of the transistor causes the transistor to turn off slowly. Taken together, the speed with which the voltage across the coil inductance can change is slowed down. Tiny parasitic capacitors can't couple slow signals very well, and any transients are vastly reduced. In addition, the driver circuit turns on a local indicator LED whenever the coil voltage is on. The +On/-Off signal can be low power, is completely isolated from the signal lines, and can more easily be placed remotely.

Of course, for reference and interest I'm happy to receive suggestions on the way to do this without all the switching deceleration, as I'm still in the design / planning stage so I'm happy to have a few options, but I would still like to try with the slowing down circuitry for comparison.

Are they the same people that say you need oxygen-free copper in the speaker wires and gold in the HDMI connectors?

Haha, not quite! HDMI is a digital signal, so the only difference between different cables would be possible flaws that interrupt the signal, since the information is either arriving or not, whilst speaker cables in HiFi etc. I imagine are carrying a low impedance signal. An electric guitar however has a relatively high output impedance, so the more electronics it travels through the more it loses the finer details of its sound, particularly the higher frequencies, resulting in an overall duller tone, and this also makes it more prone to noise and interference, e.g. from a microcontroller directly connected to the circuit. You are correct that there is still some effect on the signal when it goes through a relay, and plenty of effects pedals do just use some kind of transistor switching with the addition of a buffer to bring back the high end, but too many buffers in a row will also effect the tone in the opposite direction making it too shrill. Guitar effects bypassing is a dangerous (and fairly boring, even for a guitar player) rabbit hole to fall down, but relays is the way pretty much all commercial, professional level switchers go, which is why I'm opting for that.

I do appreciate the suggestion though, and if there is a way to isolate the control signal from the audio signal I may use some sort of MOSFET switching for some loops (or loops within loops) for e.g. echo effects so they can fade out nicely. However, for now my primary focus is to understand the way current draw scales up as I add multiples of the relay switching circuit (with or without the extra capacitors), and what I should be looking for in relay specifications to choose those that will allow me to have the most.

Oh boy, you like long posts, don't you?
Anyway, this is the gist of your last post:-

Zatoichi9:
However, for now my primary focus is to understand the way current draw scales up as I add multiples of the relay switching circuit (with or without the extra capacitors),

The way it scales up is that it adds. Just add the individual currents and Bob's your uncle.

and what I should be looking for in relay specifications to choose those that will allow me to have the most.

Most what?

We can't really help with relay specs since so far you haven't told us what currents will be switched, as far as I can tell from quickly going back over your posts.

You mentioned 100 relays. That's a hell of a lot. And a lot of 74HC595s, too.
Rather than 74HC595As with transistors, these would have been more suited to your purpose if you didn't want the slow switching, or even if you do, with a bit of fancy footwork. No transistors needed:-
TPIC6B595

Have you given consideration to the power supply yet?

OldSteve:
Oh boy, you like long posts, don't you?

Ha, yeah, sorry, I'll try to be briefer. Thanks for making the effort to read through them anyway.

OldSteve:
The way it scales up is that it adds. Just add the individual currents and Bob's your uncle.

That's easier than I thought it might be, it's not affected by the components being in parallel like resistance is then? i.e. this: 4 Ways to Calculate Series and Parallel Resistance - wikiHow

OldSteve:
Most what?

Most relays.

OldSteve:
We can't really help with relay specs since so far you haven't told us what currents will be switched, as far as I can tell from quickly going back over your posts.

In terms of the current I'll be switching, it's difficult to say as it varies depending on how hard you play, but I believe it rarely gets close to 1A, usually much less. Hence the relay series I'm considering (linked in my first post. I'm fairly sure one of them will work, I wanted to know which criteria to use for choosing them.

OldSteve:
You mentioned 100 relays. That's a hell of a lot. And a lot of 74HC595s, too.

Realistically I wouldn't need more than 32, and even that's a big stretch. The 100 was curiosity as to whether there would be a noticeable delay between the Arduino telling the last 74HC595 in a long chain of them to change the state of one of its pins and it actually doing it. Thanks for the other IC suggestion, I'll look into it.

OldSteve:
Have you given consideration to the power supply yet?

Not really, other than a quick eBay search. There seem to be plenty of 12V 1-2A supplies. Anything I should take into consideration?

The 100 was curiosity as to whether there would be a noticeable delay between the Arduino telling the last 74HC595 in a long chain of them to change the state of one of its pins and it actually doing it.

If you use SPI.transfer to send the 100 bytes out, the data can be sent in about 1.3mS using code like this, and this can be improved to about 107uS by getting rid of the for loop and writing the 100 transfers explicitly. Is that fast enough?

digitalWrite (ssPin, LOW);
for (x=0; x<100; x=x+1){
SPI.transfer (shiftArrray[x]);
}
digitalWrite (ssPin,  HIGH);

Yep, plenty fast enough! Thanks.

Zatoichi9:
That's easier than I thought it might be, it's not affected by the components being in parallel like resistance is then?

Different situation

In terms of the current I'll be switching, it's difficult to say as it varies depending on how hard you play, but I believe it rarely gets close to 1A, usually much less.
Hence the relay series I'm considering (linked in my first post. I'm fairly sure one of them will work, I wanted to know which criteria to use for choosing them.
Realistically I wouldn't need more than 32, and even that's a big stretch.

Right. You can probably cross off the first Jaycar relay, since it only switches 0.5A. Aside from that, choose whatever uses the lowest coil current I guess. And determine whether you want 5V or 12V relays. If you use a 12V supply, then a 5V regulator for the Arduino, you could power the relays from the 12V supply for a degree of isolation.
And for 32 relays, you'll only need 4 x 74HC595s. Easy.

The 100 was curiosity as to whether there would be a noticeable delay between the Arduino telling the last 74HC595 in a long chain of them to change the state of one of its pins and it actually doing it. Thanks for the other IC suggestion, I'll look into it.

74HC595 propagation delays are only of the order of nanoseconds per operation, so each one will only add a total of several microseconds to the total propagation delay. Not really noticeable for what you're doing

Not really, other than a quick eBay search. There seem to be plenty of 12V 1-2A supplies. Anything I should take into consideration?

Switching power supplies are more efficient, but might possibly introduce noise. Linear regulators run hotter, but have lower noise. You might have to experiment.

Jaycar and Altronics have pretty crappy ranges of parts. Don't overlook RS Components. A really wide range, and delivery for online orders is free. And fast, usually a couple of days.

OK, thanks very much for all your advice and patience. I've ordered a few 74HC595s and TPIC6B595s to play with, and I have access to a few different power supplies to try out. This whole thread has been very helpful to get started. I'd even missed RS Components somehow.

Zatoichi9:
OK, thanks very much for all your advice and patience. I've ordered a few 74HC595s and TPIC6B595s to play with, and I have access to a few different power supplies to try out. This whole thread has been very helpful to get started. I'd even missed RS Components somehow.

You'll find that RS are pretty good all 'round. Far better than Altronics and Jaycar. And Dick Smith are completely useless these days. :frowning:
Another good supplier is element14, (used to be Farnell).

Keep us posted on your progress.