Help for getting R of a relay on PCB card drived by Arduino

Hello everybody !
(Sorry for my english)

What I want to do :

I want to learn all steps to make a relay driven by Arduino.


Steps that I want to learn :

  • Develop a PCB Board on Eagle
  • Send it to manufacturer
  • Create simple relay schematic
  • Calculate the value of the resistor to activate the transistor
  • Add a led which turn on when relay is activated

Steps that I already did / know (a priori) :

  • Develop a PCB Board on Eagle (I know how to do it)
  • Create simple relay schematic, from the Internet I did (cf picture)
  • Add a led which turn on when relay is activated, from the Internet I did (cf picture)

Schematic explanation :


Questions :


Conclusion :

I guess I forgot nothing (I hope).
Thanks by advance for anybody who can help me.

Have a good evening mates !

Poloy

FYI, there are conventions for schematic representations, one of which you don't rotate the transistor 90 degrees unless there is a reason to.
Also, positive voltages are at the top and gnds or negative voltages are at the bottom, which means
your schematic is upside down. I suggest you learn
some discipline when creating schematics so it doesn't like like it was designed by an amateur.

1 Like

You need to know how much current the relay coil needs. Then divide by the transistor's (worst case) current gain (Beta) = 40. That tells you the minimum current into the transistor's base. Now multiply that by a factor of 2-10 to make darn-sure the transistor is saturated. Most of the 5V will be dropped across the base-resistor, so use Ohm's Law to calculate the resistance.

Or... Since the coil voltage is the same as the "signal" voltage (5V) you can get an approximate value by simply dividing the coil resistance by 10 or 20 (for 1/10th or 1/20th of the coil current into the transistor's base). If they don't give you coil resistance you can use Ohm's Law to calculate it.

(R16) Resistor to limit the current in Led

  • Value ?

Subtract the LED's on-voltage from the 5V supply to find the desired voltage across the resistor. Then use the desired current and the now-known voltage to calculate the required resistance (again with Ohm's Law) For example, if the LED is rated for 2V and 20mA (0.02A) you the resistance is 3/0.02 = 150 Ohms. ...I'm not sure if 150 Ohms is a standard value, but you can go-up for less current. (10mA is usually fine.)

...In series circuits the voltage divides, but the same current flows-through all series components.

The opto-coupler provides additional isolation - It isolates the relay coil from the Arduino circuit for extra protection against glitches from the coil's inductive kick-back.

The manufacturer will have all of the information on their website. Eagle will generate the required Gerber files.

P.S.
Something will probably "go-wrong" with your 1st batch of boards and you'll probably have to fix it and re-order. :frowning: Just be mentally (and financially) prepared for that...

I've never done this myself but I work in electronics and the even with experienced engineers & PCB designers, the 1st version usually isn't perfect.

I'm testing some boards now that are "Rev.1". We use a different numbering system for the 1st prototype boards and then the 1st production release is Rev 0. So this is the 2nd production release and there was at least one prototype version before that.

1 Like

I recall one of my customers ordered, perhaps 500 circuit boards for a new version of their product. One of the footprints for an IC was the wrong size for the IC in the design. An amateur mistake for a seasoned engineer. IT happens!

The UNO itself has a pc board mistake, the spacing between headers is misaligned.

But that is not a problem as the UNO is not suitable for any designs other than for use with a matching "shield".

It is basically only for experimentation using jumper wires. For a serious project, you use a Nano instead.

Thanks everybody !

I will respond to all one by one :wink:

@raschemmel Thanks for the advice !

So I updated my schematic (cf picture), I hope this time I did it well :

  • I changed the X3-1 / X3-2 terminal block to X7-1 / X7-2 / X7-3
  • I added groups in order to have a clean interface

Tell me if something is still wrong please :slight_smile:

:+1:

Tell me if something is still wrong please

Well , not be nit picky but why bother putting the transistor part number if the resistors
values are not shown ? The resistor values are chosen for the transistor used. Of course
you would be hard pressed to find an arduino hobbyist that wouldn't know the values
of R13 & R16 but that's not the point. You asked, so that's my answer. They could probably tell you the transistor part number , (but I know some could not)

@DVDdoug

I'm so stupif, I forgot to mention the relay I would like to use :

So I want the ref SRD-5VDC-SL-C.
From the datasheet :

  • Current needed to activate the relay
    • 71.4mA

  • Beta of the transistor
    • 30 for2N2222
    • 40 for 2N2222A

  • Intensity in transistor to saturate it
    • IRelay / Beta * SecurityFactor = ITransistorToSaturate
  • Resistor before transistor (I saw on a Website that there is a voltage drop on the transistor around 0.6V when the transistor is saturated, I will count it on my calcul, tell me if i'm wrong, so the formula is :
    • (VIN - VDROP) / ITransistorToSaturate = ResistorBeforeTransistor
    • ResistorBeforeTransistor = (VIN - VDROP) / IRelay / SecurityFactor * Beta
    • ResistorBeforeTransistor = (5 - 0.6) / (71.4 / 1000) * 40 / SecurityFactor = 2460 * SecurityFactor Ohms
    • With a Security Factor of 4, I get 10kOhms for ResistorBeforeTransistor.
      Is value correct ? Because when I do Ohm Law with coil resistance (U/I = R => R = 5 / 71.4 * 1000 = 70 ohms), I get 70 ohms xD

For the Led :

For the Opto-Coupler

  • Is it a crucial element or it is used for specifics applications ?

For the Gerber Files :

  • Thanks for the tutorial's link :slight_smile:

For the Tips :
Thanks you for this, to be honest, that's doesn't surprise me.
It's okay, I want to learn so if I fail at first, I will continue to success :wink:

Thanks a lot !! It really helped me !
I hope, values are corrects.

1 Like

Yup, that's what I calculated on my last post :slight_smile:

It’s nice to see a new person want to then succeed in learning.

We do not often see this on the forums.

Congratulations !

What Larry is so tactfully pointing out is that it is rare for any new poster to do their due
diligence. The norm is a game of 20 questions because the OP (Original Post) tells us next to nothing. On a grading scale of 1-10 , when comparing you to the typical poster,
you get a 20.

That's for Ic of 500mA. Since your Ic is much lower, you'll be in the higher-gain portion of the curve:

I would normally set the base current resistor for circuit like this depending on the maximum output of the microcontroller pin. 15 or 20mA is fine for an Arduino, so I'd plan on that for the base current, and THEN check the transistor characteristics to make sure it is "reasonable" 20mA * gain of 50 to 200 is 1 to 4 Amps, which is comfortably above the relay coil current, so I'd be pretty confident...

Then I'd put the LED in series with the base resistor. The currents are compatible, and it eliminates a component. (5-1.8-0.6)/20mA is about 150ohms...

  • ResistorBeforeTransistor = (5 - 0.6) / (71.4 / 1000) * 40 / SecurityFactor = 2460 * SecurityFactor Ohms

You inverted the sense of your security factor. You want 2460/4, rather than *4.

And, always confirm the transistor goes into saturation using a DMM.

@LarryD @raschemmel Thanks, I doesn't post often but when I search and look at some posts, it is horrible when nothing is clear.
So I prefered do my own researchs first, then come here with all elements to have a complete startpoint for you which help me :slight_smile:

@westfw

Very good Idea for the Led in Series !
Thanks for SecurityFactor, oops xD

LED :
"""
Then I'd put the LED in series with the base resistor. The currents are compatible, and it eliminates a component. (5-1.8-0.6)/20mA is about 150ohms...
"""

Is 1.8V the voltage of the led ?
In the doc I gave, the forward voltage is 2.6V to 3.2V.
Am I wrong ?

Transistor :
Understood, thanks for the curve and the explanation :slight_smile:

@LarryD Yes ! I will :slight_smile:

Look up "led forward voltage as a function of color"

Red is typically 1.8V -2.2V .
Forward voltage will vary with color .
Blue can be over 3.5V,

@raschemmel
There are things to know ahah !

I want a green one and the reference I found ( https://datasheet.lcsc.com/lcsc/1809291631_ARKLED-Wuxi-ARK-Tech-Elec-D-060306G1-SS2-G1_C118334.pdf) is pure green.
So from the picture below, the forward voltage correspond more or less ...