Merge pull request #655 from mkbel/fix_z_home_point

Fix z home point
This commit is contained in:
PavelSindler 2018-04-24 16:51:57 +02:00 committed by GitHub
commit f9d64bdfb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 32 deletions

View file

@ -3100,7 +3100,7 @@ void process_commands()
}
// 1st mesh bed leveling measurement point, corrected.
world2machine_initialize();
world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]);
world2machine(pgm_read_float(bed_ref_points_4), pgm_read_float(bed_ref_points_4+1), destination[X_AXIS], destination[Y_AXIS]);
world2machine_reset();
if (destination[Y_AXIS] < Y_MIN_POS)
destination[Y_AXIS] = Y_MIN_POS;
@ -3108,7 +3108,18 @@ void process_commands()
feedrate = homing_feedrate[Z_AXIS]/10;
current_position[Z_AXIS] = 0;
enable_endstops(false);
#ifdef DEBUG_BUILD
SERIAL_ECHOLNPGM("plan_set_position()");
MYSERIAL.println(current_position[X_AXIS]);MYSERIAL.println(current_position[Y_AXIS]);
MYSERIAL.println(current_position[Z_AXIS]);MYSERIAL.println(current_position[E_AXIS]);
#endif
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
#ifdef DEBUG_BUILD
SERIAL_ECHOLNPGM("plan_buffer_line()");
MYSERIAL.println(destination[X_AXIS]);MYSERIAL.println(destination[Y_AXIS]);
MYSERIAL.println(destination[Z_AXIS]);MYSERIAL.println(destination[E_AXIS]);
MYSERIAL.println(feedrate);MYSERIAL.println(active_extruder);
#endif
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
st_synchronize();
current_position[X_AXIS] = destination[X_AXIS];

View file

@ -20,7 +20,7 @@ float world2machine_shift[2];
#define WEIGHT_FIRST_ROW_Y_LOW (0.0f)
#define BED_ZERO_REF_X (- 22.f + X_PROBE_OFFSET_FROM_EXTRUDER) // -22 + 23 = 1
#define BED_ZERO_REF_Y (- 0.6f + Y_PROBE_OFFSET_FROM_EXTRUDER) // -0.6 + 5 = 4.4
#define BED_ZERO_REF_Y (- 0.6f + Y_PROBE_OFFSET_FROM_EXTRUDER + 4.f) // -0.6 + 5 + 4 = 8.4
// Scaling of the real machine axes against the programmed dimensions in the firmware.
// The correction is tiny, here around 0.5mm on 250mm length.
@ -56,10 +56,10 @@ const float bed_skew_angle_extreme = (0.25f * M_PI / 180.f);
// Positions of the bed reference points in the machine coordinates, referenced to the P.I.N.D.A sensor.
// The points are the following: center front, center right, center rear, center left.
const float bed_ref_points_4[] PROGMEM = {
13.f - BED_ZERO_REF_X, 10.4f - 4.f - BED_ZERO_REF_Y,
221.f - BED_ZERO_REF_X, 10.4f - 4.f - BED_ZERO_REF_Y,
221.f - BED_ZERO_REF_X, 202.4f - 4.f - BED_ZERO_REF_Y,
13.f - BED_ZERO_REF_X, 202.4f - 4.f - BED_ZERO_REF_Y
13.f - BED_ZERO_REF_X, 10.4f - BED_ZERO_REF_Y,
221.f - BED_ZERO_REF_X, 10.4f - BED_ZERO_REF_Y,
221.f - BED_ZERO_REF_X, 202.4f - BED_ZERO_REF_Y,
13.f - BED_ZERO_REF_X, 202.4f - BED_ZERO_REF_Y
};
const float bed_ref_points[] PROGMEM = {
@ -711,14 +711,22 @@ void world2machine_reset()
world2machine_update(vx, vy, cntr);
}
static void world2machine_default()
{
#ifdef DEFAULT_Y_OFFSET
const float vx[] = { 1.f, 0.f };
const float vy[] = { 0.f, 1.f };
const float cntr[] = { 0.f, DEFAULT_Y_OFFSET };
world2machine_update(vx, vy, cntr);
#else
world2machine_reset();
#endif
}
void world2machine_revert_to_uncorrected()
{
if (world2machine_correction_mode != WORLD2MACHINE_CORRECTION_NONE) {
// Reset the machine correction matrix.
const float vx[] = { 1.f, 0.f };
const float vy[] = { 0.f, 1.f };
const float cntr[] = { 0.f, 0.f };
world2machine_update(vx, vy, cntr);
world2machine_reset();
// Wait for the motors to stop and update the current position with the absolute values.
st_synchronize();
current_position[X_AXIS] = st_get_position_mm(X_AXIS);
@ -789,7 +797,7 @@ void world2machine_initialize()
if (reset) {
// SERIAL_ECHOLNPGM("Invalid bed correction matrix. Resetting to identity.");
reset_bed_offset_and_skew();
world2machine_reset();
world2machine_default();
} else {
world2machine_update(vec_x, vec_y, cntr);
/*

View file

@ -5,6 +5,7 @@
// The world coordinates match the machine coordinates only in case, when the machine
// is built properly, the end stops are at the correct positions and the axes are perpendicular.
extern const float bed_ref_points[] PROGMEM;
extern const float bed_ref_points_4[] PROGMEM;
extern const float bed_skew_angle_mild;
extern const float bed_skew_angle_extreme;
@ -37,26 +38,6 @@ extern void world2machine_initialize();
// to current_position[x,y].
extern void world2machine_update_current();
inline void world2machine(const float &x, const float &y, float &out_x, float &out_y)
{
if (world2machine_correction_mode == WORLD2MACHINE_CORRECTION_NONE) {
// No correction.
out_x = x;
out_y = y;
} else {
if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SKEW) {
// Firs the skew & rotation correction.
out_x = world2machine_rotation_and_skew[0][0] * x + world2machine_rotation_and_skew[0][1] * y;
out_y = world2machine_rotation_and_skew[1][0] * x + world2machine_rotation_and_skew[1][1] * y;
}
if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SHIFT) {
// Then add the offset.
out_x += world2machine_shift[0];
out_y += world2machine_shift[1];
}
}
}
inline void world2machine(float &x, float &y)
{
if (world2machine_correction_mode == WORLD2MACHINE_CORRECTION_NONE) {
@ -77,6 +58,13 @@ inline void world2machine(float &x, float &y)
}
}
inline void world2machine(const float &x, const float &y, float &out_x, float &out_y)
{
out_x = x;
out_y = y;
world2machine(out_x, out_y);
}
inline void machine2world(float x, float y, float &out_x, float &out_y)
{
if (world2machine_correction_mode == WORLD2MACHINE_CORRECTION_NONE) {

View file

@ -76,6 +76,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000
#define DEFAULT_Y_OFFSET 4.f // Offset of [0;0] point, when the printer is not calibrated
#define DEFAULT_MAX_FEEDRATE {200, 200, 12, 120} // (mm/sec) max feedrate (M203)
#define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201)