Quote Originally Posted by Roxy View Post
All right!!! Good! OK, here is what I think: I think we have two main issues to deal with. First, we need to make sure that any Z_Probing leaves the nozzle in a good (safe) position. And the second thing I think is going to happen is the Z-Probe is going to get fired during the middle of a print because of the edges curling upwards.

Now that everybody is on the same version of the firmware, we can probably make progress pretty quickly.

OK... First, lets try to get any Z-Probing to leave the nozzle at a safe height. There are a couple problems with this. G28 and G29 use different support functions to do their work right now. (I think they will get cleaned up eventually to use the same stuff. But right now, they do the work differently.)

We need to have

#define Z_RAISE_BETWEEN_PROBINGS 10.0

defined in configuration.h Probably 10 is excessive right now, but it will let you see if it is doing the right thing.

Now let's change run_z_probe() to leave the nozzle up. Right now it looks like this:

static void run_z_probe() {
plan_bed_level_matrix.set_to_identity();
feedrate = homing_feedrate[Z_AXIS];
...
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();

current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
// make sure the planner knows where we are as it may be a bit different than we last said to move to
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
}

Lets change the very end of it to:

plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();

current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
// make sure the planner knows where we are as it may be a bit different than we last said to move to
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);

SERIAL_PROTOCOLLNPGM( "At end of run_z_probe() raising nozzle." );
do_blocking_move_relative( 0.0, 0.0, (float) Z_RAISE_BETWEEN_PROBINGS );
SERIAL_PROTOCOLLNPGM( "At end of run_z_probe() done raising nozzle." );

}

That should handle the bulk of the G29 code. Now for the G28 code, lets make sure

#define Z_SAFE_HOMING

is enabled in configuration.h . There are a million different code paths depending upon what options are turned on. In this case, the Z-Axis is treated with extra care. So... probably it makes sense to start with that. I'm not 100% certain this next change is going to do what we want, but it is the cleanest way to do this if it works. Be sure to have your finger ready to press the reset button when you test it. I think what we want to do is go find:

static void homeaxis(int axis) {
#define HOMEAXIS_DO(LETTER) \
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))

if (axis==X_AXIS ? HOMEAXIS_DO(X) :
axis==Y_AXIS ? HOMEAXIS_DO(Y) :
axis==Z_AXIS ? HOMEAXIS_DO(Z) :
0) {
int axis_home_dir = home_dir(axis);


At the very end of this function (Macro Defination) is this code:

#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
if (axis==Z_AXIS) retract_z_probe();
#endif
}
}

Let's change it to:


#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
if (axis==Z_AXIS) retract_z_probe();
#endif
}

if (axis==Z_AXIS) {
SERIAL_PROTOCOLLNPGM( "At end of homeaxis(Z) raising nozzle." );
do_blocking_move_relative( 0.0, 0.0, (float) Z_RAISE_BETWEEN_PROBINGS );
SERIAL_PROTOCOLLNPGM( "At end of homeaxis(Z) done raising nozzle." );
}

}


If the G28 modification does not work right, we can do the changes right in the G28 code itself. Please compile and load these changes. And of course report back what is and isn't working right. Once we get the Positive Z_PROBE_OFFSET handled, we need to make sure the print doesn't stop because the Z-Probe gets fired in the middle of a print.
I have an error on compiling.



Marlin_main.cpp: In function 'void run_z_probe()':
Marlin_main.cpp:921: error: 'do_blocking_move_relative' was not declared in this scope




Section of code.

static void run_z_probe() {
plan_bed_level_matrix.set_to_identity();
feedrate = homing_feedrate[Z_AXIS];


// move down until you find the bed
float zPosition = -10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();


current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
// make sure the planner knows where we are as it may be a bit different than we last said to move to
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);


SERIAL_PROTOCOLLNPGM( "At end of run_z_probe() raising nozzle." );
do_blocking_move_relative( 0.0, 0.0, (float) Z_RAISE_BETWEEN_PROBINGS );
SERIAL_PROTOCOLLNPGM( "At end of run_z_probe() done raising nozzle." );
}


static void do_blocking_move_to(float x, float y, float z) {
float oldFeedRate = feedrate;


feedrate = XY_TRAVEL_SPEED;


current_position[X_AXIS] = x;
current_position[Y_AXIS] = y;
current_position[Z_AXIS] = z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();


feedrate = oldFeedRate;
}


static void do_blocking_move_relative(float offset_x, float offset_y, float offset_z) {
do_blocking_move_to(current_position[X_AXIS] + offset_x, current_position[Y_AXIS] + offset_y, current_position[Z_AXIS] + offset_z);
}


static void setup_for_endstop_move() {
saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply;
feedmultiply = 100;
previous_millis_cmd = millis();


enable_endstops(true);
}


static void clean_up_after_endstop_move() {
#ifdef ENDSTOPS_ONLY_FOR_HOMING
enable_endstops(false);
#endif


feedrate = saved_feedrate;
feedmultiply = saved_feedmultiply;
previous_millis_cmd = millis();
}