# Calibracion de Servomotores



## Alcocer Garcia Felix Davi (Mar 14, 2016)

Hola que tal un cordial saludo a todos tengo este controlador Veyron 24 una fuente de 5voltios 6amperios y un armazón de robot bípedo todo correcto , el problema es que el armazón cuenta con 6 servomotores y deseo calibrarlos de acuerdo a la mecánica del exoesqueleto bípedo es decir tratar de no sobresaturar en el movimiento a los servos , estuve tratando de hacerlo y ya llevo malogrando 2 servos gracias. En mi país es complicado conseguir los engranajes de los servos es por eso que cada vez que daño engranes tengo que comprar servos nuevos , aquí algunas fotos.
En Internet no encontrado información sobre esto. Se supone que al inicio de cada movimiento los servos deben tener una posición inicial gracias.

Este video muestra el movimiento pero no la calibracion


----------



## John Miller (Mar 14, 2016)

Hola buen día,  la estructura es igual a esta:






Sigue las recomendaciones del controllador Veyron en su web, luego cargas el código en arduino, ahi lsi o vas calibrando y acondicionando el codigo para los 6.


```
#include <Servo.h> 
 
Servo servo1;  // create servo object to control a servo 
Servo servo2;
Servo servo3;
Servo servo4;
                // twelve servo objects can be created on most boards
 
int pos = 0;    // variable to store the servo position 
                                            
 
void setup() 
{ 
  servo1.attach(3);  // attaches the servo 
  servo2.attach(5);
  servo3.attach(6);
  servo4.attach(9);
  
  servo1.write(99);  
  servo2.write(83);
  servo3.write(74);
  servo4.write(78);
  delay(2000);
} 
 


void leftForward(){    //Moving Left Leg Forward
  servo4.write(60);   //right foot 
  servo2.write(60);   //left foot
  delay(500);
  
  servo3.write(50);     //right hip
  servo1.write(70);     //left hip
  delay(100);
 
  servo4.write(60);       //right foot back to flat
  delay(250);
  servo4.write(70);
  delay(250);
  servo4.write(83);
  servo2.write(83);       //left foot back to flat
  delay(500);  
}


void rightForward(){     //Moving Right Leg Forward
  servo4.write(100);        //right foot                   
  servo2.write(100);         //left foot
  delay(500);
  
  servo1.write(120);        //left hip
  servo3.write(90);         //right hip
 delay(100); 
 
  servo2.write(103);         //left foot back to flat
  delay(250);
  servo2.write(93);
  delay(250);
  servo2.write(83);
   servo4.write(78);           //right foot back to flat
}


void leftBackward(){  // moving left leg backwards
  servo4.write(60);    //right foot
  servo2.write(60);    // left foot
  delay(500);
  
   servo3.write(98);     //right hip
  servo1.write(115);     //left hip
  delay(100);
  
   servo4.write(60);       //right foot back to flat
  delay(250);
  servo4.write(70);
  delay(250);
  servo4.write(83);
  servo2.write(83);       //left foot back to flat
  delay(500);  
}



void rightBackward(){
  servo4.write(100);        //right foot                   
  servo2.write(100);         //left foot
  delay(500);
  
  servo1.write(78);        //left hip
  servo3.write(58);         //right hip
 delay(100); 
 
  servo2.write(103);         //left foot back to flat
  delay(250);
  servo2.write(93);
  delay(250);
  servo2.write(83);
   servo4.write(78);           //right foot back to flat
}




//Main Function
void loop() 
{ 
 leftForward();
 rightForward();
 delay(500);
 leftForward();
 rightForward();
 delay(500);
 leftForward();
 rightForward();
 
 delay(500);
 
 
 leftBackward();
   rightBackward();
  delay(500);
  leftBackward();
   rightBackward();
  delay(500);
  leftBackward();
   rightBackward();
   delay(500);
  
  
  
  
}
```


```
#include <Servo.h>

int delayVal2 = 25; 
int delayVal = 40;
bool time = true;  
//Creating Servo Objects
Servo rightAnkle;
Servo leftAnkle;
Servo rightKnee;
Servo leftKnee;
Servo rightThigh;
Servo leftThigh;
Servo rightHip;
Servo leftHip;
Servo leftShoulder;
Servo rightShoulder;
Servo leftElbow;
Servo rightElbow;

//Function Prototype//
void stand();
void handsUp();
void handsDown();
void handsLeft();
void handsRight();
void handWave();
void turnLeft();
void turnRight();

void setup() {
 //Servo input pins
 rightAnkle.attach(2);
 rightKnee.attach(3);
 rightThigh.attach(4);
 rightHip.attach(5);
 leftAnkle.attach(6);
 leftKnee.attach(7);
 leftThigh.attach(8);
 leftHip.attach(9);
 leftShoulder.attach(10);
 rightShoulder.attach(11);
 leftElbow.attach(12);
 rightElbow.attach(13);
 stand();
 delay(2000);
 hello();
/*
stand();
for(int i = 0; i < 3; i+= 1)  
  { 
 legs();     }
handDemo();



 for(int i = 0; i < 8; i+= 1)  
  { 
 legs();     }
 
*/
 
}
void loop() 
{}


int rightAnkPos = 83;
int rightKneePos = 88;
int rightThighPos = 100;
int rightHipPos = 90;  
int leftAnkPos = 88;
int leftKneePos = 90;
int leftThighPos = 65;
int leftHipPos = 81;



//Function Definition//

void stand ()
{ 
  rightAnkle.write(83);
  int rightAnkPos = 83;
  rightKnee.write(88);
  int rightKneePos = 88;
  rightThigh.write(100);
  int rightThighPos = 100;
  rightHip.write(90);
  int rightHipPos = 90;
  leftAnkle.write(88);
  int leftAnkPos = 88;
  leftKnee.write(90);
  int leftKneePos = 90;
  leftThigh.write(65);
  int leftThighPos = 65;
  leftHip.write(81);
  int leftHipPos = 81;
  rightShoulder.write(180);
  leftShoulder.write(180);
  rightElbow.write(90);
  leftElbow.write(90);
}
  int rightShoulderPos = 180;
  int rightElbowPos = 90;
  int leftShoulderPos = 180;
  int leftElbowPos = 90;
 
void handDemo()
{
stand();
delay(1000);
handsHalf();
delay(250);
handsRight();
delay(250);
handsLeft();
delay(250);
handsRight();
delay(250);
handsHalfdown();
delay(250);
rightHandsUp();
delay(250);
rightHandsDown();
delay(250);
leftHandsUp();
delay(250);
leftHandsDown();
delay(250);
handWave();  
  
}
void handsUp()
{ 
  
  for(int i = 0; i < 18; i+= 1)  
  {   
    rightShoulderPos -= 9;
    leftShoulderPos -= 10;   
    leftShoulder.write(leftShoulderPos);
    rightShoulder.write(rightShoulderPos );
    delay(50); } 
  }

void leftHandsUp()
{ 
  
  for(int i = 0; i < 18; i+= 1)  
  {   
    
    leftShoulderPos -= 10;   
    leftShoulder.write(leftShoulderPos);
    
    delay(50); } 
  }
void leftHandsDown()
{ 
  
  for(int i = 0; i < 18; i+= 1)  
  {   
    
    leftShoulderPos += 10;   
    leftShoulder.write(leftShoulderPos);
    
    delay(50); } 
  }
 void rightHandsUp()
{ 
  
  for(int i = 0; i < 18; i+= 1)  
  {   
    rightShoulderPos -= 9;
    rightShoulder.write(rightShoulderPos );
    delay(50); } 
  }
void rightHandsDown()
{ 
  
  for(int i = 0; i < 18; i+= 1)  
  {   
    rightShoulderPos += 9;
    rightShoulder.write(rightShoulderPos );
    delay(50); } 
  }
void handsHalf()
{ 
  
  for(int i = 0; i < 9; i+= 1)  
  {   
    rightShoulderPos -= 9;
    leftShoulderPos -= 10;   
    leftShoulder.write(leftShoulderPos);
    rightShoulder.write(rightShoulderPos );
    delay(50); } 
  }

void handsHalfdown()
{ 
  
  for(int i = 0; i < 9; i+= 1)  
  {   
    rightShoulderPos += 9;
    leftShoulderPos += 10;   
    leftShoulder.write(leftShoulderPos);
    rightShoulder.write(rightShoulderPos );
    delay(50); } 
  }

void handsDown()
{
   for(int i = 0; i < 18; i+= 1)  
  {
    rightShoulderPos += 9;
    leftShoulderPos += 10;  
    leftShoulder.write(leftShoulderPos);
    rightShoulder.write(rightShoulderPos ); 
    delay(25);}      
}




void handWave()
{
   leftThigh.write(75);
  rightThigh.write(90);

  handsUp();
  
  
  for (int i = 0;i < 3; i++)
  {
  handsRight();
  handsLeft();
  handsRight();
  }
  delay(250);
  
  handsDown();
  
}



void handsRight()
{
   for(int i = 0; i < 9; i+= 1)  
  {
    rightElbowPos += 7;
    leftElbowPos += 7;  
    leftElbow.write(leftElbowPos);
    rightElbow.write(rightElbowPos ); 
    delay(25);}      
}

void handsLeft()
{
   for(int i = 0; i < 18; i+= 1)  
  {
    rightElbowPos -= 7;
    leftElbowPos -= 7;  
    leftElbow.write(leftElbowPos);
    rightElbow.write(rightElbowPos ); 
    delay(25);}      
}


void hello()
{
  leftHandsUp();
 for(int i = 0; i < 3; i+= 1)  
  {
  for(int i = 0; i < 9; i+= 1)  
  {
    
    leftElbowPos += 7;  
    leftElbow.write(leftElbowPos);
    delay(25);}
    
  for(int i = 0; i < 9; i+= 1)  
  {
    
    leftElbowPos -= 7;  
    leftElbow.write(leftElbowPos);
    delay(25);}
    
     for(int i = 0; i < 9; i+= 1)  
  {
    
    leftElbowPos -= 7;  
    leftElbow.write(leftElbowPos);
    delay(25);}
    
     for(int i = 0; i < 9; i+= 1)  
  {
    
    leftElbowPos += 7;  
    leftElbow.write(leftElbowPos);
    delay(25);}}
    delay(500);
    leftHandsDown();
}



///////////////Legs//////////////////////




void legs()
{
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos += 2;
    rightAnkPos -= 2;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(delayVal2); }   
  delay(10);
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos -= 2;
    rightAnkPos += 2;
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );
    delay(delayVal2); } 
delay(10);
for(int i = 0; i < 6 ; i+= 1)  
  {   
    leftAnkPos -= 2;
    rightAnkPos += 2;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );  
    delay(delayVal2); } 
delay(10);  
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos += 2;
    rightAnkPos -= 2;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(delayVal2); } 
   delay(10); 
}


////////////FORWARD///////////////////////////////////////////////////////

void forward()
{
  
for(int i = 0; i < 5; i+= 1)  
  {
    
    if (time){
   leftThighPos -= 2;               
    leftKneePos += 2;
   leftThigh.write( leftThighPos);
    leftKnee.write(leftKneePos );

    delay(delayVal2);}
  } 
 


//Left and Right Ankle Bend Left    
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos += 2;
    rightAnkPos += 2;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(delayVal2); } 
    
delay(delayVal); 



  //Straighten Left Leg
for(int i = 0; i < 5; i+= 1)  
  {   
 
    leftThighPos += 2;               
    leftKneePos -= 2;
   leftThigh.write( leftThighPos);
    leftKnee.write(leftKneePos ); 
 
   
    
    delay(delayVal2); } 

//right leg forward
for(int i = 0; i < 5; i+= 1)  
  {
     rightThighPos += 2;
    rightKneePos -= 2; 
    rightThigh.write( rightThighPos);
    rightKnee.write(rightKneePos );    
    
    delay(delayVal2); } 


  
//Right and Left Ankle back to Normal
  for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos -= 2;
    rightAnkPos -= 2;
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );
    delay(delayVal2); } 

  
     

  
  
//Right and left Ankle Bend right 
  
  for(int i = 0; i < 6 ; i+= 1)  
  {   
    leftAnkPos -= 2;
    rightAnkPos -= 2;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );  
    delay(delayVal2); } 

delay(delayVal);  

//Straighten Right Leg
for(int i = 0; i < 5; i+= 1)  
  {
  
    
    rightThighPos -= 2;
    rightKneePos += 2;
   rightThigh.write( rightThighPos);
    rightKnee.write(rightKneePos ); 
     
    delay(delayVal2);
  } 
  
   

  //Left Leg bend Forward
for(int i = 0; i < 5; i+= 1)  
  {
   leftThighPos -= 2;               
    leftKneePos += 2;
   leftThigh.write( leftThighPos);
    leftKnee.write(leftKneePos );
   
     
    delay(delayVal2);
  } 

//Ankles back to normal
  for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos += 2;
    rightAnkPos += 2;   
     rightAnkle.write(rightAnkPos);   
    leftAnkle.write(leftAnkPos);
    delay(delayVal2); }   

time = false;
 
 /*
 
*/ 
}







///////////////LEFT/////////////////////////////////////////


void turnLeft()
{
  
for(int i = 0; i < 5; i+= 1)  
  {  
    leftThighPos -= 2;               
    leftKneePos += 2;
   leftThigh.write( leftThighPos);
    leftKnee.write(leftKneePos );    
    delay(60);
  }   

//Left and Right Ankle Bend Left    
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); } 
    
delay(delayVal);  

//Left Hip Counter ClockWise, 

for(int i = 0; i < 5; i+= 1)  
  {   
    leftHipPos -= 4;  
    leftHip.write(leftHipPos);
    
    
    
 
    delay(60); } 
    
delay(delayVal);

//Left and Right Ankle back to normal   
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); } 

 

//Left and Right Ankle Bend Right Left Hip Straighten
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );
    leftHipPos += 4;  
    leftHip.write(leftHipPos); 
    delay(60); } 
    
delay(delayVal);



//Right Hip Counter Clockwise
for(int i = 0; i < 5; i+= 1)  
  {   

    rightHipPos -=4;
     
    rightHip.write(rightHipPos); 
    leftHipPos += 4;
      
    leftHip.write(leftHipPos);
 
    delay(60); } 
    
delay(delayVal);


//Left and Right Ankle Normal
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );
     
    delay(60); } 
    
delay(delayVal);

///////SECOND TIME///////////////

//Left and Right Ankle BEND LEFT 
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    leftThighPos += 2;               
    leftKneePos -= 2;
   leftThigh.write( leftThighPos);
    leftKnee.write(leftKneePos ); 
    delay(60); } 
    
delay(delayVal);



//LEFT HIP CC
for(int i = 0; i < 5; i+= 1)  
  {   
    leftHipPos -= 4;  
    leftHip.write(leftHipPos); 
    
    rightHipPos +=4;
     
    rightHip.write(rightHipPos);
    
    delay(60); } 
    
delay(delayVal);




//LEFT RIGHT ANKLE NORMAL   
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); } 
    
   

//Left and Right Ankle Bend Right 
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );
     
    
    
    delay(60); } 
    
delay(delayVal);
 

//Right Hip Counter Clockwise
for(int i = 0; i < 5; i+= 1)  
  {   

    rightHipPos -=5;
     
    rightHip.write(rightHipPos); 
    
    leftHipPos += 2;  
    leftHip.write(leftHipPos); 
 
    delay(60); }


//LEFT RIGHT ANKLE NORMAL   
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); }

//LEFT RIGHT ANKLE BEND LEFT
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    rightHipPos +=5; 
    rightHip.write(rightHipPos); 
    leftHipPos -= 2;  
    leftHip.write(leftHipPos); 
    
    delay(60); }
    

//LEFT RIGHT ANKLE STRAIGHT
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); }
}


/////////////////TURN RIGHT///////////////////////////////////////////////

void turnRight ()
{
  for(int i = 0; i < 5; i+= 1)  
  {  
  rightThighPos += 1;
    rightKneePos -= 1; 
    rightThigh.write( rightThighPos);
    rightKnee.write(rightKneePos );
    delay(60);
  }  
  
//Left and Right Ankle Bend Right    
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); } 
    
delay(delayVal); 



//right Hip ClockWise, Left leg forward
for(int i = 0; i < 5; i+= 1)  
  {   
    rightHipPos +=4; 
    rightHip.write(rightHipPos);
      
       delay(60); } 
    
delay(delayVal);


//Left and Right Ankle back to normal   
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); } 




//Left and Right Ankle Bend Leftt right Hip Straighten
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );
    rightHipPos -=4; 
    rightHip.write(rightHipPos);
    delay(60); } 
    
delay(delayVal);


//Left Hip Counter Clockwise
for(int i = 0; i < 5; i+= 1)  
  {   

    rightHipPos -=4;
     
    rightHip.write(rightHipPos); 
    leftHipPos += 4;
      
    leftHip.write(leftHipPos);
 
    delay(60); } 
    
delay(delayVal);

//Left and Right Ankle Normal
for(int i = 0; i < 5; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );
     
    delay(60); } 
    
delay(delayVal);

//Second Time

//Left and Right Ankle BEND RIGHT, Right Thigh/Knee Straighten
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    
    delay(60); } 
    
delay(delayVal);

//Right HIP CW, Left Hip Straighten
for(int i = 0; i < 5; i+= 1)  
  {   
    
    
    rightHipPos +=4;
     leftHipPos -= 4;  
    leftHip.write(leftHipPos); 
    rightHip.write(rightHipPos);
    
    delay(60); } 
    
delay(delayVal);

//LEFT RIGHT ANKLE NORMAL   
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); } 
////////Third Time //////////  

//Left and Right Ankle Bend Left
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos );
     
    
    delay(60); } 
    
delay(delayVal);


//Left Right Hip CW 
for(int i = 0; i < 5; i+= 1)  
  {   

    rightHipPos -=5;
     
    rightHip.write(rightHipPos); 
    
    leftHipPos += 2;  
    leftHip.write(leftHipPos);
   
   rightThighPos -= 1;
    rightKneePos += 1; 
    rightThigh.write( rightThighPos);
    rightKnee.write(rightKneePos ); 
 
    delay(60); }


//LEFT RIGHT ANKLE NORMAL   
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); }


//LEFT RIGHT ANKLE BEND Right
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos -= 3;
    rightAnkPos -= 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    delay(60); }

//Right Hip  Normal
for(int i = 0; i < 5; i+= 1)  
  {   
    
    rightHipPos +=5; 
    rightHip.write(rightHipPos); 
    
    delay(60); }
    
    
//Left Hip  Normal
for(int i = 0; i < 5; i+= 1)  
  {   
    
     
    leftHipPos -= 2;  
    leftHip.write(leftHipPos); 
    
    delay(60); }

//LEFT RIGHT ANKLE STRAIGHT
for(int i = 0; i < 6; i+= 1)  
  {   
    leftAnkPos += 3;
    rightAnkPos += 3;    
    leftAnkle.write(leftAnkPos);
    rightAnkle.write(rightAnkPos ); 
    
    delay(60); }

/*

*/
}
```

Maki.


----------



## Alcocer Garcia Felix Davi (Mar 19, 2016)

Muchas gracias por los aportes , el problema era que la mayoría de servos esta malogrado , eso se nota por como suenan . Ya estoy colocando los servos pronto subiré el vídeos del funcionamiento gracias.


----------



## armandolopezmx (Mar 20, 2016)

yo no lo probaria tan cerca de la panalla de la computadora.....  
suerte.


----------

