Solenoid diode

Hello,

I’m driving a relay through a transistor , which is driving a small 5v solenoid (http://www.sparkfun.com/products/11015). I’m powering the solenoid with a 4.5v battery separately from the arduino, which is powered by a USB cable. Do I need a diode for the solenoid? And if I need one , is the 1N4001 good for this purpose? Finally, how will I connect the diode?

Thanks

A 1N4001 will be fine. Connect it across the motor leads with the Cathode to the +5V supply (backwards). I would suggest using an n-channel MOSFET such as this http://www.sparkfun.com/products/10213 if the solenoid draws alot of current. Here’s an example of a simple driver. Maybe some capacitor filtering across the supply as well.

Thank you very much!
I found a 5v 2A psp power supply, and I managed to control the solenoid using that instead of the battery. Also, why do I need filtering with a cap ?

to stop any spikes feeding back to the rest of the circuit

Isn't the diode supposed to do that ?

it helps, but there's always more you can do!

And what can these spikes do to the arduino ?

Also, why do I need filtering with a cap ?

Increase the decoupling.
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Ok, I can understand it now. ( So, that's why we use a capacitor when we are driving a motor).
Thank you very much for your help!

Arduinoisawesome:
And what can these spikes do to the arduino ?

Well a big inductive spike vaporises parts of every chip on the board I'd guess.... Depends on the size of the coil and how much magnetic energy is has when you try and switch it off. So yes you always need protection when switching current to solenoids or non-trivial inductors.

Or even simpler things... like cause unexpected resets of your program.

Thank you pwillard and MarkT, very informative posts.
I have one more question. So, is the 1N4001 diode (without a capacitor) enough to protect my arduino from the inductive spikes that the small 5 volt solenoid creates? Also, what capacitor value would be ok for filtering the noise?

Thanks

A power rectifier like the 1N4001 is fine, if not a bit of overkill for a small 5V relay. Technically, you could get by with a small signal diode like a 1N4148 and be just fine.

As for Capacitors: it's all spelled out in the link already provided. De-coupling

Technically, you could get by with a small signal diode like a 1N4148 and be just fine.

A 1N4148 will be under-rated. According to the datasheet, and part #, the solenoid has a DC resistance of 4.5 ohms. With 5 volts, it will draw 1.1 amps. A 1N4148 is only rated for 200mA continuous with a 450mA surge rating. I would stick with the 1N4001.

A 1N4148 is only rated for 200mA continuous with a 450mA surge rating.

Yes but the diode does not have to take the continuous forward current of the relay it just has to cope with the back EMF when the voltage is removed. This will cause only a small spike which is likely to be within the current surge rating of the diode, especially considering the duty cycle involved. There are duty cycle considerations in that 450mA rating.

Thanks for your reply pwillard, and sorry for asking about the capacitor. I didn't see the values in the page.

Wbegg, I have plenty of 1N4001 diodes in handy, so I will use these. Thank you.

But if the back emf pulse of the solenoid is more than the 1N4148 450 mA rating?

Thanks

But if the back emf pulse of the solenoid is more than the 1N4148 450 mA rating?

Then you blow up the diode.

As I said in these circumstances the peak rating is likely to be well over 450mA.

Thanks grumpy_mike for your answer.

And thanks to all for your great help!