Controlling Electromagnets

Hi, I'm working on a project in which I am considering the use of small electromagnets as a method of actuation.

I was thinking of winding wire around a small machine screw with the ends of the wires connected to two pins on an ATtiny (running off a 3.3V LiPo battery).

Would I be able to control the electromagnet by pulling one pin LOW and the other pin HIGH, and vice versa to change polarity? Or would I have to create an H-bridge of sorts?

Would the electromagnet draw a lot of current? Would the electromagnet overheat if used for long periods of time? Any other advice on working with electromagnets?

Thanks

Your method will short out your IO pins and damage the uC.
Use an H-bridge of some kind, MOSFET-transistor or relay based.

GeckoDiode:
Hi, I'm working on a project in which I am considering the use of small electromagnets as a method of actuation.

I was thinking of winding wire around a small machine screw with the ends of the wires connected to two pins on an ATtiny (running off a 3.3V LiPo battery).

Would I be able to control the electromagnet by pulling one pin LOW and the other pin HIGH, and vice versa to change polarity? Or would I have to create an H-bridge of sorts?

Would the electromagnet draw a lot of current? Would the electromagnet overheat if used for long periods of time? Any other advice on working with electromagnets?

Thanks

Would the electromagnet draw a lot of current?
That depends on the size of the wire.
That depends on the length of the wire ( # of turns ).
If the pulses are short then the current will be limited.
But after a small amount of on-time the amperage will be quite large, due low wire resistance.

Would the electromagnet overheat if used for long periods of time?
Again,
That depends on the size of the wire.
That depends on the length of the wire ( # of turns ).
Most likely the wire will get warm and possibly very hot.

Back of the napkin numbers ...
If you wind 10 feet of 20 gauge wire on your electromagnetic
that will only be about 1/10th DC ohm.
Your electromagnet will draw about 33 Amps from the LiPo.
33 Amps is HOT.
Your Lipo will be dead after 6 minutes of continuous electromagnet on-time.

Magnetic Force = Amps x Turns

Mosfet's are a must, not an option.

I see. So I would use a circuit similar to this:

(of course with an electromagnet not a motor)

My electromagnet will be very small (due to size constraints), perhaps 10 to 15 wraps of 22AWG wire around a small machine screw. Would this have enough magnetic force to pull/repel a magnet a distance of about an inch? Could I control the current with a resistor?

Also, do I have to insulate the wire from the screw?

Yes, that looks like an appropriate circuit. It's a little trickier to build than the diagram indicates. It's usually best to buy an off-the-shelf motor controller. Sparkfun and Adafruit sell good ones.

The coils of wire on the screw must be insulated from each other. Otherwise the electric current will skip across turns instead of going around the long way. Use insulated wire. "Magnet wire" has a very thin coating of enamel or epoxy, usually a reddish colour.

The way to get more force is to get more turns. 100 to 150 would be better.

Don't be surprised if your DIY electromagnets are very weak. In my experience you need a very large number of turns or a very high current.

Consider buying your electromagnets. One source may be to break up small relays and take the coils from them. Other parts of the relay mechanism may also be useful.

...R

GeckoDiode:
My electromagnet will be very small (due to size constraints), perhaps 10 to 15 wraps of 22AWG wire around a small machine screw. Would this have enough magnetic force to pull/repel a magnet a distance of about an inch? Could I control the current with a resistor?

Also, do I have to insulate the wire from the screw?

10 to 15 wraps of 22AWG wire?
I think, you will need like 100 turns of 22AWG "Magnet" Wire
100 Turns x 6 Amps is about 1 Ounce of force
Or purchase a pre-made elctromagnet

Could I control the current with a resistor?
You "could", but you really would not want to.
Use PWM and the H-Bridge.

Thinking out loud ...
Why do you need a Full H-Bridge.
You could use PWM to control a Single Mosfet.
Use PWM and the Mosfet to limit the Amps through the wire.
22 AWG might be able to flow 6 amps without over heating
What is your ON-TIME?

Also, do I have to insulate the wire from the screw?
Screw threads have sharp edges.
I would insulate the Screw with tape or other.
Then wind the coils over the tape.
The enamel insulation will insulate the wires from each other.

Q1 and Q3 in your schematic aught to be P channel MOSFETs.

Using N channel MOSFETs, as you have shown, you need to take the gates of the MOSFETs more positive than the source, which is more than likely to be impossible.

Using P channel MOSFETs, you take the gates low to turn on the FETs.

I think that you need to use a very thin guage of wire, so that you can wind thousands of turns on to your former.

For example: The resistance of a typical relay coil is usually several hundreds of Ohms. You don't get this resistance from a few turns of thick wire!

mrsummitville:
Thinking out loud ...
Why do you need a Full H-Bridge?

If the current is in one direction, then the coil will attract an iron armature.

Reverse the current, and the coil will still attract an iron armature.

(This will not apply if the armature is magnetised, which you haven't said that it is.)

Keeping in mind that I need to this is for a very small application (I need to pull/repel a distance of about half an inch), do you think an electromagnet is the best option?

If so, should I try to make my own or buy a ready-made one?

My whole project is solar powered, so power is a limited factor. In fact, the electromagnets are actuating a sun-tracking mechanism. I would need four electromagnets, so would that draw too much current?

Concerning the circuit, some have said that I only need to use a single MOSFET. Would that still be able to switch the polarity of the electromagnet?

Why not use a micro servo? $5, be way easier to implement, just a single control wire needed.
http://www.rchotdeals.com/servos-parts/

The operating voltage is too high. I am using a 3.3V LiPo.

Okay, get a roll of magnet wire & do some experimenting then. Pricey.

It appears 3.3V Servos do exist

I don't think servos are the best for this project, unfortunately.

I also just realized that I just need the electromagnets to attract, not repel.

I will re-summarize my constraints:

  • 3.3V 2000mAh LiPo battery (this project aims to run 24/7, recharging with solar panels in the day)
  • minimum of 2 (out of four) electromagnets running at a time during the daytime
  • my distance between my magnet and the piece of metal that I want to pull is about 1 inch.
  • the diameter of the electromagnet has to be small (like less than a centimeter) but the length can be longer (perhaps around 6 centimeters)

I have attached a sketch of what I am thinking of.

Actually, I am coming to realize that muscle wire might be a better option. Might start a new thread.

Thanks you all for helping me out. I learned a lot about electromagnets.

GeckoDiode:
Keeping in mind that I need to this is for a very small application (I need to pull/repel a distance of about half an inch), do you think an electromagnet is the best option?

One millimetre is a more likely range. Magnetic force falls off as the square of the distance. I made a small electromagnet to trigger the coupling on a small model train and I had great difficulty getting it to work - eventually I extended the iron so it was closer to the moving part but organized so the moving part could not touch the extended part. The gap was 1mm or so.

If you can use a very small servo I think it would be a much better option. Perhaps even attach a small permanent magnet to the servo.

...R

GeckoDiode:
I don't think servos are the best for this project, unfortunately.

I also just realized that I just need the electromagnets to attract, not repel.

I will re-summarize my constraints:

  • 3.3V 2000mAh LiPo battery (this project aims to run 24/7, recharging with solar panels in the day)
  • minimum of 2 (out of four) electromagnets running at a time during the daytime
  • my distance between my magnet and the piece of metal that I want to pull is about 1 inch.
  • the diameter of the electromagnet has to be small (like less than a centimeter) but the length can be longer (perhaps around 6 centimeters)

RE: minimum of 2 (out of four) electromagnets running at a time during the daytime

So, you will have at least 2 electromagnets ON continuously for 12 hours per day?
I think, you might need to use a LATCHING Electromagnet
The type that you Pulse ON and then Pulse OFF.

I do not think you can easily make this ...
Latching_Electromagnet

I do not think you have enough energy in one battery
to continuously power, at least, 2 normal electromagnets,
12 hours per day when it is cloudy.