Difference between revisions of "Marionette"
Victor Liu (talk | contribs) (→Code) |
Victor Liu (talk | contribs) |
||
(142 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Image:MarionettePicForIntro.JPG|thumb|right|350px|Here's looking at you, kid]] |
|||
Marionette Wiki Page |
|||
<br> |
|||
[http://hades.mech.northwestern.edu/wiki/index.php/ME_333_final_projects back to project list] |
|||
==Team== |
==Team== |
||
* Jad Carson (Biomedical Engineering) |
* Jad Carson (Biomedical Engineering) |
||
* Victor Liu (Mechanical Engineering) |
* Victor Liu (Mechanical Engineering) |
||
* Matt Watras (Electrical Engineering) |
* Matt Watras (Electrical Engineering) |
||
[[Image:TeamPicMarionette.JPG|right|thumb|300px|Team Photo From left to right: Victor, Jad, Matt.]] |
|||
==Overview== |
==Overview== |
||
The goal of this project was to make a |
The goal of this project was to make a marionette that could move in a 2D plane via motors. Our group decided to show movement by programming 5 different routines, each controlled by a button press. We used a 5 bar linkage with 2 RC Servos to motivate each arm with 2 degrees of freedom, and also added one RC Servo to each shoulder of the figure to allow it to rise off the ground, giving the appearance of moving its feet. Our puppet was a [[:image:Gijoe_datasheet.jpg|GIJoe action figure]], whose joints we modified for easier motion. Also, we modeled the servo frame to resemble a stage for added effect. Our 5 routines were: |
||
* Hula Dance |
* [http://www.youtube.com/watch?v=eRolRlvKmyI Hula Dance] |
||
* Jumping Jack |
* [http://www.youtube.com/watch?v=8yr8M590zaE Jumping Jack] |
||
* Conducting |
* [http://www.youtube.com/watch?v=IOnC6MSEzm8 Conducting] |
||
* Left arm pan while right foot tap then right arm pan while left foot taps |
* [http://www.youtube.com/watch?v=rxXlxNYYN7M Left arm pan while right foot tap then right arm pan while left foot taps] |
||
* Left and right arm pointing up and going back to neutral position one after another while marching in place |
* [http://www.youtube.com/watch?v=dvNr0Xz4hQ8 Left and right arm pointing up and going back to neutral position one after another while marching in place] |
||
Our puppet was a GI Joe doll that we loosened the arm joins of and we also built a stage for him to dance on. While working on this project, we ran into a few obstacles that needed to be overcome. First, we needed to decide how to mechanically move his arms so that he had 2 degrees of freedom. Second, because we were making a marionette and therefore using string, we needed to take into account how his momentum affected his movement. Finally, we needed to be able to control his movement so that we could have him go through our desired movement, such as pure X motion, pure Y motion, or a motion in between such as diagonal or a parabola. |
|||
==Mechanical Design== |
==Mechanical Design== |
||
===Stage Construction=== |
|||
The marionette is housed in a 24x15x13.5 inch frame constructed of mainly wood. This structure is intended to mimic a theater stage while providing a solid base for the puppet itself and the accompanying servos and electronics. Four plywood pieces are used to construct the frame and put together with wood screws. The top piece is about 4 inches shallower than the base pieces to accommodate the manipulators. |
|||
The marionette is housed in a 24x15x13.5 inch frame constructed of mainly wood. This structure is intended to mimic a theater stage while providing a solid base for the puppet itself and the accompanying servos and electronics. Four plywood pieces are used to construct the frame and put together with wood screws. The top piece is about 4 inches shallower than the base pieces to accommodate the manipulators. A small button box made of PVC Expand foam sheets is attached to the side of the frame. The buttons are used to trigger the individual routines. |
|||
<center> |
<center> |
||
<gallery> |
<gallery perrow="6"> |
||
Image:stage_front.jpg| |
Image:stage_front.jpg|Front stage and descriptions |
||
Image:stage_back.jpg| |
Image:stage_back.jpg|Back stage |
||
Image:stage_side.jpg|Stage |
Image:stage_side.jpg|Stage profile |
||
Image:stage_cad.jpg|Initial design in CAD |
|||
Image:stage_cad_servos.jpg|Placement of servos in CAD |
|||
Image:stage_draft.jpg|General dimensions (inches) |
|||
Image:stage_buttons.jpg|Side-mounted button box |
|||
</gallery> |
</gallery> |
||
</center> |
</center> |
||
[[Image:manipulator_positions.jpg|right|thumb|200px|Manipulator Positions]] |
|||
[[Image:manipulator_region.jpg|right|thumb|200px|Manipulator Region]] |
|||
===5 Bar Linkage Construction=== |
|||
Six [[Actuators_Available_in_the_Mechatronics_Lab#Futaba_S3004_standard_ball_bearing_RC_servo_motor|Futaba RC servos]] are used in this project. Four are used for the movement of the two arms, and two others are used to move the entire body. Arm movement is accomplished by incorporating a pair of 2 DOF parallel manipulators using the four servos. For each parallel manipulator, two servos placed 1.5 inches apart along the edge of the top platform provide actuation to a 5-bar linkage. Each section of the linkage is made the same length at 3 inches from the point of rotation. With this linkage geometry, the tip of the 5-bar linkage can sweep an area of the X-Y plane that is parallel to the front edge of the structure. Attached to the end tip of the 5-bar linkage is a string that is attached to the wrist of the puppet on the other end. A movement of the manipulator, therefore, generates a corresponding movement of the arm, just like an actual marionette. See the Links section for other linkages that we explored. |
|||
[[Image: |
[[Image:stage_top.jpg|right|thumb|200px|Top of the stage, showing the arrangement of the 6 servos]] |
||
[[Image:stage_top.jpg|right|thumb|300px|Top of the stage, showing the arrangement of the 6 servos]] |
|||
===Physical Limitation of Movement=== |
|||
Six RC servos are used in this project. Four are used for the movement of the two arms, and two others are used to move the entire body. Arm movement is accomplished by incorporating a pair of 2 DOF parallel manipulators using the four servos. For each parallel manipulator, two servos placed 1.5 inches apart along the edge of the top platform provide actuation to a 5-bar linkage. Each section of the linkage is made the same length at 3 inches from the point of rotation. With this linkage geometry, the tip of the 5-bar linkage can sweep an area of the X-Y plane that is parallel to the front edge of the structure. The max region of travel forms a curved rhombus in this plane. Attached to the end tip of the 5-bar linkage is a string that is attached to the wrist of the puppet on the other end. A movement of the manipulator, therefore, generates a corresponding movement of the arm, just like an actual marionette. |
|||
The max region of travel of the manipulator tip forms a curved rhombus. This region is limited by both the geometry of the linkages and the limitation of the servos. The rotational travel range for the servos is 180 degrees. Within this region, a Cartesian coordinate system could have been implemented that is a function of the rotational positions/velocities of the two servos. However due to the complex nature of such function, the X and Y coordinate of our manipulator simply follows the outline of the manipulator tip limit. For the tip to move in the X direction, both servos rotate in the same direction and at the same speed. For the Y direction, the servos would rotate in the opposite direction at the same speed. This implementation provides the largest travel given the manipulator range limit, and is also much less costly in terms of processor computation. Even with this simpler method, moving in a purely horizontal X direction in the Cartesian coordinate is implemented, where the two servos are set to move at different speeds in the same direction. For this approach, the specific speeds of the servos are adjusted by trial-and-error. |
|||
===Marionette Arm Construction=== |
|||
[[Image:gijoe_arm.jpg|left|thumb|200px|Arm Dismemberment and Reattachment]] |
|||
The GIJoe action figure, as manufactured, featured a much stiffer arm joints than desired for our purpose. Therefore, the arm joints are drilled out and re-tied together with strings, leaving a much looser arm movement. |
|||
[[Image:gijoe_arm.jpg|left|thumb|100px|Arm Dismemberment and Reattachment]] |
|||
===Marionette Back/Leg Movement=== |
|||
Initial design of the marionette included only the four front servos to move the arms. However, this provided a rather dull set of movements. Therefore, two extra servos are attached behind the first row of arm manipulating servos. These servos pull strings through an opening in the middle of the platform and are attached to the puppet’s shoulders. When the strings are relaxed, both feet of the puppet contact the ground. When both strings are pulled, the puppet will look like it is jumping. When one string is pulled, one foot will lift. If correctly correlated, sideways movement of the puppet can be achieved by lifting one foot and then the other (see the “[http://www.youtube.com/watch?v=eRolRlvKmyI Hula Dance]” routine). |
|||
===Finishing Touches of the Mechanical Design=== |
|||
The GIJoe action figure, as manufactured, featured a much stiffer arm joints than desired for our purpose. Therefore, the arm joints are drilled out and re-tied together with strings, leaving a much looser arm movement. |
|||
To finish off the construction, black PVC Expand foam sheets are placed on the back and base of the frame to give it a “stage” look, which also masks the black strings quite well. In addition, a long piece of aluminum tubing is bent into shape and mounted on the back of the structure to provide support for the curtains. After the curtains are in place, none of the swing arms or electronics can be seen, giving an effect of a freestanding, free-moving puppet. |
|||
==Electrical Design== |
|||
===Primary Components=== |
|||
Two extra servos are attached behind the first row of arm manipulating servos. These servos pull strings through an opening in the middle of the platform and are attached to the puppet’s shoulders. When the strings are relaxed, both feet of the puppet contact the ground. When both strings are pulled, the puppet will look like it is jumping. When one string is pulled, one foot will lift. If correctly correlated, sideways movement of the puppet can be achieved by lifting one foot and then the other (see the “Hula Dance” routine). |
|||
The primary electronic/electromechanical components of the marionette are: |
|||
<table border=1> |
|||
To finish off the construction, black PVC sheets are placed on the back and base of the frame to give it a “stage” look, which also masks the black strings quite well. In addition, a long piece of aluminum tubing is bent into shape and mounted on the back of the structure to provide support for the curtains. After the curtains are in place, none of the swing arms or electronics can be seen, giving an effect of a freestanding, free-moving puppet. |
|||
<tr><th>Qty</th><th align="left">Part</th><th>Part No.</th><th>Vendor/Price</th></tr> |
|||
<tr><td>1</td><td>8-bit Microchip PIC microcontroller</td><td> |
|||
[http://ww1.microchip.com/downloads/en/DeviceDoc/39631a.pdf 18F4520]</td><td>[http://www.microchipdirect.com/ProductSearch.aspx?Keywords=PIC18F4520 Microchip]</td></tr> |
|||
<tr><td>6</td><td>Futaba RC servo motor</td><td>[[Actuators_Available_in_the_Mechatronics_Lab#Futaba_S3004_standard_ball_bearing_RC_servo_motor|S3004]]</td><td>[http://www3.towerhobbies.com/cgi-bin/wti0001p?&I=LXVW07 Tower Hobbies]</td></tr> |
|||
<tr><td>5</td><td>4.75K ohm 1/4W 1% metal film resistor</td><td>475KXBK</td><td>[http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=475KXBK-ND Digikey]</td></tr> |
|||
<tr><td>5</td><td>Momentary push-button switch</td><td>26622PS</td><td>Jameco</td></tr> |
|||
</table> |
|||
All parts were available in the Mechatronics lab. The part number for the switch returned an error on the Jameco site. |
|||
==Electrical Design== |
|||
===Basic Build and Operation=== |
|||
The 6 Futaba RC servos, which control the marionette as described above, have 3 electrical connections: supply voltage, ground, and control signal. Control signals connect to pins RD0-5 on the PIC, and the supply voltage connects to the +5V regulated by the PIC PCB. |
|||
The width of a pulse-width modulation signal determines the angle of each motor; this square wave is generated by code routines on the PIC provided by Prof. Peshkin, and output to the pins connected to the servos. Timed interrupts repeatedly set output pins low and high to create the square wave, and an argument passed to this function sets what percentage of the wave's period is high. This way, the each servo's position is set by a single numeric value- changing this value gradually over time can create the perception of continuous movement, from which we built our dancing routines. |
|||
The push-button switches connect to the +5V supply and pins RA0-4 on the PIC. When pushed, a switch momentarily raises its associated pin high, which prompts the code of an associated routine to run. Pull-down resistors connected from pins RA0-4 to ground ensure low values for all pins when the switches are not pushed. |
|||
===Schematic=== |
|||
[[Image:Marionette schematic.jpg|none|thumb|400px|]] |
|||
===Implementation=== |
|||
[[Image:Marionette Dsc04550.jpg|none|thumb|400px|Wired prototype]] |
|||
==Code== |
==Code== |
||
===Setup Code=== |
|||
This first section is our set up code, which contains everything but the routines and main method. |
|||
[[media:giJoe.c|Our full code is here]]. |
|||
<pre> |
<pre> |
||
#include <18f4520.h> |
|||
code |
|||
#device high_ints=TRUE // this allows raised priority interrupts, which we need |
|||
#fuses HS,NOLVP,NOWDT,NOPROTECT |
|||
#use delay(clock=40000000) |
|||
int16 RCservo[6]; // We used 6 servos. |
|||
int RCcount; |
|||
signed int16 i = 400; |
|||
int16 j = 400; |
|||
int m = 1; |
|||
int16 k = 400; |
|||
int16 n = 0; |
|||
#INT_TIMER2 // designates that this is the routine to call when timer2 overflows |
|||
void MyInterruptRoutine() { |
|||
if (++RCcount >= 25) RCcount = 0; // 25mS cycle to check all servos. |
|||
if ((RCcount & 3) == 0) { // on the 4mS boundaries turn all the pins low |
|||
output_low(PIN_D0); // comment out the pins you don't want involved |
|||
output_low(PIN_D1); |
|||
output_low(PIN_D2); |
|||
output_low(PIN_D3); |
|||
output_low(PIN_D4); |
|||
output_low(PIN_D5); |
|||
set_timer3((int16) 60536 + RCservo[RCcount>>2]); // yes 60536, not 65536. Go high 4000uS (5000*0.8uS) from now, and sooner due to desired High period |
|||
} |
|||
} |
|||
#INT_TIMER3 fast // "fast" allows Timer 3 to interrupt Timer 2's ISR |
|||
void InterruptTimer3() { // this ISR is called when Timer 3 times out, to set one of the RC servo output pins high |
|||
switch (RCcount>>2) { |
|||
case 0: |
|||
output_high(PIN_D0); // This finishes setting up all our servos for use. |
|||
break; |
|||
case 1: |
|||
output_high(PIN_D1); |
|||
break; |
|||
case 2: |
|||
output_high(PIN_D2); |
|||
break; |
|||
case 3: |
|||
output_high(PIN_D3); |
|||
break; |
|||
case 4: |
|||
output_high(PIN_D4); |
|||
break; |
|||
case 5: |
|||
output_high(PIN_D5); |
|||
break; |
|||
} |
|||
} |
|||
void servoLeft(int16 x, int16 y) { //This routine controls the two left arm servos in the X and Y direction. |
|||
RCservo[0] = 1700 - x + y; //Typing servoLeft(100,0) would move the arm in the X direction 100. |
|||
RCservo[1] = 1700 - x - y; //It uses the two servos of the arm together to move correctly. |
|||
} |
|||
void servoRight(int16 x, int16 y) {//This is the same as above except for the right arm. |
|||
RCservo[2] = 1700 - x + y; |
|||
RCservo[3] = 1700 - x - y; |
|||
} |
|||
void servoXY2(int16 x, int16 y) { //This controls the feet. X was for one shoulder and Y was for the other. |
|||
RCservo[4] = 1400 + x ; |
|||
RCservo[5] = 1900 - y; |
|||
} |
|||
void servoArm(int16 x, int16 y){ //This is another way of controlling the left arm. Instead of moving in a |
|||
RCservo[0] = 1700 - x ; //specific XY direction, using servoArm let you control the two servos for the |
|||
RCservo[1] = 1700 - y; //left arm individually, which made some movements easier to code for. |
|||
} |
|||
void servoArm2(int16 x, int16 y){ //This is the same as above but for the right arm. |
|||
RCservo[2] = 1700 - x ; |
|||
RCservo[3] = 1700 - y; |
|||
} |
|||
void ZeroServos() { //This routine reset the servo positions back to neutral. |
|||
servoLeft(0,0); |
|||
servoRight(0,0); |
|||
servoXY2(0,0); |
|||
i = 0; |
|||
} |
|||
</pre> |
|||
<br> |
|||
===Example Routine=== |
|||
The next section of code are our routines. The routine showed here is our HulaHula dance. |
|||
<pre> |
|||
void HulaHula(){ //This is one of our routines, the Hula dance. The if statements inside the |
|||
i=0; //while loops controlled the movement of the feet going up and down. |
|||
j=0; // k controlled how how each foot went and m controlled if the foot was going up |
|||
k=200; //or down. i and j controlled the arm servos. the delay_ms found in these routines |
|||
while(i<700){ //was to slow down the movements slightly. this reduced the jerkyness which reduced |
|||
servoArm(i,j); //the swaying of the string so our movements were more controlled. |
|||
servoArm2(i,j); |
|||
i=i+1; |
|||
j=j+1; |
|||
servoXY2(k, 0); |
|||
if(k > 200) m=2; |
|||
if(k < 2) m = 1; |
|||
if(m == 1) k=k+1; |
|||
if(m == 2) k=k-1; |
|||
delay_ms(1); |
|||
} |
|||
delay_ms(500); |
|||
while(i>0){ |
|||
servoArm(i,j); |
|||
servoArm2(i,j); |
|||
i=i-1; |
|||
j=j-1; |
|||
servoXY2(k, 0); |
|||
if(k > 200) m=2; |
|||
if(k < 2) m = 1; |
|||
if(m == 1) k=k+1; |
|||
if(m == 2) k=k-1; |
|||
delay_ms(1); |
|||
} |
|||
while(i<700){ |
|||
servoArm(i,j); |
|||
servoArm2(i,j); |
|||
i=i+1; |
|||
j=j+1; |
|||
servoXY2(k, 0); |
|||
if(k > 200) m=2; |
|||
if(k < 2) m = 1; |
|||
if(m == 1) k=k+1; |
|||
if(m == 2) k=k-1; |
|||
delay_ms(1); |
|||
} |
|||
delay_ms(500); |
|||
while(i>0){ |
|||
servoArm(i,j); |
|||
servoArm2(i,j); |
|||
i=i-1; |
|||
j=j-1; |
|||
servoXY2(k, 0); |
|||
if(k > 2) m=2; |
|||
if(k < 200) m = 1; |
|||
if(m == 1) k=k+1; |
|||
if(m == 2) k=k-1; |
|||
delay_ms(1); |
|||
} |
|||
while(i<700){ |
|||
servoArm(-i,-j); |
|||
servoArm2(-i,-j); |
|||
i=i+1; |
|||
j=j+1; |
|||
servoXY2(0, k); |
|||
if(k > 200) m=2; |
|||
if(k < 2) m = 1; |
|||
if(m == 1) k=k+1; |
|||
if(m == 2) k=k-1; |
|||
delay_ms(1); |
|||
} |
|||
delay_ms(500); |
|||
while(i>0){ |
|||
servoArm(-i,-j); |
|||
servoArm2(-i,-j); |
|||
i=i-1; |
|||
j=j-1; |
|||
servoXY2(0, k); |
|||
if(k > 200) m=2; |
|||
if(k < 2) m = 1; |
|||
if(m == 1) k=k+1; |
|||
if(m == 2) k=k-1; |
|||
delay_ms(1); |
|||
} |
|||
while(i<700){ |
|||
servoArm(-i,-j); |
|||
servoArm2(-i,-j); |
|||
i=i+1; |
|||
j=j+1; |
|||
servoXY2(0, k); |
|||
if(k > 200) m=2; |
|||
if(k < 2) m = 1; |
|||
if(m == 1) k=k+1; |
|||
if(m == 2) k=k-1; |
|||
delay_ms(1); |
|||
} |
|||
delay_ms(500); |
|||
while(i>0){ |
|||
servoArm(-i,-j); |
|||
servoArm2(-i,-j); |
|||
i=i-1; |
|||
j=j-1; |
|||
servoXY2(0, k); |
|||
if(k > 200) m=2; |
|||
if(k < 2) m = 1; |
|||
if(m == 1) k=k+1; |
|||
if(m == 2) k=k-1; |
|||
delay_ms(1); |
|||
} |
|||
} |
|||
</pre> |
|||
<br> |
|||
===Main Function=== |
|||
After our routines, we have our Main function. |
|||
<pre> |
|||
void main() { |
|||
setup_timer_2(T2_DIV_BY_4, 155, 16); // clock at 16KHz; interrupt every 4*50nS * 4 * (77+1) * 16 = 1.0mS |
|||
setup_timer_3(T3_INTERNAL | T3_DIV_BY_8); // Timer 3 is used for the High period for the RC servo signal, ticks every (4*50nS) * 4 = 0.8uS |
|||
enable_interrupts(INT_TIMER3); |
|||
enable_interrupts(INT_TIMER2); |
|||
enable_interrupts(GLOBAL); |
|||
while (TRUE) { //This is the while loop in our main function. it zeros the servos and then |
|||
ZeroServos(); //waits for a button press. When it gets a button press it does its |
|||
if(input(PIN_A0)) //specified routine. |
|||
{ |
|||
leftArmPoint(); |
|||
} |
|||
if(input(PIN_A1)) |
|||
{ |
|||
HulaHula(); |
|||
HulaHula(); |
|||
} |
|||
if(input(PIN_A2)) |
|||
{ |
|||
Jump(); |
|||
Jump(); |
|||
Jump(); |
|||
Jump(); |
|||
} |
|||
if(input(PIN_A3)) |
|||
{ |
|||
Conduct(); |
|||
Conduct(); |
|||
Conduct(); |
|||
} |
|||
if(input(PIN_A4)) |
|||
{ |
|||
Move4(); |
|||
Move4(); |
|||
Move4(); |
|||
Move4(); |
|||
} |
|||
} |
|||
} |
|||
</pre> |
</pre> |
||
==Results== |
==Results== |
||
Our robot marionette worked as we wanted it to. The five routines we programmed showcased its ability to control each arm independently and in interesting movements through the XY plane. We also showed the ability to control the arms and legs at the same time to develop more complicated looking patterns. Our marionette going through its dances can be seen [http://www.youtube.com/watch?v=4_FOv3u4hiQ here]. We ended up able to map its movements onto an XY plane fairly closely. This not only allowed us to create interesting dances, but also made it easier to write new motions by just typing in coordinate pairs for our servoLeft() and servoRight() methods. |
|||
==Reflection== |
|||
===Issues Encountered=== |
|||
* Method to move marionette arms with 2 degrees of freedom |
|||
** We originally considered a servo/track motor combination, where the track motor would move in one plane and the servo in a plane perpendicular to the track, thus combining to create 2 degrees of freedom. Switching to a linkage controlled by two fixed servos eliminated the construction headache associated with the servo/track method. A simple five-bar linkage was sufficient to provide our desired range of motion. |
|||
* Momentum build-up from fast and/or continued movement |
|||
** Since string connects the figure to the linkages, the figure is free to move independent of the linkages. This resulted in the marionette's arms rocking back and forth after the linkages stopped moving, which was particularly apparent after abrupt starts and stops. Slowing down the servo movement by changing position in small increments followed by delays, rather than changing position all at once, helped to alleviate this. |
|||
* Method to determine movement of marionette |
|||
** Our goal was not simply getting the figure to move, but to move in a controlled, predictable manner. Observing the servo positions while moving the linkages when the servos were unpowered let us derive simple formulas for movement in the X and Y planes. |
|||
===Next Steps=== |
|||
*Enlarge the area of our XY plane of movement by trying different 5 bar linkage designs and servos |
|||
*Add more Servos to the back/legs to create more options for movement |
|||
*Add a rail and motor on the top to create 3D movement |
|||
*Add music that plays while dancing |
|||
*Try different types of input sensors, such as a way to map hand movement to puppet movement |
|||
*Find ways to remove more string swaying |
|||
==Useful Links== |
|||
===YouTube video of our Marionette=== |
|||
*[http://www.youtube.com/watch?v=4_FOv3u4hiQ Full Routine w/ Curtain] |
|||
===Interesting Linkage Coupling Videos=== |
|||
*[http://www.youtube.com/watch?v=q12IV1MhQgc&NR=1 Tsebysev Mechanism] |
|||
*[http://www.youtube.com/watch?v=PtnvXDwMmgQ&feature=related Straight Line Linkage] |
|||
*[http://www.youtube.com/watch?v=U76Vg2vceA0&feature=related Chebysev's Linkage] |
|||
*[http://www.youtube.com/watch?v=hSdW-i3nO1M&feature=related Peaucellier's Linkage] |
|||
*[http://www.youtube.com/watch?v=CufN43By79s Theo Jansen] |
|||
===Data Sheets=== |
|||
*[http://ww1.microchip.com/downloads/en/DeviceDoc/39631a.pdf Microchip PIC18F4520 Data Sheet] |
|||
*[[Actuators_Available_in_the_Mechatronics_Lab#Futaba_S3004_standard_ball_bearing_RC_servo_motor|Futaba S3004 standard ball bearing RC servo motor]] |
|||
*[[:image:Gijoe_datasheet.jpg|GIJoe Ninja Datasheet]] |
Latest revision as of 20:39, 29 March 2009
Team
- Jad Carson (Biomedical Engineering)
- Victor Liu (Mechanical Engineering)
- Matt Watras (Electrical Engineering)
Overview
The goal of this project was to make a marionette that could move in a 2D plane via motors. Our group decided to show movement by programming 5 different routines, each controlled by a button press. We used a 5 bar linkage with 2 RC Servos to motivate each arm with 2 degrees of freedom, and also added one RC Servo to each shoulder of the figure to allow it to rise off the ground, giving the appearance of moving its feet. Our puppet was a GIJoe action figure, whose joints we modified for easier motion. Also, we modeled the servo frame to resemble a stage for added effect. Our 5 routines were:
- Hula Dance
- Jumping Jack
- Conducting
- Left arm pan while right foot tap then right arm pan while left foot taps
- Left and right arm pointing up and going back to neutral position one after another while marching in place
Mechanical Design
Stage Construction
The marionette is housed in a 24x15x13.5 inch frame constructed of mainly wood. This structure is intended to mimic a theater stage while providing a solid base for the puppet itself and the accompanying servos and electronics. Four plywood pieces are used to construct the frame and put together with wood screws. The top piece is about 4 inches shallower than the base pieces to accommodate the manipulators. A small button box made of PVC Expand foam sheets is attached to the side of the frame. The buttons are used to trigger the individual routines.
5 Bar Linkage Construction
Six Futaba RC servos are used in this project. Four are used for the movement of the two arms, and two others are used to move the entire body. Arm movement is accomplished by incorporating a pair of 2 DOF parallel manipulators using the four servos. For each parallel manipulator, two servos placed 1.5 inches apart along the edge of the top platform provide actuation to a 5-bar linkage. Each section of the linkage is made the same length at 3 inches from the point of rotation. With this linkage geometry, the tip of the 5-bar linkage can sweep an area of the X-Y plane that is parallel to the front edge of the structure. Attached to the end tip of the 5-bar linkage is a string that is attached to the wrist of the puppet on the other end. A movement of the manipulator, therefore, generates a corresponding movement of the arm, just like an actual marionette. See the Links section for other linkages that we explored.
Physical Limitation of Movement
The max region of travel of the manipulator tip forms a curved rhombus. This region is limited by both the geometry of the linkages and the limitation of the servos. The rotational travel range for the servos is 180 degrees. Within this region, a Cartesian coordinate system could have been implemented that is a function of the rotational positions/velocities of the two servos. However due to the complex nature of such function, the X and Y coordinate of our manipulator simply follows the outline of the manipulator tip limit. For the tip to move in the X direction, both servos rotate in the same direction and at the same speed. For the Y direction, the servos would rotate in the opposite direction at the same speed. This implementation provides the largest travel given the manipulator range limit, and is also much less costly in terms of processor computation. Even with this simpler method, moving in a purely horizontal X direction in the Cartesian coordinate is implemented, where the two servos are set to move at different speeds in the same direction. For this approach, the specific speeds of the servos are adjusted by trial-and-error.
Marionette Arm Construction
The GIJoe action figure, as manufactured, featured a much stiffer arm joints than desired for our purpose. Therefore, the arm joints are drilled out and re-tied together with strings, leaving a much looser arm movement.
Marionette Back/Leg Movement
Initial design of the marionette included only the four front servos to move the arms. However, this provided a rather dull set of movements. Therefore, two extra servos are attached behind the first row of arm manipulating servos. These servos pull strings through an opening in the middle of the platform and are attached to the puppet’s shoulders. When the strings are relaxed, both feet of the puppet contact the ground. When both strings are pulled, the puppet will look like it is jumping. When one string is pulled, one foot will lift. If correctly correlated, sideways movement of the puppet can be achieved by lifting one foot and then the other (see the “Hula Dance” routine).
Finishing Touches of the Mechanical Design
To finish off the construction, black PVC Expand foam sheets are placed on the back and base of the frame to give it a “stage” look, which also masks the black strings quite well. In addition, a long piece of aluminum tubing is bent into shape and mounted on the back of the structure to provide support for the curtains. After the curtains are in place, none of the swing arms or electronics can be seen, giving an effect of a freestanding, free-moving puppet.
Electrical Design
Primary Components
The primary electronic/electromechanical components of the marionette are:
Qty | Part | Part No. | Vendor/Price |
---|---|---|---|
1 | 8-bit Microchip PIC microcontroller | 18F4520 | Microchip |
6 | Futaba RC servo motor | S3004 | Tower Hobbies |
5 | 4.75K ohm 1/4W 1% metal film resistor | 475KXBK | Digikey |
5 | Momentary push-button switch | 26622PS | Jameco |
All parts were available in the Mechatronics lab. The part number for the switch returned an error on the Jameco site.
Basic Build and Operation
The 6 Futaba RC servos, which control the marionette as described above, have 3 electrical connections: supply voltage, ground, and control signal. Control signals connect to pins RD0-5 on the PIC, and the supply voltage connects to the +5V regulated by the PIC PCB.
The width of a pulse-width modulation signal determines the angle of each motor; this square wave is generated by code routines on the PIC provided by Prof. Peshkin, and output to the pins connected to the servos. Timed interrupts repeatedly set output pins low and high to create the square wave, and an argument passed to this function sets what percentage of the wave's period is high. This way, the each servo's position is set by a single numeric value- changing this value gradually over time can create the perception of continuous movement, from which we built our dancing routines.
The push-button switches connect to the +5V supply and pins RA0-4 on the PIC. When pushed, a switch momentarily raises its associated pin high, which prompts the code of an associated routine to run. Pull-down resistors connected from pins RA0-4 to ground ensure low values for all pins when the switches are not pushed.
Schematic
Implementation
Code
Setup Code
This first section is our set up code, which contains everything but the routines and main method. Our full code is here.
#include <18f4520.h> #device high_ints=TRUE // this allows raised priority interrupts, which we need #fuses HS,NOLVP,NOWDT,NOPROTECT #use delay(clock=40000000) int16 RCservo[6]; // We used 6 servos. int RCcount; signed int16 i = 400; int16 j = 400; int m = 1; int16 k = 400; int16 n = 0; #INT_TIMER2 // designates that this is the routine to call when timer2 overflows void MyInterruptRoutine() { if (++RCcount >= 25) RCcount = 0; // 25mS cycle to check all servos. if ((RCcount & 3) == 0) { // on the 4mS boundaries turn all the pins low output_low(PIN_D0); // comment out the pins you don't want involved output_low(PIN_D1); output_low(PIN_D2); output_low(PIN_D3); output_low(PIN_D4); output_low(PIN_D5); set_timer3((int16) 60536 + RCservo[RCcount>>2]); // yes 60536, not 65536. Go high 4000uS (5000*0.8uS) from now, and sooner due to desired High period } } #INT_TIMER3 fast // "fast" allows Timer 3 to interrupt Timer 2's ISR void InterruptTimer3() { // this ISR is called when Timer 3 times out, to set one of the RC servo output pins high switch (RCcount>>2) { case 0: output_high(PIN_D0); // This finishes setting up all our servos for use. break; case 1: output_high(PIN_D1); break; case 2: output_high(PIN_D2); break; case 3: output_high(PIN_D3); break; case 4: output_high(PIN_D4); break; case 5: output_high(PIN_D5); break; } } void servoLeft(int16 x, int16 y) { //This routine controls the two left arm servos in the X and Y direction. RCservo[0] = 1700 - x + y; //Typing servoLeft(100,0) would move the arm in the X direction 100. RCservo[1] = 1700 - x - y; //It uses the two servos of the arm together to move correctly. } void servoRight(int16 x, int16 y) {//This is the same as above except for the right arm. RCservo[2] = 1700 - x + y; RCservo[3] = 1700 - x - y; } void servoXY2(int16 x, int16 y) { //This controls the feet. X was for one shoulder and Y was for the other. RCservo[4] = 1400 + x ; RCservo[5] = 1900 - y; } void servoArm(int16 x, int16 y){ //This is another way of controlling the left arm. Instead of moving in a RCservo[0] = 1700 - x ; //specific XY direction, using servoArm let you control the two servos for the RCservo[1] = 1700 - y; //left arm individually, which made some movements easier to code for. } void servoArm2(int16 x, int16 y){ //This is the same as above but for the right arm. RCservo[2] = 1700 - x ; RCservo[3] = 1700 - y; } void ZeroServos() { //This routine reset the servo positions back to neutral. servoLeft(0,0); servoRight(0,0); servoXY2(0,0); i = 0; }
Example Routine
The next section of code are our routines. The routine showed here is our HulaHula dance.
void HulaHula(){ //This is one of our routines, the Hula dance. The if statements inside the i=0; //while loops controlled the movement of the feet going up and down. j=0; // k controlled how how each foot went and m controlled if the foot was going up k=200; //or down. i and j controlled the arm servos. the delay_ms found in these routines while(i<700){ //was to slow down the movements slightly. this reduced the jerkyness which reduced servoArm(i,j); //the swaying of the string so our movements were more controlled. servoArm2(i,j); i=i+1; j=j+1; servoXY2(k, 0); if(k > 200) m=2; if(k < 2) m = 1; if(m == 1) k=k+1; if(m == 2) k=k-1; delay_ms(1); } delay_ms(500); while(i>0){ servoArm(i,j); servoArm2(i,j); i=i-1; j=j-1; servoXY2(k, 0); if(k > 200) m=2; if(k < 2) m = 1; if(m == 1) k=k+1; if(m == 2) k=k-1; delay_ms(1); } while(i<700){ servoArm(i,j); servoArm2(i,j); i=i+1; j=j+1; servoXY2(k, 0); if(k > 200) m=2; if(k < 2) m = 1; if(m == 1) k=k+1; if(m == 2) k=k-1; delay_ms(1); } delay_ms(500); while(i>0){ servoArm(i,j); servoArm2(i,j); i=i-1; j=j-1; servoXY2(k, 0); if(k > 2) m=2; if(k < 200) m = 1; if(m == 1) k=k+1; if(m == 2) k=k-1; delay_ms(1); } while(i<700){ servoArm(-i,-j); servoArm2(-i,-j); i=i+1; j=j+1; servoXY2(0, k); if(k > 200) m=2; if(k < 2) m = 1; if(m == 1) k=k+1; if(m == 2) k=k-1; delay_ms(1); } delay_ms(500); while(i>0){ servoArm(-i,-j); servoArm2(-i,-j); i=i-1; j=j-1; servoXY2(0, k); if(k > 200) m=2; if(k < 2) m = 1; if(m == 1) k=k+1; if(m == 2) k=k-1; delay_ms(1); } while(i<700){ servoArm(-i,-j); servoArm2(-i,-j); i=i+1; j=j+1; servoXY2(0, k); if(k > 200) m=2; if(k < 2) m = 1; if(m == 1) k=k+1; if(m == 2) k=k-1; delay_ms(1); } delay_ms(500); while(i>0){ servoArm(-i,-j); servoArm2(-i,-j); i=i-1; j=j-1; servoXY2(0, k); if(k > 200) m=2; if(k < 2) m = 1; if(m == 1) k=k+1; if(m == 2) k=k-1; delay_ms(1); } }
Main Function
After our routines, we have our Main function.
void main() { setup_timer_2(T2_DIV_BY_4, 155, 16); // clock at 16KHz; interrupt every 4*50nS * 4 * (77+1) * 16 = 1.0mS setup_timer_3(T3_INTERNAL | T3_DIV_BY_8); // Timer 3 is used for the High period for the RC servo signal, ticks every (4*50nS) * 4 = 0.8uS enable_interrupts(INT_TIMER3); enable_interrupts(INT_TIMER2); enable_interrupts(GLOBAL); while (TRUE) { //This is the while loop in our main function. it zeros the servos and then ZeroServos(); //waits for a button press. When it gets a button press it does its if(input(PIN_A0)) //specified routine. { leftArmPoint(); } if(input(PIN_A1)) { HulaHula(); HulaHula(); } if(input(PIN_A2)) { Jump(); Jump(); Jump(); Jump(); } if(input(PIN_A3)) { Conduct(); Conduct(); Conduct(); } if(input(PIN_A4)) { Move4(); Move4(); Move4(); Move4(); } } }
Results
Our robot marionette worked as we wanted it to. The five routines we programmed showcased its ability to control each arm independently and in interesting movements through the XY plane. We also showed the ability to control the arms and legs at the same time to develop more complicated looking patterns. Our marionette going through its dances can be seen here. We ended up able to map its movements onto an XY plane fairly closely. This not only allowed us to create interesting dances, but also made it easier to write new motions by just typing in coordinate pairs for our servoLeft() and servoRight() methods.
Issues Encountered
- Method to move marionette arms with 2 degrees of freedom
- We originally considered a servo/track motor combination, where the track motor would move in one plane and the servo in a plane perpendicular to the track, thus combining to create 2 degrees of freedom. Switching to a linkage controlled by two fixed servos eliminated the construction headache associated with the servo/track method. A simple five-bar linkage was sufficient to provide our desired range of motion.
- Momentum build-up from fast and/or continued movement
- Since string connects the figure to the linkages, the figure is free to move independent of the linkages. This resulted in the marionette's arms rocking back and forth after the linkages stopped moving, which was particularly apparent after abrupt starts and stops. Slowing down the servo movement by changing position in small increments followed by delays, rather than changing position all at once, helped to alleviate this.
- Method to determine movement of marionette
- Our goal was not simply getting the figure to move, but to move in a controlled, predictable manner. Observing the servo positions while moving the linkages when the servos were unpowered let us derive simple formulas for movement in the X and Y planes.
Next Steps
- Enlarge the area of our XY plane of movement by trying different 5 bar linkage designs and servos
- Add more Servos to the back/legs to create more options for movement
- Add a rail and motor on the top to create 3D movement
- Add music that plays while dancing
- Try different types of input sensors, such as a way to map hand movement to puppet movement
- Find ways to remove more string swaying