I have installed the comp and tried a few changes to it. It works best with my latest changes.
Code:
case 0:
if (axis_home_switch(axis)) {
axis_pos_cmd_out(axis) = axis_home_offset(axis) * 2;
axis_vel_cmd(axis) = axis_home_search_velocity(axis);
home_state = 1;
} else {
axis_index_enable(axis) = 1;
axis_pos_cmd_out(axis) = -1 * axis_home_offset(axis);
axis_vel_cmd(axis) = axis_home_search_velocity(axis);
home_state = 2;
}
break;
case 1: // searching down, Press Up
if (! axis_home_switch(axis)){
[color=#c0392b][u]axis_pos_cmd_out(axis) = 0;[/u][/color]
home_state = 0;
}
break;
case 2: // searching up, Press Down
if (! axis_index_enable(axis)){
offset(axis) = axis_pos_fb_in(axis) - axis_home_offset(axis);
[color=#c0392b][u]axis_pos_cmd_out(axis) = 0;[/u][/color]
home_state = 0;
state = 0;
}
break;
I still get the rapid move of the offset when it homes to the axis.
If I startup with the axis close to the home position with min. offset correction it works great, but greater distance I'm off of the index position the greater the jump.
Would it be possible to get it to stop at rising edge of the home switch, then apply a rough correction offset, then resume to final homing with the index? It seems to me it needs to apply offset correction while motion is stopped, but I might be wrong.
I looked over the homing.c file.
It's more than I can figure out. I feel like a 1st grader learning to read when it comes to programming.
Take your time Andy, don't feel like this project is a rush. I'm amazed at the time you spend with LinuxCNC.
EW
homing.c
Code:
case HOME_INDEX_ONLY_START:
/* This state is used if the machine has been pre-positioned
near the home position, and simply needs to find the
next index pulse. It starts a move at latch_vel, and
sets index-enable, which tells the encoder driver to
reset its counter to zero and clear the enable when the
next index pulse arrives. */
/* is the joint already moving? */
if (joint->free_tp.active) {
/* yes, reset delay, wait until joint stops */
H[joint_num].pause_timer = 0;
break;
}
/* has delay timed out? */
if (H[joint_num].pause_timer < (HOME_DELAY * servo_freq)) {
/* no, update timer and wait some more */
H[joint_num].pause_timer++;
break;
}
H[joint_num].pause_timer = 0;
/* Although we don't know the exact home position yet, we
we reset the joint coordinates now so that screw error
comp will be appropriate for this portion of the screw
(previously we didn't know where we were at all). */
/* set the current position to 'home_offset' */
offset = H[joint_num].home_offset - joint->pos_fb;
/* this moves the internal position but does not affect the
motor position */
joint->pos_cmd += offset;
joint->pos_fb += offset;
joint->free_tp.curr_pos += offset;
joint->motor_offset -= offset;
/* set the index enable */
H[joint_num].index_enable = 1;
/* set up a move at 'latch_vel' to find the index pulse */
home_start_move(joint, H[joint_num].home_latch_vel);
/* next state */
H[joint_num].home_state = HOME_INDEX_SEARCH_WAIT;
break;