# Need help for value of resistor

#### Michael Quiñones

Dec 6, 2016
19
I have this diagram, now the arduino uno output pin (microcontroller) is 5 volts, what is the value of resistor R1 and R2 ?

#### Harald Kapp

##### Moderator
Moderator
Nov 17, 2011
13,828
R1 is not required at all. The arduino can pull-up or pull-down the output.
The value of R2 depends on the current required by the relais and the gain offered by the transistor.
Assuming a conservative DC gain of the transistor of 10 (for full saturation), the base current needs to be 1/20* Irelay. From the min output voltage of the arduino and the base-emiter voltage drop of U2 you can calculate
R = (Voutmin-Vbe)/Ibase

Of course you could replace the bipolar transistor by a logic level MOSFET (e.g. BSS138) then you will need no static gate drive current at all. A 100 Ω resistor for limiting the inrush current to the MOSFETs gate would be sufficient in that case.

#### duke37

Jan 9, 2011
5,364
Why are D3 and D4 different? I would keep a stock of 1N2007 for all situations such as this.

#### BobK

Jan 5, 2010
7,682
Why are D3 and D4 different? I would keep a stock of 1N2007 for all situations such as this.
Because some people think the flyback resistor needs to handle high voltage spikes. In reality, it does not, it only sees the same voltage as is applied to the relay coil.

Bob

#### 73's de Edd

Aug 21, 2015
3,665
duke37
Why are D3 and D4 different? I would keep a stock of (sic) 1N2007 . . . . ( 1N4007) . . . for all situations such as this.

BobK
Because some people think the
flyback resistor needs to handle high voltage spikes. In reality, it does not, it only sees the same voltage as is applied to the relay coil.

Query . . . . . Where is the flyback resistor on that schematic ?

Last edited:

#### BobK

Jan 5, 2010
7,682
That should have been diode, not resistor.

Bob

#### Tha fios agaibh

Aug 11, 2014
2,253
Because some people think the flyback diode needs to handle high voltage spikes. In reality, it does not, it only sees the same voltage as is applied to the relay coil.

Bob
Bob, can you elaborate on this?

I always thought the inductive voltage spike was multiple times higher, depend on the inductor size, the load it sees when turned off vs time.
So, If the 1n007 responded to the back emf within a few ms, wouldn't the voltage at the relay coil still be significantly higher than the voltage applied?

#### Harald Kapp

##### Moderator
Moderator
Nov 17, 2011
13,828
1) The voltage spike is multiple times higher only if not limited.
2) When flyback sets in, the diode is forward biased, therefore limniting the flyback voltage to ~ 0.7 V.

The misconception here is, iI think, confusing the flyback voltage with the diode's reverse voltage. The reverse voltage the diode experiences is the operating voltage of the relay coil, 12 V in this circuit.

#### Tha fios agaibh

Aug 11, 2014
2,253
When flyback sets in, the diode is forward biased, therefore limniting the flyback voltage to ~ 0.7 V

Wouldn't it be flyback voltage minus the .7v dropped across diode at the instant its forward biased?

#### Harald Kapp

##### Moderator
Moderator
Nov 17, 2011
13,828
We're talking about the voltage across the diode, right?
Then your statement makes no sense, sorry. Where in the world would the voltage difference (flyback voltage minus the .7v) be dropped? During the "flyback phase" the circuit under consideration consists only of the loop made of the relay coil and the diode.

#### duke37

Jan 9, 2011
5,364
Sorry that I specified 1N2007 instead of the correct 1N4007.
When the relay is energised, it will have 12V across it and a current determined by the resistance. When the relay is turned off this current has to go somewhere until the inductive energy is dissipated, the diode will do this.
If the diode is replaced by a resistor equal in resistance to the relay, initially it will have 12V across it so the switch will see 24V at turn off. The relay will open faster than when a diode is used. You could use a resistor (or Zener) and diode in series as long as the switch can withstand the voltage.

#### BobK

Jan 5, 2010
7,682
The flyback voltage only rises to the voltage that allows the current in the inductor to continue flowing. The flyback diode is forward biased and thus only about 0.6 to 1V, depending on the current and the diode are required to keep the current flowing, and it goes no higher than that.

The diode is reverse biased only when power is supplied to the relay coil, so it’s reverse voltage needs only to be higher than the voltage driving the relay coil.

As far as the voltage of the flyback pulse, maybe it would be easier to understand if there was resistor in place of the diode.

If the coil is carrying 1A and suddenly the voltage driving it is cut off we can calculate the voltage flyback voltage. If the resistance is 100 Ohm, the voltage will be 100V. Raise it to 1000 Ohms and you get 1000V!

Bob

#### Tha fios agaibh

Aug 11, 2014
2,253
Thanks, that helps my understand.
The statement "it only sees the same voltage applied" threw me.
A higher voltage potential is there but it's quickly shunted (low resistance)once the diode conducts.

#### BobK

Jan 5, 2010
7,682
No, it never becomes a high voltage. The voltage only rises to the level that will allow the current flow, in the case of the diode, that is between about 0.6 and 1V. I don't consider that a high voltage.

It if was otherwise, what voltage would it rise to, 100V 1000V, 100 MV?

If you scoped it you would not see any high voltage.

Bob

#### hevans1944

##### Hop - AC8NS
Jun 21, 2012
4,891
This IS a hands-on forum, riiight? Get the damned scope out from under the work bench and connect its input across the relay coil using capacitive coupling. Pulse the relay coil with a logic-level MOSFET and measure the so-called fly-back wave form. Take some pictures, post them here with a clear explanation of what we are looking at.

I would do this for you, but I am over 75 years old and too damned lazy to perform this rudimentary test whose outcome @BobK has already described.

Get rid of R1; farkle with R2 until U2 reliably saturates; remove D4 and replace it with a piece of wire, connecting VCC 1 = +12 V DC to cathode of D3 and one end of the relay coil.

Nothing more to see here, folks. Move along. Ask some newbie questions about how to light up a string of LEDs instead of reading this resource.

#### Tha fios agaibh

Aug 11, 2014
2,253
No, it never becomes a high voltage. The voltage only rises to the level that will allow the current flow, in the case of the diode, that is between about 0.6 and 1V. I don't consider that a high voltage.

It if was otherwise, what voltage would it rise to, 100V 1000V, 100 MV?

If you scoped it you would not see any high voltage.

Bob

Ok, I was thinking a voltage spike could happen before the diode switches on to do its job of snubbing it.

I think I got a better understanding.
The induced voltage across the inductor never gets the chance to rise (spike) because the instant current flows back through diode and into the inductor, it prevents voltage from rising.

I think I was confusing the switching speed of a diode with its forward biasing, which I believe happens the instant current flows through it. So, it's not a race between inductor voltage rising and the diode switching on as I was thinking.

Thanks, and my apologies to op for side tracking this thread.

#### Harald Kapp

##### Moderator
Moderator
Nov 17, 2011
13,828
Ok, I was thinking a voltage spike could happen before the diode switches on to do its job of snubbing it.
The 1N4000x diodes are not particularly fast with reverse recovery times in the µs range (link). Therefore your assumption is not completely wrong. There will be a rising voltage across the diode until conduction sets in. A scope measurement as suggested by Hop could sort this out.

However, A much better and faster solution here is using a fast switching diode, e.g. a 1N4148. It will operate perfectly across a 12 V relay coil and with reverse recovery times in the ns range you will observe almost no voltage spike.

#### duke37

Jan 9, 2011
5,364
There will be limit to the speed at which the switch will turn off which will depend on the characteristics of the switch and the Miller effect. Therefore I would think that any diode would do.
The UF4007 is faster than the 1N4007 and can pass an Amp.

#### one_electron

Nov 1, 2019
1
2SC1815 comes in four different hFE grades 70 -O, 120 -Y, 200 -GR, 350 -BL.
It's max Ic is 150mA and for saturation 10-15mA base drive would be great - so R2 = (4.75V-0.9V/10mA) is around 385Ω.

R1 is only needed if the relay must be on if the Arduino is dead, stuck in reset. But if the Arduino gets hung in a loop with the relay output off, R1 is useless. I would leave it out.

D4 is only to deal with -ve voltage transients like you would see in a car. They are around -250 to -400V so D4 should be 1N4005 or higher, or you can swap D3 and D4. D3 can be smaller a 1N4148.

#### hevans1944

##### Hop - AC8NS
Jun 21, 2012
4,891
The 1N4148 virtually replaced the venerable 1N914 signal switching diode in most logic applications. I have been using it since the 1970s and have never found fault using it to replace the 1N914. However, both diodes are fast signal diodes, not power diodes. You need to be aware of this limitation when dumping the energy stored in large inductive loads. Relays that mount on printed circuit boards typically DO NOT exhibit large inductive loads, but external, high-amperage, contactors typically DO. Such contactors are also not typically rapidly cycled, so average amount of energy storage in their magnetic fields is small. It is with high inductance, high coil current, rapid and frequent ON/OFF cycling contactors that the designer must be careful when considering to place a diode across the actuator coil. A considerable current pulse will flow through the diode when the contactor coil is de-energized, so make sure the diode is up to the task of conducting this current pulse.

Another element of design that is often neglected, or not considered at all, is the drop-out time after the actuator coil circuit is open-circuited. Because there is an inductance and a current involved, simply creating an "open circuit" by, say, turning a transistor off, does not mean the current drops instantaneously to zero. It cannot, nor does it. I will not go into the details here, but essentially placing a diode across the coil slows down the decay of current and increases the drop-out time,

Replies
2
Views
1K
Replies
1
Views
1K
W
Replies
2
Views
2K
jasen
J
S
Replies
2
Views
1K
My Name
M
P
Replies
1
Views
1K
DragonMaster
D