Author Topic: A simple relay doubt  (Read 3931 times)

0 Members and 1 Guest are viewing this topic.

Offline alectoTopic starter

  • Contributor
  • Posts: 21
A simple relay doubt
« on: September 06, 2017, 02:37:23 pm »
Hello,

I attached(I hope) a shema of a little circuit I breadboarded...it works fine...well it seems to anyway...

would you advice such kind of stuff?

PS : Please excuse the crudity of this model. I didn't had time to build it to scale or paint it.  ;)

thanks in advance for your time...
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 12298
  • Country: au
Re: A simple relay doubt
« Reply #1 on: September 06, 2017, 02:43:34 pm »
Not bad - but the first thing I would suggest is a back emf protection diode.

Just something like a 1N4007 connected between coil + and coil - with the arrow pointing up.

Reason: When you energise a coil, the magnetic field builds up according to the ability of the power supply and the circuit energising it.  However, when you disconnect the power, there is no current to maintain the magnetic field, so it collapses.... very quickly.  It is this speed of collapse that can generate hundreds or even thousands of volts which could kill any susceptible components, such as your transistor.

The mechanism is identical in the coil in a car ignition system.  That's how they get 12V to generate the voltages required for spark plugs.
« Last Edit: September 06, 2017, 02:47:59 pm by Brumby »
 

Offline Connoiseur

  • Regular Contributor
  • *
  • Posts: 104
  • Country: in
Re: A simple relay doubt
« Reply #2 on: September 06, 2017, 02:47:49 pm »
What's exactly you want to accomplish? I'm guessing this is some sort of an emergency light :-//

The circuit will illuminate an area, depending of the wattage of LED. You can improve efficiency by eliminating the relay and using either a PMOS in its exact place or NMOS on the common ground side of LED's. :popcorn:
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Re: A simple relay doubt
« Reply #3 on: September 06, 2017, 03:07:43 pm »
Also the 2N3904 has a minimum HFE of 100 @Ic=10mA dropping to 60@Ic=50mA.   With a 10K base resistor, it only has about 0.43mA base drive, its only good for a bit over 30mA, before in the worst case scenario, it could drop out of saturation and the relay may fail to pull in reliably.   Although you'll get away with it if the relay draws less than 30mA coil current, its good design practice for a saturated switch to provide excess base current, so Ib=Ic/10, and it should *NEVER* have less base current than Ic/(2*HFE) 2*Ic/*HFE, so replacing the 10K resistor with a 1K one would be advisable.

P.S. We *much* prefer a clear hand-drawn schematic, in black ink on an even white background, to blurry photos of a breadboard or a schematic sketched in faint pencil on what looks like a used paper wrapper from a takeaway kebab, taken on a crappy low-res phone camera by someone with an essential tremor.  Overall I think I'd award you 7/10 for that schematic - its clear enough and had readable part numbers and component values.

Edit: corrected formula above. Sorry - brain fart!  :palm:
« Last Edit: September 06, 2017, 03:49:14 pm by Ian.M »
 

Offline alectoTopic starter

  • Contributor
  • Posts: 21
Re: A simple relay doubt
« Reply #4 on: September 06, 2017, 03:18:59 pm »
Just something like a 1N4007 connected between coil + and coil - with the arrow pointing up.

oops sorry there is one...I just forgot to put it on the shema... :o

What's exactly you want to accomplish? I'm guessing this is some sort of an emergency light :-//

The circuit will illuminate an area, depending of the wattage of LED. You can improve efficiency by eliminating the relay and using either a PMOS in its exact place or NMOS on the common ground side of LED's. :popcorn:

just some lightings for my 3D printer...
I had a relay...some leds...and a cheap nano clone....this was just a test...
I was just wondering if I could tie the com to the coil...but I heard your remark about PMOS or NMOS...

and for the efficiency...if I understand correctly...the speed is not really that important to me in this case...and the 50mA current for the coil is not too much...the circuit as it is is around 123mA wich is ok for my purpose


 

Offline alectoTopic starter

  • Contributor
  • Posts: 21
Re: A simple relay doubt
« Reply #5 on: September 06, 2017, 03:25:35 pm »
Also the 2N3904 has a minimum HFE of 100 @Ic=10mA dropping to 60@Ic=50mA.   With a 10K base resistor, it only has about 0.43mA base drive, its only good for a bit over 30mA, before in the worst case scenario, it could drop out of saturation and the relay may fail to pull in reliably.   Although you'll get away with it if the relay draws less than 30mA coil current, its good design practice for a saturated switch to provide excess base current, so Ib=Ic/10, and it should *NEVER* have less base current than Ic/(2*HFE), so replacing the 10K resistor with a 1K one would be advisable.

P.S. We *much* prefer a clear hand-drawn schematic, in black ink on an even white background, to blurry photos of a breadboard or a schematic sketched in faint pencil on what looks like a used paper wrapper from a takeaway kebab, taken on a crappy low-res phone camera by someone with an essential tremor.  Overall I think I'd award you 7/10 for that schematic - its clear enough and had readable part numbers and component values.

thank you...there you see I am a complete noob...so much to learn....I will change the resistor....and try to understand this...till now I only used transistors as switch without reflexion...it is time to evolve
 

Online madires

  • Super Contributor
  • ***
  • Posts: 7765
  • Country: de
  • A qualified hobbyist ;)
Re: A simple relay doubt
« Reply #6 on: September 06, 2017, 03:36:26 pm »
I second the idea to replace the NPN with a logic level n-ch MOSFET switching the LEDs directly (low side switch). That would also allow you to PWM the LEDs by the Arduino.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Re: A simple relay doubt
« Reply #7 on: September 06, 2017, 03:47:42 pm »
Arrgh. Formula error!

Use: Ib>2*Ic/HFE_min, as the minimum safe base current for saturation should be double what would be needed for the desired Ic with a minimum HFE transistor in its linear region.  Be aware that Vce_sat voltage drops in the datasheet are likely to be quoted for a 1:10 Ib:Ic ratio, and will be higher at the lower base current, which may result in excessive dissipation.  However I think that wont be a problem unless you try to drive a low coil resistance heavy duty relay.
« Last Edit: September 06, 2017, 05:04:14 pm by Ian.M »
 

Offline alectoTopic starter

  • Contributor
  • Posts: 21
Re: A simple relay doubt
« Reply #8 on: September 06, 2017, 04:14:01 pm »
I second the idea to replace the NPN with a logic level n-ch MOSFET switching the LEDs directly (low side switch). That would also allow you to PWM the LEDs by the Arduino.

I am not sure I have one of those...probably a few p-channel...but I'll admit I never tried mosfets...yes I feel the shame... :-[
but to my defence I don't have too much free time to exercise my passions...the work...the wife...the kids...(and yes my wife and kids are also a passion...she can read you know ;))

anyway with such nice replies I feel the need to do some homework...first trying to understand what Ian.M wrote...it won't be easy...like a child trying to speak to an engineer ;)
and next checking if I can't find a n-ch mosfet somewhere...i have a lot of recup stuff...and then read a lot I guess + some experimentations

could you write me a note for my wife ;D
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Re: A simple relay doubt
« Reply #9 on: September 06, 2017, 05:35:42 pm »
To help understand my comments above, take a look at page 6 of the OnSemi 2N3904 datasheet   

Figure 15.Normalised DC Current Gain shows how the large signal current gain varies with collector current.  Normalised means its plotted as a fraction of the peak HFE (DC current gain), so if you want to put some actual numbers on it, the 25 deg C curve reaches '1.0' on the vertical axis at about 8mA Ic, which is near enough the 10mA Ic quoted in the ON CHARACTERISTICS section on page 2, so the minimum peak HFE (worst transistor) will be 100 and the maximum (best transistor) will be 300.  It also shows you how the DC gain falls off at high or low currents or at low temperatures, which is typical for most BJTs (bipolar junction transistors) .   A graph like this is found in most datasheets.

The next graph - Figure 16. Collector Saturation Region is not a common one, but its very useful if they provide it.  It shows you the voltage drop for various fixed IC as you vary Ib.  As I previously pointed out if you don't have enough base current, the voltage drop rises rapidly as the transistor starts to come out of saturation*.

The final graph of interest is Figure 17. “ON” Voltages.   This is plotted for a 1:10 Ib:Ic ratio and lets you predict the base voltage, and thus the drop across the base resistor, giving you the avaible base drive current, and the Vce drop to expect at the corrisponding 10x higher collector current.

You may also find Sparkfun's Transistor Tutorial helpful as it goes into BJT usage in some detail but still manages to avoid the heavy maths.

could you write me a note for my wife ;D
Just copy this out in your own handwriting and sign it:
Quote
Dear .......
I promise you time support and funding for your hobbies equal to that spent on my electronics hobby.
>:D

* Saturation is when the transistor is turned on hard enough for tVce to be less than Vbe, and is desirable for a low loss power switching application, but should generally be avoided if you need very fast switching.
« Last Edit: September 06, 2017, 05:47:43 pm by Ian.M »
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 12298
  • Country: au
Re: A simple relay doubt
« Reply #10 on: September 08, 2017, 04:25:10 am »

could you write me a note for my wife ;D
Just copy this out in your own handwriting and sign it:
Quote
Dear .......
I promise you time support and funding for your hobbies equal to that spent on my electronics hobby.
>:D

That would take a brave man.....
 

Offline alectoTopic starter

  • Contributor
  • Posts: 21
Re: A simple relay doubt
« Reply #11 on: September 08, 2017, 11:01:08 am »
That would take a brave man.....
in my own handwriting...no too risky...I won't be able to deny... ;)
and to quote somebody else..."she who must be obeyed" must be obeyed...

anyway thank you Ian.M for the explanation....this WE I have a bit of time ahead of me....so a lot of lecture...a bit(or a lot) of bjt testing...probably a few stupid questions.....
and then I'll have to replace the relay with a N-Mosfet...because after all I have some of those...(and actually no P-Mosfets...  :palm:)
IRF540 / IRF510 / IRF634 / AP20T03 / 2N7000 / P55NF06 / VN10KN3 / BS170 ...a bunch of datasheets to read...err decypher I mean :o ...to find a suitable one
finally quite a bit of work...and since my wife 's not at home...a little bit of this :popcorn: and a little bit of that  :=\ and surely a lot of  |O
 

Online madires

  • Super Contributor
  • ***
  • Posts: 7765
  • Country: de
  • A qualified hobbyist ;)
Re: A simple relay doubt
« Reply #12 on: September 08, 2017, 11:38:46 am »
If you want to use a MOSFET with a V_GS roughly around 10V you're going to need a driver. Or use a logic level MOSFET which can be driven directly by a 5V MCU.
 

Offline alectoTopic starter

  • Contributor
  • Posts: 21
Re: A simple relay doubt
« Reply #13 on: September 09, 2017, 04:32:00 pm »
ok it is time for some stupid questions...

first a few assertions

1° 2N3904 has a HFE between 100~300 if Ic =10mA
2° 2N3904 has a HFE of 60 if Ic =50mA
3° Ic = HFE * Ib
4° the coil of my relay needs about 40mA to pull in at 12v

then my deduction (probably wrong)...

Let's say that with a current of 50mA I am sure that the coil will pull in....
 
Ib@60HFE =0,05A/60 =0,00083A or 830µA

so the base resistor could be

R =V/I = (5v-0,7v)/830 µA = 4,3/0,00083 =5180 \$\Omega\$

=> about 5K

Am I completely wrong here?is there something else I should take account of?

PS sorry Ian.M...I tried to understand your explanations and if sometimes I kind of get it....most of the time I'm just |O ...
to be honest figure 16 is a complete mystery to me :scared:

PPS if you think I am too much of a beginner...don't hesitate and tell me...
I just feel I need some human help here...reading is not enough...I need a eureka moment with transistors

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Re: A simple relay doubt
« Reply #14 on: September 09, 2017, 08:55:41 pm »
"2° 2N3904 has a minimum HFE of 60 if Ic =50mA"
You must remember that those figures are limits, beyond which the transistor doesn't meet spec. as a 2N3904 and shouldn't have made it out of the factory marked as one.   However unless you want to be *REALLY* *STUPID* and f**k about with 'select on test' till it works*, you do have to design to the worst case specs, for each limit determining whether the worst case is the minimum or maximum value.   Sometimes we extrapolate from the specs for a prototype or small scale production with reasonable confidence that failure to meet our extrapolated spec will be caught by testing, but if you are doing anything high reliability or for volume production, that can bite you in the ass.

So @Ic=50mA it *probably* has more gain, maybe up around 120, or even as high as 180 as the 3:1 ratio at 10mA indicates the gain isn't tightly controlled. 

Your base resistor calculation is OK if you have actually measured the gain and don't care about saturation.  However that's 'select on test' territory, and as you are already here asking for help understanding BJTs, I *KNOW* you aren't that stupid.  As NOT STUPID, you will of course round down to 4K7 not up to 5K6.  It will probably have enough excess base current, and an outlying HFE 180 (estimated) device would have well over 3x excess base current so would be well into saturation.

However the low gain outlier of a HFE 60 (spec) transistor wont have enough margin, and here's why:     

Lets look at fig. 16 and consider 10mA IC load current for a bit (as we don't have a curve on fig 16 for 50mA, and have limiting values for the HFE @10mA),  you will see its left saturation if the base current is below 0.085mA and the knee of the curve is at about 0.095mA.  Unfortunately we aren't given a number for the typical HFE the curve was plotted for but as all the other HFE values we were given were aat Vce=1V and the fig 16 graph goes up that high we can take Ib @ Vce=1V from the graph and calculate it: 10/0.08 gives typ. HFE of 125 @Ic=10mA.  That's quite a surprise how heavily biassed it is towards the low end of the permitted HFE range.
Looking at the 30mA curve, the knee is at about 0.45ma and at 1V its about 0.36ma, so the excess required to get below the knee is 25%,  and similarly for the 100mA curve 4.3mA and 3.0mA shows it needs 43% excess base current.    Its fairly obvious that providing 2x the base current will always get you below the knee and properly into saturation at 25 deg C hence the formula I gave earlier Ib>2*Ic/HFE_min
[/quote]

Ideally we'd design to a forced beta of 10 (Beta is the *old* name for HFE and a forced beta is the ratio of Ic to Ib you decide to provide to ensure its saturated), as that will guarantee saturation over the full temperature range with any 2N3904, but assuming you are short of MCU output current, the highest forced beta we could tolerate would be HFE_min/2.

Re-running the calc for a forced beta of 10:
Ic=50mA, Vbe=0.85V (from fig.17), and Voh=4.55V (extrapolated from ATmega328P datasheet, assuming Vcc is 5% low)

Ib=Ic/forced_beta=50mA/10=5mA

Vrb=Voh-Vbe=4.55V-0.85V=3.7V

Rb=Vrb/Ib=3.7V/5mA=740 Ohms
Next lowest E12 preferred value is 680 Ohms

Rerunning it for a forced beta of 30 (HFE_min/2 @50mA Ic):

Ic=50mA, Vbe=0.8V ('guesstimated' from fig.17), and Voh=4.7V (assuming Vcc is 5% low)

Ib=Ic/forced_beta=50mA/30=1.67mA

Vrb=Voh-Vbe=4.7V-0.8V=3.9V

Rb=Vrb/Ib=3.9V/1.67mA=2340 Ohms
Next lowest preferred value is 2.2K

My original suggestion of 1K is between these two values and biased towards the lower one.


Going back to your understanding of fig.16: 
Take a PSU with an accurate current limit (or rig a current limiter or current source of some sort that can cover the range 1mA to 100mA).
Keep the max voltage available from the current source down to a few volts as we are only interested in the region below 1.0V.

Take a box of 2N3904 transistors and a transistor tester, set its test Ic to 10mA  and select one with HFE of 125 - a truly average device.
Hook it up on a breadboard with the emitter grounded and the current source feeding the collector.    Set up to provide an adjustable base current in the range 10uA to 10mA - a variable voltage supply and a series resistor going up in decade steps would be the easiest option.

Take 3 multimeters - one for base current, one for collector voltage,  and the last for collector current (so you can be certain your current source is delivering the correct current), and wire them into the circuit and you can start plotting each curve.  If you've got an EEVblog uCurrent, the base circuit would be a good place to use it.

First set Ib to the leftmost point on the curve, then increase the collector current supply till it reaches the current marked by the line you are plotting, and then readjust Ib.   Read Vce and Ib, plot them then decrease Ib to the next division on the graph paper, check Ic hasn't changed and repeat till Vce reaches 1.0V.  That's one curve done.  Reset Ic to the next curve and repeat till you've got them all.  For the 100mA curve you should switch off and let the transistor cool in between readings. That's your whole afternoon gone reproducing one figure in the datasheet.   

A similar rig can be used for the 25 deg C line of fig.15 and for fig.17 though fig.17 needs an extra High impedance voltmeter to monitor Vbe.
More practically you can get these sorts of plots from a curve tracer.   Analog curve tracers consist of a ramp generator that controls a voltage or current source (selectable) over a preset range, + a circuit to measure the resulting current or voltage (again selectable) at the same or another terminal of the device.  Additional fixed voltage or current sources are typically required to bias the device (e.g. at fixed Vce or fixed Ic or fixed Ib etc.) for the desired curve.   The ramp generator and the measured result converted to a voltage are applied to a CRO in X-Y mode to plot the result.  If the ramp is slow enough its also possible to plot it on a chart recorder, but then one assumes the ramp is linear with respect to time.  Another 'cheat' is if your CRO has a timebase (X axis) ramp output on the back panel - then you can skip the ramp generator, let the timebase free-run and just scale the output with an OPAMP to drive your D.U.T.    Another refinement is to add a crude 3 bit DAC to sweep one of the 'fixed' sources.  Increment the counter driving it after every ramp and you'll get eight curves on the screen as that source is stepped.

Nowadays you are better off with a digital curve tracer.  It has a job lot of DACs, ADCs and scaling circuits, and pulses the device on only long enough to take each measurement so it doesn't heat up and shift the results.  Output gets logged to a file and can be plotted on your PC.  Google: Arduino curve tracer for some ideas on how you could build one.

* Occasionally 'select on test' is NOT STUPID e.g. when it lets you get away without a *MUCH* more expensive part, and you are certain that voltage and temperature variations wont throw the carefully tweaked circuit out of operation, but you'd better figure in to the costings your cost per hour, so if you are only saving a few bucks you are back to stupidity. 
 

Offline alectoTopic starter

  • Contributor
  • Posts: 21
Re: A simple relay doubt
« Reply #15 on: September 10, 2017, 08:57:36 am »
first of all, I can't be thankfull enough for the time you spent to explain me this... :-+

unfortunatelly I have to stop now because the wife is about to come home....and I don'have to explain  why I have to put her on my top priority list....first because I'm afraid ;)...and more so because...well... she's my wife and I love her ( I repeat she can read ;) )

So even if I didn't had  my eureka moment yet...reading you gave me some "aaaah" moments....I understand the 'select on test' limitations and the necessity to take in account the worst case specs...
BTW I did round down to 4.7K... ;) even though I understand now a 1k would have been better(your calculated demonstration was ideal to make me get it)...I hope you don't mind that I didn't use one right after you first told me to...I read a few articles and tried to get it my own way...wich wasn't the best way...I know
Now I look at fig. 16 and it is not as "hieroglyphic" as it was yesterday...another of the "aaah" moments...

I don't have (yet) a proper PSU with an accurate current limit...but I have seen in the datasheet of the LM317(I think) circuits for simple current limiter...wich, I believe, in serie with my ampmeter could prove usefull for lack of anything better at the moment....
I'll think seriously about purchasing an EEVblog uCurrent...I see the point...and a third multimeter...man it isn't the cheapest hobby... :o
thank you also for the idea of the curve tracer...I did google "Arduino curve tracer" and I am more than motivated to build one(even improve one) and surely program it myself...because I like that...and also because I know I learn more by writing my own libraries than to just copy/paste existing ones....without forgeting the hobby part of it too ^-^

anyway my work is settled... (<==hope it's english) THANK YOU again...i feel I never been so close to finally understand, more in depth, the bjt...that strangely complicated little beast  ;)
an MCU is so much easier to understand than those I think...maybe the 400+ pages of datasheet...who knows  ;)

Have I already thanked you?? well...thank you  ^-^
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Re: A simple relay doubt
« Reply #16 on: September 10, 2017, 11:31:46 am »
A LM317 configured as a current source cant go below 5mA, its minimum load current and remain stable.  However for 10mA up to its current limit it will work nicely.   

For lower currents you can use a JFET with a resistor between its gate and source.  It can only deliver a maximum of its Idss, which is not well specified, so its 'select on test' territory (OK here as the alternative would be a $$$.$$ bench supply).  e.g. a 2N3819 has its Idss specced as between 2.0V and 20V, and its pinch-off (or cutoff) voltage Vgs_off specced as max 8.0V   You can measure Idss and Vgs_off quite easily.  Take the circuit below and replace R2 with a short.  Ramp up the supply voltage till the current stops rising and then 50% more (or to whatever voltage was specced for Idss), and measure it.  Vgs_off is also quite easy - replace R2 with your DMM on volts.   It will read slightly under the true pinch-off voltage because a few hundred nanoamps will pass through your meter's 10Meg input impedance, but its near enough.  Its difficult to calculate the current source current even with those parameters measured, but I will be more or less proportional to 1/R2, so put a pot in and twiddle it!

The final easy option is a BJT and a single cell battery to bias the base.   There is 1.5V - Vbe across R3 so its pretty easy to work out the expected current.  It does have a few flaws - if you reduce the supply below about 1V the b-c junction becomes forward biassed and it starts passing reverse current.  Also the battery then has to supply all the current through R3, so disconnect the battery before switching the main supply off.    You can use just about any transistor including a spare 2N3904, and in normal operation the battery only sees the load current divided by HFE so an AA cell wont discharge significantly over the course of a bench session.



A uCurrent reduces the burden voltage for low current measurements.  Its by no means essential but it does make a lot of measurements easier and allows a cheap multimeter (or even a Harbour Freight 'free' seven function multimeter) to read current down to picoamps.

I wouldn't trust a really cheap multimeter for a lot of things, but if all you are measuring is DC voltage under 50V on a breadboard, don't care if the input impedance may be less than the normal DMM 10 Meg, and you have a better quality multimeter to check it against, then just about any sh!tty DMM will do.  It only needs to be stable, repeatable, and within the same small percentage of the good DMM when spot checked at the upper limit, middle and lower limit of the voltage range you are interested in.
« Last Edit: September 10, 2017, 12:25:39 pm by Ian.M »
 

Online madires

  • Super Contributor
  • ***
  • Posts: 7765
  • Country: de
  • A qualified hobbyist ;)
Re: A simple relay doubt
« Reply #17 on: September 10, 2017, 11:52:51 am »
For lower currents you can use a JFET with a resistor between its gate and source.  It can only deliver a maximum of its Idss, which is not well specified, so its 'select on test' territory.

There are also CLD/CRDs, for example 1N5283 - 5314.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf