Electromagnetic Marble Accelerator for Gravitrax

by lincoln1clarke in Workshop > 3D Printing

223 Views, 5 Favorites, 0 Comments

Electromagnetic Marble Accelerator for Gravitrax

PXL_20250114_070448272.jpg
(From Above) Electromagnetic Marble Accelerator Gif - Made with Clipchamp.gif

Hi, I'm Lincoln Clarke, a grade 12 student at Toronto French School. In physics class, I recently studied electromagnetism and induction, so when I saw this contest, I immediately thought of magnets as a great topic: Magnets can act at a distance—to make things move.


In this Instructable, I'll show how I designed an electromagnetic marble accelerator.

Supplies

  1. 150 grams PLA filament
  2. 1x Arduino Nano
  3. 2x RFP30N06LE 30A 60V MOSFET
  4. 1x L7808 Voltage Regulator
  5. 2x 10SQ050 Schottky diode
  6. 3x SS49E Hall effect sensor
  7. 2x 10k resistor
  8. 1x 220 ohm resistor
  9. 1x LED
  10. 8x Female Jumper Wire
  11. Solder
  12. 120 grams of copper wire
  13. Hot glue
  14. Super Glue
  15. (12 V, 10A Power Supply)
  16. (3D printer, Solder Iron)

Inspiration

Untitled video - Made with Clipchamp.gif

I remembered using a Gauss cannon (As shown in the GIF above) in marble runs when I was little, but always disliking having to reset it. Electromagnets don't need resetting, and they provide even faster acceleration. Let's dive in!

Concept Design & Prototype #1

Electromagnetic Marble Accelerator (Write-up images) (7).png
Electromagnetic Marble Accelerator (Write-up images) (8).png
PXL_20250114_072633410.jpg
PXL_20250114_072624273.jpg

I initially considered 2 designs: One with electromagnets under the marble track, and one with electromagnets through which the balls pass. I initially decided on the first one, shown in the photos above, but it didn't work nearly as well as I hoped. To be strong, electromagnets need to have a soft iron core (or certain other metals). With the ball passing through the copper windings, the ball essentially acts as that core. The design with the ball passing through the magnet is much more effective, so that's what I'll be focusing on.

Optimizing the Electromagnets

desmos-graph (3).png

To start, the inner radius of the electromagnet (the hole in it) needs to be just large enough for the ball and the track to pass through. The inner radius will be 7.9 mm

Now, we need to optimize the outer radius.

Using the equation of the strength of an electromagnet and then developing it a bit, I created a Desmos graph that gives the magnetic field strength B in function of the outer radius of the electromagnet (given our inner radius). The formulas account for copper's specific heat capacity and increasing temperature as the device is used. I limited the power of the electromagnet to whatever causes a 1 degree increase in temperature per second the electromagnet is on (The electromagnet will be on for less than that each time). The power increases with increasing outer radius, because there's more copper to dissipate the heat. My graph also gives the mass of copper wire in function of the outer radius.

Link to Desmos graph

As shown in the graph above, field strength B increases linearly as we increase radius, and mass increases quadratically.

So, there isn't really an obvious perfect value. I'm going to make the outer radius 17 mm.

Detailed Design

Electromagnetic Marble Accelerator (Write-up images) (2).png
Electromagnetic Marble Accelerator (Write-up images) (3).png
Electromagnetic Marble Accelerator (Write-up images) (4).png

In this section, I'll explain my main design considerations.

Here are my priorities:

  1. Making it easily printable; minimizing the need for supports, especially ones that would be difficult to remove.
  2. Making it easy enough to manufacture (Finding a less tedious way to spool electromagnets than doing it manually. I once built a project with multiple 300-turn electromagnets and that was so tedious 😭)
  3. Building a housing for all the electronics. The final product looks much cleaner when the only wire coming out is a barrel jack for power. It also makes it easier to keep the product and use it years from now. With other Arduino projects I've made without electronics housings, I tend to go back to them later and I don't know where to put wires that have come lose.

My biggest challenge I encountered was making the device assemble-able. For printability reasons, I couldn't print the track and the electromagnets in once piece, so I needed to be able to insert the track after the electromagnets are assembled. That's why I settled on an asymmetrical design where the track is wide at the front, making it easy to attach to the housing, and narrow at the back, allowing it to be inserted through the electromagnets (Picture 1).

The electromagnet assembly also can't be printed in one piece, and even if it were possible, that wouldn't satisfy goal #2, manufacturability, because the spools need to be wound on their own before attaching them into the device. I added a thread in one end of each electromagnet, which serves both to wind the magnets, and to attach them into the final design (Picture 2). For winding the magnets, I went with the simple solution of designing a threaded drill bit (red in picture 2). Then, I just wound the electromagnets using a regular drill. This avoids the need for a specialized spooling device. After spooling, the electromagnets thread onto the connectors (blue in picture 2).

I designed the white housing in 3 pieces, top, middle, and bottom, because the black electromagnet assembly needs to be screwed in from the bottom, as shown in picture 3. That requires a removable bottom. The top and middle are separated for printability.

3D Printing

PXL_20250114_014410819.jpg

3D print one of every part below except the hex inserts—print two of those. The top cover is optional. In the end I chose not to use it.


My main tips for printing are

  1. Use resolution higher than 0.17 mm layer height because of screws
  2. Use support blockers for small areas that don't need supports. I've added an STL of a large block I designed for this purpose rather than adding a bunch of little ones in Cura.
  3. Print electromagnet spools separately: Don't use support brim, and set support overhang to 80 degrees. Also set X/Y distance over 1 mm and set X/Y support distance to take priority over Z. Otherwise supports can stick to the threads.

Circuit Design: Electromagnet Control

Electromagnetic Marble Accelerator (Write-up images) (10).png

Our circuit needs to be capable of turning on and off 2 electromagnets, which will each draw 12V, and around 4.5 amps.

We'll use 2 MOSFETs with the Arduino. However, the MOSFETs need additional protection because of the back emf induced by the electromagnets when turned on or off. This is not intuitive, and I fried a MOSFET in my first prototype before I realized this.

Faraday's law of induction explains why the back emf or flyback is produced: A changing magnetic field in a solenoid induces a current in the solenoid to oppose the change in magnetic field. When a solenoid is on, it creates its own magnetic field. When you turn it off, that magnetic field decreases rapidly and a current is induced in the solenoid to oppose the change. Because the current is opposing the change, the solenoid lead that was initially + becomes - and vice versa. That can damage MOSFETs.

We need to add a flyback diode on each electromagnet. To pick which diode to use, we need to calculate the voltage of the back emf.

EMF = - (μ * N^2 * A / L) * (dI / dt)
Where:
μ: Permeability of free space
N^2: Number of turns squared.
A: Cross-sectional area of the solenoid.
L: Length of the solenoid.
dI / dt: Rate of change of current.

Substituting our values, we can find the EMF. First, we need to calculate the number of turns given the mass of wire, since I didn't manually count as I spooled the electromagnets, but I did weigh them before and after spooling.

They have an average of 58 grams of copper per magnet. 454 grams is 251 meters, so 58 grams is 32 meters.

The average circumference is

C = 2 * pi * (r2 + r1)/2 = pi * (r2 + r1) = pi * (17.25 mm + 8.7 mm) = 81.5 mm = 0.0815 m

Dividing the total length by average circumference gives the number of turns: 32/0.0815 = 393 turns.

We also need to calculate the electrical current.

The 24 AWG wire we used has a resistance of 0.085 Ω/m. Multiplying by 32, the solenoid has a resistance of 2.72 Ω.

So, the current is 12 V/2.72 Ω = 4.41 A. When turning the electromagnet off, we'll make the assumption current decreases to zero in 1 millisecond.

EMF = - (μ * N^2 * pi * r^2 / L) * (dI / dt)
EMF = - (4π × 10^-7 H/m * 393^2 * pi * (0.017 m)^2 / 0.017 m) * (-4.41 A/0.001 s)
EMF = 45.7 V

So, we'll use a 50 V, 10 A (10SQ050) Schottky diode on each electromagnet along with a 30V, 60A MOSFET (RFP30N06LE).


The wiring for the electromagnet control is shown in the diagram.

Circuit Design: Sensing

Screenshot 2025-01-15 212126.png

Okay, so our circuit is capable of turning on and off the two electromagnets, but how will the Arduino know when to turn them on and off?

We'll use analog hall effect sensors (model SS49E), which sense magnetic field intensity.

First, we'll have a hall sensor under the track at the very front of the device, along with some very small, circular, permanent magnets (I stacked 4 3mm*1mm magnets). When the ball rolls into the device, its high magnetic permeability will change the magnetic field produced by those magnets, changing the value we read from the hall sensor. That allows the Arduino to sense when the ball rolls in, which will trigger the first electromagnet to be turned on.

Then, there's a hall sensor inside each of the two electromagnets. The electromagnets produce a magnetic field, which again, changes when the ball rolls in. The value we from the hall sensor will reach a maximum when the ball gets to the middle of the electromagnet and that's the point at which we shut off the electromagnet. If it's electromagnet #1, this also triggers #2 to be turned on.

The wiring for hall sensors is very simple as shown in the diagram.

Complete Circuit

Screenshot 2025-01-15 213912.png

Combining the last two steps and adding an LED which will indicate when the electromagnets are on, we get the circuit in the diagram above.

I soldered everything and used perfboard for the MOSFETs. I ended up making somewhat of a 3D circuit. The Schottky diodes are large so I soldered them vertically onto the perfboard and then bent them around.

By the end, it does get really messy with all the wires! I added electrical tape around any exposed wires.

Fortunately, the housing hides the mess!

Assembly

Electromagnetic Marble Accelerator (Write-up images) (11).png
Electromagnetic Marble Accelerator (Write-up images) (12).png
Electromagnetic Marble Accelerator (Write-up images) (13).png

Before coiling the electromagnets, glue in a hall effect sensor and tape around it (Picture 4). Then coil them using the drill.

Screw the electromagnet connectors together with M3 screws, and THEN screw on the electromagnet (Picture 5).

For the first Hall sensor, superglue four small magnets (I used 1mm*3mm) to add a magnetic field.

Screw the electromagnet assembly into the middle housing. Then, screw the top housing. Next, insert the track into the electromagnets, and snap it onto the top housing (with superglue).

Glue the first hall sensor to the bottom of the track.

Solder the MOSFETs to the perfboard, and then solder all the electronics in the housing. Glue the barrel jack using superglue.

Screw on the bottom casing.

Programming

There are a couple of tests we need to do before uploading the final code. First, we need to find the threshold at which to set the first hall sensor. Using the code "HallTest", I had the Arduino print the value from the first hall sensor to the serial monitor, and rolled a ball over the hall sensor. I found that with no all, the value was around 366, and with a ball, the value went down to around 361. I set it so that it detects a ball when the value falls below 365.

The next test is finding the value of the hall sensor in the electromagnets when the ball is at the center. When the ball reaches the center, we want to turn the electromagnet off so that it isn't pulling the ball back. For this test I programmed the file "ElectromagnetTest..." It basically just turns the electromagnet on for a couple seconds, and I allow the ball to get sucked to the center. I recorded my screen while I did this because it happens quickly.

I found that with the magnet off, the reading was around 523. With the magnet on and no ball, it read 544. As the ball approaches the center, the reading increases. With the magnet on and ball in the middle, the reading was 560.

I set it to turn off the first electromagnet when the value reached 551, since at that point things are happening very quickly, and by the time the electromagnet actually turns off, the ball is likely in the middle.

The second hall sensor didn't collaborate so well. In the test I just described, it worked fine. But when I uploaded the final program, the first electromagnet seemed to be interfering with results. I went for the simplest solution, which actually works very well: Setting a hard-coded amount of time for the second electromagnet to be on for. I played around with different values and ended up setting it at 83 milliseconds.

The Final Product

3D Printed Electromagnetic Marble Accelerator Demo

It works really well! I'm very impressed at the speed gets the ball going and at the height that speed can get the ball up. It truly makes an perpetual marble run—and a decently long one too!

Potential Improvements

desmos-graph (4).png

I'm very happy with the 3D design. The only change I'd maybe make would be to make the 2 electromagnet connectors one piece instead of two. That would require a bit more supports for printing, but probably still easy enough to remove, and it would make assembly a bit quicker.

The coding works well, but if the device was sitting for a long time, or temperatures changed, it's possible that the readings from the hall effect sensors would be slightly different. On the ones in the electromagnets, that's not such a big deal, because the thresholds aren't as sensitive. However, on the first hall sensor, even the value changing by 2 analog increments could cause the device to detect a ball even when one isn't there, or to never detect a ball at all. To improve this, I could a calibration period at the beginning where the user makes sure there's no ball on the track, and the Arduino sets the detection threshold to 2 analog increments below the value sensed with no ball.

Again, to make the code a bit more robust, rather than relying on specific thresholds for turning off the electromagnets (And a hard-coded time for the second electromagnet), we could use the derivative of the analog signal: As the ball approaches the center, the rate of change of the value from the hall sensor increases. The graph of the derivative would probably look something like the one shown above. We could set a threshold for the derivative, and when it increases past that value, then the electromagnet shuts off.

Another, simpler solution would be to shut off the electromagnet as soon as the hall sensor's value starts declining. However, that would reduce performance because the electromagnet would shut off slightly late.