    
    for(int i=0; i<steps; i++)
    {
-     long int delay_us = round(1000*(DELAY_MAX - (DELAY_MAX-delay_min)*sin((double)i*PI/(steps-1))));
-     Serial.println(delay_us);
+     long int delay_us = round(1000*(DELAY_MAX - (DELAY_MAX-delay_min)*sin(0.5*PI*sin((double)i*PI/(steps-1)))));
+     //Serial.println(delay_us);
      if ( ( ret_val = moveArmCoord( rMove, hMove, bMove, dMove, delay_us ) )  != 0 ) return ret_val;
      rMove += rStep; hMove += hStep; bMove += bStep; dMove += dStep;
    }

         case 'p':
            servoWrite(GRI,GRI_MICROPLATE); Serial.println("Gripped Microplate"); break;
         case 'r':
            if( ( ret_val = slowMoveArm(BAS_PARK,SHL_PARK,ELB_PARK,WRI_PARK,5,1) ) == 0 ) Serial.println("Arm returned to park position");
            else Serial.println(ret_val);
            break;
         case 'R':
            moveArm(degToPulse(BAS, BAS_PARK), degToPulse(SHL, SHL_PARK), degToPulse(ELB, ELB_PARK), degToPulse(WRI, WRI_PARK)); Serial.println("ARM PARKED!"); break;
         case 't':
            if( ( ret_val = slowMoveArm(90,90,90,90,5,1) ) == 0 ) Serial.println("Arm returned to park position");
            else Serial.println(ret_val);
            break;
            

  return ((double)pulseLength - OFFSET[id])/GRADIENT[id];
}

void delayFunc ( long int delay_ )
{
  long int start = micros();
  int delay_ms = delay_/1000;
  int delay_us = delay_%1000;
  if ( delay_ms > 0 ) delay(delay_ms);
  if ( delay_us > 0 ) delayMicroseconds(delay_us);
  long int fin = micros();
  /*Serial.print(delay_ms);
  Serial.print("+");
  Serial.print(delay_us);
  Serial.print("=");
  Serial.println(fin-start);*/
}

/*********/
/* SETUP */
/*********/
void setup()
{
   Serial.begin(57600);
   Serial.println("Serial connection started\n");  
   
   pinMode(STEP_PIN, OUTPUT);
   pinMode(DIR_PIN, OUTPUT);
