Arduino Forum

Community => Exhibition / Gallery => Topic started by: ea123 on Jan 28, 2012, 01:08 pm

Title: Magnetic levitation
Post by: ea123 on Jan 28, 2012, 01:08 pm
Hello,
here is a magnetic levitation project realized with arduino. The suspended ball is a permanent magnet whose distance from the electromagnet is measured by a hall effect sensor placed under the coil. The digital control loop is a PID algorithm that modulates a PWM output to energize the electromagnet through a MOSFET. A voltage regulator is used to provide a fixed voltage and to limit the current in the coil (the schematics can be found in attachment).

http://www.youtube.com/watch?v=7yGMYXWVjSU


Title: Re: Magnetic levitation
Post by: robtillaart on Jan 28, 2012, 03:27 pm
Cool!, well done

Code ?
Title: Re: Magnetic levitation
Post by: ea123 on Jan 28, 2012, 03:50 pm
You can find the sketch file in attachment. Basically it consists in the following functions:

1) PWM setup to change the frequency from the default value (490 Hz) to 3921 Hz;
2) A command handler used to configure the controller gains and setpoint through the serial line (when arduino is connected to USB cable);
3) A state machine that manages the transition between OFF, IDLE and CONTROL modes (this to avoid the controller to turn on the electromagnet
   at full power when the ball is not in range);
4) The control loop.

Title: Re: Magnetic levitation
Post by: robtillaart on Jan 28, 2012, 06:40 pm

I forwarded the tube to a teacher at a technical school this afternoon and he was so enthousiastic he thinks about adding it as a exercise in the semester.

Thanks again (also for the code),
Title: Re: Magnetic levitation
Post by: tytower on Jan 28, 2012, 09:50 pm
Any chance of a picture?
Edit - when I logged in am -no videos but schematic pic was there
I think videos might have been turned off for a time by the server.
Good as gold now thanks
Title: Re: Magnetic levitation
Post by: ea123 on Jan 28, 2012, 10:17 pm
Quote
I forwarded the tube to a teacher at a technical school this afternoon and he was so enthousiastic he thinks about adding it as a exercise in the semester.

Thanks again (also for the code),


good! It' a nice didactical project indeed.
Title: Re: Magnetic levitation
Post by: ea123 on Jan 28, 2012, 10:22 pm
Quote
Any chance of a picture?


Hi, look at the attachment. As you can see the connections are done on a breadboard...it's just an experiment.
Title: Re: Magnetic levitation
Post by: GaryP on Jan 28, 2012, 10:43 pm
Time for a contest! Who can create longest gap!!!

Two of these and I could hang a painting on the air?

Cheers,
Kari
Title: Re: Magnetic levitation
Post by: pmills03 on Feb 26, 2012, 10:12 pm
Thanks much for sharing.  I have a very similar project, but I'm driving the magnet through a D/A and then an opamp instead of with a PWM signal.  I'm wondering if you ran into problems with the hall effect picking up both the field of the electromagnet and the field of the levitated magnet.  I was planning on using two hall effect sensors (one at each pole of the electromagnet) and looking at the difference in the signals.  This should give a good reading on the levitated magnet.

Also, how did you come up with your PID values?  Did you model the system in Matlab or something similar?  Or did you just experimentally come up with the values?

-Patrick
Title: Re: Magnetic levitation
Post by: Nishant_Sood on Feb 29, 2012, 09:42 am
PID Values? ,How you managed them?
Title: Re: Magnetic levitation
Post by: simon.monk on Feb 29, 2012, 09:41 pm
Very nice!

This is mine, it uses an optical sensor rather than the Hall sensor. Hall sensor much cooler.

http://www.dangerouslymad.com/projects/chapter-13-levitation-machine (http://www.dangerouslymad.com/projects/chapter-13-levitation-machine)

(http://www.dangerouslymad.com/_/rsrc/1294514255960/projects/chapter-13-levitation-machine/F13-02.jpg?height=400&width=215)
Title: Re: Magnetic levitation
Post by: liuzengqiang on Mar 02, 2012, 05:27 am
Super cool! I'll think about making this or having this made. That's the fun of being a teacher, you can order students to make things and that's all for their learning :) Considering this for instrumentation course because of PID and its application, also as a PR show item like my rotating stage with POV display.

I thought Si had one and thanks for posting so someone looking for this later sees two projects to learn from!

I shamelessly saved every file in a folder  ;)
Title: Re: Magnetic levitation
Post by: simon.monk on Mar 02, 2012, 10:19 am
At some point, I will update mine to use a Hall sensor - I still have long term dreams of a planetarium ceiling populated with floating, rotating planets!

However, one power outage and it would be raining celestial bodies!
Title: Re: Magnetic levitation
Post by: robtillaart on Mar 02, 2012, 10:12 pm

An evil genius would use a 2nd hand nuclear reactor from a Borg space ship - or if those are out of stock, a car battery as backup for the power supply.

idea ! -> Arduino as intelligent UPS controller :)
Title: Re: Magnetic levitation
Post by: JO3RI on Mar 02, 2012, 11:07 pm
@robtillaart sssst  :smiley-zipper: He is an evil genius and he wrote a book about being it
Title: Re: Magnetic levitation
Post by: simon.monk on Mar 03, 2012, 12:16 am
MWAHAHAHAHA
Title: Re: Magnetic levitation
Post by: JosEnrique on Dec 11, 2012, 10:53 pm
Hi, im talking to you guys from Mexico. I tried to do this experiment at home, but it doesn't levitate. I also tried making different kinds of electromagnets but that was not enough. I don't know which the reason can be. I hope you guys can help me with this. Greetings.
Title: Re: Magnetic levitation
Post by: summersja on Dec 22, 2012, 09:13 pm
Very cool!  :smiley-mr-green:  Where did you get the electromagnet?  I am posting this for my son and he wants to build a similar unit but doesn't know where to start looking for a suitable electromagnet.  (BTW, he is autistic so reading/writing is difficult for him but is brilliant in electronics and circuitry).  Thanks in advance!
Title: Re: Magnetic levitation
Post by: jrlp on Dec 26, 2012, 10:22 am
Well, the one in the video looks like a solenoid with the plunger removed.

They're rather easy to find, and if you're mechanically inclined at all you'll know where hundreds are!

In cars alone:
Pretty much every emissions / vacuum / boost solenoid to control air/vacuum/boost
Power door lock actuators (some may be gear driven, but most are simple push-pull solenoids)
Air conditioning solenoids (in cars)

You can probably buy 20 of them at a junkyard for under $10 bucks, since it doesn't matter if the housing or nipples are broken off of them.

Any equipment that has the ability to turn on and off, let's say.. water or fluid as well.

A solenoid is an electromagnet wrapped in a metal can, with a hollow tube in the middle. The plunger is a steel shaft that sits in the tube, partially spaced out with a small spring.

When electricity is added, the plunger shaft gets sucked into the can, pulling the linkage it's connected to in with it.

Pull the plunger out, and put a bolt with a nut on one side, as the OP did (at least it looks like).

You can epoxy the hall effect sensor on the head of the bolt through the electromagnet.
Title: Re: Magnetic levitation
Post by: Jujo on Dec 26, 2012, 04:04 pm
Hi ea123, can you post the list of components you used?
thanks.
Title: Re: Magnetic levitation
Post by: ea123 on Dec 29, 2012, 04:14 pm
Quote
Very cool!    Where did you get the electromagnet?


Hello, I bought the electromagnet and magnetic sphere here:

http://zeltom.com/products/magneticlevitation/emlscomponents

they sell a complete magnetic levitation kit (not based on Arduino) or single components.
Title: Re: Magnetic levitation
Post by: ArJack on Jan 16, 2013, 09:57 am
Hi,
very cool project!
... but... the code is no more available... (503 error)  =(
Title: Re: Magnetic levitation
Post by: mcwhorpj on Jan 22, 2013, 01:10 am
I have been trying to replicate this but am having some difficulty. I have the circuit nominally working, but I can not get it tweaked to levitate the magnet. Either the magnet drops to the base, or slams into the electromagnet ( I am using the same electromagnet, permanent magnet, and code presented in the OP, the hall sensor might be slightly different as I am using the A1321). It is easy to see that the parameters depend critically on the specific permanent magnet being used, the characteristics of the hall sensor, and the electromagnet.

I have tried different magnets, and different settings without success. In trying to be methodical, I run into the complication that the hall sensor itself picks up the signal from the electromagnet. So, trying to turn the electromagnet off and map hall sensor reading to distance from permanent magnet to electromagnet does not help, because that mapping will be distorted depending on the signal to the electromagnet. Another complication is that the permanent magnet is attracted to the metallic parts of the electromagnet so there is an uncontrolled attractive element that increases as the gap decreases.

Can anyone suggest a methodical approach to tweaking the set point, P-gain, D-gain, and I-gain to get this thing floating? Given that there are 4 parameters, and no real equations to guide, I am sort of at a loss at this point.

Thanks!
Title: Re: Magnetic levitation
Post by: skkash on Feb 26, 2013, 06:57 am
We are working on a similar project. Kindly let me know about the specifications of the coil used. We want to levitate a small steel ball of weight 0.3 g. I would like to know the voltage and current applied to the coil. Number of turns used. What core did you use for this ?
Title: Re: Magnetic levitation
Post by: WWCC on Apr 26, 2013, 03:43 am
Is your code available? If it is there i didn't see it.
Thanks
W
Title: Re: Magnetic levitation
Post by: codlink on Apr 27, 2013, 04:28 am
The code is in reply #2
Title: Re: Magnetic levitation
Post by: WWCC on Apr 27, 2013, 04:15 pm
It sure is. Thanks
Title: Re: Magnetic levitation
Post by: francisroan on Jun 21, 2013, 08:32 pm
Hi could you please tell us the value of L1..?

Thank you.!
Title: Re: Magnetic levitation
Post by: invintive on Jun 23, 2013, 02:30 am
I'm curious, how stable is this? Has anyone ran it for long periods of time?
Title: Re: Magnetic levitation
Post by: retrolefty on Jun 23, 2013, 02:57 am

At some point, I will update mine to use a Hall sensor - I still have long term dreams of a planetarium ceiling populated with floating, rotating planets!

However, one power outage and it would be raining celestial bodies!


Not if they were tethered with a 'invisible' safety line attached to the ceiling. That would allow them to drop but not all the way to people level.

Lefty
Title: Re: Magnetic levitation
Post by: robtillaart on Jun 23, 2013, 01:08 pm
Quote
That would allow them to drop but not all the way to people level.

that could be part of the show ;)
Title: Re: Magnetic levitation
Post by: invintive on Jun 27, 2013, 12:49 am
Would this electromagnet work? http://rover.ebay.com/rover/0/e11401.m1842.l3160/7?euid=4da31cf6c6b447e3a49e34bf2a6a599b&loc=http%3A%2F%2Fcgi.ebay.com%2Fws%2FeBayISAPI.dll%3FViewItem%26item%3D170710884727%26ssPageName%3DADME%3AL%3AOU%3AUS%3A3160&exe=10013&ext=100025&sojTags=exe=exe,ext=ext (http://rover.ebay.com/rover/0/e11401.m1842.l3160/7?euid=4da31cf6c6b447e3a49e34bf2a6a599b&loc=http%3A%2F%2Fcgi.ebay.com%2Fws%2FeBayISAPI.dll%3FViewItem%26item%3D170710884727%26ssPageName%3DADME%3AL%3AOU%3AUS%3A3160&exe=10013&ext=100025&sojTags=exe=exe,ext=ext)
Title: Re: Magnetic levitation
Post by: invintive on Jun 30, 2013, 07:08 am
So I'm having trouble making this work. I don't know if it's because of the electromagnet I used (the one in the link above) or because I used a different hall effect sensor. The sensor I used is the ss495a (a ratiometric type hall sensor commonly used in non-arduino levitators). When I hold the magnet close both of the lights go from being off to flashing rapidly and I can hear the electromagnet and feel a pulse in the magnet I'm holding, but it doesn't levitate.

Any help? I'm so exited to get this working!
Title: Re: Magnetic levitation
Post by: 1ChicagoDave on Jul 01, 2013, 07:27 am
That's a great update of this old Popular Electronics project from 1996 --

http://www.coilgun.info/lev_popelex1996/home.htm (http://www.coilgun.info/lev_popelex1996/home.htm)

You should send it in as a Flashback/Update article...?

Nice work.
Title: Re: Magnetic levitation
Post by: siddharthverma on Sep 15, 2013, 07:13 am
Hey how did you make the electromagnet??
Title: Re: Magnetic levitation
Post by: elementcollector1 on Sep 23, 2013, 07:16 am
I'm about to build an electromagnetic levitation machine myself, but I've got a few questions (being an amateur to Arduino itself...)
-What Hall Effect Sensor should I use? Apparently I'm looking for a non-latching sensor that can vary the strength of the field to counteract gravity (instead of simply tripping ON/OFF whenever a magnet is nearby). Where would I find this?
-Is it possible to use an electromagnet at an angle instead of pointing straight down? If not, is it possible to use a 'bent' electromagnet (i.e. the iron core is bent at an angle, and the wire wraps around it as such)?
-What kind of power supply should I use? Would a stronger power supply (probably more amps? Volts?) equal a stronger magnet (and thus able to 'lift' heavier objects)? If so, how well would a series of NiCd batteries (say maybe 10) fare?
All help is much appreciated, as well as good links.
Title: Re: Magnetic levitation
Post by: 0miker0 on Sep 23, 2013, 01:49 pm
Nice project! I've always considered creating my own. Where can I find one of the large coils? Would a speaker work once the back paper is pulled off?
Title: Re: Magnetic levitation
Post by: elementcollector1 on Sep 24, 2013, 03:39 am
I found this (http://www.amazon.com/gp/product/B009M86TFG/ref=gno_cart_title_2?ie=UTF8&psc=1&smid=A3H4GF5KJX48AW) on Amazon. Apparently it modifies the Hall Effect Sensor to better work with the Arduino. Not exactly cheap, though...
Would this work? It has analog output.
Also found this (http://www.youtube.com/watch?v=LaGv2FHS5zg), which helps a lot to explain how to build this kind of circuit.
Title: Re: Magnetic levitation
Post by: ravi20084 on Dec 27, 2013, 08:59 pm
where is arduino the code.......????
Title: Re: Magnetic levitation
Post by: haris954 on Jan 14, 2014, 01:47 pm
Can i levitate an iron or steel bolt using hall effect sensor without using permanent magnet?
Title: Re: Magnetic levitation
Post by: retrolefty on Jan 14, 2014, 05:17 pm

Can i levitate an iron or steel bolt using hall effect sensor without using permanent magnet?



Yes in theory one could. However the strength of the electromagnet would have to be much stronger to control a non-magnetic 'target' of the same mass weight as the permanent magnet 'target'.

Title: Re: Magnetic levitation
Post by: vsalma on Feb 05, 2014, 02:23 pm
I think there is a bug in PID code. In D component, "derivative of sensor value had used. But I think  "derivative of error" should be used.

Am I right ??
Title: Re: Magnetic levitation
Post by: micklug on Feb 20, 2014, 01:33 pm
For those with control problems, was enough for me to add a first order filter on the sensor (without this insertion was not possible for me to stabilize) and change the ranges of threshold to enter in control mode (due to being using another hall effect sensor). The initial control parameters are sufficient for stabilization and I only realized a fine adjustment.

Good luck everyone and greetings from Brazil.
Title: Re: Magnetic levitation
Post by: micklug on Feb 20, 2014, 07:38 pm
For vslma:
" I think there is a bug in PID code. In D component, "derivative of sensor value had used. But I think  "derivative of error" should be used.

Am I right ?? "

If the reference is constant there is no difference between the derivative of the error and the derivative of the output.

Title: Re: Magnetic levitation
Post by: KodyB on Oct 20, 2014, 06:05 pm
Can someone add the file attachment for this with the schematic and the code for Arduino? They will no longer show up for me at school as of 3 days ago and I'm trying to do this as a project for school.
Title: Re: Magnetic levitation
Post by: UNarmed on Dec 03, 2014, 11:02 am
Great work, looks very promising! Im curious however, how would it have to be altered to float the object above the electromagnet as opposed to below it?
Title: Re: Magnetic levitation
Post by: sheldor94 on Mar 19, 2015, 01:55 pm
how you set the PID value?
Title: Re: Magnetic levitation
Post by: kmtn on May 06, 2015, 04:45 am
It is not working. How do I tune the PID values?
Title: Re: Magnetic levitation
Post by: Grieva on May 08, 2015, 05:49 pm
would someone be able to provide schematics and the component list too?
Title: Re: Magnetic levitation
Post by: arduinoV on May 30, 2015, 04:56 pm
Hey guys,

I've been trying to implement this project at my university, but we are facing a nosy problem and because of it it's been really hard to control the system. We figured out that a FIR filter could possibly solve our problem. so there it goes.

Does someone know how my friends and I could add a FIR filter at this project ?


oh and of course, thanks a lot for sharing your project with us.

I hope somebody can help.

Best regards
Title: Re: Magnetic levitation
Post by: nguyenkhanhtien on Apr 14, 2016, 08:53 am
you can give you the detailed circuit about magnetic levitation and code it's. I wan do magnetic levitation system  one simple use Arduino.
Title: Re: Magnetic levitation
Post by: AWOL on Apr 14, 2016, 09:01 am
you can give you the detailed circuit about magnetic levitation and code it's. I wan do magnetic levitation system  one simple use Arduino.
Did you read the start of this thread?
Title: Re: Magnetic levitation
Post by: Marius_Elvenwood on May 21, 2016, 05:36 am
Hi
I'm very excited to make this project!
Do you have a top-down photo of your circuit board and components? I'm not sure how to replicate it using the circuit diagram so perhaps a photo will help.
Cheers
Title: Re: Magnetic levitation
Post by: alex27riva on Jun 26, 2016, 11:45 am
Hi everyone, i want to make this project.

I tried this  (http://www.thingiverse.com/thing:943091)but doesn't work, maybe the coil i used (https://www.amazon.it/Solenoide-ventosa-elettromagnete-supporto-sollevamento/dp/B00JR3V7UI/ref=sr_1_1?ie=UTF8&qid=1466934195&sr=8-1&keywords=elettromagnete) is not good and i want to try with Arduino.
I already have an SS495A hall effect sensor.
What coil should i use?
Thanks.
Title: Re: Magnetic levitation
Post by: tautau123 on Jul 14, 2016, 10:38 pm
What type of hall effect sensor do i need for this project ?
Title: Re: Magnetic levitation
Post by: blimpyway on Jul 16, 2016, 08:08 pm
a linear one
Title: Re: Magnetic levitation
Post by: Chiggiboy on Oct 13, 2016, 12:26 pm
Guys I want some help ..can you give me information about the inductor like how much turn ? If you give me this information it is very helpful for me .
Title: Re: Magnetic levitation
Post by: the_muck on Oct 31, 2016, 06:36 pm
Hallo,
i use 2333 Turns, ~100m 0,4mm wire with a ferrit rod inside. It need 0,04A@12V when the magnet is staple, 0,4A@12V when full powered -> so the coil resistance  is ~30ohm.

https://www.youtube.com/watch?v=kcYpK9xGT9o (https://www.youtube.com/watch?v=kcYpK9xGT9o)

But it need time to find out the right PID Values, setpoint and wight of the magnet ;). It is also important to have very stable 5V for the sensor ;)
Title: Re: Magnetic levitation
Post by: Budvar10 on Oct 31, 2016, 06:44 pm
 :)
Title: Re: Magnetic levitation
Post by: jona_xz on Apr 07, 2017, 08:09 am
hello im a new research scholar can u please tell me the no of turns on your magnetic coil and thickness of the core