17
Zane Youmans Embedded Systems 5/5/2015 Introduction: For the final project, I am to demonstrate what I have learned in the Embedded Systems class by undertaking a project of my own choice, and implementing the skills necessary to make it function. Objective: My choice for a final project was to build a tabletop arcade claw machine. The claw machine had the following design goals: Fit on a tabletop Move in the X, Y and Z directions Pick up objects within its sphere of influence Have custom frame and 3D printed parts Simple interface Mechanically appealing to see Figure 1 shows the project at its current stages of completion.

e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Embed Size (px)

Citation preview

Page 1: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

Introduction:For the final project, I am to demonstrate what I have

learned in the Embedded Systems class by undertaking a project of my own choice, and implementing the skills necessary to make it function.

Objective:My choice for a final project was to build a tabletop arcade

claw machine. The claw machine had the following design goals:

Fit on a tabletop Move in the X, Y and Z directions Pick up objects within its sphere of influence Have custom frame and 3D printed parts Simple interface Mechanically appealing to see

Figure 1 shows the project at its current stages of completion.

Figure 1 – Semi-complete

Methods:In order to accomplish as many of the goals as possible, the

mechanical and electrical systems needed to be taken into consideration. The mechanical system was dealt with first. A metal frame was constructed out of 0.75 inch steel tube. Custom 3D printed parts were designed in Autodesk 123D design and

Page 2: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed parts.

Figure 2 – Autodesk CAD

Figure 3 – Printed parts

To achieve X, Y and Z motion, a gantry system had to be devised that could be moved by means of a motor. The lead screw method was chosen for its easy of construction and durability at the cost of speed. The lead screw method uses a long, threaded rod down the center of the axis that goes through a captive nut in the gantry. A motor will turn this threaded rod and move the nut back and forth along the axis. Figure 4 shows the implementation of this system.

Page 3: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

Figure 4 – The two Lead Screw systems

Two lead screw gantries were used to obtain X and Y motion. The Z direction was simply controlled by another motor that winds the claw string up and down. X, Y and Z motion make for a very sturdy frame that moves in the Cartesian coordinate system, or Rectangular coordinate system. Figure 5 shows this in detail.

Figure 5 – Cartesian coordinates

The motors of choice for this project were stepper motors. Stepper motors were chosen for their convenient shape and high torque at low speeds. The motors can be run at low speeds because the Lead Screw method is slow anyway.

Page 4: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

The electrical system played an intricate part in the project, as it demonstrates skills that were learned in class.The microcontroller of choice was the MSP430F5529 from TI. This controller was selected for its large number of I/O pins. A chip to help drive the stepper motors was also required. The L293 Dual H-Bridge from TI was selected for this job. The L293 can run two DC motors, or one stepper motor depending on the setup. A common circuit is used to run a four pin stepper motor with four pins from the MSP430. Figure 6 shows the circuit.

Figure 6 – Motor controller

Each of the leads labeled “Pin” are connected to a pin on the MSP430, and the leads labeled “Coil” are connected to the coils of the stepper motor. At that point, it’s a matter of pulsing the pins on the MSP430 in the right sequence to get the motor to rotate.

The interface to control the claw machine is a simple digital joystick and button. The joystick has four switches inside that are pressed when the joystick is moved. The button also has a single switch inside that is activated when the button is pressed. Figure 7 shows the back of these components.

Page 5: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

Figure 7 – The back of the controls

These five switches can be read in easily by the MSP430 to control the motors. The button is what activates the dropping of the claw to pick up objects. Figure 8 shows the full layout of the electronics.

Figure 8 – Electrical system

Page 6: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

Notice how there is a servo near the bottom of the system. This is what controls the opening and closing of the claw, but it has not yet been implemented. The five switches on the right side are the joystick and pushbutton. The whole system is powered from an old computer power supply because of the high current needed by the motors. Figure 9 shows the implemented electronics.

Figure 9 – The electronics

Each motor controller is a separate board for prototyping reasons. A special board was made to allow the MSP430 to easily connect to the motor drivers and controls by simply plugging it in. Some specialty heat syncs were also manufactured to help keep the motor driver chips cool. The code running the whole system can be found the Appendix A.

Page 7: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

Results:The construction of this project required the following

materials:

Part Name Qty Price/Unit RetailerMSP430F5529 1 $12 TI.com

L293 3 Free Samples TI.comStepper Motors 3 $13.50 DFrobot.com

Joystick 1 $8.40 Ebay.comPush Button 1 $0.90 Sparkfun.comPower Supply 1 Free Already hadSteel tube N/A Free Already had

Upon completion of this documentation, the met and unmet goals are as follows:

Goals met Goals not metFits on a table

Move in X,Y and Z dir.Pick up objects

Custom frame/3D printSimple interface

Mechanically appealing

Due to the number of goals that have been met, this project can be considered a success at its current point.

Conclusions:Even though the project is not yet complete, there were many

lessons learned from the process.

Start early Don’t focus too much on the mechanics Stepper motors are difficult to program manually 3D modeling skills Time budgeting Ask for help when it’s needed Failure is a good way to learn

Page 8: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

Appendix A:

#include <msp430.h>

//motor 0 is P1 5-2 the y//motor 1 is P6 0-3 the x//motor 2 is P2 0,2,6,3 the claw//joystick dir P3.4/up P3.3/down P3.6/left P3.5/right

volatile int current_step[] = {0,0,0};volatile int motor[]={0,1,2};volatile int i=0;

void step_cw(int motor, int steps);// int current_step);void step_ccw(int motor, int steps);void delay(int ms);int direction(void);

int main(void) {volatile int current_dir=0;WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timerP1DIR = BIT2+BIT3+BIT4+BIT5;P6DIR = BIT0+BIT1+BIT2+BIT3;P2DIR = BIT0+BIT2+BIT6+BIT3;P3REN = 0xFF;P2OUT = 0x00;P1OUT = 0x00;P6OUT = 0x00;P3OUT = 0x00;

while(1){current_dir = direction();if(current_dir == 1){step_ccw(1,4);}if(current_dir == 5){step_cw(1,4);}if(current_dir == 3){step_ccw(2,4);}if(current_dir == 7){step_ccw(2,4);}

if (current_dir == 9){

Page 9: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

step_cw(0, 600);__delay_cycles(1200000);step_ccw(0,600);

}}}

void step_ccw(int motor, int steps)// what motor to turn and how far to turn it{

switch(motor){

case 0:{

for( i = 0; i <= steps; i++){

if(P1OUT == 0){

P1OUT = BIT5+BIT2;}else if(P1OUT == BIT4+BIT2){

P1OUT = BIT5+BIT2;

}else if(P1OUT == BIT5+BIT2){

P1OUT = BIT5+BIT3;}else if(P1OUT == BIT5+BIT3){

P1OUT = BIT4+BIT3;}else{

P1OUT = BIT4+BIT2;}__delay_cycles(3000);

}P1OUT=0;break;}case 1:{

for( i = 0; i <= steps; i++){

if(P6OUT == 0){

P6OUT = BIT0+BIT3;

Page 10: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

}else if(P6OUT == BIT1+BIT3){

P6OUT = BIT0+BIT3;

}else if(P6OUT == BIT0+BIT3){

P6OUT = BIT0+BIT2;}else if(P6OUT == BIT0+BIT2){

P6OUT = BIT1+BIT2;}else{

P6OUT = BIT1+BIT3;}__delay_cycles(3000);

}P6OUT=0;break;}case 2:{

for( i = 0; i <= steps; i++){

if(P2OUT == 0){

P2OUT = BIT0+BIT3;}else if(P2OUT == BIT2+BIT3){

P2OUT = BIT0+BIT3;

}else if(P2OUT == BIT0+BIT3){

P2OUT = BIT0+BIT6;}else if(P2OUT == BIT0+BIT6){

P2OUT = BIT2+BIT6;}else{

P2OUT = BIT2+BIT3;}

if(P1OUT == 0){

P1OUT = BIT4+BIT2;

Page 11: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

}else if(P1OUT == BIT5+BIT2){

P1OUT = BIT4+BIT2;

}else if(P1OUT == BIT4+BIT2){

P1OUT = BIT4+BIT3;}else if(P1OUT == BIT4+BIT3){

P1OUT = BIT5+BIT3;}else{

P1OUT = BIT5+BIT2;}

__delay_cycles(3000); //change for claw}P2OUT=0;P1OUT=0;

break;}

}}

void step_cw(int motor, int steps)// same as above, but the other way{switch(motor){

case 0:{

for( i = 0; i <= steps; i++){

if(P1OUT == 0){

P1OUT = BIT4+BIT2;}else if(P1OUT == BIT5+BIT2){

P1OUT = BIT4+BIT2;

}else if(P1OUT == BIT4+BIT2){

P1OUT = BIT4+BIT3;}else if(P1OUT == BIT4+BIT3){

P1OUT = BIT5+BIT3;

Page 12: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

}else{

P1OUT = BIT5+BIT2;}__delay_cycles(3000);

}P1OUT=0;break;}case 1:{

for( i = 0; i <= steps; i++){

if(P6OUT == 0){

P6OUT = BIT1+BIT3;}else if(P6OUT == BIT0+BIT3){

P6OUT = BIT1+BIT3;

}else if(P6OUT == BIT1+BIT3){

P6OUT = BIT1+BIT2;}else if(P6OUT == BIT1+BIT2){

P6OUT = BIT0+BIT2;}else{

P6OUT = BIT0+BIT3;}__delay_cycles(3000);

}P6OUT=0;

break;}case 2:{

for( i = 0; i <= steps; i++){

if(P2OUT == 0){

P2OUT = BIT2+BIT3;}else if(P2OUT == BIT0+BIT3){

P2OUT = BIT2+BIT3;

}

Page 13: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

else if(P2OUT == BIT2+BIT3){

P2OUT = BIT2+BIT6;}else if(P2OUT == BIT2+BIT6){

P2OUT = BIT0+BIT6;}else{

P2OUT = BIT0+BIT3;}

if(P1OUT == 0){

P1OUT = BIT5+BIT2;}else if(P1OUT == BIT4+BIT2){

P1OUT = BIT5+BIT2;

}else if(P1OUT == BIT5+BIT2){

P1OUT = BIT5+BIT3;}else if(P1OUT == BIT5+BIT3){

P1OUT = BIT4+BIT3;}else{

P1OUT = BIT4+BIT2;}

__delay_cycles(3000); // change for claw}P2OUT=0;P1OUT=0;

break;}

}}

void delay(int ms)// didn't use this one{volatile int l;for(l=0; l <= ms; l++){__delay_cycles(250000);}}

int direction(void) // check the direction of the joystick and button state{if(P3IN == BIT4 )

Page 14: e2e.ti.com · Web viewCustom 3D printed parts were designed in Autodesk 123D design and printed on a 3D printer. Figure 2 shows one of the CAD files and Figure 3 shows some printed

Zane Youmans Embedded Systems 5/5/2015

{return 1;}else if(P3IN == BIT4 + BIT6){return 2;}else if(P3IN == BIT6){return 3;}else if(P3IN == BIT6+BIT3){return 4;}else if(P3IN == BIT3){return 5;}else if(P3IN == BIT3+BIT5){return 6;}else if(P3IN == BIT5){return 7;}else if(P3IN == BIT5+BIT4){return 8;}else if(P3IN == BIT2){return 9;}else{return 0;}}