Doubt regarding connecting relay to arduino

Hi,
I am new to arduino platform and not very familiar with the details of related electronics, but I wish to learn so I apologize in advance if this is be a stupid question.
I am trying to connect a relay to arduino to drive a motor and from all I have read, it is my understanding that some variation of the attached circuit is used to protect the micro-controller from damage.

But I am wondering if it could be connected so that the transistor collector is connected to the voltage source (Vcc) and the relay and diode part of the circuit is connected between transistor emitter and ground.
Would this circuit serve the same purpose or is there some drawback to this configuration?

Hi, welcome to the forum.

The circuit is good if that is an darlington transistor.
I would use a 1k resistor instead of 10k.

Some relays are 12V, and the relay at the emitter and GND won't work.

If that relay is 5V and VCC in the picture is 5V, then it might work a little.
The voltage at the relay would be : Arduino output 5.0V; voltage drop over 10k resistor perhaps 1.0V; voltage drop base-emitter 0.6V. That results into 3.4V for the relay.
[EDIT]Voltage drop base-emitter for a darlington is 1.2V, that results in 2.8V for the relay.

When the relay is at the collector, there is only one voltage drop, the collector-emitter voltage drop of about 0.1V for a normal transistor and 0.7V for a darlington transistor. That means the relay gets 4.3V (when a darlington is used), which is a lot better.

If you really want the relay to be connected to GND, and the VCC is 5V, then you can use a PNP darlington transistor. It is the same circuit, but upside-down.

Using an emitter-follower has some kind of shortcut protection fail-safe design (if carefully calculated and with the right components). That can be very useful in some situations when the current is unknown. For example for an unknown coil or transformer, or when current is pushed into capacitors. I prefer an emitter-follower if possible, it covers up the mistakes in the rest of the design. But for a relay it is not the right thing.

No question is a dumb question :slight_smile: he seems to have covered all the bases /
|

There are many ways to design circuits. One option I find easy (bit more expensive), is to use an electronic relay. It is a black box, and provides good protection for your processor. Depending on your load (AC or DC) you can get either type of electronic relay. Just my thoughts.

Peter_n:
Hi, welcome to the forum.

The circuit is good if that is an darlington transistor.
I would use a 1k resistor instead of 10k.

220 ohms is likely to be better.

The basic rule of thumb for a switching transistor is make the base current 5% to 10% of the
collector current for proper saturation (hence cool running). 220 ohms gives about 20mA,
so you'll be able to drive loads upto about 0.4A (assuming the transistor can handle it) without
worry.

If you know the relay's current requirement you can calculate the base resistor accordingly.

maze871:
But I am wondering if it could be connected so that the transistor collector is connected to the voltage source (Vcc) and the relay and diode part of the circuit is connected between transistor emitter and ground.
Would this circuit serve the same purpose or is there some drawback to this configuration?

You'd probably need a heatsink on the transistor and the relay might not switch properly
with less voltage available.

Switching circuits are normally common emitter which is highly efficient. The only advantage
of the emitter follower you describe is faster switching as the device is not in saturation, but the
difference between 0.1us and 3us is neither here nor there for a mechanical relay.

Logic chips using BJT use various tricks to avoid saturation to get faster switching, but they
aren't handling significant power.

1:10 is quite enough to get any small transistor into deep saturation.
No need to have 20mA base current for a 50mA relay.

Imagine having to drive 8+ relays. You could end up with a hot regulator.

For a 5volt Arduino, 1k (~4mA base current) is usually enough for a small relay.
I would only go as low as 220ohm for large relays, solenoids, or small motors.
Leo..

Thanks Peter and Mark for the replies, they really helped clearing up the confusion. I hadn't considered the voltage and current considerations for the relay, but now having read up about the characteristics of common emitter and common collector configurations I understand how they can be important. And thanks for the tip Jack, I will also consider using electronic relays in my circuit.
Wawa could you elaborate on the conditions when using 220 ohm resistor would be useful? I want to use the relays to drive a 240v ac supply for a motor. should I use 220 ohm in this case? Also please post how you come to the conclusion.

Post the relay coil voltage and resistance (or relay current), and the transistor you are going to use.

In general, most small to medium power switching transistors need a base current that is 1/10 of the collector current, to fully saturate.
More just wasts power. Less will not fully saturate the transistor.

There have been many posts about this in the past.
Here is one. Read the last post.
http://forum.arduino.cc/index.php?topic=308620.15
Leo..

I want to use the relays to drive a 240v ac supply for a motor

Makes me wonder, is the relay big enough for the motor? In the USA, most 240V motors are really large.

Large inductive loads on a relay contact may have back EMF problems also.

In the UK, 240v AC motors can be any size.
Leo..

maze871:
when using 220 ohm resistor would be useful?

Knowing relay coil resistance, you can estimate required collector current: Ic = Vcc/ Rcoil. For instance, if you take Omron G5LE relay with 24V coil, its resistance is 1.44 kOhm, and required collector current is 16.7 mA.

You transistor has minimum DC current gain specified in the datasheet. For instance, popular NPN transistor BC546 fas minimum gain of 110. It means that you need to feed at least 16.7/100 = 0.152 mA into its base to achieve 16.7 mA of collector current.

If your Arduino operating voltage is 5 V then with base resisor of 10 kOhm (as in your original circuit) the transistor base current will be about 5V/10k = 0.5 mA, or more than 3 times greater than required. It means that this transistor with that relay will be perfectly OK, because transistor will be in saturation mode as it supposed to be.

If you use more powerful relay with smaller coil resistance, or you use a transistor with less gain, then a smaller base resistor value is required. As a rule of thumb, a base resistor in the range 1k...3.3k is suitable in most cases.

Don't confuse the lineair current calculations for a transistor with the saturation current calculations.
Leo..

I don't worry so much about the gain when using transistors as digital switches.
Calculate base resistors as (5V - Vbe_saturation)/.02A.
If Vbe - 0.7V when saturated (~1 diode drop), then
(5V - 0.7V)/20mA = 215 ohm. So 180 ohm, 220 ohm to turn a NPN transistor on & off nice & quick.

Similar for MOSFETs - cap looks like short.
(5V - 0V)20mA = 250 ohm
So 180, 220, 250 again for fast on/off speeds.

Too much base current, and the transistor does not turn OFF fast.
Unless you use a schottky diode "Baker clamp".

But all of this is irrellevant for slow things like relays, motors and solenoids.
Leo..

CrossRoads:
Calculate base resistors as (5V - Vbe_saturation)/.02A.
If Vbe - 0.7V when saturated (~1 diode drop), then
(5V - 0.7V)/20mA = 215 ohm. So 180 ohm, 220 ohm to turn a NPN transistor on & off nice & quick.

To be precise, with 20 mA output current microcontroller cannot deliver full 5V swing. You should use 4.5V instead of 5V in the equasion: (4.5V - 0.7V)/20mA = 190R.

Pin current of 20 mA is excessive, it creates unnecessary stress to microcontroller, contributes to noise and dissipiates power. If required pin current exceeds few milliamps, it is a clear sign of something wrong in design. In case of relay driver 20 mA of base current cannot be justified. Just use Darlington transistors if you wish to have a big collector current.

AFAIK, a correct calculation includes the ~40ohm internal mosfet "on" resistance.
(5V-0.7V)/20mA=215ohm, 215-40=175ohm.
Leo..