MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.14k stars 19.2k forks source link

Safe Z Homing at coodinates failure #1679

Closed woodsmoke closed 9 years ago

woodsmoke commented 9 years ago

Core XY printer, Marlin development downloaded 24/03/15. Arduino 1.05

#define X_PROBE_OFFSET_FROM_EXTRUDER -10
#define Y_PROBE_OFFSET_FROM_EXTRUDER 60
#define Z_PROBE_OFFSET_FROM_EXTRUDER 4.0

#define Z_SAFE_HOMING 
#define Z_SAFE_HOMING_X_POINT 16    // X point for Z homing when homing all axis (G28)
#define Z_SAFE_HOMING_Y_POINT 60    // Y point for Z homing when homing all axis (G28)

G28 just triggers a standard X-Y-Z home without moving to safe Z homing coordinates

thinkyhead commented 9 years ago

Are you using G28 by itself, or G28 Xn Yn ?

woodsmoke commented 9 years ago

Just G28. It doesn't replicate? Here is my config:

//===========================================================================
//============================= Mechanical Settings =========================
//===========================================================================

// Uncomment this option to enable CoreXY kinematics
#define COREXY

// Enable this option for Toshiba steppers
// #define CONFIG_STEPPERS_TOSHIBA

// The pullups are needed if you directly connect a mechanical endstop between the signal and ground pins.
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_XMIN
#define ENDSTOPPULLUP_YMIN
#define ENDSTOPPULLUP_ZMIN

// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup).
const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
//#define DISABLE_MAX_ENDSTOPS
//#define DISABLE_MIN_ENDSTOPS

// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
#define X_ENABLE_ON 0
#define Y_ENABLE_ON 0
#define Z_ENABLE_ON 0
#define E_ENABLE_ON 0 // For all extruders

// Disables axis when it's not being used.
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z false
#define DISABLE_E false // For all extruders
#define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled

// If you motor turns to wrong direction, you can invert it here:
#define INVERT_X_DIR true
#define INVERT_Y_DIR true
#define INVERT_Z_DIR true
#define INVERT_E0_DIR true
#define INVERT_E1_DIR true
#define INVERT_E2_DIR true
#define INVERT_E3_DIR true

// ENDSTOP SETTINGS:
// Sets direction of endstops when homing; 1=MAX, -1=MIN
#define X_HOME_DIR -1
#define Y_HOME_DIR -1
#define Z_HOME_DIR -1

#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops true  // If true, axis won't move to coordinates greater than the defined lengths below.

// Travel limits after homing (units are in mm)
#define X_MAX_POS 194
#define X_MIN_POS 0
#define Y_MAX_POS 154
#define Y_MIN_POS 0
#define Z_MAX_POS 144
#define Z_MIN_POS -30

#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
#define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
#define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)

//===========================================================================
//============================= Filament Runout Sensor ======================
//===========================================================================
//#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament
                                 // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made.
                                 // It is assumed that when logic high = filament available
                                 //                    when logic  low = filament ran out
//const bool FIL_RUNOUT_INVERTING = true;  // Should be uncommented and true or false should assigned
//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined.

//===========================================================================
//============================ Manual Bed Leveling ==========================
//===========================================================================

// #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
// #define MESH_BED_LEVELING    // Enable mesh bed leveling

#if defined(MESH_BED_LEVELING)
  #define MESH_MIN_X 10
  #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)
  #define MESH_MIN_Y 10
  #define MESH_MAX_Y (Y_MAX_POS - MESH_MIN_Y)
  #define MESH_NUM_X_POINTS 3  // Don't use more than 7 points per axis, implementation limited
  #define MESH_NUM_Y_POINTS 3
  #define MESH_HOME_SEARCH_Z 4  // Z after Home, bed somewhere below but above 0.0
#endif  // MESH_BED_LEVELING

//===========================================================================
//============================= Bed Auto Leveling ===========================
//===========================================================================

//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line)
#define Z_PROBE_REPEATABILITY_TEST  // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.

#ifdef ENABLE_AUTO_BED_LEVELING

  // There are 2 different ways to specify probing locations
  //
  // - "grid" mode
  //   Probe several points in a rectangular grid.
  //   You specify the rectangle and the density of sample points.
  //   This mode is preferred because there are more measurements.
  //
  // - "3-point" mode
  //   Probe 3 arbitrary points on the bed (that aren't colinear)
  //   You specify the XY coordinates of all 3 points.

  // Enable this to sample the bed in a grid (least squares solution)
  // Note: this feature generates 10KB extra code size
  //#define AUTO_BED_LEVELING_GRID

  #ifdef AUTO_BED_LEVELING_GRID

    #define LEFT_PROBE_BED_POSITION 20
    #define RIGHT_PROBE_BED_POSITION 140
    #define BACK_PROBE_BED_POSITION 150
    #define FRONT_PROBE_BED_POSITION 210

    #define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this

    // Set the number of grid points per dimension
    // You probably don't need more than 3 (squared=9)
    #define AUTO_BED_LEVELING_GRID_POINTS 2

  #else  // !AUTO_BED_LEVELING_GRID

      // Arbitrary points to probe. A simple cross-product
      // is used to estimate the plane of the bed.
      #define ABL_PROBE_PT_1_X 26
      #define ABL_PROBE_PT_1_Y 84
      #define ABL_PROBE_PT_2_X 26
      #define ABL_PROBE_PT_2_Y 150
      #define ABL_PROBE_PT_3_X 150
      #define ABL_PROBE_PT_3_Y 150

  #endif // AUTO_BED_LEVELING_GRID

  // Offsets to the probe relative to the extruder tip (Hotend - Probe)
  // X and Y offsets must be integers
  #define X_PROBE_OFFSET_FROM_EXTRUDER -10     // Probe on: -left  +right
  #define Y_PROBE_OFFSET_FROM_EXTRUDER 60     // Probe on: -front +behind
  #define Z_PROBE_OFFSET_FROM_EXTRUDER 4  // -below (always!)

  #define Z_RAISE_BEFORE_HOMING 4       // (in mm) Raise Z before homing (G28) for Probe Clearance.
                                        // Be sure you have this distance over your Z_MAX_POS in case

  #define XY_TRAVEL_SPEED 8000         // X and Y axis travel speed between probes, in mm/min

  #define Z_RAISE_BEFORE_PROBING 4    //How much the extruder will be raised before traveling to the first probing point.
  #define Z_RAISE_BETWEEN_PROBINGS 4  //How much the extruder will be raised when traveling from between next probing points
  #define Z_RAISE_AFTER_PROBING 4    //How much the extruder will be raised after the last probing point.

//   #define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10" //These commands will be executed in the end of G29 routine.
                                                                            //Useful to retract a deployable probe.

  //#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
  //#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.

  //If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk
  //The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.
  // You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile.

//  #define PROBE_SERVO_DEACTIVATION_DELAY 300

//If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!!!

  #define Z_SAFE_HOMING   // This feature is meant to avoid Z homing with probe outside the bed area.
                          // When defined, it will:
                          // - Allow Z homing only after X and Y homing AND stepper drivers still enabled
                          // - If stepper drivers timeout, it will need X and Y homing again before Z homing
                          // - Position the probe in a defined XY point before Z Homing when homing all axis (G28)
                          // - Block Z homing only when the probe is outside bed area.

  #ifdef Z_SAFE_HOMING

    #define Z_SAFE_HOMING_X_POINT 16    // X point for Z homing when homing all axis (G28)
    #define Z_SAFE_HOMING_Y_POINT 60    // Y point for Z homing when homing all axis (G28)

  #endif

#endif // ENABLE_AUTO_BED_LEVELING

// The position of the homing switches
#define MANUAL_HOME_POSITIONS  // If defined, MANUAL_*_HOME_POS below will be used
//#define BED_CENTER_AT_0_0  // If defined, the center of the bed is at (X=0, Y=0)

// Manual homing switch locations:
// For deltabots this means top and center of the Cartesian print volume.
#ifdef MANUAL_HOME_POSITIONS
  #define MANUAL_X_HOME_POS 0
  #define MANUAL_Y_HOME_POS 0
  #define MANUAL_Z_HOME_POS 0
  //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
#endif

//// MOVEMENT SETTINGS
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
#define HOMING_FEEDRATE {50*60, 50*60, 200, 0}  // set the homing speeds (mm/min)

// default settings

#define DEFAULT_AXIS_STEPS_PER_UNIT   {100,100,4000,174}  // default steps per unit for Ultimaker
#define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 25}    // (mm/sec)
#define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.

#define DEFAULT_ACCELERATION          3000    // X, Y, Z and E acceleration in mm/s^2 for printing moves
#define DEFAULT_RETRACT_ACCELERATION  3000   // E acceleration in mm/s^2 for retracts
#define DEFAULT_TRAVEL_ACCELERATION   1000    // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves

// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
// For the other hotends it is their distance from the extruder 0 hotend.
// #define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis
// #define EXTRUDER_OFFSET_Y {0.0, 5.00}  // (in mm) for each extruder, offset of the hotend on the Y axis

// The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously)
#define DEFAULT_XYJERK                20.0    // (mm/sec)
#define DEFAULT_ZJERK                 0.4     // (mm/sec)
#define DEFAULT_EJERK                 5.0    // (mm/sec)
Wurstnase commented 9 years ago
#define Z_PROBE_OFFSET_FROM_EXTRUDER 4 // **-below (always!)**

replace it with

#define Z_PROBE_OFFSET_FROM_EXTRUDER -4 // -below (always!)

I don't know if this is the issue, but this is wrong in your setup.

woodsmoke commented 9 years ago

@Wurstnase See issue #1667

thinkyhead commented 9 years ago

Another item for SanityCheck.h. — That offset must always be negative.

woodsmoke commented 9 years ago

Please don't do that, for the reasons discussed.

thinkyhead commented 9 years ago

@woodsmoke When would Z_PROBE_OFFSET_FROM_EXTRUDER be positive? Can it be positive and result in code that makes any sense?

nophead commented 9 years ago

@woodsmoke explained earlier that his probe is higher than his nozzle and diagonally offset from it. His nozzle can move outside of the bed area so he can probe three corners without the nozzle hitting the bed. A neat solution if you have a machine with over travel.

woodsmoke commented 9 years ago

This is it! The bleeding edge of Open Sore Hardware Movement. Personal savings are a prerequisite. When I have personal savings I'm going to take up coding.

woodsmoke commented 9 years ago

Let's steer this back towards the safe homing coordinates issue. Last time this feature failed was because the probe offset caused the safe homing coordinates to fall outside the travel extents. So it just homed at 0. Soft endstops are still present, but some associated code has been removed from config:

define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)

define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)

define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)

Has that got anything to do with it?

Wurstnase commented 9 years ago

you will find this in Conditionals.h. I think this could be go back to config.

thinkyhead commented 9 years ago

You are allowed to have a negative Z_MIN_POS (and the other min values as well) which should give the right limits and the correct max_length values. With Z_PROBE_OFFSET_FROM_EXTRUDER set to a positive value and the travel limits set far enough, the firmware should at least attempt do all the right stuff, but it's possible there is some code to prevent Z going below 0. Also I see that the M851 gcode won't allow values outside of -5 to -15, so you can't use that currently.

Wurstnase commented 9 years ago

Just edit this limits. I've done this and it works.

thinkyhead commented 9 years ago

We can re-open this if there's still more to do to get everything working smoothly.

woodsmoke commented 9 years ago

I still can't get a safe home at coordinates to work. I'm not having any luck narrowing it down either.

thinkyhead commented 9 years ago

Some of the homing code has been tweaked, so give the latest a try. Might not fix it, but at least one known homing bug was addressed.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.