-
1Construction of Base
Note: See Paper for Figures
- Go to an open area, put on safety goggles, and long pants. Tie back any long hair
- Obtain the 6 in x 6 in wooden block and the ⅝ in drill bit.
- Mark off parallel lines 0.75 in from each edge of the block (see Figure 1)
- The intersections of the 4 lines should make four crosses. Drill 4 holes at these intersections using the ⅝ in drill bit and the drill press. (see Figure 1)
- Obtain the four 6 in bolts. Thread the four bolts through the holes.
- Thread the four washers through the bolts.
- Twist the ⅝ in nut on the narrow end of the bolt until the nut is flush with the washer.
-
2Construction of Electromagnet
Note: When using a band saw or drill press, make sure to wear safety goggles, clear the area, and be extremely careful.
- Obtain a 8 in x 8.5 in x 0.75 in block of wood.
- Mark 2 lines 2.5 in from the two longer edges with a t-square.
- Mark a line 2.5 inches from the top of the wood.
- This should divide the wood into six regions. Using a band saw, cut out the bottom left and bottom right portion to make a “T” shape. (See Figure 4)
- Mark lines 0.625 inches from each of the longer edges.
- Mark lines 0.625 inches and 1.375 inches from the top. This will create 4 intersections (see Figure 4)
- Repeat steps 1-6 on another piece of wood
- Obtain a 6 in x 8.5 in x 0.75 in block of wood.
- Mark 2 lines 1.5 in from the two longer edges.
- Mark a line 2.5 inches from the top of the wood.
- This should divide the wood into six regions. Using a band saw, cut out the bottom left and bottom right portions to make a “T” shape. (See Figure 5)
- Repeat steps 8-11 on another piece of wood.
- Use a vice grip to clamp one of the wider walls with the narrow ones as shown in Figure 4
- Drill a ½ in hole with the ½ in drill bit at the two intersections made in step 6 using a drill press.
- Repeat steps 13-14 on the other 3 sides of the 2 walls.
- Use the slotted screwdriver to screw 8 ½-11 x 1 screws into the 8 newly made holes. It should now look like Figure 6.
- Place the structure of 4 walls on the base (see Figure 7).
-
3Circuitry/Wiring
- Obtain 4 transistors, 4 6 amp diodes, 4 1 Ω resistors, 18 gauge wire, the 6 row terminal, the 12 volt power source, the perfboard, and the Arduino.
- Connect the parts as shown in Figures 8 and 9 (the 2 power sources represent the positive and negative coming in from the 12 volt power source going into the 6 row terminal).
- Connect the base wires of the electromagnets into the black side of the diodes and the top wires of the electromagnet into the white sides.
- Solder 5 wires to the shown pins on the MPU-6050, and connect it as shown in Figures 8 and 9. In addition, solder all wires down in the perfboard. When soldering, be extremely careful. Make sure the iron doesn’t touch your skin. Use safety goggles and tie back long hair
- Plug in the 12 volt power source into the power surge as shown in Figure 10.
-
4Levitating Structure
- Mark off four lines 0.75 inches from the edges of a 6 in x 6 in wood (see Figure 11).
- Mark off two diameters on each 1 inch magnet.
- Line up the intersection of the diameters with the intersections of the lines (see Figure 11).
- To find the orientation of the magnets, temporarily turn on the electronics to see which side repels the magnets.
- Use gorilla glue to glue the magnets to the surface.
- Using a hand sander, sand a 0.25 inch fillet on all 8 6 inch sides of the wood.
- Use the mounting screws and phillips screwdriver to attach the gyrometer to the center of the surface. (see Figure 14)
- Place the surface in the walls (see Figure 13)
-
5Code
- Open a laptop with the Arduino software (https://www.arduino.cc/en/Main/Software).
- Download the code from https://github.com/stressmaniac/ELSA or copy the code below
- Connect the Arduino to the laptop using the USB 2.0 cable.
- Press the upload button on the software.
- Plug in the surge protector into an outlet and turn on the surge protector.
//ELECTROMAGNETIC LEVITATION STABILIZATION APPARATUS //ELSA #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif MPU6050 mpu; #define OUTPUT_READABLE_YAWPITCHROLL #define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy-- is 6) bool blinkState = false; // MPU control/status vars bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer[64]; // FIFO storage buffer // orientation/motion vars Quaternion q; // [w, x, y, z] quaternion container VectorInt16 aa; // [x, y, z] accel sensor measurements VectorInt16 aaReal; // [x, y, z] gravity-free accel sensor measurements VectorInt16 aaWorld; // [x, y, z] world-frame accel sensor measurements VectorFloat gravity; // [x, y, z] gravity vector float euler[3]; // [psi, theta, phi] Euler angle container float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector // packet structure for InvenSense teapot demo uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' }; volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } void setup() { pinMode(6, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz) #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif // initialize serial communication // (115200 chosen because it is required for Teapot Demo output, but it's // really up to you depending on your project) Serial.begin(115200); while (!Serial); // wait for Leonardo enumeration, others continue immediately // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to // the baud timing being too misaligned with processor ticks. You must use // 38400 or slower in these cases, or use some kind of external separate // crystal solution for the UART timer. // initialize device Serial.println(F("Initializing I2C devices...")); mpu.initialize(); // verify connection Serial.println(F("Testing device connections...")); Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed")); // wait for ready //Serial.println(F("\nSend any character to begin DMP programming and demo: ")); //while (Serial.available() && Serial.read()); // empty buffer //while (!Serial.available()); // wait for data //while (Serial.available() && Serial.read()); // empty buffer again // load and configure the DMP Serial.println(F("Initializing DMP...")); devStatus = mpu.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(88); mpu.setYGyroOffset(42); mpu.setZGyroOffset(98); mpu.setZAccelOffset(1785); // 1688 factory default for my test chip // make sure it worked (returns 0 if so) if (devStatus == 0) { // turn on the DMP, now that it's ready Serial.println(F("Enabling DMP...")); mpu.setDMPEnabled(true); // enable Arduino interrupt detection Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)...")); attachInterrupt(0, dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus(); // set our DMP Ready flag so the main loop() function knows it's okay to use it Serial.println(F("DMP ready! Waiting for first interrupt...")); dmpReady = true; // get expected DMP packet size for later comparison packetSize = mpu.dmpGetFIFOPacketSize(); } else { // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) Serial.print(F("DMP Initialization failed (code ")); Serial.print(devStatus); Serial.println(F(")")); } // configure LED for output pinMode(LED_PIN, OUTPUT); } double Out9=255; double Out6=255; double Out11=255; double Out10=255; void loop() { // put your main code here, to run repeatedly: while (true){ mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus(); // get current FIFO count fifoCount = mpu.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if ((mpuIntStatus & 0x10) || fifoCount == 1024) { // reset so we can continue cleanly mpu.resetFIFO(); Serial.println(F("FIFO overflow!")); // otherwise, check for DMP data ready interrupt (this should happen frequently) } else if (mpuIntStatus & 0x02) { // wait for correct available data length, should be a VERY short wait while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); // read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); /*Serial.print(ypr[1] * 180/M_PI); Serial.print("\t"); Serial.println(ypr[2] * 180/M_PI); Serial.print("\t");*/ if (ypr[1] * 180/M_PI+4.3>5) { //Serial.print("y is pos"); if (Out9>=20){ Out9--; } if (Out11>=20){ Out11--; } if (Out6<255){ Out6++; } if (Out10<255){ Out10++; } } else if (ypr[1] * 180/M_PI+4.3<-5) { //Serial.print("y is neg"); if (Out6>=20){ Out6--; } if (Out10>=20){ Out10--; } if (Out9<255){ Out9++; } if (Out11<255){ Out11++; } } else if (ypr[2] * 180/M_PI+1.7>5) { //Serial.print("z is pos"); if (Out6>=20){ Out6--; } if (Out9>=20){ Out9--; } if (Out10<255){ Out10++; } if (Out11<255){ Out11++; } } else if (ypr[2] * 180/M_PI+1.7<-5) { //Serial.print("z is neg"); if (Out10>=20){ Out10--; } if (Out11>=20){ Out11--; } if (Out9<255){ Out9++; } if (Out6<255){ Out6++; } } else { //Out10=255; //Out6=200; //Out9=200; //Out11=255; } } analogWrite(9,Out9); analogWrite(6,Out6); analogWrite(10,Out10); analogWrite(11,Out11); //analogWrite(9,255); //analogWrite(6,255); //analogWrite(11,255); //analogWrite(10,255); Serial.print(ypr[1] * 180/M_PI+4.3); Serial.print("\t"); Serial.print(ypr[2] * 180/M_PI+1.7); Serial.print("\t"); Serial.print(Out6); Serial.print("\t"); Serial.print(Out9); Serial.println("\t\n"); Serial.print(Out10); Serial.print("\t"); Serial.print(Out11); // Serial.print("\t\n"); } }
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.