Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Controlling Electromagnets with a Microcontroller, Arduino or Raspberry Pi

Status
Not open for further replies.

John Ingato

Newbie level 4
Joined
Aug 30, 2015
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
88
Hello internet strangers,

I was hoping to get some advice from some electronics experts. I am a software engineer with a background in C/C++ but electromagnets are new to me. Here's what I am trying to accomplish. I was hoping to get some advice on how I can achieve this and where to start to learn how.

My goal is to be able to have a set of electromagnets that I can control with computer software. I would like to be able to turn them on / off and also have a variable strength that I can adjust. I also need to be able to flip the polarity of the electromagnet at any given time. I was thinking I could use an Arduino or Raspberry Pi for the hardware, but I'm not sure what else I would need. I would obviously need an external battery for the power source and the breakout board to connect to the magnets to. I've read online of people using light dimmers to adjust the strength, but I want to be able to do that with software, from my computer.

Is this something that could be done pretty easily? I could do all the programming Im sure. I just need to understand the hardware and electromagnetic properties. I'd also like to use very small electromagnets, under a half inch in diameter at least, but I can't seem to find any that small? If you could suggest a good site to buy the hardware that would be awesome.

Thanks!

-J
 

The simple method is to drive each electromagnet from a full H-bridge. It can provide current in either direction.

A solenoid can make an electromagnet. I'm not sure how small these are made.

Or you can take a small relay, and remove the moving parts, leaving the electromagnet.

There are supply houses which might carry batches of inexpensive relays.
Example, All-Electronics. (There used to be Hosfelt electronics but now their website's url appears abandoned.)
 

Any of the mentioned devices can be programmed to offer logic-level outputs for a desired effect. Then you need a "power driver" which accepts the logic output and can drive a relay coil, a solenoid or a DC motor. You can find various driver schematics for each power actuator. DC coils and small motors can be driven by MOSFET switches, to isolate the microcontroller from the power lines, optocouplers (or opto-switches) can be used.
There are also high-power opto-coupled switches for AC 120-230V, and some for up to 100 A peak current.
Some interesting devices can be found at "www.allelectronics.com" .
 

Hi,

Depending on voltage and current, maybe you can use a class d audio amplifier and a dac.

Klaus
 

The question isn't very clear regarding intended drive power and control speed. Your question about small electromagnets also suggest that you didn't come yet very far in defining the magnet hardware.

It may be helpful if you could describe the planned system in terms of moved object size, required force and timing.
 

Hello and thanks for the replies. You are correct that I have not fully defined the magnetic hardware as I'm not really sure what it is I will need. I don't have a full understanding yet of what components are required and what does what. I am just starting to learn this by researching online. The magnets don't have to be super strong and I'm not sure what you mean by control speed. Are you referring to some type of latency? I would need a pretty quick response for this project.

Depending on voltage and current, maybe you can use a class d audio amplifier and a dac.
How do I determine what voltage and current I should use? Is it just depend what battery I buy? Is the audio amplifier what I would use to give it a variable strength?

**broken link removed** is the smallest electromagnet I could find online. I think it will be small enough, at least for a proof of concept. Will that work for something like this?

I found some tutorials online about turning electromagnets on and off with an Arduino, but nothing about controlling the strength. I'm assuming I just need a way to adjust the amount of current being sent to the magnets?

Thanks
 

COnsider a DIY electro-magnet from 5V using 30 AWG magnet wire and iron 20AWG ( twist tie spool in HW store)


AWG30 is .39 Ohm/m so for 5V, 5Watt max ,you need 5 Ohms or 12.8m or wire. wrapped around a small bundle of short cut wires taped tightly with mylar or epoxy coated or similar to prevent abrasion or shorting of magnet wire and a loose core.

THen choose a "Logic level" gate drive N Ch FET and switch the low side to ground with V+ on the coil high side. Polarity of EMF is determine by direction of current CW or CCW. Choose FET RdsOn to be <<10% of wire resistance for lowest loss. e.g. << 500mOhm or even 100mOhm

5W coil may be used at 50% duty cycle or so if small
 

Thanks for all the help guys. I've been researching all your suggestions and I'm not sure if this will be able to do what I want. I am trying to put together a working prototype for a personal project of mine. I was wondering if you guys think that elecromagnets will even be a good fit for this. Basically I have an analog stick that I want to be able to control, but without touching it. My idea was to somehow use electromagnets to achieve this. One of the additional requirements is that I need to be able to physically move the stick even while the magnets are on, causing resistance. Then when you release the stick the magnets would back into the original position. The analog stick does not have much range of motions, so I was thinking of putting the electromagnets around the outside of the stick pointing inwards and since the stick will be either metal or a regular magnet, whichever would work best. I could then use the electromagnet to push or pull the stick in the direction I want.

What do you guys think. Is this feasible? I attached a drawing showing what I mean. Please excuse my lack of artistic skill. Is there perhaps a better way to do this? Could you maybe put the magnet at the base and spherically rotate it somehow?

Thanks

-J

magnetstick.jpg
 

A control stick with drive mechanism is known as "active control stick". It's e.g. used in modern aircrafts,

The usual drive technology is servo motor. Either specially designed to generate little force against manual movement, or with active compensation.

If you make some simple experiments with electromagnets, you'll find out that you need impractically large devices to generate sufficient force over a larger distance.
 

This is what I picture working. A magnet between two coils of wire. One coil produces a N pole, the other a S pole, or vice-versa based on current direction. The magnet is embedded in the stick.

The coils should not contain ferrous metal, because the magnet would want to remain close to it after the coils are turned off.

This system controls the stick in one direction (the X axis). You also need to control along the Y axis. Therefore add a second system, about an inch away from the first system, oriented at a right angle.



Just to see what happens, I experimented with neodymium magnets, and a coil of wire carrying 3 A.

By stacking many disc magnets, I get a strong bar magnet a few inches long. The coil of wire is 1.3 inches long and 0.8 inch diam.

The magnets sit on paper. I bring the magnetized coil close to the magnets, but it is barely able to move them. (As a matter of fact, the magnets prefer to jump toward the steel alligator clip gripping the coil leads.)

You will need to make the stick so it has very little resistance, in order for this idea to work.
 

Update: I tried a different coil which has about 100 turns. Power about 15W. This time the attractive/repelling force is much greater. The magnets move a couple of inches.
 

Hey, thanks for the ideas bradthRad. It's at least hopeful that you were able to get to produce more power. I wouldn't need the stick to move very much. As for the resistance, it is a nice to have, but not really necessary. The question I have is, using this meathod, how acurate do you think you could position that stick? Do you think accuracy would be something that would be too difficult? I have had more electromagnets going with variable, controllable strengths would I be able to get more accurate....or less?

Thanks!
 

The question I have is, using this meathod, how acurate do you think you could position that stick? Do you think accuracy would be something that would be too difficult? I have had more electromagnets going with variable, controllable strengths would I be able to get more accurate....or less?
There are basically two methods to achieve a defined movement with an electromagnet drive:
- use a strong restoring force, e.g. by a spring
- use position feedback

The first variant (restoring force) must achieve a stable equilibrium of forces, although the attraction of an electromagnet increases near the magnet. Without a strong spring, you get a purely bistable action.

Apart from the continuous control problem, I still doubt that an electromagnet drive is feasible for your application.
 

Hey FvM, How familiar are you with the active controls stick you mentioned? You said they would be used with servo motors. Do you think it is feasible to build something on a much smaller scale in terms of size, power and accuracy? Do you know how they design them to "generate little force against manual movement". Also, what is Active compensation?

Thanks
 

I'm not familar with ACS specifically, but with different kinds of servo controls. In so far I'd say, it's surely possible.

"generate little force against manual movement" is a matter of gear ratio and motor type. A brushless DC with moderate gear reduction should work.

Active compensation means that a feedback systems senses the force applied by the operator and drive the motor to reduce it. Or - in case of haptic feedback - generate a specified forth.
 

So I had another idea about how to achieve this, but I don't know if it will allow me to manually move the stick at all. So the idea is to put a disk at the base of the stick and underneath the disk put four of these. Then I could put power to specific ones to push against the disk, moving the stick into position. Do you think a setup like that would work? Do those types of solenoids have variable strength? Like, is it possible to hook one up to a light dimmer and tune the position or are they basically binary on / off? Also, one power is running to one of these can you push against it and manually push it in? What do you think?
 

I believe that direct drive by solenoids is a better idea than the electromagnets attracting the stick. But the magnet systems aren't designed for proportional control.
 

Then I could put power to specific ones to push against the disk, moving the stick into position. Do you think a setup like that would work? Do those types of solenoids have variable strength? Like, is it possible to hook one up to a light dimmer and tune the position or are they basically binary on / off? Also, one power is running to one of these can you push against it and manually push it in? What do you think?

Yes, that solenoid looks suitable. It has 5.5 mm of movement.

It might respond to PWM (pulse width modulation). That would allow you to position it accurately. The description says "lower voltage results in weaker/slower operation." As for whether you can position the stick reliably and predictably... you'll have to experiment.

There are threads at this forum which discuss positioning a solenoid with PWM.
 

Using solenoids for "long" movements requires a high-power DC input, and the force is weak at the larger distance. Much better is to use small DC motor linear or rotary drives, low-power and constant force during movement.
Learn from RC model systems.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top