Relay directly connected to IO pin?!

Hi,

some time ago I have bought a couple of miniature relays (5V, 30mA - if I have calculated correctly). Since a IO pin can provide max. 40mA, I was wondering whether one could use those relays directly, i.e. without a driver circuit?

Thanks,
Phil

If it truly is 30mA then yes, you will need a diode across the coil to protect against reverse voltage fly back caused when you turn off the relay.

Note that 30mA to trip a relay is very unusual.

Thank you for your answer.
I must admit that I'm really lacking some basic knowledge here...

According to the data sheet, the coil resistance is 178 ohms, the nominal voltage 5V. Doesn't that make 30mA of current draw?

Thanks, Phil

Oh, maximum limit, of course... :-/
Actually, I'm planing to use at least 4 relays in my project, so I will need drivers anyway.

You may wonder why I want to use relays in the first place.
I'm building a "true bypass" switcher for high-impedance guitar signals, that's why... :wink:

Thanks again.
Phil

I'm planing to use at least 4 relays in my project,

The current limit for the chip is 200mA so at 30mA each you can drive 4 relays directly.

The current limit for the chip is 200mA so at 30mA each you can drive 4 relays directly.

Though you might want to take into account anything else connected as an output device (LEDs or such); though with your budget of 200mA, and only ~120mA used, you still have some headroom...

Thank you all for your advice.

I have another (related) question...

As I said above, I'm planning to switch low-impedance signals (from passive guitar pickups) using relays. The problem is that relays have a bad habit of "bouncing" (is that the correct english term?), thus producing an audible "plop" ... I have seen a circuit that tries to avoid this by using a capacitor/resistor/transistor combination to drive a relay. As far as I have understood the circuit, the capacitor slows down the switching signal so that the relay coil is increasingly building up its magnetic field (instead of getting the full nominal voltage at once). Apparently, this reduces the "plop", because the mechanical switch inside the relay is attracted with less "force" and thus doesn't bounce back as much.

OK ;-), my qestion is: Do you think it would be possible to achieve the same effect using PWM on the Arduino? What I mean is, if I put out a PWM signal of 2V and "slowly" (well, over the period of - say - 300ms) increase that signal up to the nominal 5v, do you think that would help against the audible crackling?

I guess one would have to try, but since chances are good that I'm completely on the wrong track, I thought I better ask you guys first :-).

Thanks, and sorry for my English.

Phil

"bouncing" (is that the correct english term?),

Yes :slight_smile:

Apparently, this reduces the "plop", because the mechanical switch inside the relay is attracted with less "force" and thus doesn't bounce back as much.

I would guess that this is rubbish. Most of the plop is due to switching DC levels.

Do you think it would be possible to achieve the same effect using PWM on the Arduino?

You can switch power to a relay slowly with PWM if you filter the PWM with an R and C so you are not gaining much.

@Richard: You're right, HIGH IMPEDANCE is what I meant ;-).

Here is the circuit that I based my first-ever electronic project on (it works like a charm - there is no switching noise whatsoever, and I have used this circuit extensivly on live gigs for over a year):


And here's the complete article on the subject:

http://www.geofex.com/Article_Folders/rmtswtch/rmtsw.htm

I'm quite new to electronics, so I don't exactly know why or how it works, but it does work. I just thought I could save a couple of components by going the PWM way, but ... oh well.

I'm just wondering: Would I have to re-calculate the resistors in that circuit if the switching signal is 5V (from Arduino) instead of 12V as in the original diagram?

Thanks a ton,
Phil

That article explains that it is capacitive coupling between the relay driver and the audio circuit causing the problem. This is nothing to do with what you thought the problem was (contact bounce).

What it does is to slow down the current rise to reduce any induced signal. You can use exactly the same circuit with the arduino. Although there is lots of other sources of interference (the arduino itself) that might cause you problems if you circuit is that sensitive to pickup.

Thanks for clearing things up!

capacitive coupling

I guess I will have to do some further googling to understand what this term means ;-).

Actually, I have already built this circuit using an Atmega8 (programmed with Bascom, though) for the signal lines. Back then it occurred to me that I would have to adapt the driver circuit to suit my particular relay type and the 5v vs. 12v going to the base of the transistor. Somewhere I found a formula and re-calculated the resistor values based on my transistor's gain factor (10x I think), the base current and the load that was to be switched (the relay).

I really have to read up on this topic, as (back then) I really didn't understand what I was doing... It works, though.

So, you are saying I can strictly take that circuit and just apply 5V to the transistor's base instead of the 12V, provided that I'm using the same transistor type and relay?

and just apply 5V to the transistor's base

Through a resistor yes.

based on my transistor's gain factor (10x I think),

It is not a critical calculation most transistors have a gain of between 100 to 300.

One last question (fully on-topic this time):
What would be the components needed to prevent the "capacitive coupling" when driving the relay directly from an Arduino?

Thanks for all the help and suggestions...

Thanks... Hmmm.

As a bloody beginner, it is difficult for me to see what is an "input filter" and what is the dropping resistor (network) for the transistor's base... In other words, which components in the circuit are needed as a part of the "driver circuit" (which I might try to leave out altogether) and which parts are responsible for preventing the "capacitive coupling".

As to the type of relay: In the article they say that

Relays rated for "low signal" or "telecom applications" should be good in this application

So I guess I might take a chance with the miniature relays I have kicking round, as they seem to fit this application. If they don't work, I can always go back to the ones I have used before (they worked fine), or buy the exact same NEC relays used in that circuit.

I really appreciate your help, thanks again!

I've used some relays without a transistor but it was solely due space constraints and low current needs. The relay itself could only switch about 500 Milliamps... so it's hardly your normal relay. The relay coil required about 13 milliamps at 5V.

It's TINY, that's probably a bit larger than actual size.

Will 3PDT switches not work for what you are doing? That's how most true bypass is done.

This must be COTO's specialty... mine is also a COTO relay.

Thanks again, I will take a look at those COTOs more closely...

I'm realising that selecting the right relay is quite essential. Actually, I have quite a few requirements that have to be met.

For one, I'm afraid the 6-legged COTO won't do it in my application, since I need a double switch (I don't know the correct term). In the closed position, the audio signal is meant to go right through the relay (thus forming the "true bypass"). In the open position, the signal goes out of the relay into an effects unit, and coming back from the effect it goes back into the relay and is coming out again on the same pin as in the "bypass mode", like so:

Oh well, I guess I will have to try a couple of different relays in a prototype and see how they perform ...

@Ccc56: No, in this case the standard 3PDT switches won't do. The whole point of all this is to be able to switch effects remotely, via a MIDI signal (or RF signal) which is sent to the Arduino, which in turn is driving the relays :-).

What would be the components needed to prevent the "capacitive coupling" when driving the relay directly from an Arduino?

It is more dependent on constructional layout rather than actual components.
Try and keep the rapid switching stuff away from the audio path as much as possible.