Arduino Air Bonsai Levitation

72,421

882

107

It's been a long time since my previous tutorial, my work is quite busy and I spend less time on Instructables. This time is a project that I like very much since my first saw it on Kickstarter: Air Bonsai. I was really surprised at how the Japanese made it, really a beautiful and mysterious piece.

Any mystery can be explained by looking inside, where it works. I have learn a lot about air bonsai more than a month ago and it was actually a magnetic levitation. I have also seen many tutorials on how to make magnetic leviation and all of them are making an object levitating from above where there is an electromagnet controlled by the circuit. There are no instructions on how to make a circuit similar to air bonsai.

Take a look at my steps below to make your own bonsai air with Arduino.

Pls note English isn't my native language, be generous with any grammatical errors. :D

Update #1: Dec 09 2018

Step 1: Instruction Video

Take a look at the video above for a quick look at how to make a magnetic levitation.

Pls note the instructions in the video are very simple and do not fully tips to start. Just take a look at the video and follow all of steps below to make sure you can make your own air-bonsai successfully.

Step 2: How It Works

I find out and realized that the circuit of kickstarter air-bonsai version was quite complex, without any microcontroller, I didn't have any knowledge of its analog circuit, there seems to be no way to do it. After looking careful, I realized its principle is quite simple, that is to make a magnet piece floating above another magnet piece. All of my rest work is make the floating magnet not falling down.

I think to do this with the Arduino actually a lot easier than calculating the analog circuit. And I succeeded in this way, really a lot simpler.

A magnetic levitation consists of two parts, the base piece and floating piece.

  1. Base piece
  • This part is at the bottom, which consists of a magnet to create a round magnetic field and electromagnets to control that magnetic field.
  • Each magnet has two poles: the north and the south. Experiments show that opposites attract and same-poles repel. Four cylindrical magnets are placed in a square and have the same polarity, forming a round magnetic field upward to push any magnet, which has a same pole and in between of them.
  • There are four electromagnets at all, they are placed in a square, two symmetric magnets is a pair and their magnetic field is always opposite.
  • The hall sensors and drive circuits control the electromagnets. Create opposing poles on the electromagnets by diverting the current through them.

2. Floating piece

  • Include a magnet floating above the base piece, which can carry a small pot.

How it works?

The magnet on top is raised by the magnetic field of the bottom magnets because they are the same poles. It however tends to turn over to fall down and attract in each other.

To prevent the top magnet piece from turning upside down and falling, electromagnets will create magnetic fields to push or pull to balance it, thanks to hall sensors.

Electromagnets are controlled in two X and Y axes, resulting in the upper magnet being kept balanced and floating.

Controlling electromagnets is not easy, this requires you to have knowledge of the PID controller, which is discussed in detail in the next step.

Step 3: PID Controller

What Is PID?
From Wikipedia: "A proportional–integral–derivative controller (PID controller or three term controller) is a control loop feedback mechanism widely used in industrial control systems and a variety of other applications requiring continuously modulated control. A PID controller continuously calculates an error value {\displaystyle e(t)} as the difference between a desired setpoint (SP) and a measured process variable (PV) and applies a correction based on proportional, integral, and derivative terms (denoted P, I, and D respectively) which give the controller its name."

In a simple way to understand: "A PID controller calculates an 'error' value as the difference between a measured [Input] and a desired setpoint. The controller attempts to minimize the error by adjusting [an Output]."

So, you tell the PID what to measure (the "Input",) Where you want that measurement to be (the "Setpoint",) and the variable to adjust that can make that happen (the "Output".)

Get understanding about PID easy in Youtube: https://www.youtube.com/watch?v=UR0hOmjaHp0

The PID then adjusts the output trying to make the input equal the setpoint. For reference, in a car, the Input, Setpoint, and Output would be the speed, desired speed, and gas pedal angle respectively.

In this project:

1. The Input is the current realtime value from hall sensor, which are updated continuously because the position of the floating magnet will change in real time.

2. Setpoint is the value from hall sensor, which is measured when the floating magnet is in the balance position, at the center of the magnets base. This index is fixed and doesn't change over time.

3. Output would be the speed to control electromagnets.

Thanks to Arduino community to write PID library and it really easy to use.

More info about Arduino PID at https://playground.arduino.cc/Code/PIDLibrary

We need to use a couple of PID controller in Arduino, one for X axis and other for Y axis.

Now is the time to start buying the necessary components.

Step 4: Materials List

Below is the list of the components you need to buy for this project, make sure you have them all before starting.

Some of the components are very popular and I believe you are already available in your own stock.

The components come with a quantity and a suggested link. Most of the suggested links come from Aliexpress where you can buy cheap and free shipping. You can buy in other places as long as you can buy them in the easiest way.

  • 5.6K ohm resistor - X2
  • 180K ohm resistor - X2
  • 47K ohm resistor - X2

  • 10K ohm potentiometer - X2

  • Acrylic sheet A5 size - X1

  • Wooden pot - X1

  • PCB Breadboard - X1

  • 3mm screw - X8

  • Wire

  • Mini plan such as succulent, cactus, mini bonsai

Step 5: Tools

Here is a list of tools, most commonly used by anyone.

  • Soldering iron
  • Hand saw
  • Multimeter
  • Scew drivers
  • Osilloscope (optinal, you can use multimeter instead)
  • Table drilling
  • Hot glue gun
  • Electronic plier

Step 6: LM324 Opamp and L298N Driver and SS495a

LM324 Op-amp

Operational amplifiers (op-amps) are some of the most important, widely used, and versatile circuits in use today.

We use the opamp to amplify the signal from the hall sensor, the purpose is to increase the sensitivity so that arduino easily recognize the change of magnetic field. When only change a few mV at the output of the hall sensor, after passing the amplifier can change several hundred units in the Arduino. This is necessary to keep the PID controller smooth and stable.

Learn more about how op-amp works in this tutorial.

A common opamp IC that I choose is the LM324, it's very cheap and you can buy it at any electronics store. The LM324 has 4 internal amplifiers, which allow you to use flexibly, however in this project I only need two amplifiers, one for the X axis and the other for the Y axis.

You can find how to assemble the LM324 in the follow step.

L298N module

Dual H-Bridge L298N are typically used in controlling motors speed and direction of two DC motors, or control one bipolar stepper motor with ease. The L298N H-bridge module can be used with motors that have a voltage of between 5 and 35V DC.

There is also an onboard 5V regulator, so if your supply voltage is up to 12V you can also source 5V from the board.

In this project I used L298N to control two pair of electromagnet coils and use 5V output to power to Arduino and hall sensor.

Module pinouts:

  • Out 2: pair of electromagnet X
  • Out 3: pair of electromagnet Y
  • Input power supply: DC 12V input
  • GND: Ground
  • 5v: 5v output to Arduino and hall sensors
  • EnA: Enables PWM signal for Out 2
  • In1: Enable for Out 2
  • In2: Enable for Out 2
  • In3: Enable for Out 3
  • In4: Enable for Out 3
  • EnB: Enables PWM signal for Out3

Wiring to Arduino: we need to remove 2 of jumpers in EnA and EnB pin, then connect 6 pins In1, In2, In3, In4, EnA, EnB to Arduino. Detail in the follow step.

Learn more about L298N module in this instructions.

SS495a Hall sensor

SS495a is a Linear Hall Sensor with analog output.

Notice the difference between analog output and digital output, you can't use a sensor with digital output in this project, it only has two states of 1 or 0, so you can't measure the output of magnetic fields.

An analog sensor will result in a voltage range of 250mV to Vcc, which you can read with Arduino's Analog Input.

Two hall sensors are required to measure the magnetic field in both the X and Y axes.

Step 7: Neodymium Ndfeb Magnets

Wikipedia: "Neodymium is a metal which is ferromagnetic (more specifically it shows antiferromagnetic properties), meaning that like iron it can be magnetized to become a magnet, but its Curie temperature is 19 K (−254 °C), so in pure form its magnetism only appears at extremely low temperatures. However, compounds of neodymium with transition metals such as iron can have Curie temperatures well above room temperature, and these are used to make neodymium magnets."

STRONG, that's the word I use to describe the Neodymium magnet. You can not use ferrite magnets because their magnetism is too weak. Neodymium magnets are much more expensive than ferrite magnets.

Small magnets are used to make the base piece, large magnets to make the floating piece.

Caution: You need to be careful about using neodymium magnets, since their strong magnetism can hurt you, or it can break the data of your hard drive or other electronic devices that are affected by magnetic fields.

Tips: You can only separate the two pieces of the magnet by pulling them sliding to the horizontal, you can not separate them in the opposite direction because their magnetic field is too strong. They are also very brittle and easy broken.

Step 8: Prepare the Cover for the Base Piece

I use a small terracotta pot with diameter of 3 3/4 ", which is usually used to grow succulent or cactus. You can also use a ceramic pot or wooden pot, as long as they fit perfectly.

Use a 8mm drill to create a hole near the bottom of the pot, which is used to hold the DC jack.

Tips: You should use a flat wood bit to drill into the terracotta pot, I used an iron drill and it almost burned, really not effective.

Also you can use water to cooling down the drill, avoid making it overheat.

Step 9: 3D Printing Floating Magnet Holder and Acrylic Laser Cut

3D Printing

Printing the floating magnet holder with the STL file that I have attached.

If you have a 3D printer available, this is really great. Congratulations, you have the opportunity to make everything with this machine. If not, don't be disappointed because you can use a cheap 3D printing service, which is very popular now.

Tips: You only need about 20 minutes to complete this part and infill only 30%.

Laser cut

You should use a local laser cutting service to cut two acrylic pieces with the file, which I have attached as AcrylicLaserCut.dwg. This is an autocad file.

An acrylic piece is used to support the magnets and electromagnets, the rest to cover the surface of the terracotta pot.

Step 10: Prepare SS495a Hall Sensor Module

Cut the pcb breadboard into two pieces, one piece to attach the hall sensor and the other to make the LM324 circuit.

Attach two magnetic sensors perpendicular to the pcb. Note the two sides are engraved of the sensors rotate to each other, fixed welding.

Use the thin wires to connect two VCC pins of sensors together, do the same with the GND pins. The output pins are separate.

Step 11: Opamp Circuit

Solder the socket and the resistors to the pcb following the schematic, paying attention to put two potentiometers in the same direction for easy calibration later.

Attach the LM324 to the socket, then connect the two outputs of the hall sensors module to the op-amp circuit.

Wiring two LM324 output wires to connect to Arduino. The 12V input should be shared with the 12V input of the L298N module, the 5V output of the L298N module connected to the 5V of the potentiometers.

Step 12: Assembly the Electromagnets

Assemble the electromagnets onto the acrylic sheet, noting that fixed at four holes near the center.

Tighten the screws to avoid moving.

Because the electromagnets are symmetric across the center, they are always in poles opposite, so that the wires on the inside of the electromagnets are connected together, the wires on the outside of the electromagnets being connected to the H-driver L298N.

Pull down the wires under the acrylic sheet through the nearby holes to connect to the L298N.

Tips: The copper wire is coated with a insulated layer, so you must remove it with a knife before you can solder them together, remember to use Heat Shrinkable Tube after welding.

Step 13: Attach the Sensor Module and Magnets

Use hot glue to fix the sensor module between the electromagnets, pay attention that each sensor must be square with two electromagnets, one on the front and the other on the back.

Try to calibrate the two sensors as centrally as possible so they do not overlap, which will make the sensor the most effective.

The next step is to assemble the magnets on the acrylic base. Combining two D15*4mm magnets and a D15*3mm magnet together to form a cylinder, this will cause the magnets and electromagnets to have the same height.

Assemble the magnets between the pairs of electromagnets, note the poles of the upward magnets must be the same.

Step 14: DC Power Jack and L298N 5V Output

Solder the DC power jack with two wires and use a heat shrink tubing. Connected DC power jack to the input of the L298N module, its 5V output will power the Arduino.

Step 15: L298N and Arduino

Connect the L298N module to the Arduino following to the schematic above.

L298N ===> Arduino

Out 5V ===> VCC

GND ===> GND

EnA ===> 7

In1 ===> 6

In2 ===> 5

In3 ===> 4

In4 ===> 3

EnB ===> 2

Step 16: Arduino Pro Mini Progamming

Since Arduino pro mini don't have any usb to serial port, you need to connect an external programmer.

The FTDI Basic will be used to program (and power) the Pro Mini.

Follow this Sparkfun instruction to get more info.

Step 17: Preparation of the Floating Piece

Attach two D35 * 5 magnets together to increase magnetism.

Step 18: Calibration Setpoint Value

Load program ReadSetpoint.ino to Arduino, which I have attached. This program will read the values of the hall sensor and send it to the computer via the serial port. Open COM port to see it.

Plug the 12V DC to the DC power jack, you also use osilloscope to readout the sensor value.

Observe the values on the screen, make adjustments by adjusting the two potentiometer. The best value is 560, at which point the output of the sensor is about 2.5V.

After setting the setpoint, place the floating magnet piece above the base piece and shake it to see the change of the setpoint on the screen.

Tips: Mark the pair of electromagnets and potentiometers respectively in the X and Y axes so that you can easily correct them later.

Step 19: Load the Main Program

After calibrate the Setpoint value, now is the time to enjoy the results.

Load the Levitation.ino main program, which I have attached below.

Use the super glue to fix the magnet piece and the magnet holder, which was 3D printed before.

Tips: After loading the main program, you can make small adjustments on the potentiometers to make the floating piece fixed in the center.

Step 20: Put All Together

First attach the DC power jack to the pot, then put the remaining parts into the pot.

Finally, use the remaining acrylic sheet to make the surface of the pot.

Step 21: Prepare the Plant

Attach the wooden pot to the floating magnet piece.
I used a small cactus to plant. You can use cactus or succulent or any mini bonsai that is symmetrical or small and lightweight.

Step 22: Finish and Enjoy

Enjoy your results, your efforts will be met with a bonsai air pot on your own desk, which is made by yourself.

Microcontroller Contest

Grand Prize in the
Microcontroller Contest

Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • PCB Contest

      PCB Contest
    • First Time Author

      First Time Author

    107 Discussions

    0
    None
    llobet

    1 hour ago

    Hello
    Any news of Funlab?
    I've replayed the whole setup again. I've modified everything to put eight columns of magnets.
    Nothing!!
    I don't know how the video was manufactured.
    Unless you have used an existing and functional assembly.
    I do not lose the hope of a clarifying answer and more having reached this point.
    Thank you

    0
    None
    GiancarloA3

    Question 7 days ago

    X and Y magnetic sensors are supposed to be in a mess of magnetic fields, coming from lateral coils e magnets.
    1) Do not they saturate?
    2) Do not they get coupled in an unwanted loop with lateral coils?

    By the way: very nice work!

    0
    None
    llobet

    11 days ago

    I would very sincerely appreciate any help that allows the assembly to work.
    Thanks Funlab

    0
    None
    snakerattle

    12 days ago

    Good Message for us All
    Funlab contact me and say he will do his best ( maybe this week) that this Project will work !
    Thanks Funlab

    0
    None
    Jonakis

    13 days ago

    hi guys, I dont know if it's by the same author, but the code looks like this one, minus some lines for lcd screen:

    http://jingyan.eeboard.com/article/73828

    hope that helps someone better in coding. i'm still struggling with this project

    0
    None
    snakerattle

    14 days ago

    I sent Funlab a Message about these and i hope he will get in touch.

    0
    None
    llobet

    15 days ago

    Hello
    Yes, it's true. I have also built and modified the program according to the pinout of the schema.
    I've adjusted the potentiometer values, and it's not working.
    Since you have made us arrive with such enthusiasm to this point, I would appreciate if you could help us with any contribution that may have been forgotten or wrong.
    Thank you

    1 reply
    0
    None
    snakerattlellobet

    Reply 14 days ago

    Thank you llobett for your Comment !
    I also spent many many hours to this Project. It would be very nice of Funlab if he did not let us down now !
    Thanks in advance Funlab

    0
    None
    Amirkhan986

    Question 17 days ago on Step 12

    Hi Everyone
    I have problem with purchasing the "Levitation Coil" in my country.can anyone demonstrate the specifications of it?(e.g. number of Rev.s and diameter of copper wire used in it?Please Please ANSWER ME IF YOU KNOW

    1 answer
    0
    None
    snakerattle

    17 days ago

    Hello everybody and Hello Funlab

    You are all right this is an awesome Instructabel but it has one Mistake IT DOESNT WORK !
    First the pin layout is not right,okay thats not so bad but the code does not work-is that anybody noticed !!!
    I built this one and play around with it- I failed like all the others here.....Read the Comments !
    So FUNLAB once again we need your help Please give us the right Code because that's just worthless garbage.
    Please be so Kind Thank you Robert

    0
    None
    llobet

    Question 18 days ago on Introduction

    Extraordinarily fantastic the project.
    My question is: in Levitation. Ino, appears (# define BL 2)
    Can you please tell me where you are connected?
    Thanks for this project!

    0
    None
    MichaelW735

    Question 4 weeks ago on Step 4

    Can you use electro magnets in the base instead of the permanent magnets? Main reason is that I like stronger magnet field to make objects float higher or through thicker materials (like mountings base under a table and making objects float on the table)

    1 answer
    0
    None
    JosiahK5MichaelW735

    Answer 26 days ago

    Hey man,
    I would guess, in order to get a stronger magnetic field, you could use a variety of tactics. I'm sure electromagnets could definitely help (make sure you have enough power to make the electromagnets worth it!). Other ideas might be to add more magnets in each column (or even make new columns of magnets) and to buy/use stronger magnets.
    Good luck on your project! If you're going to use it under a table, that would be awesome!

    0
    None
    eldimars

    4 weeks ago

    Hello, where are you using the magnet Ring magnet D15*3mm? you are not only using Ring magnet D15*4mmof

    0
    None
    Luis PabloC

    Question 5 weeks ago

    Hi, What are the diodes for? i can see a pair of diodes in some pictures but are missing some others.

    0
    None
    RAJI S

    5 weeks ago

    How to increase Magnetic Levitation Height?
    Maximum Height can you Explain Sir?

    0
    None
    leobruno

    Question 5 weeks ago

    I am very excited to do this, and already have all the parts, just waiting for some free time to come up. Well, I have one question: the floating magnets appears in the list of components as "Magnet D35*5mm - X2". However, in all images it seems you are using two different sizes. Can you tell the actual diameters of theses magnets? Thank you.

    0
    None
    bvbreddy

    2 months ago

    Funelab sir,I also buy one kit from AliExpress with analog circuit,but it is not working.since one year I am waiting for Arduino circuit and I made same as you made but magnet is attracted to sides.please send me the correct Arduino code.pin 8 is not used in circuit and ena pins are different.so please send me correct code my mail bv25826@gmail.com. Thank you sir.

    1 reply
    0
    None
    Sagar73594bvbreddy

    Reply 6 weeks ago

    Change that Arduino code . And for EN pin you can set any pwm enable Arduino pin. After that change your circuit according to the pin you select.