Last chance to enter The Hackaday Prize.

AVR Atmega based PID Magnetic Levitator

magnetic_levitator_atmega_pic

[Davide] saw our recent post on magnetic levitation and quickly sent in his own project, which has a great explanation of how it works — he’s also included the code to try yourself!

His setup uses an Atmega8 micro-controller which controls a small 12V 50N coil using pulse-width-modulation (PWM). A hall effect sensor (Allegro A1302) mounted inside the coil detects the distance to the magnet and that data is used by a PID controller to automatically adjust the PWM of the coil to keep the magnet in place. The Atmega8 runs at 8Mhz and the hall effect sensor is polled every 1ms to provide an updated value for the PWM. He’s also thrown in an RGB LED that lights up when an object is being levitated!

So why is there a kid with a floating balloon? [Davide] actually built the setup for his friend [Paolo] to display at an art fair called InverART 2013!

After the break check out the circuit diagram and a short demonstration video of the device in action!

Oh yeah, those of you not impressed by magnetic levitation will probably appreciate acoustic levitation.

magnetic_levitator_atmega_schematics

(click for full size diagram)

Comments

  1. Jordan says:

    Just a silly comment: since there’s no friction on the object being levitated by that which is suspending it, if this was put in a complete vacuum, could you spin something and it would spin for infinity?

    I know it’s useless as you wouldn’t be able to harvest any energy from it but it’s just a thought I had…. it’d be like a top on a frictionless surface with no air friction/drag… right?

    Sorry if there’s a glaring hole in my logic, as I’m completely uneducated on the matter and relatively young >.<

    • rogier21 says:

      Yes it would spin forever because nothing would stop it. Hand a generator on it and it would stop because of drag ofcourse.

      Same as astronauts in IIS would be able to get stuck in the exact middle of a room and never be able to reach the sides if it wasn’t for the airflow through the space station :)

      • Jordan says:

        Hanging a generator would stop it—hence my mentioning that it was useless for energy harvesting :P

        But the astronaut aspect was something I’d never considered. Good point!

      • SmithsALot says:

        “Same as astronauts in IIS would be able to get stuck in the exact middle of a room and never be able to reach the sides if it wasn’t for the airflow through the space station”

        I suppose that’s another reason to eat your beans with every meal. :P

        • Um, I don’t think you actually need artificial help there ;-) Would simply not breathing in slowly and blowing out fast (from either end!) do the trick?

          Of course you can then start throwing bits of your spacesuit away to propel yourself in the other direction….

          • tekkieneet says:

            Zero-g strip tease! One way to grow the support for the underfunded space program.

          • rogier21 says:

            According to Chris Hadfield’s last AMA he said, and I quote “We all tried it – too muffled, not the right type of propulsive nozzle :)”.

      • Sven says:

        It would be possible to propel yourself by breathing in in one direction and breathing out in the other. It would take a hell of a long time but you would eventually move and hit a wall if you kept it up. Or just undress and throw your clothes in one direction as acceleration mass, just be prepared for the question “why are you naked, and why are your clothes all over the instrument panel?”

      • Randomnut says:

        The iss is not gravity free. It’s in microgravity. You would eventually drift to the earth side of the iss. It would take while but you wouldn’t get stuck.

    • RP says:

      Well there wouldn’t be any air friction but there would still eddy current friction due to the movement of a conductor in a magnetic field

    • Interesting question.

      If the object being levitated was COMPLETELY free from the influence of external forces/fields, and the vacuum was perfect then yes, there’s no reason it couldn’t rotate forever.

      However, the biggest issue I see in the real world is eddy current losses. The rotating object is a piece of moving metal, and it’s present in a magnetic field. Therefore you will have induced eddy currents which will try and slow down the rotation. Even if you ignore the field of the driving coil, you’ve still got Earth’s magnetic field, albeit many times weaker.

      So I would say that it will eventually come to rest, perhaps quicker than you might think!

    • Dax says:

      No because the slight magnetic drag due to the induced currents would slow it down, but it would take the life of the universe to happen.

  2. Thopter says:

    I don’t get it. Why is the Hall Effect sensor not affected by the coil surrounding it?

    • Jordan says:

      Since you’re controlling the coil, you know what value it’s at, and can offset the hall effect sensor appropriately.

      Alternately, you can have a sensor on top of the coil and on the bottom of the coil; both will read the same value from the coil but different values from the magnet, so you just subtract the smaller value from the bigger value and viola. :)

    • scorinth says:

      It is, but that’s okay. Because of the superposition principle, the strengths of the magnetic fields simply add up, so you could cancel it out if you know one or the other….
      But it turns out you don’t even need to do that! If you define the target of the PID as the field strength at the hall effect sensor and set the P term of the control loop to a negative gain, the controller will respond to a stronger field at the sensor by lowering the power of the coil, and vice versa.
      What this means is that when the magnet gets closer, the controller will decrease the strength of the coil, letting the magnet drop, and when it gets far away, the controller will compensate by increasing power and pulling it closer. See how you don’t need to “cancel out” the coil’s field to make it work?

      • Jordan says:

        Riiiight… except that as you’re detecting the magnet dropping, resulting in a lower signal on the Hall effect sensor, you’re also adjusting the coil itself, which changes the value of the Hall effect sensor too. So you do, in fact, have to cancel out the coil’s field to make it work.

  3. Scott says:

    Confused noob here. How is the Hall Effect sensor not thrown off by being in the middle of a magnetic coil? Is the field pulsed off just long enough for the sensor to work or…?

    • Jordan says:

      The sensor is affected by both the magnetic coil and the levitated magnet. But since, at any given time, the program knows how strong the magnetic coil is (it’s controlling it, after all) it also knows how much to offset it.

  4. peter says:

    “small 12V 50N coil”
    Anyone know what the N refers to regarding a coil or electromagnet? I am trying to figure out what it can be referring to and am drawing a blank– turns, inductance, resistance, force? Anyone, anyone? Bueller?

  5. Eirinn says:

    Is there a way to reliably float it from below? :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 91,175 other followers