Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by WBS00001!

Controlling An Electromagnet With An Ez-Bv4

Hello!

I am wondering if it is possible to control an electromagnet with an ez-b. All I would need is to turn it on and off. The electromagnet I would use would just be a simple iron nail wrapped in insulated copper wire. How would I go about connecting this to the ez-b so I can control it?

Thanks!

#1  
Use the EZB(4) to operate a relay. The relay would close a contact to connect the battery to the wire wound nail circuit.
#2  
You will want to power it seperatly from the EZ-B and have the EZ-B act as a switch. You can make a simple and cheap TIP 120 transistor switch, or probably handle a little more voltage with a relay depending on how powerful you want your magnet to be. As a kid I made the type you are describing with 6v lantern batteries that would pick up washers and other small metal bits.

For a simple TIP 120 circuit, see this thread http://www.ez-robot.com/Community/Forum/posts.aspx?threadId=3050 unfortunately there is a lot of nonsense from a now banned former member polluting the discussion, just read the posts by Rich.

Several users utilize this relay, which is comparable in price to the parts you would need for a TIP 120 and is plug and play: http://www.robotshop.com/en/electronic-brick-5v-relay.html

Alan
#3  
Thanks @Robot-Doc and @thetechguru, I'll try those out!
Could I use the 7.4V LiPo battery that would power the ez-b to power the electromagnet as well or would I have to use a separate battery?
#4  
I would strongly recommend using a separate battery for the electromagnet . Using same battery would cause noise and interference to the EZB.
#5  
OK, so I think I'm going to use the Electronic Brick 5V Relay that Alan suggested. I quickly drew out a circuit diagram of how I'm going to hook this thing up. I've only done one class in circuits, so I'm not sure if this is right. The shaded part is the Relay board.
User-inserted image


Also would a 9V battery work here? It would be nice to use a 9V since they have those connectors.
#6  
Alright, thanks
EDIT: I do not know how this got below my previous post with the circuit diagram.
United Kingdom
#7  
That will work. EZ-B connects to the Relay board - Ground to Ground, Vcc to Vcc, Signal to Data.

When enabled the relay will close across COM and NO which will complete the circuit. When disabled it will open across COM and NO which will break the circuit.

Provided the electro magnet doesn't require any resistors etc. and works fine with the supply given there will be no problems.

A TIP circuit would also work (as Alan suggested) but if you have no or little experience and don't have many components the relay board probably works out cheaper and better.
#8  
I don't think 9v batteries provide enough amps for anything but a weak magnet, and if they do, it won't last long. Not my area of expertise, the last one I made I was maybe 12 years old (an embarrassingly long time ago), but their should be plenty of info on the Internet. Get the magnet working first, then wire in the relay to have EZ-B control it.

Alan
#9  
When dealing with inductive loads (which is what your electromagnet is) in a DC circuit, it is best to place a diode across the coil as shown below:

User-inserted image


This is often called a "flyback diode" and will prevent arcing between the contacts of the relay when it opens, as well as, suppress transients (voltage spikes) in other parts of the circuit. Since you are using a separate 9V supply for the magnet, that should not be much of a problem for the EZB4, but a large spike can cause electromagnetic pulses to be induced into other circuits as well.

The size you will need would be determined by the current flow going into the electromagnet when in operation. As a rule of thumb, the current capability of the diode should be at least the same, and the voltage would be based on the voltage of the power supply (9V in this case).

It's impossible to advise you on the proper size needed since I don't know the current flow. However, a 1N001 will probably do. A 1A ,1N007 would be a pretty safe bet but larger size. Neither costs very much. Connect the diode as close to the electromagnet as is feasible. Be careful to observe the polarity as indicated in the diagram above (reverse biased).

To know if the diode is working a simple test is to look at the contacts of the relay without the diode in place and see how much arcing there is when the relay opens. Then see what it is with the diode on place. Using a flyback diode will also extend the life of the relay contacts. Be sure to actually solder it in place when you are happy with the location. Simply wrapping the leads of the diode will not always provide proper protection. Especially later on as oxidation builds up between the diode leads and the wire.

As an FYI, a small capacitor can give you much the same protection when using an AC circuit. Also, this same problem can occur when putting a relay in a circuit. The coil of the relay should have a flyback diode as well. The relay board you are about to use, however, probably already has one in it so that should not be a concern in this case.

There, probably more than you ever wanted to know. My fingers tend to get verbose. :D
#10  
Awesome! @WBS00001, here is the schematic of the relay itself.

User-inserted image


Am I correct in labeling the flyback diode? If that is the flyback diode then I wouldn't need to solder an extra one on like you suggested right?

Also would there be any way to prolong the battery life? The electromagnet is pretty much a short circuit so it would drain the battery extremely fast. Would putting a resistor between the magnet and the battery help?

Thanks!
#11  
To prolong battery life will require a battery with higher capacity. Adding resistance into the loop will only decrease battery capacity at a faster rate than just the electromagnetic coil resistance.
#12  
@Johnnybib
Very good. Yes, that is the flyback diode for the relay coil (only). I'm not sure if you understand, however, it will not protect you from your electromagnet's spike as well. You will still have to put in another one for that.

And yes, adding a resistor in series with your electromagnet will reduce the current flow to your electromagnet and prolong battery life considerably. Even 100 0hms can help a lot. If the electromagnet is considered a short circuit, then 100 ohms would limit the current to 9v/100 =0.09A =90ma. Of course the "pulling" power of the electromagnet will also be considerably reduced. The power that such a 100 ohm resistor would have to be able to handle in this circuit would be 9V x 0.09A =0.81W. So you would need a 1W resistor (at least).

The thing to keep in mind about electromagnets is the strength of the magnetic field is dependent on both the current flowing through it and the number of windings it has. The more windings, the greater the magnetic strength. Though that does not go on forever since the more the number of windings the greater the distance the outer windings are from the core. That weakens the magnetic field at the center. Magnetic strength falls off by the square of the distance so even a small change in distance can have a large impact on the strength of the magnetic field generated. That's why very thin wire is usually used for the windings. Of course such thin wire also limits the amount of current they can handle before burning out. There's always a trade-off.

Also, as you probably know, the electromagnet should have a metal core. Steel is often used. You want a core that will concentrate the magnetic field generated by the windings but not remain magnetized when the power is cut. It becomes a compromise.

Having said all that, you may be better off buying an electromagnet as opposed to making one of your own. These often have a much higher resistance than a home made one with many more windings. Usually the windings will have a high enough resistance so as to not need a series current limiting resistor, yet still provide a strong magnetic field. You can often find a such electromagnet in the core of a relay. That's basically all it is; an electromagnet which pulls in a switch. The core is selected so as to not retain a magnetic field when there is no current flow as well.

Such an electromagnet will also require much less power to run because you don't need a series resistor. You can get an idea of how much power that is by touching the resistor when in operation. It will be warm, maybe hot depending on the physical size of the resistor used. That's totally wasted power and will run the battery down sooner than need be.
#13  
Would this electromagnet give me the same effect as just the nail and wire? If I used this I would need a 12V battery then if I am correct.
#14  
Wait nevermind, I found this electromagnet! I could just plug this one straight into the i2c port of the ez-b.
#15  
The Grove electromagnet should plug into any of the ezb's digital ports. It's not I2C.... If it has a switching transistor on board then it should be plug n' play as long as you are using a 5V reg ... Toggling the digital port (high/Low) should turn it on and off... I mean, that's what it looks like how it works to me anyway.
#16  
OK, I was just assuming i2c because it had four pins but upon closer inspection I see the GND, VCC and SIG labels. There is also an NC pin. Would I have to split the PWM cable and connect only to the GND, VCC and SIG pins?
#17  
I am assuming NC means "No Connection" otherwise yes, you are using SIG, VCC and GRN only....
#18  
Alright, I guess this thread is solved now. Thanks for the help everyone! @WBS00001 I think you won in the helped the most category (although everyone helped a lot!) so I'm gonna say the question was resolved by you.