Servos play back not accurately

I am doing robot arm controlled by potentiometers. When i store the data into EEPROM as well as array to remember degrees for each servo. When I require it play back, robot arm doesnot play back accurately even though I store exactly data. For instance, the base of my robot arm turns on to approximately 50 degree, although the data is 60 degree.
I am using servo 996R, and the pulse at 0 degree and 180 degree is completely different to that of standard servo.
Do you have any suggestion to solve the problem
Sincere thanks!
Part of my code
First I would like to explain my code for readable. I store data in matrix. Because servo moves full speed when it is with rapid written degree. FOr instance, when I store 100 and 180 as degree, Servo moves very fast from 100 to 180. Therefore in my code, from 100, I add it one until it is equal to 180, allowing servo can move smoothly.
However, when it plays back, it doesnt accurate

int addr1=0;
int dem=0;
int array_in[10][5]={1,1,1,1,30,   // create an matrix tro store temporary data.
                    1,1,1,1,1,
                    1,1,1,1,1,
                    1,1,1,1,1,
                    1,1,1,1,1,
                    1,1,1,1,1,
                    1,1,1,1,1,
                    1,1,1,1,1,
                    1,1,1,1,1,
                    1,1,1,1,1};
void recordServo(){  // record data to matrix
  switch(addr1)
  {
    case 0:
    {
      digitalWrite(ledPin2,HIGH);
      
      array_in[0][0]=integerFromPC;
      
      array_in[0][1]=integerFromPC1;
      
      array_in[0][2]=integerFromPC2;

      array_in[0][3]=integerFromPC3;
     
      array_in[0][4]=taygap;

    
    }
    case 1:
    {
      digitalWrite(ledPin2,HIGH);

      array_in[1][0]=integerFromPC;

      array_in[1][1]=integerFromPC1;

      array_in[1][2]=integerFromPC2;
 
      array_in[1][3]=integerFromPC3;

      array_in[1][4]=taygap;


        delay(100);
        digitalWrite(ledPin2,LOW);
      
    }
        case 2:
    {
      digitalWrite(ledPin2,HIGH);

      array_in[2][0]=integerFromPC;

      array_in[2][1]=integerFromPC1;

      array_in[2][2]=integerFromPC2;

      array_in[2][3]=integerFromPC3;

      array_in[2][4]=taygap;
}
}
void playServo(){ 
    digitalWrite(ledPin1,HIGH);                   
    myservo1.attach(servoPin1);

    myservo2.attach(servoPin2);

    myservo3.attach(servoPin3);

    myservo4.attach(servoPin4);

    myservo5.attach(servoPin5);

    myservo6.attach(servoPin6);
    get_duty();        
               // call get duty
    myservo1.detach();

    myservo2.detach();

    myservo3.detach();

    myservo4.detach();

    myservo5.detach();

    myservo6.detach();

    delay(100); 
}
void get_duty()
{
  int j, i;
  unsigned long duty[5]={ 90, 70, 100, 90, 30};

  for (i=0;i<3;i++)     // number of line in matrix 
  {
  for (j=0; j<5; j++){       5 = numbers of columns in matrix
 
   set_duty(duty[j], array_in[i][j],j);     // call_set duty

    duty[j]=array_in[i][j]; 
  } 
}  
}
    digitalWrite(ledPin1,LOW);
  }
void set_duty(unsigned long value_last, unsigned long value_in, int set_channel)
{
   unsigned long j;
   if (value_last > value_in)   // just make comparation between 2 data
      {
      for (j=value_last; j>=value_in; j--) // subtract 1 degree write in Servo 
         { 
         set_power_channel(set_channel,j);  
         Serial.println(j);
         delay(20);
         }
      }
      else if(value_last < value_in)
         {
         for (j = value_last + 1; j <= value_in; j++)
            {
            
            set_power_channel(set_channel,j);   // add 1 to degree written in servo
            Serial.println(j); 
            delay(20);
            }
            
         } 
         else if(value_last==value_in)
            {
            set_power_channel(set_channel,value_in);
            delay(20);
            }           
                  
}
void set_power_channel(int channel, unsigned long duty_value)
{
   switch (channel)
         {
         case 0:  
        {
        myservo1.write(duty_value);
        delay(15);
        Serial.println("servo1");
        break;
          }
         case 1: 
        {
        myservo2.write(duty_value);
        myservo3.write(duty_value); 
         delay(15); 
        Serial.println("servo2");
        break;
        }
         case 2:  
        {
        myservo4.write(duty_value); 
         delay(15); 
        Serial.println("servo3");
        break;
        }
        case 3:  
         {
         myservo5.write(duty_value); 
          delay(15);
         Serial.println("servo4");
         break;
        }
         case 4:  
         {
         myservo6.write(duty_value); 
          delay(15);
         Serial.println("servo5");
         break;
        }
 
         }
}

Before you are asked to post your code, I have a question. Have you used a stripped down, simple test program to test the servo, or tested it only as part of a larger sketch with other functions in it?

aarg:
Before you are asked to post your code, I have a question. Have you used a stripped down, simple test program to test the servo, or tested it only as part of a larger sketch with other functions in it?

I also add my code. Stripped down what is it. I also test the sample servo with default setting in Arduino

The code snippet that you provided does not really allow any analysis of the problem.
Where is the code used to input the integers ?

Have you tried printing the contents of the array and/or EEPROM after entering the numbers to ensure that it is storing what you think it is ?

Why are you using an array of ints when the servo angle will never exceed 180 degrees ?

How are you storing the integers in EEPROM ?

phamb587:
I am doing robot arm controlled by potentiometers. When i store the data into EEPROM as well as array to remember degrees for each servo. When I require it play back, robot arm doesnot play back accurately even though I store exactly data. For instance, the base of my robot arm turns on to approximately 50 degree, although the data is 60 degree.
I am using servo 996R, and the pulse at 0 degree and 180 degree is completely different to that of standard servo.
Do you have any suggestion to solve the problem

The "degree" units used by the servo write command are meaningless. Very few servos have exactly 180 degrees rotation range and those which may happen to have exactly 180 degrees range of motion are very unlikely to use the same endpoints as those used by default.

I think you'd be better off using writeMicroseconds (or use microseconds as the units with the normal write command). You get nearly ten times the precision using microseconds instead of degrees and the units have a real world meaning.

Servos don't have to jerk as they move. If you ramp the speed of the servo, you get much smoother motion than using constant speed most sweep algorithms produce.

Here's my first Arduino project video I ever made showing the results of using constant acceleration.

How are you powering your servos? A lot of servo problems are caused by power supply problems.

Here are some recent threads discussing powering servos.

http://forum.arduino.cc/index.php?topic=366517.0

http://forum.arduino.cc/index.php?topic=370762.0

https://forum.arduino.cc/index.php?topic=368417.0