Marionette

From Mech
Jump to: navigation, search
Here's looking at you, kid



back to project list

Contents

Team

  • Jad Carson (Biomedical Engineering)
  • Victor Liu (Mechanical Engineering)
  • Matt Watras (Electrical Engineering)
Team Photo From left to right: Victor, Jad, Matt.

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:

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.


Manipulator Positions
Manipulator Region

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.

Top of the stage, showing the arrangement of the 6 servos

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.

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 “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:

QtyPartPart No.Vendor/Price
18-bit Microchip PIC microcontroller 18F4520Microchip
6Futaba RC servo motorS3004Tower Hobbies
54.75K ohm 1/4W 1% metal film resistor475KXBKDigikey
5Momentary push-button switch26622PSJameco

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

Marionette schematic.jpg

Implementation

Wired prototype

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

Useful Links

YouTube video of our Marionette

Interesting Linkage Coupling Videos

Data Sheets

Personal tools