Solenoid Control

Dear all,
easy question today (I hope).

I would like to use a Solenoid with Arduino, something like this:

They say

To drive a solenoid you will need a power transistor and a protection diode, check this diagram for how to wire it to an Arduino or other microcontroller. You will need a fairly good power supply to drive a solenoid, as a lot of current will rush into the solenoid to charge up the electro-magnet, about 1 Amp, so be careful of trying to power/activate from a computer's USB.

So, a few things:

  1. what kind of transistor should I use? Would this be ok?
  1. So, I cannot power it from the USB? Because it looks like this is what they are doing. If not, what kind of external battery should I use?

  2. I would like to operate 2 solenoids at the same time. Can I just plug the second solenoid to a separate transistor/diode/battery?

Thank you all for your time

Gluce:
Dear all,
easy question today (I hope).

I would like to use a Solenoid with Arduino, something like this:
Mini Push-Pull Solenoid - 5V : ID 2776 : $4.95 : Adafruit Industries, Unique & fun DIY electronics and kits

They say
So, a few things:

  1. what kind of transistor should I use? Would this be ok?
    TIP120 Power Darlington Transistors - 3 pack : ID 976 : $2.50 : Adafruit Industries, Unique & fun DIY electronics and kits

It has to handle 5V and 1.1A, so this completely rules out simple BJT's which don't have
enough saturated current gain to drive 1.1A from an Arduino pin. (Saturated gain is about
10 to 20 for a single BJT).

A darlington has enough current gain, but will lose 1V or more, so will need a 6V supply or so,
and may need a small heatsink.

A logic level MOSFET with 0.3 ohms or less on-resistance will be perfectly fine.

The TIP120 from a 6V supply and with 1k base resistor would be fine, remember the Arduino 5V
rail cannot provide enough current anyway so a separate supply for the solenoid is needed.

  1. So, I cannot power it from the USB? Because it looks like this is what they are doing. If not, what kind of external battery should I use?

6V or 7.4V capable of 1.5A or so?

  1. I would like to operate 2 solenoids at the same time. Can I just plug the second solenoid to a separate transistor/diode/battery?

Separate transistor and diode, but why not use the same battery and ensure its powerful enough (3A
capable)

Thank you all for your time

Thank you very much for your response.

Let me see if I understand:

t has to handle 5V and 1.1A, so this completely rules out simple BJT's which don't have
enough saturated current gain to drive 1.1A from an Arduino pin. (Saturated gain is about
10 to 20 for a single BJT).

So, if I understand, TPJ's are these ones

right? So, We can rule them out. Ok.

A darlington has enough current gain, but will lose 1V or more, so will need a 6V supply or so,
and may need a small heatsink.

I don't know much about the heatsink. How would I do it?

A logic level MOSFET with 0.3 ohms or less on-resistance will be perfectly fine.

The TIP120 from a 6V supply and with 1k base resistor would be fine, remember the Arduino 5V
rail cannot provide enough current anyway so a separate supply for the solenoid is needed

Hmm, ok, so bottom line I can use the TIP120? Otherwise, could you suggest me one? What would you use?

6V or 7.4V capable of 1.5A or so?

Would this work? https://uk.rs-online.com/web/p/products/7174029/?grossPrice=Y&cm_mmc=UK-PLA-DS3A--google--PLA_UK_EN_Batteries--Non-Rechargeable_Batteries%7CSpeciality_Size_Batteries--PRODUCT+GROUP&matchtype=&aud-360874231623:pla-437881069326&gclid=CjwKCAjwio3dBRAqEiwAHWsNVbJB5-kME69Yd-olpEmlh4XZxMPEfTU3lopYUh5zjTST4ZEHotBy2hoChWYQAvD_BwE&gclsrc=aw.ds

Otherwise, could you suggest me something?

Separate transistor and diode, but why not use the same battery and ensure its powerful enough (3A
capable)

If I connect two solenoids to the same battery and turn them on at the same time, wouldn't I need more Volts to power both the solenoids?

Sorry, I know these are stupid questions, but this is really not my field. I need to do this and I am trying to learn...

Sorry, I put the wrong link to the battery:

https://uk.rs-online.com/web/p/products/0596062/?grossPrice=Y&cm_mmc=UK-PLA-DS3A--google--PLA_UK_EN_Batteries--Non-Rechargeable_Batteries%7CCamera_Batteries--PRODUCT+GROUP&matchtype=&aud-359121783329:pla-394243212383&gclid=CjwKCAjwio3dBRAqEiwAHWsNVRZQNNrD_8Zv93rqQnmorQYJdBQHtqrbSkWQ-IY59QFzBXV7_RdP-BoCT5oQAvD_BwE&gclsrc=aw.ds

Also, I think I figured out the thing about the heat sink:

Would this work?


https://uk.rs-online.com/web/p/heatsink-mounting-accessories/7128225/

It was also suggested by adafruit:

Also, it looks like they suggest

  1. a TIP102. There are many types of TIP102. Would this work? https://uk.rs-online.com/web/p/darlington-transistors/8080489/

  2. for the diode, a MUR340
    I can't find one online. Do you know where can I buy one of these?

Finally, the thing left to understand would be the type of battery to use...

a mosfet along with a flyback diode is by-far the best solution here. they will more than handle the current and can be driven straight off an arduino pin.

you may have trouble running this off USB if you want to operate both solenoids at once. That would be >2.2A. But you should be able to easily find a cheap wall-wart type power supply that could handle this. Unless you require this to operate outdoors away from available wall-power, I would discourage the use of batteries. Just find yourself a properly rated 5V power supply.

Also, to drive both solenoids simultaneously, yes you could use two mosfets, each with their own diode, each attached to its own pin. Or you could just attach both solenoids to the same mosfet in parallel with each other.

These mosfets on ebay are literally the first ones to pop up when I do a search for "mosfet," and they will be more than adequate for what you're doing. They have a Gate Threshold Voltage of 2.0V, and 8 mOhm on resistance, and can handle more amps than you'll be able to supply it reasonably.

Hi silly_cone,
thank you so much for your reply.

I don't want to take too much advantage of your time but, if you can, could you also suggest me a diode and a wall-wart power supply? I really don't know much about it.

Is it something like this:

https://www.sparkfun.com/products/12889

P.S.
For the diode, they suggest either the 1N4004 or MUR340.
I have not been able to find the MUR340.

As for the 1N4004, there are many types on RS. Can I just use any of those?

[url=https://uk.rs-online.com/web/c/?sra=oss&r=t&searchTerm=1n4004[/url]

Gluce:
If I connect two solenoids to the same battery and turn them on at the same time, wouldn't I need more Volts to power both the solenoids?

No. What you're setting up here is a parallel circuit. Each solenoid will see the same voltage from the P.S. One terminal of each solenoid connected to the power supply and the other terminal of each connected to its own transistor switch. Very similar to your house wiring. You could run a dozen solenoids connected like this if the P.S. has sufficient *current *capacity for that many loads.

That sparkfun link didn't work, but here's one of their 5V, 4A power supplies that would give you plenty of current for what you're doing. If you shop around, you'll probably find a better price by half, I would think.

And these diodes would be an option for flyback protection.

Great, thank you so much.

Can I ask you one last question (hopefully ^^ sorry again to bother).

The power supply you sent says: 5V output at up to 4 Amps (4000mA)

Isn't 4 Amps a bit too much? Can it be controlled with that circuit (that is, with the IRF3205 MOSFET and a 1N4004 Diode).

Also, should I use one of these converter: https://www.adafruit.com/product/1328 to connect the solenoid to the power supply and power the Arduino through the USB as usual? Or should I power the arduino as usual using the power supply you suggested?

By the way,
let me try and send again the one on sparkfun:

once I manually copied and pasted the links they worked. That power supply you posted is only 2A. If you only intend to drive one solenoid at a time that will work, and it might work okay for two. But you'd be maxing it out, and it may cause your solenoids or arduino to behave strangely when it can't quite keep up. With power supplies and current, you always want to have more current capacity than expected demand, as the components will only pull as much current as they need to run. So you want an overhead.

If you get the 4A power supply, then you can run the arduino and the solenoids off it together. How you go about connecting them will depend on the connectors on the solenoid you actually get and personal taste. Some solenoids have spade connectors, others use JST, others pigtails, and on and on and on. I like to keep a healthy stock of DC barrel adapters on-hand for exactly these purposes.

If you haven't bought a breadboard yet for prototyping, you definitely should invest in one. They're only a few bucks and will simplify your testing.

That power supply you posted is only 2A. If you only intend to drive one solenoid at a time that will work, and it might work okay for two. But you'd be maxing it out, and it may cause your solenoids or arduino to behave strangely when it can't quite keep up. With power supplies and current, you always want to have more current capacity than expected demand, as the components will only pull as much current as they need to run. So you want an overhead.

Ok, I see. I thought that you could not have more amps than needed otherwise the circuit would fry. Now I understand.

If you get the 4A power supply, then you can run the arduino and the solenoids off it together. How you go about connecting them will depend on the connectors on the solenoid you actually get and personal taste. Some solenoids have spade connectors, others use JST, others pigtails, and on and on and on. I like to keep a healthy stock of DC barrel adapters on-hand for exactly these purposes.

The solenoid that I am going to buy is this one:

I have used breadboards for several projects. So, say I connect the power supply you posted to the barrel of the Arduino. Then I connect the 5V pin of the arduino and the ground to the power and ground of the breadboard. Then I connect the power and ground of the solenoid to P and G on the breadboard. Would that work?

silly_cone:
These mosfets on ebay are literally the first ones to pop up when I do a search for "mosfet," and they will be more than adequate for what you're doing. They have a Gate Threshold Voltage of 2.0V, and 8 mOhm on resistance, and can handle more amps than you'll be able to supply it reasonably.

Absolutely wrong.

The threshold voltage is not relevant here. You need a logic-level mosfet, and the IRF3205 is not logic level.

The gate threshold is nothing at all to do with using a MOSFET as a switch, forget it, go straight to the
"on resistance" rating in the datasheet and see what value(a) of Vgs is quoted - that's the gate drive
voltage needed to turn the device on, and typically will be 4.5V for a logic-level device, or 10V for a
non-logic level device.

The threshold voltage is the point the device turns fully off, not on, and is very much less
than the Vgs needed to turn a device fully on, typically 3 or 4 times less. And also note the IRF3205
has a threshold voltage of between 2 and 4V, depending on manufacturing variations, so if
your device happens to have a turn off threshold of 4V how poor it will be at 5V.

Thanks for correcting that, I was clearly mistaken. :-[

Is there another name for the value at which the mosfet turns fully on, or is VGS under RDS(on) generally the best place to find it?

And just to clarify, the relationship of voltage at the gate and current through drain is given in Figure 3 on the datasheet, correct? If I'd have taken 3 seconds to look at that, I could've saved myself some embarrassment, and saved the OP bad advice. :confused:

Not trying to confuse you but my solution is to use an Arduino relay module, like this

There are quite a few different types so you choose.

Also, I was wondering if your solenoid was 12volt as most I have encountered are. If so, you will need a power supply that matches the solenoid voltage.

I have to say: I am a bit confused by at this point T__T
First, thank you all for your comments.

Let's try and clarify:

  1. I would like to use this solenoid: https://www.adafruit.com/product/2776 It is a 5V.
    I would also like to try this one: https://www.adafruit.com/product/412
    This is a 12VDC. BUT, for the time being, I will be happy to just figure out the 5V. Once it works, I will also consider the 12V.

Not trying to confuse you but my solution is to use an Arduino relay module, like this

Probably a great idea but I have no idea of how to use one of those.

Absolutely wrong.

The threshold voltage is not relevant here. You need a logic-level mosfet, and the IRF3205 is not logic level.

So, I should go back to the TIP120 idea? As you (MarkT) were saying here:

A logic level MOSFET with 0.3 ohms or less on-resistance will be perfectly fine.

The TIP120 from a 6V supply and with 1k base resistor would be fine

  1. If I use this: https://www.adafruit.com/product/1466 as suggested by silly_cone, then can I just connect to the barrel of the Arduino? Probably that is not a good idea, right?