We describe here in an ino file an algorithm how to put your servo in homing position and it is needed always to perform a positive direction rotation. The following code can be transformed easily with arrays to perform for many servos. We did it for lot 20 (see video after code):


void simple_homing (int curActuatorId) {
  
command_complete_flag = false ;
motor.broadcastStart();
delay(15);
int absolute_positions_homing = 16161;
int absolute_positions_entry_positions = 0;
int absolute_positions_ticks_positive = 0;
int loop_count ;
unsigned int entry_time = 0xffff & millis();

// We save the entry positions in the array "absolute_positions_entry_positions"
absolute_positions_entry_positions = motor.getAbsolutePosition(curActuatorId);
delay(3);

int ticks_to_go_positive = 0;
ticks_to_go_positive = (16384 + absolute_positions_homing - absolute_positions_entry_positions) % 16384 ;
absolute_positions_ticks_positive = ticks_to_go_positive;

motor.setProfiledAbsolutePositionSetpoint( curActuatorId , absolute_positions_ticks_positive );
delay(4);

motor.broadCastDoMove();

delay(3510); //wait for the servo to home

delay(10);

motor.broadcastStart();

unsigned long homing_time = (0xffff + millis() - entry_time)%0xffff;

Serial.print("homing done in ");
Serial.print((int)homing_time);
Serial.println(" milliseconds");
delay(10);
command_complete_flag = true ;

}