This is a magnetic levitator implemented using Atmega8 microcontroller.
Magnetic levitation is a method by which an object is suspended with no support other than magnetic fields.
To make a magnet levitate, an
hall sensor is attached to a coil. The
coil acts as an electromagnet, and the hall sensor measure the distance of the magnet from the coil.
The coil it is driven by
PWM impulses, the closer the magnet is from the hall sensor, the bigger is the duty cycle and vice versa.
The coil works only if the magnet is in a certain range, out of this range no current flow through the coil, and the system is in is idle state.
The system has to mantain the
equilibrium position of the magnet, the pull force of the coil has to be equal to the gravity force that pull the magnet to ground.
To stay on the budget, a small 12V 50N coil (
ZYE1-P25/20) is used, with this coil the system can not lift heavy loads.
The hall sensor used it the
Allegro A1302.
Because the heavy loads limitation, i've to put the hall sensor next to the coil, this solution produce a problem, the magnet can be pull even by the ferrite core of the coil, If it gets too close to the coil. To prevent this situation we have to emitting less current to the coil.
A bigger coil and a more sensible hall sensor can lift heavier load, and also the magnet can levitate far away from the coil.
An RGB led, next to the hall sensor, is powered on when the magnet is detected.
To adjust PWM intensity, a PID controller is used.
A proportional-integral-derivative controller (
PID controller) is a generic control loop feedback mechanism (controller) that calculates an "error" value as the difference between a measured process variable and a desired setpoint. The controller attempts to minimize the error by adjusting the process control inputs.
The micro runs at 8Mhz, every 1ms the hall sensor it is checked, and the PWM for the coil is adjusted. The PWM period is 1953Hz.
The PID controller parameters, and other configuration options are stored in eeprom and can be edited by a software application connected through the UART connection. The software used for this functionality is
avruartconfig.
All the
configuration values could be changed through the UART connection for different coil / hall sensor / magnet hardware.
For an art fair next to my town,
InverART 2013, a friend of mine,
Paolo Crespi, build the sculptures you can see on the image above.
Code
Notes
- read risk disclaimer
- excuse my bad english