Driving solenoids. Please help

Hi, I need help with something probably is very simple for you guys.

I need to drive 2 solenoids (24vdc, 2 amps), Ive been looking for a software controlled driver and found this device which looks like the product i need. Can someone please show me how it is connected, I looked at the tutorials but couldnt find anything similar. I just need to drive solenoid 1 for less than a second, turn it off, wait 1 second, turn on solenoid 2 for less than a second, turn it off, wait 1 second then it cycles again

Can the unit drive the solenoids directly?.

The code for the blinking LED seems like it just needs to modified a bit for it to be used in this application.

All suggestions and info are very welcome.



You won't be able to drive the solenoids directly. The Arduino only wants to drive about 40mA at 5v and that is not enough current or voltage. What you are going to need to do is add a device that acts as a switch to turn the 24v power on and off and a path to absorb the big reverse voltage spike that the solenoid coil will create when you turn it off.

Following, I'm guessing from your question that you don't have much exerience with electronics at the component level. You are going to need to get some components and solder them together to build this. I'll describe the bits in enough detail that you can get them, but you will want to look at some sort of circuit building tutorial or better yet get someone who has done this sort of thing to help out.

I think in the interest of simplicity, you might be best using a single component for this. I won't sweat cost and will suggest a part that is many times too good. Get an IRF640, which is a kind of MOSFET transistor that costs under $1 US in single quantities. Get a couple spares too so you can make mistakes. It has three pins, there are 6 permutations for hooking it up, several of which may explode the transistor. Wear glasses. (For those following along, I avoided the darlington so it should be very difficult to explode.)

The three pins of the MOSFET are named "gate", "source", and "drain". Electrons live in the "minus" side of the circuit, the ground for you. That is your source. You let them out the "drain" (the plus side) by turning on the "gate". This may seem backwards to you, but it makes more sense if you remember electrons have a negative charge.

I will now describe your circuit in a thousand words for the lack of a picture. I assume you have a 24v power supply. Attach its ground (minus side) to the ground of your Arduino. You really need to share a ground. Attach a digital output pin of the arduino to the gate. Attach the source to the ground (of your power supply, don't make 2 amps run through the arduino board). Attach the drain to one end of your solenoid and the +24v to the other. Viola! You are done. Use wire at least the size of a pencil lead for the path through the solenoid and out the source. Any sort works for the rest.

Ok, I lied. There is one more part you want to have. Just in case your arduino is off and your +24v power supply is on you need to make sure that the MOSFET is either all the way on or all the way off or it could heat up and explode. A 10kohm resistor attached between the gate and the source should take care of this. The Arduino will easily overpower this when it is on and when the Arduino is off this will hold the MOSFET off.

One more caveat... Many people will be expecting a bypass diode around the solenoid, but I don't think you need one. The IRF640 should be able to handle the beating from the solenoid according to its spec sheet. That said... I'd put a diode in parallel with the solenoid so that it didn't conduct normally but would gently pass the surge when the solenoid is turned off. No sense tempting fate. I hesitate to explain the diode because if you put it in backwards then you are going to blow the fuse in your power supply at the very least. The diode has two wires, one end of the diode has a stripe. You want to connect the stripe side of the diode to the +24 end of the solenoid and the non-stripe end of the diode to the other end of the solenoid. Something like a 1N5401 would be a fine diode for this. On further though... since I don't know how much energy your solenoid stores, you'd better put this in. It is 10 cents well spent.

There was a nice one sheet circuit in the playground tutorials, http://www.arduino.cc/playground/Learning/Tutorials

I didn't realize that and did some experiments and added a rambling discussion of solenoid interfacing there as well.

Just a note for those who might skip the protection diode... I got 250V spikes on my test circuit without it and that was limited to 250V by a secondary protection circuit, it would have gone higher.