Introduction: Magnetic Pendulum
Here is a quick and simple project for a lazy afternoon. We are going to make a perpetual pendulum using Arduino and a few components. If you pack it nicely it will make a great decoration for your workshop or a nice gift.
Step 1: Parts
Here are the basic parts you will need:
- Arduino.I used Nano on a small breadboard.
- Coil. You can salvage one from a dead hard drive, or even make one, as described below.
- Acquire some magnets. I found some small neodymium 2x5mm disk shape magnets on eBay.
- 100Ω..1kΩ resistor.
You will need some additional parts to complete the pendulum. This is up to your imagination, but I will give an example.
Step 2: How It Works
Imagine a magnet passing over a coil. According to the Faradey's law of induction, the voltage induced in the coil is proportional to the rate of change of the magnetic flux through the coil. Without going into equations, the induced voltage will depend on the number of turns in the coil, speed of the magnet, magnet's flux density ("strength") and the size/shape of the coil. The induced voltage will look pretty much like the one shown above (or inverted, depending on polarity). The first, in this case negative, part is induced as the magnetic field is entering the coil (magnetic flux rises) and the second, in this case positive, part as the field is leaving the coil (magnetic flux decreases). When the magnet is right above the coil the induced voltage is zero as the magnetic flux is constant, since the magnet is neither coming nor going, and the rate of change (derivative) of the field is zero.
OK, enough with the science. What we want is to detect the second part of the waveform just when the magnet passes the center of the coil. Then, by turning the coil into electromagnet, we'll give the magnet a small push.
Step 3: Schematic
Connect the resistor and the coil in series between A0 and GND on your Arduino board. Do not worry about the coil polarity as the proper operation can be achieved later by flipping the coil or the magnet. The resistor value is not fixed, different values will change the force that the magnet will be pushed with (lower resistance - higher force). Although it might even work without the resistor if the coil resistance is high enough, I would not recommend going bellow 100 Ω and relying on Arduino's current limiting (or the lack thereof).
If you do not have a premade coil you can make one. Find some thin enameled wire and wind a coil using this calculator. Aim for couple of mH or more. Mine is about 2.6 mH, inner radius ~15 mm, approximately 250 turns of 0.14 mm wire.
Step 4: Code
The ADC is constantly sampling the coil voltage at 1 ms period. Once the THRESHOLD value is reached during the second, positive, part of the waveform the coil turns into electromagnet, pushes the coil for PUSH_TIME milliseconds and than goes back to sensing the voltage again. Here, it is important that the second part of the waveform is positive since we cannot measure negative voltages directly with the Arduino's ADC.
Set THRESHOLD low enough to detect the magnet as soon as it passes the center of the coil, but high enough to avoid false triggering by noise. Set PUSH_TIME to couple of tens of milliseconds.
Step 5: Completing the Pendulum
Here is one example how to complete the pendulum. Using a plastic cap, a wire, some cotton thread and an IC make a miniature swing. Place the circuit inside the box, glue the coil under the top side of the cap and cut a hole for the power supply. Using some LEDs, diodes and resistors make a small figure, give it a pair of magnetic feet and place it on the swing. Adjust the thread length and bend the figure's legs to position the magnets just above the coil. Plug the power in, give the figure a little push and enjoy the perpetual motion! In case it is not working reverse the coil or magnet polarity and give it another try, or play with THRESHOLD and PUSH_TIME values as described above.
martin.pfitzner.942 made it!
We have a be nice policy.
Please be positive and constructive.