Need help controlling an electromagnet with the arduino

I need a good way to turn a coil on/off with a 15ms delay.

I tried using a transistor, which turned out to be a mistake because I fried it. I believe this was either due to the current of my 9 volt battery or the voltage spike from turning the copper coil off. The transistor was rated at a max of 20v, so that was fine, but it was likely the spikes or the amperage.

The key is that I need to do it fast, so something like a relay would not work. If anyone has any advice, please let me know.

arduino_x:
Did you have a flyback diode connected "backwards" across the inductive load as shown (just as an example) here?

I didn't. Do you think that caused it?

arduino_x:
Let's say I wouldn't be surprised. The spikes from inductive loads turning off are huge.

Wikipedia explains all.

Thank you. This is spot on. Definitely my issue. I'll get to the reading.

What transistor were you using? Is this a DIY electromagnet, like you're literally just shorting out a power source around a wire you wrapped around something?
Because if that's the case, the flyback isn't going to fix a thing when you have much larger problems like current draw in the proper direction. Worry about that before you think back current is an issue.

arduino_x:
Did you have a flyback diode connected "backwards" across the inductive load as shown (just as an example) here?

Very bad example.
Amazing what students are allowed to post under the name of a university.

The base of that TIP120 could draw (5 - 1.25) / ~25 (estimated pin resistance) = 150mA from the Arduino pin.
Enough to fry it.

The resistor should be between pin and base, not from pin to ground.
Resistor value should be between 220ohm and 1k, depending on collector current.

A 9volt smoke alarm battery is no match for a solenoid.
Leo..

xrex64:
... I tried using a transistor, which turned out to be a mistake because I fried it. I believe this was either due to the current of my 9 volt battery or the voltage spike from turning the copper coil off. The transistor was rated at a max of 20v, so that was fine, but it was likely the spikes or the amperage.

The key is that I need to do it fast, so something like a relay would not work. If anyone has any advice, please let me know.

You know the motor isn't gonna react instantaneously either, right?

You most likely blew your transistor (and ...) because it wasn't hooked up right. Look at ardino-x's link, and then apply Wawa's correction (manditory!) and power your motor that way.

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Including you power supply.
What sort of 9V battery are you using?

Thanks. Tom.. :slight_smile: