Scrap what I've got - lets get the right stuff.

In another post, I was looking to use some C106D1G or 2N2222A's for controlling larger V and A to other appliances that the output pins could not handle.

Why ? well, simply because I already had these components.

But thinking about it, I think it would be wiser to use better components instead of trying to save a few cents.

So looking at other posts, I get the impression that I should be using a MOSFET, activated by the output pin ( with Resistor in series and a pull down resistor ) to control power to a 12V relay.

Please tell me if you see any flaws in this ( I need to go thru this learning curve ) :

I want to drive a small relay which, in turn, will activate a gates' magnetic lock or similar item (requires 12V 1A).
The relay spec is : N4078 2c 12v 0.2(w). 1A/125VAC. 2A/30VDC.

So my logic is :

  1. Relay can easily carry the current required by the end device.
  2. 0.2W / 12V = 16mA required to drive the relay coil.

So I need to find a MOSFET that I can drive with the output pin, and can easily handle 12V 16mA. Correct ?

Here's where the difficulty starts :
Our local supplier has stock of IRLZ44NPBF MOSFETs.

Unfortunately, I don't know what I am looking for on the datasheet in relation to :

  1. what V is required to fully activate the MOSFET.
  2. what A the MOSFET will draw from the output pin ( need to make sure it is within the specs for the board ).
  3. is there a minimum current that the MOSFET will pass from S to D ?
  4. what is the maximum that can pass thru the MOSFET ?

Once I know these values, I can highlight them on my datasheet (http://docs-europe.electrocomponents.com/webdocs/0791/0900766b807913d7.pdf) and learn the terminology used. Then if you don't think this is the correct component, I can go searching for something better ( and available ).

I'm trying to understand why you think you can't drive your small relay (N4078) with a 2N2222A.

driver3.jpg

Here's where the difficulty starts :
Our local supplier has stock of IRLZ44NPBF MOSFETs.

That is a fine LOGIC level Mosfet and it will do the job. However it's overkill to an extream for your use to pull in a 12v 16ma relay coil. That mosfet can handle up to 47amps (with proper heat sinking), and is most suited for switching large DC motors. A simple small signal npn bipolar transistor should be more then enough to handle the relay coil and should cost less then the mosfet. I would think it would be hard to find a npn transistor that can't switch that relay coil on and off.

Unfortunately, I don't know what I am looking for on the datasheet in relation to :

  1. what V is required to fully activate the MOSFET.

That is a little tricky to find on a datasheet. The Vgs(th) is called the Gate Threshold voltage and it tells you at what gate voltage the mosfet just starts to conduct. The Rds(on) spec tells you how hard the device will turn on at various gate voltages, in your example a +5vdc on the gate will result in a device resistance of just .025 ohms which is full on for all pratical purposes. There are also graphs in the datasheet showing drain current Vs different gate voltages. Again a logic level mosfet is perfect for interfacing to an arduino digital output pin.

  1. what A the MOSFET will draw from the output pin ( need to make sure it is within the specs for the board ).

The suprizing answer is that the gate will draw no current at all once it's fully off or on. The gate only draws current during the brief time it's transiting from on to off or off to on. A 300-500 ohm series resistor from the output pin to the gate will protect the output pin from the momentary current spikes during switching of the mosfet.

  1. is there a minimum current that the MOSFET will pass from S to D ?

No minimum current rating, it can assume full off to full on from 0-47amps for that device.

  1. what is the maximum that can pass thru the MOSFET ?

Yes, every mosfet will have it's own specified maximum current limit, your datasheet show Is (continous source current) of 47 amps, with proper heatsinking of course.

Once I know these values, I can highlight them on my datasheet (http://docs-europe.electrocomponents.com/webdocs/0791/0900766b807913d7.pdf) and learn the terminology used. Then if you don't think this is the correct component, I can go searching for something better ( and available ).

I still think to power a simple 12vdc 16ma relay coil, a simple small npn transistor is more in line. See if they have a 2N2222A or 2N3904, or really any small npn transistor. Just wire a 1k ohm resistor from the output pin to the base of the npn, wire the emitter to ground and the collector goes to one lead of the relay coil and the other relay coil terminal goes to +12vdc. Be sure to jumper a wire from the +12vdc supply negitive terminal to a arduino ground pin, and you should be good to go.

Lefty

I want to drive a small relay which, in turn, will activate a gates' magnetic lock or similar item (requires 12V 1A).

You can of course forget the small relay to directly control the mag lock (or whatever) with the FET.

The only reason I can see for having an intermediate relay is to make it a generic voltage-free output that you can hook pretty much anything to without worrying about voltage spikes etc.

Doing it this way keeps the FET connections short to a local relay, and the actual control wires (which may be long and prone to being abused) are connected to a relay that is very robust.


Rob

@pwillard -- thank you so much for such a detailed drawing. really appreciated.

@Graynomad -- Yes, I am running long 12V wires ( about 40 meters ) so wanting to keep that 12V circuit separated from the Arduino by the relay.

@retrolefty -- to you too, my sincere thanks for the time and effort you put into your reply.

I have looked at the 2N2222A and 2N3904.

The 2N2222A is almost the same price as the IRLZ44NPBF MOSFET ( R4.28 in my currency -- $0.54 ) whereas the 2N3904 is only 0.31c ($0.03).

My calc tells me the relay needs 5V 0.2W = 40mA. The 2N3904 can manage 200mA continuous and needs between 0.85V and 6V to saturate the gate, so doesn't require a resistor between the pin and gate, unless I want to drop the output-to-gate to about 2V using a 150ohms resistor.

The only thing which I don't seem to be able to find, is the A that the 2N3904 base will draw from the output pin ? Is it so small that is isn't even mentioned on the datasheet, or am I just not seeing it ?

The 2N3904 can manage 200mA continuous

That will be with a decent heatsink I would think, but at 40mA I think it would be OK in free air.

0.85V and 6V to saturate the gate

Transistors are current-driven, the voltage on the base isn't very important, basically you just have to exceed the effective diode drop of the Base/emitter junction IIRC.

so doesn't require a resistor between the pin and gate,

Yes it does, the BE junction is essentially a forward biased diode, without a resistor you have a short to 0.6V.

the 2N3904 base will draw from the output pin ?

That is controlled by the base resistor you have to have. If the transistor has a gain of 100 and you set the base current to 1mA then it will conduct 100mA. For simple switching applications there's normally no need to calculate stuff, just use some values from an example. The above schematic shows 1k, that's as good a value as any. 1k over say 4.4V (5v - diode drop of BE junction) == 4.4mA, so you only need a gain of 10 for the relays and any transistor will have that much gain.

Hope I'm right with the above, It's been some time since I thought much about transistors.


Rob

Thanks Rob

OK. I don't understand where you get the "short to 0.6V", "gain of 100", "1k over say 4.4V (5v - diode drop of BE junction) == 4.4mA".

However, maybe I have to stop trying to understand every detail ( until I have time to study at leasure ) and just go with the Guru's suggestions.

So either a 2N2222A or 2N3904, with a 1k resistor from pin to base as in the drawing earlier in the post, and a diode across the relay contacts.

I assume that a floating gate does not happen with a transistor like it does with a MOSFET, so no pull-down resistor required ?

Thanks again to all who have contributed to this.

OK. So now we've got the right stuff for the pin output side of things, to isolate the board from the 12V system of mag locks, etc.

Now for the input.

If I am feeding 12V to a bunch of sensors ( cables up to 50m in length ) and my board is waiting for a break of the ground signal, I assume it would be best to have the 12V circuit running through an optocoupler, with only a short isolated loop from the board ground to the input pin.

I have found the following online : CNY75GA

Can anyone tell me if this should be suitable, or what the preferred part should be, and any links to how this should be wired ?

Use this board ,it can drive till 4 chanels
Arduino 4 Route MOSFET Button IRF540N Free 4 cable

and a diode across the relay contacts.

Diode goes across the relay's coil, not it's contacts. Cathode end to the positive 12vdc side of the relay coil.

Lefty

Thanks Lefty

Yep, I meant to say the contacts for the relays' coil.

Appreciate you catching me. will teach me to try to use the correct terminology in the future.

elandd2011:
Use this board ,it can drive till 4 chanels
Arduino 4 Route MOSFET Button IRF540N Free 4 cable

Thanks elandd2011

At this point, I am trying to find a way to protect my board from damage in the input side.

Yes, I know that if I leave it in its box, it won't get broken, but then it wouldn't be a very interesting toy, would it.

Yep, I meant to say the contacts for the relays' coil.

Better to call them 'relay coil terminals', as 'contacts' have a specific meaning in context with relays. :wink:

Lefty

retrolefty:

Yep, I meant to say the contacts for the relays' coil.

Better to call them 'relay coil terminals', as 'contacts' have a specific meaning in context with relays. :wink:

Lefty

Thanks Lefty.

Now about the best way to isolate the boards' input pins from the 12V circuit around my house (magnetic door and window contacts) .....

Now about the best way to isolate the boards' input pins from the 12V circuit around my house (magnetic door and window contacts) .....

If you mean you have external switched +12vdc on/off signals that you want to wire to arduino input pins (digital or analog?) then you can use transistors or optoisolators or even two resistor voltage dividers. I would need to see a drawing of these system inputs to suggest the 'best' solution.

Lefty

What I plan is a series of magnetic contacts on the doors and windows of each room ( we live in a high crime country, and robbery & murder is, well, lets just say we don't get surprised any more ).

So I have 12V+ to a resistor and an LED showing the circuit is alive. Each closed contact in the room connected in series to the - contact on the LED. My logic is that any broken contact results in the LED going off ( as would any wires cut in the ceiling ) and the current stops flowing. It is at this point that the input pin on my board needs to detect that the current has stopped.

Due to the length of the cables, and the noise ( we on a hill - had 4 lightning strikes within 75m of the house in the last 6 months during storms ), I think I could use a 12V relay powered by the contacts circuit, with the relay contact connected to the boards ground and input pin. However, I would like it to be silent, and got the impression on the forum that an optocoupler ( same as an optoisolators ? ) would be the better option.

However, I would like it to be silent, and got the impression on the forum that an optocoupler ( same as an optoisolators ? ) would be the better option.

Sounds like optoisolators would be a better option as they are silent and still offer electrical isolation. They are generally a 4 terminal device. Two of the pins are the input side of the opto and they are an internal led, so it would wire in series with your existing led. You may have to lower the series current limiting resistor so that the same led current flows with the now two series leds in each circuit. The two output pins of most simple optoisolators are just a simple npn transistor without the base connection. The emitter wires to your arduino ground pin and the collector can wire directly to a digital input pin. You must provide a pull-up resistor between the pin and the arduino's +5vdc pin, but that can be done by just enabling the internal pull-up for the pin with software. A low reading for the digital input pin means there is current flowing in the external led circuit and a high reading means there is no current flowing. Note that you can get optoisolator ICs that have one, two, or four independent isolators in one package if desired.

Lefty

Hi Lefty

Thank You for the great explanation. I didn't even know about the existance of the simple npn transistor types ( without the base ). Sounds like the perfect solution for me to use.

Can you recommend any part numbers for me to use ? I wouldn't know where to start trying to filter thru the many different ones available.

ps .. is this the sort of thing I need .. ?

ps .. is this the sort of thing I need .. ?

Yes, that should work just fine.

Lefty