hi Rod,
I do not know which type of drivers you are actually using but for my configuration homing works normally. Everytime it starts and dones right. and repeatabelity is usefull too.. but it was pain to done it for my old hardware stuff..
I had customized Dominiks cia402 homing subroutine for my hardware and shaped them like in my regular PLC programs.. but you have to had a right servo homming subroutine setup inside the servodrive, right sensor or switching device type, right homing mode codes etc...
code should be splitted to read and write function, but I do not have time to do it and because of them I added single scan time delay temp...
there is starting of homing subroutine for each type of drive different and therefore I am setting bit 4 or bit 11 in the controlword
Code:
if(home) {
switch (home_state){
//#############################################################################3#
case HOME_TRIGGER:
opmode = homing_mode_code;
pos_fb_from_incremental = pos_cmd;
if(opmode_homing){
pos_fb_from_incremental = pos_cmd;
home_state = HOME_CONFIRM;
homingStatus = home_state;
}
break;
//#############################################################################3#
case HOME_CONFIRM:
pos_fb_from_incremental = pos_cmd;
if(opmode_homing){ // Homing request accepted from driver
if(opmode_display == homing_mode_code){
controlword |= (1 << 4); // homing subroutine request set
if(homingDelay > waitingDelay){
if(!stat_internal_homed){
home_state = HOME_SEEKING;
homingStatus = home_state;
homingDelay = 0;
}
}
else{
homingDelay++;
}
}
else{
if(opmode_display == homing_mode_code_display_from_drive){
controlword |= (1 << 11); // homing subroutine request set
if(homingDelay > waitingDelay){
if(!stat_internal_homed){
home_state = HOME_SEEKING;
homingStatus = home_state;
homingDelay = 0;
}
}
else{
homingDelay++;
}
}
}
}
break;
//#############################################################################3#
case HOME_SEEKING:
if(stat_internal_homed){
if(opmode_display == homing_mode_code){
controlword &= ~(1 << 4); // reset homing subroutine request reset
}
else{
controlword &= ~(1 << 11); // reset homing subroutine request reset
}
home = 0;
home_state = HOME_TRIGGER;
homingStatus = home_state;
pos_fb_from_incremental = (drv_actual_position_incremental) * pos_scale_rcpt * incremental_pos_scale_rcpt;
if(pos_mode){
opmode = csp_mode_code;
}
else{
opmode = csv_mode_code;
}
}
break;
//#############################################################################3#
}
}
else{
if(pos_mode){
opmode = csp_mode_code;
}
else{
opmode = csv_mode_code;
}
}