loading

Hello Instructables community!

A while back I published an Instructable for a wireless screen, as part of my GR.9 science fair. Right at the top I mentioned that when the project was done, that I would publish an Instructable on my project, which happened to be Levitation. Now before I get started, I would like to say that the code is a fork of Simon Monks code from www.dangerouslymad.com, and that the idea for a 3D Printed Frame is from Tinkernut /Gigafide(here on Instructables).

This device uses an Arduino, as well as an IR LED and IR Photoresistor and electromagnet to levitate the object. When the object rises, it breaks the beam of the IR Sensor system, and the electromagnet deactivates, or when the beam is not broken, and the object is falling, the electromagnet activates, lifting the object.

My best guess is that this project was the result of over 500 hours of work!

DISCLAIMER: I don't even know what could go wrong, but if anything happens, it's on you. As well I would like to say that i am not affiliated or sponsored by any links here.

Step 1: The Parts and Tools

FRAME

· 3D printer Filament

· 2 M6 Bolts

· 1 M6 Nut

ELECTRONICS

· IRFZ44N N-Channel MOSFET

· 5W Electromagnet

· 200, 1K, 10K Ohm 1/4 watt resistors

· Arduino Nano

· Any toggle switch

· IR LED

· IR Photo Resistor (This isn't the one I got, but it is close)

· Diode

· Bi-Colour LED

MISCELLANEOUS

· Breadboard

· MM, MF Dupont Wires

· 22, 30 AWG wire

· Heatshrink

· USB mini cable

· 12 Volt wall adapter

· 35 MM Film Canister

· Non-Neodymium Magnets

· A Good Case

TOOLS

· Drill

· Spade Bits

· Soldering Iron/Solder

· 3D Printer (I used the Velleman K8200)

Overall the parts I bought for this project only, costed me about $20 CAD, but in total, all the parts cost about $45-55 CAD

Step 2: The Software

This Step is really simple. All you need to do is download Arduino IDE from here: www.arduino.cc. If you ordered your Arduino from Ebay(or it is a clone), then you will need the CH340G Driver: www.arduined.eu. Also if you have a clone, consider donating to the Arduino Project, or buy a genuine board to support the great work they do.

Step 3: The Frame

This is my first useful model, and I made this in TINKERCAD. Here is the TINKERCAD link: Levitation Stand.Make sure to sand the poles, so that they fit into the holes. In the large arc, you may need to drill out the holes, so that the poles can fit in. It should like like the attached photo.

Step 4: The Electromagnet Driver

The Arduino needs a way to control the electromagnet. The Atmega 328p specifies that on any GP I/O it can output 40 mA at 5 volts, or .2 watts, but the electromagnet needs 5 watts. To overcome this, I had to use a circuit that controls an external power supply. This MOSFET controller connects or disconnects the electromagnets ground wire from the actual power supply ground wire. Whether the two grounds are connected is determined by the gate, or control pin (Blue wire connects to it). If the Arduino applies voltage to that pin, the two grounds are connected, therefor turning on the electromagnet. If the Arduino doesn't apply voltage to that pin, the two grounds are disconnected, and the electromagnet is turned off.

Step 5: The Infared Sensor and Reciever

The Infrared Sensor and Receiver function together to complete one key task, which is to find the position of the object. One problem with a photoresistor is that they change their resistance based on IR light. The Arduino Itself cannot measure resistance, but with the help of a voltage divider, changes in resistance result in changes in voltage. The IR LED is just connected between Arduino Pin 8 and ground, with a 200 Ohm resistor thrown in series.

(Make sure to check if your IR sensor has a polarity, and consider that. It took me a whole night to figure that out!)

Step 6: The Flyback Diode

Although you can’t see the actual diode that sits in the red heat shrink on the red and black wires, there is a good reason for this. When an inductor is disconnected, current wants to continue to flow. This results in a 1000 volts in the opposite direction. Without that diode, the Arduino would probably crack, smoke then burst into flames. So, you should try to avoid that by adding in a diode.

Step 7: The Case

The case is one I found in my basement, and it simply has a breadboard attached to the bottom with double sided tape. There are 6 Holes, one for the Arduino Nano USB cable, one for the switch, one for the potentiometer, one for the electromagnet driver wires, and one for all the other wires. I simply hot-glued the electromagnet driver to the back. The heat of that circuit isn't an issue, as the MOSFET can handle hundreds of watts(I'm currently working on a project where a MOSFET must switch ~300 watts), and my electromagnet is 5 watts. All the wires coming out of the box have to be hot glued to prevent them from being pulled out of the box.

Step 8: Assembling the Electronics

This step is the hardest. I find the Fritzing Diagram a little hard to understand, so I added notes on each part. Let me know if something is unclear, and I will try to help you. Also make sure to connect the Arduino ground to the power rails; I forgot to add that.

The potentiometer has no real use, so skip that, and the three wires connected to it.

Step 9: Physical Assembly: Electromagnet

First, you need to solder and attach extension wires to the leads of the electromagnet. Use the thicker wire, and heatshrink. then feed those wires through the small hole in the inner side of the semi-circle, and out through the large hole. After, feed the wire through the hole shown in the second photo, and out through the hole shown in the 3rd picture. It should look like the last photo. Now Assemble the stand. Make sure that the holes are oriented as shown in the photo above. Attach the bolt through the top hole in the stand, and into the electromagnet.

Step 10: Physical Assembly: IR LED

The anode of the IR LED goes to pin 8, with a 220 Ohm resistor in series. The cathode goes to ground. Refer to the fourth picture for the location of the LED and Wires. I had spiced the other end with a jumper wire, so that way i can plug the wires into a breadboard.

Step 11: Physical Assembly: IR Sensor

The IR sensor is a photoresistor connected in a voltage divider. Vcc, or 5 volts goes through a 10K Ohm resistor, and into the actual sensor, which then goes to ground. To measure the voltage, we read the values from in between the Sensor and the fixed resistor. This goes to arduino A1. It is physically placed in the identical configuration as the IR LED. I made a little adapter which one sensor lead pugs into my adapter, which connects it to 5 volts and A1(while including a resistor internally), Then the other sensor wire just goes to ground.

Step 12: Physical Assembly: Flyback Diode

The flyback diode in mine is coiled with all the extra wire for the electromagnet (I cut the wires for the electromagnet about 2 feet too long). It is wired in parallel with the electromagnet, except in the opposite direction. you want the line on the diode to connect to the side of the electromagnet with 12 volts, and the other side of the diode is connected to the other wire from the electromagnet. I covered this in loads of heatshrink, and it looks nice.

Step 13: Extras on the Case

On the case there is a potentiometer (Don't put one on. It's useless), and a SPDT toggle switch. I drilled out holes for them, and then used thier mounting hardware to attach them. The potentiometer acts like a variable voltage divider. There are three pins on it. The switch can be any type of toggle switch, I used a SPDT type. The middle pin goes to D2, and the one to the outer pins goes to GND.

Step 14: The Levitating Objects

The Levitating Objects are 35mm film canisters, with magnets. One magnet is placed on the lid, and 2 underneath the lid. They are filled with some oil to dampen vibrations. After, I decorated them with electrical tape. They weighted in at about 65-75 grams. If I were to remake them, I would have them all with identical weights, as that would work better. I did try large 1 inch (diameter) neodymium magnets, but they were so powerful they just flew up and stuck to the metal casing on the electromagnet because they are stronger than the electromagnet. You must ensure that all the magnets are put on correctly, and that the same pole on the magnets faces up. You can do this by pushing the top of each object together, and every object should repel every other object.

Step 15: Testing

To setup the actual code, run the test code. If everything is connected right, The number beside the label PHOTORESISTOR:IR LED LOW should be at least 100 lower than the number with the label PHOTORESISTOR:IR LED HIGH. The label of SWITCH 1 should be either 1/0. (Change the position of the switch, and when it gives you more data in 7 seconds, check that the number changed). Next, get the film canisters, and check that the electromagnet is pulsing quickly every 5 seconds. Also check that when it pulses, the film canisters fly up toward to electromagnet, and are not repelled. If they are repelled, then either swap the polarity of the electromagnet, or switch the orientation of the permanent magnets on the film canister. If everything looks right, and is verified by this code, continue to the next step, if it isn't working, go back and check your wiring. I also found it useful to indicate which way the switch would yield 0 and 1.

Step 16: The Levitation Code

This will need some calibration, but to start, take the PHOTORESISTOR:IR LED LOW number from the test code, then round it to the nearest fifty, and change the value of MIN_MAP in the Arduino code to that number. Then upload the code to the Arduino.

Step 17: Turning It On

Make sure that the switch is in the position that yielded 1 in the test code. Then plug in the electromagnet power supply, and then the Arduino into the computer. Open the serial monitor at 115200 Baud, Your levitation device is now active.

Step 18: Calibration

Calibration is very important!

Put your object under the electromagnet level with the IR Beam. Adjust the height of the electromagnet using the bolt on top until your object can levitate for a couple seconds. Load the code provided, and configure the variables.

Step 19: Final Thoughts, Ideas and Code

If you ever need any help with this project, please feel free to P.M me, and I can provide my contact details so we can solve your problem.

Potential Improvements
• Model a hexagonal hole for the bolt head to sit in
• 3D Print a Case

Instructable user Jhardenberg, was able to modify this to use a Hall effect sensor, with a PID control loop. I will post some photos and code later.

Final Thoughts

Thank you for reading all 20 sections of my instructable! It was a lot of fun to make. I didn't win the science fair, but I won 4 plaques for engineering awards, a computing award and a math award. I really hope that the community will find this useful. I was inspired to post this because I saw the interest in this project, so i wanted to share my version.

Comment or share if you like it.

<p>Hi,</p><p>I have several questions that probably arise more from my inexperience than from any lack of clarity in your instructions.</p><p>-Can I use any electromagnet, or does it need to be 12V 5W 10kg P30 like the one in your link? How did you choose these specs? Would it be feasible to wind one's own solenoid using magnet wire?</p><p>-Could you describe in more detail (a drawing maybe) the polarity of the electromagnet and the permanent magnets? I was confused by your description in step 15. Why are there three permanent magnets?</p><p>-Is the potentiometer used for any purpose other than calibration? Couldn't this same function be achieved in the code instead? Maybe I'm misinterpreting its use...</p>
Hi. so to answer your questions the electromagnet doesn't really matter, it just needs to be strong enough to be powered with your power supply. The magnets are oriented so that the magnets attract to the electromagnet when powered. the 3 magnets was just for weight and some additional magnetic strength. Also, TBH. I don't know why I used a potentiometer. You are right that everything is controlled by the software. Pm for my contact info. I would love to help you succeed on this project, and the comments section isn't the best way to do that.<br><br>Clark.
<p>Hi! Great project!</p><p>Approximately what precision is necessary in the position sensing of the floating object? In other words, how much distance does the object have to fall before the electromagnet needs to adjust its force to keep it back up? </p><p>I was going to try using an ultrasonic sensor mounted beneath the object instead of IR to the side. The potential problem is that my US sensor is accurate within +-3mm and I am not sure if this will be enough. Would a variation in position as small as this be impactful?</p><p>Thanks!</p>
<p>I'm glad you liked it! Ultrasonic sensors will not work. You will get an object that bounces around, then becomes so unstable that it falls out. I would suggest that you either use a magnetic (analog hall effect sensor), or resistive light based sensor. If you have trouble using an IR system, you could probably use regular LEDs and a <a href="https://cdn.instructables.com/FOH/F83V/IAMCFJPJ/FOHF83VIAMCFJPJ.MEDIUM.jpg" rel="nofollow">photoresistor</a>. Just be aware it would be very sensitive to room lights. If you would like to discuss this in more detail, PM me, and I will provide contact details for you.</p>
<p>Hi!</p><p>How many Volts and Amp is used as the External Source?</p>
<p>My supply was 12v, 1.25 A, but the ampreage does not really matter, as long as it is above 1.25. </p>
<p>Hi! </p><p>what kind of the Diode in use project it ?</p>
<p>I don't know. I just found it lying around. I think most diodes should work.</p>
<p>Hi,</p><p>I'm an electronics newbie... can you clarify please. Your parts list says &quot;IR Photo Resistor&quot; and your circuit shows a resistor. But it links to &quot;LTR-301-002 Lite On Phototransistor NPN&quot;. Is that correct? In that circuit, would the phototransistor essentially be functioning as a nil/infinite resistance IR photo-resistor?</p>
<p>Hi. The IR sensor I used was a special one I found at my school. It was in a bin, and undocumented, so unfortunately, I can't give you any part number. What I can tell you, is that is was a resistive sensor. That meant that it would have a linear resistance (well, possibly not exactly linear, but you get the idea). So when no IR light reached the sensor. The resistance would be quite high. As more and more IR light reached the sensor, the resistance started to lower. So, to answer your question, No, it is not a on/off sensor, but rather one that, in a voltage divider, outputs an analog voltage based on the amount of IR light the sensor can detect. </p>
<p>Hi!<br>In the part list, there is 5W electromagnet, You are use HCNE1-P49/21, it is 10W.<br>5W is 100N, 10W is 400N.</p>
When I checked with my multimeter, i believe it only had .42 A, at 12V.
<p>Oh, okay. Thank you</p>
Hi, hello, is there a simplified version?
What are you looking for in a simplified version? Less code, less frame building, less components?<br><br>If you are looking for less components, it will be hard, as my project doesn't use that many parts. It has a LED and sensor and an electromagnet, and controller.<br><br>if you are looking for simple code, grab your code from the source I used, which is the second link in the intro.<br><br>if you are looking for a simple frame, just use a Clementine box made from wood.<br><br>If you would like, PM me and I can share my email so can discuss further<br><br><br>Hope this helps,<br>Headslant
<p>Hi Headslant,</p><p>I really interested with your project since I'm working on a project that similar with this, except I use PID control in my project.</p><p>I have some questions, though. Would you mind to share your email so we can discuss?</p><p>Regards,</p><p>Julian</p>
<p>Please pm me, and I will give it to you</p>
<p>Hi headslant,<br>This is a reply for your comment posted to <a href="https://www.instructables.com/id/A-Levitating-Sphere-Rotates-Glows-and-Blinks-With-/?comments=all#CSLEDXVIOAAVGGH" rel="nofollow">my article</a>.</p><p>I saw your article and <a href="https://www.instructables.com/id/Homemade-Levitation-Machine/" rel="nofollow">its prior art</a> in Instructables. In both of them, IR parts are used to know the position of the levitating object in the air. IR is hardly affected by magnetic field. That is good. But I think that it requires a strict or fine arrangement where the IR parts are attached. The balancing position of the levitating object would depend on the given condition. And IR parts ought to be located near the point, oughtn&rsquo;t they?</p><p>Also I wonder whether the oil sealed in the levitating object works as the absorber against the oscillation of the levitating object in the air. In a standard oil dumper, the sealed oil moves and spends kinetic energy in the oscillation. Does the oil sealed in your levitating object work so?</p><p>Not as an absorber, the oil can be just an added weight or mass, which changes the natural frequency of the oscillation and may be able to make the levitation stable.</p>
<p>So, my project does appear to use PD control, but when I modified the code, it showed me that the output is always at the max power or zero. I left it to run for 2 hours, and got that only once, the value was not either zero or max power. Also, I used the ir LED from a remote, so its beam angle is quite wide, and is easy to aim at the photo transistor. As for the fine position, I have a bolt at the top to adjust my magnets location, and that must be calibrated. As for the oil, I don't really understand your question, but I know that is I make an equal weighted object without oil, it vibrates then falls, so it does help. Is this the info you were looking for?</p>
<p>I understand you. In some case, PD control would work as Bang-Bang control.</p><p>And <strong><a href="https://www.youtube.com/watch?v=WbrYy0EyULw" rel="nofollow">this video</a></strong> tells us a hint for your last question. A raw (unboiled) egg can exhaust kinetic energy sooner which was given by one&rsquo;s fingers. I think you can try some different cases for the levitating object and compare them.</p><p>(1) containing oil<br>(2) containing water<br>(3) containing a solid weight attached rigidly<br>(4) containing a solid small ball without attaching</p>
<p>Currently, my project is broken as I had to transport it to my school for an event, and i think the IR LED has burnt out or been fractured. When I put in a new one, I'll try it. I'll keep you posted, but I have a lot of work to do, so it isn't my top priority right now.</p>
<p>Totally awesome! Great job!</p>
Also, your frame looks a lot better than mine...

About This Instructable

12,018views

128favorites

License:

Bio: Hi, I am a Canadian student who is avid about all things electronic and stuff using microcontrollers.
More by headslant:TINKERCAD Tutorials Sphere trapped in A Cube Modeled with TINKERCAD 3D Printed Inset Drawing 
Add instructable to: