Arduino Air Bonsai Levitation
by funelab in Circuits > Microcontrollers
214449 Views, 1312 Favorites, 0 Comments
Arduino Air Bonsai Levitation
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
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.
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.
- 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.
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.
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.
- LM324N - X1 - $0.87
- Levitation coil - X4 - $14.09
- SS495a Hall sensor - X2 - $5.44
- 12V 2A DC adapter - X1 - $8.82
- Ring magnet D15*4mm - X8 - $6.8
- DC power jack - X1 - $1.64
- Ring magnet D15*3mm - X4 - $4.11
- Arduino pro mini - X1 - $3.2
- L298N module - X1 - $2.25
- 14 pins socket - X1 - $1.91
- Magnet D35*5mm - X2 - $6.65
- 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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
Preparation of the Floating Piece
Attach two D35 * 5 magnets together to increase magnetism.
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.
Downloads
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.
Downloads
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.
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.
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.