## Final Project

### The Final Final Project: Magnet Maze

Something more fun. Something with more Fab Lab skills. Something called: MagMaze

I wanted to do something fun.  I wanted to do a game.  In review of input and output possibilities, programming environments I am familiar with, and a desire to use as many new skills as possible, I landed on the MagMaze.  This fully functional prototype acts as a play and puzzle surface wher you navigate a user constructed maze with a steel ball pulled, pushed, and bounced.

Presentation Slide

MagMaze Development - Skills Learned - R&D - What Worked and What Did Not - What I Learned - Bill of Materials - Fabduino and Coding - Future Enhancements

What is the MagMaze?
The MagMaze (pictured at left) allows the player to control the X/Y position of an electromagnet via joystick in a 300mmX 300mmX150mm enclosed box (Game Box).  The electromagnet moves with varying speed based on the joystick input under a plastic netting stretched over the box.  On the top of this netting rests a 3/4" polished steel ball suspended via the netting 1" above the  electromagnet.  Above the ball is a clear plexiglass 300mm X 300mm X 150mm partial box (Puzzle Grid) that rests on the Game Box.  This Puzzle Grid has 5mm holes drilled every 15mm in X and Y to allow the user to insert puzzle pieces suspended under the clear plexiglass top.  The player can create a puzzle or maze by pulling the Puzzle Grid off the Game Box and inserting a variety of puzzle pieces.  The player can create many different kinds of mazes and obstacles that include walls, holes, jumps, poles, and magnet hazards.

The nature of the game lies in navigating the maze or just plyaing with the ball by using the electromagnet.  When the electromagnet is engaged it pulls the ball down causing a storage of elastic potential energy in the plastic netting.  When the electromagnet is switched off the energy is transformed to kinetic energy which causes the ball to jump off the netting.  Thus, the ball can be made to move across the plastic netting and  through suspended hoops and bars in the maze.

How this was developed
This game started out as an attempt at magnet levitation.  I peformed tests with various electromagnets to see if I could code something that adjusted a series of electromagnets under a magnetic disk to balance the repulsion of the disk and net a "floating" disk.  I quickly learned that the toroidal magnetic fields necessary, and their rapid constant adjustment, was beyond my coding capability at the moment.  Aside from the challenges of coding an X/Y apparatus to respond to an analog joystick and move a mounting plate (for the electromagnet), the addition of the levitation was clearly not going to be attainable in the time frame necessary.  I dove into the electronics and programming to explore the possibilities and learned how to control the stepper motors with the joystick inputs.  Once I had the two two steppers and joystick conencted to the Arduino I started work on the mechanical enclosure.  The Arduino Uno was used to prototype while I worked the kinks out of fabricating an home made Arduino called a Fabduino. I then started scavenging parts from various printers and other electronics to start work on the enclosure.  The enclosure is prototyped with old metal from various robots and an extruded aluminum square rod called Openbeam.  Openbeam allowed construction of the Game Box, it's X/Y control infrastructure and the Puzzle Grid.

What skills learned in the course were used to accomplish this:

Electronics production: Fabduino is the central control for user input via an analog joystick to output on two NEMA 17 stepper motors.  It also controls the on/off of the electromagnet via a switch built into the joystick.

1. Electronics production: Eagle, FAB ISP to burn the bootloader onto the Fabduino
2. Programming with the Arduino IDE and Text editor
3. Inputs: Analog joystick with incoporated switch, LEDs
4. Outputs: Stepper motors
5. CAD design: intial design using paper and pencil and then AI and TinkerCad for multiple areas
6. 3D printing: the X and Y axis control rods connecting to the Stepper screw rods requires a custom part.  I ended up with 7 differnet custom parts all printed with a 3D printer.  I ended up using a printer called the Cube, by 3D Systems.
7. Laser cutter: design of case and control mounting board (not in prototype, future enhancement).  The entire case can be a press fit construction and allow for easy scaling of the project via kit form if desired.

What worked and what didn't

1. I moved through three versions of the stepper mounting plate.  V0.3 is current build being used.
2. The mounting plate made of PLA is working very well and seems strong enough.
3. When the motors work together they pull against each other.  The steel rods do not remain perpendicular to the plane of motion causing binding.  I will need to develop more than just a ledge for the rod to move along. I will need to add control rods and bearings to follow the control rod opposite the stepper motor rod.
4. The magnet works well to draw the steel ball along the netting.  However, the ball is only getting 5V and is rated for 12V.  I need to power the ball through the computer power supply 12V and add a knob to vary the intensity of the magnet.  This will allow the ball to sprung higher in the air.
5. The Fabduino continues to be temperamental and I am going to mill the board over again after I manually tweak some traces in Gimp.  I cannot get consistent operation out of it.
6. The puzzle peg board needs to be designed in CAD and run through a CNC to get accurate peg holes for the puzzle pieces.  I created a jig, but it needs to be perfect to work easily.  An alternate to this could be to make the board out of acrylic and cut it on the Laser cutter.
7. The puzzle pieces need to milled or 3D printed to get better tolerances for the peg board.

What I learned

1. I learned a ton on how to code the joystick with the motors.
2. I learned how bring together a whole system of mechanical parts and have them work in concert with user input.
3. I learned about stepper motors and various driver boards.  With easier access to the lab I can mill my own and use a custom design.
4. That there are only 60 minutes in an hour and no matter what you do to squeeze more in you have to give stuff up to get to the finish line.

R&D

1. Game Box
1. The Game Box is constructed out 15mmX15mmX1000mm extruded aluminum stock from a company called Openbeam.  The owner is great and helped me setup a classroom right after his kickstarter campaign.  The Openbeam stock is connected using his "T" and "L" fittings and standard 3mm hardware.  The box has VEX rails to serve as tracks for the steel rods which serve as the X and Y axises. The vex also uses the same connecting bolts.
2. Puzzle Grid
1. The puzzle grid is a five sided box made with Openbeam stock and hardware with Lexan.  The Lexan is mounted in the grooves of the Openbeam stock.  The Lexan has holes driled at 20mm intervals to form a grid that will accept the insertion of puzzle pieces which extend under the top of the Lexan going toward the plastic netting.  This allows the user to change the obstacles for a variety of challenges.
3. Stepper control bar linkage boxes (qty 2)
1. These boxes serve as the connector between the stepper motor drive shafts and drive shaft nut and the steel rods for both X and Y. These are custom designs and 3d printed in PLA.  The X and Y boxes are not identical due to spacing in tracks.
1. Cube workflow:
1. Design part and export as .STL file.
2. Open Cubify design software and import file.
3. jClick the "heal" button on the software.
4. Under settings: set to PLA, set to medium density for Cube 2, set to no rafts or supports
5. Click on "Upload" button to export and save t thumb drive
2. X and Y axis linkage boxes
1. V0.2 X axis linkage box on Thingiverse here.
2. V0.2 Y axis linkage box on Thingiverse here.
3. [UPDATE] Due to the nature of the blocks and linkages interferring with chassis connecting hardware, the stepper control plate had slides instead of holes designed into the plate so the plate can slide up and down to tune the linkage blocks.

1. Magnet central mount: This box connects the two steel rods and serves as a mounting point for the electro magnet.  This also allows the use of bearings to hold the steel rods.  Part on Thingiverse.

1. Rod pillow block: this connects on the opposite end of the guide rod to keep it level across the Game Box. Part on Thingiverse.
1. Stepper motor mounting plate
1. A component is available from Openbeam to mount NEMA17 stepper motors.  However, the design did not quite meet my specification for mounting the motors in a hybrid Openbeam and VEX infrastructure. I designed custom plates and printed them out on a Cubify 3D printer.  The printing ended up taking quite a bit of time as I attempted to make a new 3d printer operational (The Buccaneer by Pirate 3D), but it would not even load filament out of the box.  The Cube 1 is a fairly solid printer that is dependable…usually.  We will see if the PLA plates will hold up.
1. Cube settings
1. Print 1 set with raft enabled and at medium (strong) density.
2. Probably need to remove the raft since this is a flat piece and added thickness.
2. These should probably be machined out aluminum plate for strength.  The Shapeoko just arrived and is 6-8 hours of build time.  Time that is not currently available to meet deadlines.
3. Nema 17 stepper motor mounting plate V0.2 available on Thingiverse here
1. Fabduino - I used a Fabduino and the Arduino IDE to control the motors, switches, and magnet.

1. Openbeam components
1. extruded aluminum
1. 8 X 6"
2. 8 X 15"
2. plastic connectors
1. 8 X "T" connectors
2. 8 X corner connectors
3. bolts, nuts, washers
1. 144 M3 5mm bolts
2. 144 M3 nuts
3. 76 #8 washers
4. 2 X Stepper motor mounts
2. VEX metal
1. 4 "L" bracket strips
3. Plastic netting
1. 1 X 18"X18"
4. Lexan
1. 1 X 15"X15"X3/16"
2. 10 X 1"X6"X3/16"
5. Electronics
1. 1 X Fabduino
2. 2 X Stepper driver boards
3. 1 X Joystick
4. Varous connecting wires
1. 2 X Stepper driver board to Fabduino
2. 2 X Stepper power supply
3. 2 X Stepper to driver board connectors
4. 1 X electro magnet to Fabduino
5. 1 X
5. 1 X Electromagnet
6. 2 X Stepper motors
7. 1/2" steel ball
8. 1 X Pushbutton switch (prototype switch is built-in to joystick)
9. Computer power supply
6. Miscellaneous
1. 2X polished steel rods

The Fabduino

I decided to use the Arduino IDE and fabricate a Fabduino to control the stepper motors, analog joystick, limit switches (future enhancement), electromagnet and anything else that was needed.  I control the stepper motors with a Stepper Motor Driver v3.3 off an old Makerbot (version 1).

The Fabduino development from Week 10:

Arduino Code

//Magnetic Sphere Sphere Game

//This uses a dual potentiometer joystick to control two stepper motors in X and Y axis

//declare pins for X axis

int potPin = 1;

int Step_X = 13;

int Dir_X = 12;

int Enable_X = 8;

//declare pins for Y axis

int potPin2 = 2;

int Step_Y2 = 11;

int Dir_Y2 = 10;

int Enable_Y2 = 7;

//declare values

int Speed_X = 0;       //step speed (delay between steps)

int val= 0;

int j = 0;

int Speed_Y2 = 0;       //step speed (delay between steps)

int val2= 0;

int j2 = 0;

void setup() {

pinMode(Step_X, OUTPUT);

pinMode(Dir_X, OUTPUT);

pinMode(Enable_X, OUTPUT);

pinMode(Step_Y2, OUTPUT);

pinMode(Dir_Y2, OUTPUT);

pinMode(Enable_Y2, OUTPUT);

//Serial.begin(9600); // used to debug, must add writes after joystick valued reads

}

void loop() {

j = val - 432;  // 517 is center positions - how far from center?

j = abs(j);      //absolute value

Speed_X = 10000/j;  //This math inverts the value and scales as needed

//(value found through trial and error)

// The delay between steps will determine the speed of the motor

// So, delay up = speed down

j2 = val2 - 432;  // 432 is center positions - how far from center?

j2 = abs(j2);      //absolute value

Speed_Y2 = 10000/j2;  //This math inverts the value and scales as needed

//(value found through trial and error)

// The delay between steps will determine the speed of the motor

// So, delay up = speed down

if (val >= 442){

digitalWrite(Enable_X,LOW); // enable

digitalWrite(Dir_X, HIGH);  // Set direction

digitalWrite(Step_X,HIGH);

delayMicroseconds(2);

digitalWrite(Step_X,LOW);

delayMicroseconds(Speed_X);

}

if (val2 >= 442){

digitalWrite(Enable_Y2,LOW); // enable

digitalWrite(Dir_Y2, HIGH);  // Set direction

digitalWrite(Step_Y2,HIGH);

delayMicroseconds(2);

digitalWrite(Step_Y2,LOW);

delayMicroseconds(Speed_Y2);

}

if (val <= 422) {

digitalWrite(Enable_X,LOW);// enable

digitalWrite(Dir_X, LOW);  // Other direction

digitalWrite(Step_X,HIGH);

delayMicroseconds(2);

digitalWrite(Step_X,LOW);

delayMicroseconds(Speed_X);

}

if (val2 <= 422) {

digitalWrite(Enable_Y2,LOW);// enable

digitalWrite(Dir_Y2, LOW);  // Other direction

digitalWrite(Step_Y2,HIGH);

delayMicroseconds(2);

digitalWrite(Step_Y2,LOW);

delayMicroseconds(Speed_Y2);

}

if (val <=442 && val >= 422) {

digitalWrite(Enable_X,HIGH);  // disable the stepper X motor if the X axis is centered

}

if (val2 <=442 && val2 >= 422) {

digitalWrite(Enable_Y2,HIGH);  // disable the stepper Y motor if the Y axis is in the center

}}

Future Enhancements aka What I would do differently:

1. A planned enhancement is an additional knob to control the intensity of the electromagnet.
2. Make stepper motor mounting plates out of ABS and or CNC them out of hi density plastic and/or aluminum on the Shapeoko.
3. Create more puzzle pieces.
1. Create pieces with bars, walls, small openings, jumps, magnet hazards, holes.
4. Create custom rails via 3d print or CNC for steel rods.
5. Add a separate button for controlling the magnet on/off state.
6. Bump the voltage on the electromagnet to 12V.
7. Add guides for the puzzle grid and perhaps velcro attachment points.
8. Add an edge to the puzzle grid so the ball will not fall off.
9. Add limit switches to prevent the motor for over extending.

### A new project idea

I have decided to redirect to a project that involves more electronics, sensors and kinetic movement of structures to reflect the local world via an artistic representation.  I feel this is more in line with my current work and will serve as an example of integrating an "A" into STEM to give us STEAM.  This project is not yet named, but there is a rough sketch below.  This 3-4 foot across creation will be prototyped in a plywood veneer.  The person on the unicycle, pedaling speed being driven by a photo voltaic panel (which powers the device), will move from left to right to indicate day of the month. Sensors include: UV, Ammeter, Clock, Pressure, and maybe humidity.  The movement of the unicyclist from left to right requires a track and may be the most complex.  The moving pieces include the person, sun/moon, clouds (they rise from behind mountains, and thunderclouds.  Each sensor is tied to a movement reflected in real time.  I would like to include user interaction and am considering the inclusion of a decibel sensor.

### 3d Model

This week we were tasked with exploring tools and modeling our final project.

Inkscape (vector drawing), Gimp (bitmap painting) and Tinkercad (3d modeling) all seemed like good tools and all free and readily available.  The first tool, and I think the most fun, is Tinkercad.  Below is a rendering from Tinkercad using another website called SketchFab to present the model on this site and be able to jump out and manipulate it.  Tinkercad is an online modeling program and the coolest feature comes from it being online.  All your models are in the cloud and easily manipulatable via any Internet connected computer.  I started using this tool with 4th graders and middle school students and  love its simplicity.  They have great online tools and I just learned yesterday that Autodesk bought them.  The model below shows the beginning of our Street Shower project.

Briefly, the shower will function to allow the homeless to take showers.  It will feature elements such as photo voltaic power, solar radiation water heating, a bioswale to filter reclaimed water for hydroponics irrigation (possibly Aquaponics if time permits), environmental educational write-ups on the outside, a myriad of sensors to collect data on the Street Showers use, current status, etc. as well as an environmental music system that interacts with the environment for mood music.

You can manipulate the below model if you click on the cube.  This version of the shower shows the trailer, tanks underneat the decking, and the beginning of a hollow wall structure that will house a bioswale and hydroponics grow bay.  The walls will have transparent and translucent panels to allow users to see the inner workings while maintaining privacy of the shower.  On top will be placed a photo voltaic panel to power a low voltage power system to run pumps, electronics and the sound system.

Two of my students and I started prototyping the wall system for the bioswale and hydroponic walls.  We made extensive use of the whiteboard to do some rapid prototyping.

We then took extruded aluminum to create a working prototype to test the bioswale concept as well as the hydroponic concept.

We are looking at a series of drawers for the bioswale each with a different substrate: dirt, sand, gravel, etc.  The desire is to have a visual of all elements so a clear polycarbonate drawer is ideal.  The design currently has a clear solid panel on the exterior and interior as well as the sides of the drawers.  the drawers will be approximately 3.5ft and six inche square.  A breakout of this design in CAD is in the works.  The hydroponic wall will possibly have PVC pipe that snakes across and down using beer cups to hold individula plants all behind clear polycarbonate interior and exterior walls.  The exterior panels of the walls will need to be removable or hinged to gain access for maintenance.  In addition, we will have a hydroponic system near the entrance to the shower to allow users to harvest hydroponically grown mint to add fragrance to the interior in a crush (mortar) dish on the wall.

The design will include a low voltage power system driven from a PV panel on the roof.  This system will power pumps, microcontroller sensors, and data presentation to the users and those waiting for the shower (schematic in the works)

The exterior of the shower will include documentation on the systems and how they interoperate to provide the shower, hydroponics, and sound system (which is environmental).  While users wait for the shower they can learn and interact with the shower.  This will help maintain the shower via assisting water recovery, adding energy to the systems, maintenance of the bioswale and hydroponics systems, etc.

The biowswale will function to filter the drain water for the use in the hydroponic system.  Shower water will come from a potable water source and will be stored in a tank below the floor.  A "Green" water tank will accumulate filtered water from bioswale.

### Proposal

When our small cohort of 3 met to brainstorm our final project we had three ideas:

1. Aquaponics
2. Boom box on a skate board
3. A mobile shower

It occurred to me that perhaps we might do all three combined.  Ambitious?  Perhaps.  Lets tease the idea and see where it leads.  For now, we will call this Street Spa.  Our ideation session was both short and rich.  Here is a whiteboard sketch from today.