Homing search sequence now compile-time option. New defaults.h file. Tidying up.
- The homing sequence is now a compile-time option, where a user can choose which axes(s) move in sequence during the search phase. Up to 3 sequences. Works with the locating phase and the pull-off maneuver. - New defaults.h file to store user generated default settings for different machines. Mainly to be used as a central repo, but each set may be select to be compiled in as a config.h define.
This commit is contained in:
parent
5dd6d90122
commit
d85238cc9b
48
config.h
48
config.h
@ -24,6 +24,10 @@
|
|||||||
|
|
||||||
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
|
// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them.
|
||||||
|
|
||||||
|
// Default settings. Used when resetting EEPROM. Change to desired name in defaults.h
|
||||||
|
#define DEFAULTS_GENERIC
|
||||||
|
|
||||||
|
// Serial baud rate
|
||||||
#define BAUD_RATE 9600
|
#define BAUD_RATE 9600
|
||||||
|
|
||||||
// Define pin-assignments
|
// Define pin-assignments
|
||||||
@ -90,34 +94,6 @@
|
|||||||
#define PINOUT_PCMSK PCMSK1 // Pin change interrupt register
|
#define PINOUT_PCMSK PCMSK1 // Pin change interrupt register
|
||||||
#define PINOUT_MASK ((1<<PIN_RESET)|(1<<PIN_FEED_HOLD)|(1<<PIN_CYCLE_START))
|
#define PINOUT_MASK ((1<<PIN_RESET)|(1<<PIN_FEED_HOLD)|(1<<PIN_CYCLE_START))
|
||||||
|
|
||||||
|
|
||||||
// Default settings (used when resetting eeprom-settings)
|
|
||||||
// TODO: Begin to fill these out for various as-built machines, i.e. config_sherline5400.h
|
|
||||||
#define MICROSTEPS 4
|
|
||||||
#define DEFAULT_X_STEPS_PER_MM (94.488188976378*MICROSTEPS)
|
|
||||||
#define DEFAULT_Y_STEPS_PER_MM (94.488188976378*MICROSTEPS)
|
|
||||||
#define DEFAULT_Z_STEPS_PER_MM (94.488188976378*MICROSTEPS)
|
|
||||||
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
|
|
||||||
#define DEFAULT_MM_PER_ARC_SEGMENT 0.1
|
|
||||||
#define DEFAULT_RAPID_FEEDRATE 500.0 // mm/min
|
|
||||||
#define DEFAULT_FEEDRATE 250.0
|
|
||||||
#define DEFAULT_ACCELERATION (DEFAULT_FEEDRATE*60*60/10.0) // mm/min^2
|
|
||||||
#define DEFAULT_JUNCTION_DEVIATION 0.05 // mm
|
|
||||||
#define DEFAULT_STEPPING_INVERT_MASK ((1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT))
|
|
||||||
#define DEFAULT_REPORT_INCHES 0 // false
|
|
||||||
#define DEFAULT_AUTO_START 1 // true
|
|
||||||
#define DEFAULT_INVERT_ST_ENABLE 0 // false
|
|
||||||
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
|
||||||
#define DEFAULT_HOMING_ENABLE 0 // false
|
|
||||||
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
|
|
||||||
#define DEFAULT_HOMING_RAPID_FEEDRATE 250.0 // mm/min
|
|
||||||
#define DEFAULT_HOMING_FEEDRATE 25 // mm/min
|
|
||||||
#define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k)
|
|
||||||
#define DEFAULT_HOMING_PULLOFF 1 // mm
|
|
||||||
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-255)
|
|
||||||
#define DEFAULT_DECIMAL_PLACES 3
|
|
||||||
#define DEFAULT_N_ARC_CORRECTION 25
|
|
||||||
|
|
||||||
// Define runtime command special characters. These characters are 'picked-off' directly from the
|
// Define runtime command special characters. These characters are 'picked-off' directly from the
|
||||||
// serial read data stream and are not passed to the grbl line execution parser. Select characters
|
// serial read data stream and are not passed to the grbl line execution parser. Select characters
|
||||||
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
|
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
|
||||||
@ -170,10 +146,24 @@
|
|||||||
// just moves them all at 100% speed.
|
// just moves them all at 100% speed.
|
||||||
#define HOMING_RATE_ADJUST // Comment to disable
|
#define HOMING_RATE_ADJUST // Comment to disable
|
||||||
|
|
||||||
|
// Define the homing cycle search patterns with bitmasks. The homing cycle first performs a search
|
||||||
|
// to engage the limit switches. HOMING_SEARCH_CYCLE_x are executed in order starting with suffix 0
|
||||||
|
// and searches the enabled axes in the bitmask. This allows for users with non-standard cartesian
|
||||||
|
// machines, such as a lathe (x then z), to configure the homing cycle behavior to their needs.
|
||||||
|
// Search cycle 0 is required, but cycles 1 and 2 are both optional and may be commented to disable.
|
||||||
|
// After the search cycle, homing then performs a series of locating about the limit switches to hone
|
||||||
|
// in on machine zero, followed by a pull-off maneuver. HOMING_LOCATE_CYCLE governs these final moves,
|
||||||
|
// and this mask must contain all axes in the search.
|
||||||
|
// NOTE: Later versions may have this installed in settings.
|
||||||
|
#define HOMING_SEARCH_CYCLE_0 (1<<Z_AXIS) // First move Z to clear workspace.
|
||||||
|
#define HOMING_SEARCH_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) // Then move X,Y at the same time.
|
||||||
|
// #define HOMING_SEARCH_CYCLE_2 // Uncomment and add axes mask to enable
|
||||||
|
#define HOMING_LOCATE_CYCLE ((1<<X_AXIS)|(1<<Y_AXIS)|(1<<Z_AXIS)) // Must contain ALL search axes
|
||||||
|
|
||||||
// Number of homing cycles performed after when the machine initially jogs to limit switches.
|
// Number of homing cycles performed after when the machine initially jogs to limit switches.
|
||||||
// This help in preventing overshoot and should improve repeatability. This value should be one or
|
// This help in preventing overshoot and should improve repeatability. This value should be one or
|
||||||
// greater.
|
// greater.
|
||||||
#define N_HOMING_CYCLE 2 // Integer (1-128)
|
#define N_HOMING_LOCATE_CYCLE 2 // Integer (1-128)
|
||||||
|
|
||||||
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
|
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
|
||||||
// and addresses are defined in settings.h. With the current settings, up to 5 startup blocks may
|
// and addresses are defined in settings.h. With the current settings, up to 5 startup blocks may
|
||||||
|
122
defaults.h
Normal file
122
defaults.h
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/*
|
||||||
|
defaults.h - defaults settings configuration file
|
||||||
|
Part of Grbl
|
||||||
|
|
||||||
|
Copyright (c) 2012 Sungeun K. Jeon
|
||||||
|
|
||||||
|
Grbl is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Grbl is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The defaults.h file serves as a central default settings file for different machine
|
||||||
|
types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
|
||||||
|
here are supplied by users, so your results may vary. However, this should give you
|
||||||
|
a good starting point as you get to know your machine and tweak the settings for your
|
||||||
|
our nefarious needs. */
|
||||||
|
|
||||||
|
#ifndef defaults_h
|
||||||
|
#define defaults_h
|
||||||
|
|
||||||
|
#ifdef DEFAULTS_GENERIC
|
||||||
|
// Grbl generic default settings. Should work across different machines.
|
||||||
|
#define DEFAULT_X_STEPS_PER_MM 250
|
||||||
|
#define DEFAULT_Y_STEPS_PER_MM 250
|
||||||
|
#define DEFAULT_Z_STEPS_PER_MM 250
|
||||||
|
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
|
||||||
|
#define DEFAULT_MM_PER_ARC_SEGMENT 0.1
|
||||||
|
#define DEFAULT_RAPID_FEEDRATE 500.0 // mm/min
|
||||||
|
#define DEFAULT_FEEDRATE 250.0
|
||||||
|
#define DEFAULT_ACCELERATION 10*60*60 // 10 mm/sec^2
|
||||||
|
#define DEFAULT_JUNCTION_DEVIATION 0.05 // mm
|
||||||
|
#define DEFAULT_STEPPING_INVERT_MASK ((1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT))
|
||||||
|
#define DEFAULT_REPORT_INCHES 0 // false
|
||||||
|
#define DEFAULT_AUTO_START 1 // true
|
||||||
|
#define DEFAULT_INVERT_ST_ENABLE 0 // false
|
||||||
|
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||||
|
#define DEFAULT_HOMING_ENABLE 0 // false
|
||||||
|
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
|
||||||
|
#define DEFAULT_HOMING_RAPID_FEEDRATE 250.0 // mm/min
|
||||||
|
#define DEFAULT_HOMING_FEEDRATE 25 // mm/min
|
||||||
|
#define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k)
|
||||||
|
#define DEFAULT_HOMING_PULLOFF 1 // mm
|
||||||
|
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-255)
|
||||||
|
#define DEFAULT_DECIMAL_PLACES 3
|
||||||
|
#define DEFAULT_N_ARC_CORRECTION 25
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEFAULTS_SHERLINE_5400
|
||||||
|
// Description: Sherline 5400 mill with three NEMA 23 185 oz-in stepper motors, driven by
|
||||||
|
// three Pololu A4988 stepper drivers with a 30V, 6A power supply at 1.5A per winding.
|
||||||
|
#define MICROSTEPS 4
|
||||||
|
#define STEPS_PER_REV 200.0
|
||||||
|
#define MM_PER_REV (0.050*MM_PER_INCH)) // 0.050 inch/rev leadscrew
|
||||||
|
#define DEFAULT_X_STEPS_PER_MM (STEP_PER_REV*MICROSTEPS/MM_PER_REV)
|
||||||
|
#define DEFAULT_Y_STEPS_PER_MM (STEP_PER_REV*MICROSTEPS/MM_PER_REV)
|
||||||
|
#define DEFAULT_Z_STEPS_PER_MM (STEP_PER_REV*MICROSTEPS/MM_PER_REV)
|
||||||
|
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
|
||||||
|
#define DEFAULT_MM_PER_ARC_SEGMENT 0.1
|
||||||
|
#define DEFAULT_RAPID_FEEDRATE 635.0 // mm/min (25ipm)
|
||||||
|
#define DEFAULT_FEEDRATE 254.0 // mm/min (10ipm)
|
||||||
|
#define DEFAULT_ACCELERATION 50.0*60*60 // 50 mm/sec^2
|
||||||
|
#define DEFAULT_JUNCTION_DEVIATION 0.05 // mm
|
||||||
|
#define DEFAULT_STEPPING_INVERT_MASK ((1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT))
|
||||||
|
#define DEFAULT_REPORT_INCHES 1 // false
|
||||||
|
#define DEFAULT_AUTO_START 1 // true
|
||||||
|
#define DEFAULT_INVERT_ST_ENABLE 0 // false
|
||||||
|
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||||
|
#define DEFAULT_HOMING_ENABLE 0 // false
|
||||||
|
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
|
||||||
|
#define DEFAULT_HOMING_RAPID_FEEDRATE 254.0 // mm/min
|
||||||
|
#define DEFAULT_HOMING_FEEDRATE 25 // mm/min
|
||||||
|
#define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k)
|
||||||
|
#define DEFAULT_HOMING_PULLOFF 1 // mm
|
||||||
|
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-255)
|
||||||
|
#define DEFAULT_DECIMAL_PLACES 3
|
||||||
|
#define DEFAULT_N_ARC_CORRECTION 25
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEFAULTS_SHAPEOKO
|
||||||
|
// Description: Shapeoko CNC mill with three NEMA 17 stepper motors, driven by Synthetos
|
||||||
|
// grblShield with a 24V, 4.2A power supply.
|
||||||
|
#define MICROSTEPS_XY 8
|
||||||
|
#define STEP_REVS_XY 400
|
||||||
|
#define MM_PER_REV_XY (0.08*18*MM_PER_INCH) // 0.08 in belt pitch, 18 pulley teeth
|
||||||
|
#define MICROSTEPS_Z 2
|
||||||
|
#define STEP_REVS_Z 400
|
||||||
|
#define MM_PER_REV_Z 1.250 // 1.25 mm/rev leadscrew
|
||||||
|
#define DEFAULT_X_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
|
||||||
|
#define DEFAULT_Y_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
|
||||||
|
#define DEFAULT_Z_STEPS_PER_MM (MICROSTEPS_Z*STEP_REVS_Z/MM_PER_REV_Z)
|
||||||
|
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
|
||||||
|
#define DEFAULT_MM_PER_ARC_SEGMENT 0.1
|
||||||
|
#define DEFAULT_RAPID_FEEDRATE 1000.0 // mm/min
|
||||||
|
#define DEFAULT_FEEDRATE 250.0
|
||||||
|
#define DEFAULT_ACCELERATION 15.0*60*60 // 15 mm/sec^2
|
||||||
|
#define DEFAULT_JUNCTION_DEVIATION 0.05 // mm
|
||||||
|
#define DEFAULT_STEPPING_INVERT_MASK ((1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT))
|
||||||
|
#define DEFAULT_REPORT_INCHES 0 // false
|
||||||
|
#define DEFAULT_AUTO_START 1 // true
|
||||||
|
#define DEFAULT_INVERT_ST_ENABLE 0 // false
|
||||||
|
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||||
|
#define DEFAULT_HOMING_ENABLE 0 // false
|
||||||
|
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
|
||||||
|
#define DEFAULT_HOMING_RAPID_FEEDRATE 250.0 // mm/min
|
||||||
|
#define DEFAULT_HOMING_FEEDRATE 25 // mm/min
|
||||||
|
#define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k)
|
||||||
|
#define DEFAULT_HOMING_PULLOFF 1 // mm
|
||||||
|
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255 // msec (0-255)
|
||||||
|
#define DEFAULT_DECIMAL_PLACES 3
|
||||||
|
#define DEFAULT_N_ARC_CORRECTION 25
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
16
gcode.c
16
gcode.c
@ -250,14 +250,16 @@ uint8_t gc_execute_line(char *line)
|
|||||||
// ([F]: Set feed and seek rates.)
|
// ([F]: Set feed and seek rates.)
|
||||||
// TODO: Seek rates can change depending on the direction and maximum speeds of each axes. When
|
// TODO: Seek rates can change depending on the direction and maximum speeds of each axes. When
|
||||||
// max axis speed is installed, the calculation can be performed here, or maybe in the planner.
|
// max axis speed is installed, the calculation can be performed here, or maybe in the planner.
|
||||||
|
|
||||||
|
if (sys.state != STATE_CHECK_MODE) {
|
||||||
|
// ([M6]: Tool change should be executed here.)
|
||||||
|
|
||||||
|
// [M3,M4,M5]: Update spindle state
|
||||||
|
spindle_run(gc.spindle_direction);
|
||||||
|
|
||||||
// ([M6]: Tool change should be executed here.)
|
// [*M7,M8,M9]: Update coolant state
|
||||||
|
coolant_run(gc.coolant_mode);
|
||||||
// [M3,M4,M5]: Update spindle state
|
}
|
||||||
if (sys.state != STATE_CHECK_MODE) { spindle_run(gc.spindle_direction); }
|
|
||||||
|
|
||||||
// [*M7,M8,M9]: Update coolant state
|
|
||||||
if (sys.state != STATE_CHECK_MODE) { coolant_run(gc.coolant_mode); }
|
|
||||||
|
|
||||||
// [G54,G55,...,G59]: Coordinate system selection
|
// [G54,G55,...,G59]: Coordinate system selection
|
||||||
if ( bit_istrue(modal_group_words,bit(MODAL_GROUP_12)) ) { // Check if called in block
|
if ( bit_istrue(modal_group_words,bit(MODAL_GROUP_12)) ) { // Check if called in block
|
||||||
|
56
limits.c
56
limits.c
@ -39,7 +39,6 @@ void limits_init()
|
|||||||
{
|
{
|
||||||
LIMIT_DDR &= ~(LIMIT_MASK); // Set as input pins
|
LIMIT_DDR &= ~(LIMIT_MASK); // Set as input pins
|
||||||
LIMIT_PORT |= (LIMIT_MASK); // Enable internal pull-up resistors. Normal high operation.
|
LIMIT_PORT |= (LIMIT_MASK); // Enable internal pull-up resistors. Normal high operation.
|
||||||
|
|
||||||
if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) {
|
if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) {
|
||||||
LIMIT_PCMSK |= LIMIT_MASK; // Enable specific pins of the Pin Change Interrupt
|
LIMIT_PCMSK |= LIMIT_MASK; // Enable specific pins of the Pin Change Interrupt
|
||||||
PCICR |= (1 << LIMIT_INT); // Enable Pin Change Interrupt
|
PCICR |= (1 << LIMIT_INT); // Enable Pin Change Interrupt
|
||||||
@ -88,8 +87,7 @@ ISR(LIMIT_INT_vect)
|
|||||||
// algorithm is written here. This also lets users hack and tune this code freely for
|
// algorithm is written here. This also lets users hack and tune this code freely for
|
||||||
// their own particular needs without affecting the rest of Grbl.
|
// their own particular needs without affecting the rest of Grbl.
|
||||||
// NOTE: Only the abort runtime command can interrupt this process.
|
// NOTE: Only the abort runtime command can interrupt this process.
|
||||||
static void homing_cycle(bool x_axis, bool y_axis, bool z_axis, int8_t pos_dir,
|
static void homing_cycle(uint8_t cycle_mask, int8_t pos_dir, bool invert_pin, float homing_rate)
|
||||||
bool invert_pin, float homing_rate)
|
|
||||||
{
|
{
|
||||||
// Determine governing axes with finest step resolution per distance for the Bresenham
|
// Determine governing axes with finest step resolution per distance for the Bresenham
|
||||||
// algorithm. This solves the issue when homing multiple axes that have different
|
// algorithm. This solves the issue when homing multiple axes that have different
|
||||||
@ -99,10 +97,20 @@ static void homing_cycle(bool x_axis, bool y_axis, bool z_axis, int8_t pos_dir,
|
|||||||
// NOTE: For each axes enabled, the following calculations assume they physically move
|
// NOTE: For each axes enabled, the following calculations assume they physically move
|
||||||
// an equal distance over each time step until they hit a limit switch, aka dogleg.
|
// an equal distance over each time step until they hit a limit switch, aka dogleg.
|
||||||
uint32_t steps[3];
|
uint32_t steps[3];
|
||||||
|
uint8_t dist = 0;
|
||||||
clear_vector(steps);
|
clear_vector(steps);
|
||||||
if (x_axis) { steps[X_AXIS] = lround(settings.steps_per_mm[X_AXIS]); }
|
if (cycle_mask & (1<<X_AXIS)) {
|
||||||
if (y_axis) { steps[Y_AXIS] = lround(settings.steps_per_mm[Y_AXIS]); }
|
dist++;
|
||||||
if (z_axis) { steps[Z_AXIS] = lround(settings.steps_per_mm[Z_AXIS]); }
|
steps[X_AXIS] = lround(settings.steps_per_mm[X_AXIS]);
|
||||||
|
}
|
||||||
|
if (cycle_mask & (1<<Y_AXIS)) {
|
||||||
|
dist++;
|
||||||
|
steps[Y_AXIS] = lround(settings.steps_per_mm[Y_AXIS]);
|
||||||
|
}
|
||||||
|
if (cycle_mask & (1<<Z_AXIS)) {
|
||||||
|
dist++;
|
||||||
|
steps[Z_AXIS] = lround(settings.steps_per_mm[Z_AXIS]);
|
||||||
|
}
|
||||||
uint32_t step_event_count = max(steps[X_AXIS], max(steps[Y_AXIS], steps[Z_AXIS]));
|
uint32_t step_event_count = max(steps[X_AXIS], max(steps[Y_AXIS], steps[Z_AXIS]));
|
||||||
|
|
||||||
// To ensure global acceleration is not exceeded, reduce the governing axes nominal rate
|
// To ensure global acceleration is not exceeded, reduce the governing axes nominal rate
|
||||||
@ -110,14 +118,14 @@ static void homing_cycle(bool x_axis, bool y_axis, bool z_axis, int8_t pos_dir,
|
|||||||
// used in the main planner to account for distance traveled when moving multiple axes.
|
// used in the main planner to account for distance traveled when moving multiple axes.
|
||||||
// NOTE: When axis acceleration independence is installed, this will be updated to move
|
// NOTE: When axis acceleration independence is installed, this will be updated to move
|
||||||
// all axes at their maximum acceleration and rate.
|
// all axes at their maximum acceleration and rate.
|
||||||
float ds = step_event_count/sqrt(x_axis+y_axis+z_axis);
|
float ds = step_event_count/sqrt(dist);
|
||||||
|
|
||||||
// Compute the adjusted step rate change with each acceleration tick. (in step/min/acceleration_tick)
|
// Compute the adjusted step rate change with each acceleration tick. (in step/min/acceleration_tick)
|
||||||
uint32_t delta_rate = ceil( ds*settings.acceleration/(60*ACCELERATION_TICKS_PER_SECOND));
|
uint32_t delta_rate = ceil( ds*settings.acceleration/(60*ACCELERATION_TICKS_PER_SECOND));
|
||||||
|
|
||||||
#ifdef HOMING_RATE_ADJUST
|
#ifdef HOMING_RATE_ADJUST
|
||||||
// Adjust homing rate so a multiple axes moves all at the homing rate independently.
|
// Adjust homing rate so a multiple axes moves all at the homing rate independently.
|
||||||
homing_rate *= sqrt(x_axis+y_axis+z_axis);
|
homing_rate *= sqrt(dist); // Eq. only works if axes values are 1 or 0.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Nominal and initial time increment per step. Nominal should always be greater then 3
|
// Nominal and initial time increment per step. Nominal should always be greater then 3
|
||||||
@ -153,34 +161,34 @@ static void homing_cycle(bool x_axis, bool y_axis, bool z_axis, int8_t pos_dir,
|
|||||||
|
|
||||||
// Set step pins by Bresenham line algorithm. If limit switch reached, disable and
|
// Set step pins by Bresenham line algorithm. If limit switch reached, disable and
|
||||||
// flag for completion.
|
// flag for completion.
|
||||||
if (x_axis) {
|
if (cycle_mask & (1<<X_AXIS)) {
|
||||||
counter_x += steps[X_AXIS];
|
counter_x += steps[X_AXIS];
|
||||||
if (counter_x > 0) {
|
if (counter_x > 0) {
|
||||||
if (limit_state & (1<<X_LIMIT_BIT)) { out_bits ^= (1<<X_STEP_BIT); }
|
if (limit_state & (1<<X_LIMIT_BIT)) { out_bits ^= (1<<X_STEP_BIT); }
|
||||||
else { x_axis = false; }
|
else { cycle_mask &= ~(1<<X_AXIS); }
|
||||||
counter_x -= step_event_count;
|
counter_x -= step_event_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (y_axis) {
|
if (cycle_mask & (1<<Y_AXIS)) {
|
||||||
counter_y += steps[Y_AXIS];
|
counter_y += steps[Y_AXIS];
|
||||||
if (counter_y > 0) {
|
if (counter_y > 0) {
|
||||||
if (limit_state & (1<<Y_LIMIT_BIT)) { out_bits ^= (1<<Y_STEP_BIT); }
|
if (limit_state & (1<<Y_LIMIT_BIT)) { out_bits ^= (1<<Y_STEP_BIT); }
|
||||||
else { y_axis = false; }
|
else { cycle_mask &= ~(1<<Y_AXIS); }
|
||||||
counter_y -= step_event_count;
|
counter_y -= step_event_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (z_axis) {
|
if (cycle_mask & (1<<Z_AXIS)) {
|
||||||
counter_z += steps[Z_AXIS];
|
counter_z += steps[Z_AXIS];
|
||||||
if (counter_z > 0) {
|
if (counter_z > 0) {
|
||||||
if (limit_state & (1<<Z_LIMIT_BIT)) { out_bits ^= (1<<Z_STEP_BIT); }
|
if (limit_state & (1<<Z_LIMIT_BIT)) { out_bits ^= (1<<Z_STEP_BIT); }
|
||||||
else { z_axis = false; }
|
else { cycle_mask &= ~(1<<Z_AXIS); }
|
||||||
counter_z -= step_event_count;
|
counter_z -= step_event_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we are done or for system abort
|
// Check if we are done or for system abort
|
||||||
protocol_execute_runtime();
|
protocol_execute_runtime();
|
||||||
if (!(x_axis || y_axis || z_axis) || sys.abort) { return; }
|
if (!(cycle_mask) || sys.abort) { return; }
|
||||||
|
|
||||||
// Perform step.
|
// Perform step.
|
||||||
STEPPING_PORT = (STEPPING_PORT & ~STEP_MASK) | (out_bits & STEP_MASK);
|
STEPPING_PORT = (STEPPING_PORT & ~STEP_MASK) | (out_bits & STEP_MASK);
|
||||||
@ -210,23 +218,27 @@ void limits_go_home()
|
|||||||
// Enable only the steppers, not the cycle. Cycle should be inactive/complete.
|
// Enable only the steppers, not the cycle. Cycle should be inactive/complete.
|
||||||
st_wake_up();
|
st_wake_up();
|
||||||
|
|
||||||
// Jog all axes toward home to engage their limit switches at faster homing seek rate.
|
// Search to engage all axes limit switches at faster homing seek rate.
|
||||||
// First jog z-axis to clear workspace, then jog the x and y axis.
|
homing_cycle(HOMING_SEARCH_CYCLE_0, true, false, settings.homing_seek_rate); // Search cycle 0
|
||||||
homing_cycle(false, false, true, true, false, settings.homing_seek_rate); // z-axis
|
#ifdef HOMING_SEARCH_CYCLE_1
|
||||||
homing_cycle(true, true, false, true, false, settings.homing_seek_rate); // xy-axes
|
homing_cycle(HOMING_SEARCH_CYCLE_1, true, false, settings.homing_seek_rate); // Search cycle 1
|
||||||
|
#endif
|
||||||
|
#ifdef HOMING_SEARCH_CYCLE_2
|
||||||
|
homing_cycle(HOMING_SEARCH_CYCLE_2, true, false, settings.homing_seek_rate); // Search cycle 2
|
||||||
|
#endif
|
||||||
delay_ms(settings.homing_debounce_delay); // Delay to debounce signal
|
delay_ms(settings.homing_debounce_delay); // Delay to debounce signal
|
||||||
|
|
||||||
// Now in proximity of all limits. Carefully leave and approach switches in multiple cycles
|
// Now in proximity of all limits. Carefully leave and approach switches in multiple cycles
|
||||||
// to precisely hone in on the machine zero location. Moves at slower homing feed rate.
|
// to precisely hone in on the machine zero location. Moves at slower homing feed rate.
|
||||||
int8_t n_cycle = N_HOMING_CYCLE;
|
int8_t n_cycle = N_HOMING_LOCATE_CYCLE;
|
||||||
while (n_cycle--) {
|
while (n_cycle--) {
|
||||||
// Leave all switches to release them. After cycles complete, this is machine zero.
|
// Leave all switches to release them. After cycles complete, this is machine zero.
|
||||||
homing_cycle(true, true, true, false, true, settings.homing_feed_rate);
|
homing_cycle(HOMING_LOCATE_CYCLE, false, true, settings.homing_feed_rate);
|
||||||
delay_ms(settings.homing_debounce_delay);
|
delay_ms(settings.homing_debounce_delay);
|
||||||
|
|
||||||
if (n_cycle > 0) {
|
if (n_cycle > 0) {
|
||||||
// Re-approach all switches to re-engage them.
|
// Re-approach all switches to re-engage them.
|
||||||
homing_cycle(true, true, true, true, false, settings.homing_feed_rate);
|
homing_cycle(HOMING_LOCATE_CYCLE, true, false, settings.homing_feed_rate);
|
||||||
delay_ms(settings.homing_debounce_delay);
|
delay_ms(settings.homing_debounce_delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,13 @@
|
|||||||
// backlash segment(s).
|
// backlash segment(s).
|
||||||
void mc_line(float x, float y, float z, float feed_rate, uint8_t invert_feed_rate)
|
void mc_line(float x, float y, float z, float feed_rate, uint8_t invert_feed_rate)
|
||||||
{
|
{
|
||||||
|
// TODO: Perform soft limit check here. Just check if the target x,y,z values are outside the
|
||||||
|
// work envelope. Should be straightforward and efficient. By placing it here, rather than in
|
||||||
|
// the g-code parser, it directly picks up motions from everywhere in Grbl.
|
||||||
|
|
||||||
|
// If in check gcode mode, prevent motion by blocking planner.
|
||||||
|
if (sys.state == STATE_CHECK_MODE) { return; }
|
||||||
|
|
||||||
// TODO: Backlash compensation may be installed here. Only need direction info to track when
|
// TODO: Backlash compensation may be installed here. Only need direction info to track when
|
||||||
// to insert a backlash line motion(s) before the intended line motion. Requires its own
|
// to insert a backlash line motion(s) before the intended line motion. Requires its own
|
||||||
// plan_check_full_buffer() and check for system abort loop. Also for position reporting
|
// plan_check_full_buffer() and check for system abort loop. Also for position reporting
|
||||||
@ -62,25 +69,21 @@ void mc_line(float x, float y, float z, float feed_rate, uint8_t invert_feed_rat
|
|||||||
protocol_execute_runtime(); // Check for any run-time commands
|
protocol_execute_runtime(); // Check for any run-time commands
|
||||||
if (sys.abort) { return; } // Bail, if system abort.
|
if (sys.abort) { return; } // Bail, if system abort.
|
||||||
} while ( plan_check_full_buffer() );
|
} while ( plan_check_full_buffer() );
|
||||||
|
plan_buffer_line(x, y, z, feed_rate, invert_feed_rate);
|
||||||
// If in check gcode mode, prevent motion by blocking planner.
|
|
||||||
if (sys.state != STATE_CHECK_MODE) {
|
// If idle, indicate to the system there is now a planned block in the buffer ready to cycle
|
||||||
plan_buffer_line(x, y, z, feed_rate, invert_feed_rate);
|
// start. Otherwise ignore and continue on.
|
||||||
|
if (!sys.state) { sys.state = STATE_QUEUED; }
|
||||||
// If idle, indicate to the system there is now a planned block in the buffer ready to cycle
|
|
||||||
// start. Otherwise ignore and continue on.
|
// Auto-cycle start immediately after planner finishes. Enabled/disabled by grbl settings. During
|
||||||
if (!sys.state) { sys.state = STATE_QUEUED; }
|
// a feed hold, auto-start is disabled momentarily until the cycle is resumed by the cycle-start
|
||||||
|
// runtime command.
|
||||||
// Auto-cycle start immediately after planner finishes. Enabled/disabled by grbl settings. During
|
// NOTE: This is allows the user to decide to exclusively use the cycle start runtime command to
|
||||||
// a feed hold, auto-start is disabled momentarily until the cycle is resumed by the cycle-start
|
// begin motion or let grbl auto-start it for them. This is useful when: manually cycle-starting
|
||||||
// runtime command.
|
// when the buffer is completely full and primed; auto-starting, if there was only one g-code
|
||||||
// NOTE: This is allows the user to decide to exclusively use the cycle start runtime command to
|
// command sent during manual operation; or if a system is prone to buffer starvation, auto-start
|
||||||
// begin motion or let grbl auto-start it for them. This is useful when: manually cycle-starting
|
// helps make sure it minimizes any dwelling/motion hiccups and keeps the cycle going.
|
||||||
// when the buffer is completely full and primed; auto-starting, if there was only one g-code
|
if (sys.auto_start) { st_cycle_start(); }
|
||||||
// command sent during manual operation; or if a system is prone to buffer starvation, auto-start
|
|
||||||
// helps make sure it minimizes any dwelling/motion hiccups and keeps the cycle going.
|
|
||||||
if (sys.auto_start) { st_cycle_start(); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -223,20 +226,29 @@ void mc_go_home()
|
|||||||
sys_sync_current_position();
|
sys_sync_current_position();
|
||||||
sys.state = STATE_IDLE; // Set system state to IDLE to complete motion and indicate homed.
|
sys.state = STATE_IDLE; // Set system state to IDLE to complete motion and indicate homed.
|
||||||
|
|
||||||
// Pull-off all axes from limit switches before continuing motion. This provides some initial
|
// Pull-off axes (that have been homed) from limit switches before continuing motion.
|
||||||
// clearance off the switches and should also help prevent them from falsely tripping when
|
// This provides some initial clearance off the switches and should also help prevent them
|
||||||
// hard limits are enabled.
|
// from falsely tripping when hard limits are enabled.
|
||||||
int8_t x_dir, y_dir, z_dir;
|
int8_t x_dir, y_dir, z_dir;
|
||||||
x_dir = y_dir = z_dir = -1;
|
x_dir = y_dir = z_dir = 0;
|
||||||
if (bit_istrue(settings.homing_dir_mask,bit(X_DIRECTION_BIT))) { x_dir = 1; }
|
if (HOMING_LOCATE_CYCLE & (1<<X_AXIS)) {
|
||||||
if (bit_istrue(settings.homing_dir_mask,bit(Y_DIRECTION_BIT))) { y_dir = 1; }
|
if (settings.homing_dir_mask & (1<<X_DIRECTION_BIT)) { x_dir = 1; }
|
||||||
if (bit_istrue(settings.homing_dir_mask,bit(Z_DIRECTION_BIT))) { z_dir = 1; }
|
else { x_dir = -1; }
|
||||||
|
}
|
||||||
|
if (HOMING_LOCATE_CYCLE & (1<<Y_AXIS)) {
|
||||||
|
if (settings.homing_dir_mask & (1<<Y_DIRECTION_BIT)) { y_dir = 1; }
|
||||||
|
else { y_dir = -1; }
|
||||||
|
}
|
||||||
|
if (HOMING_LOCATE_CYCLE & (1<<Z_AXIS)) {
|
||||||
|
if (settings.homing_dir_mask & (1<<Z_DIRECTION_BIT)) { z_dir = 1; }
|
||||||
|
else { z_dir = -1; }
|
||||||
|
}
|
||||||
mc_line(x_dir*settings.homing_pulloff, y_dir*settings.homing_pulloff,
|
mc_line(x_dir*settings.homing_pulloff, y_dir*settings.homing_pulloff,
|
||||||
z_dir*settings.homing_pulloff, settings.homing_seek_rate, false);
|
z_dir*settings.homing_pulloff, settings.homing_seek_rate, false);
|
||||||
st_cycle_start(); // Move it. Nothing should be in the buffer except this motion.
|
st_cycle_start(); // Move it. Nothing should be in the buffer except this motion.
|
||||||
plan_synchronize(); // Make sure the motion completes.
|
plan_synchronize(); // Make sure the motion completes.
|
||||||
|
|
||||||
// The gcode parser position was circumvented by the pull-off maneuver, so sync position vectors.
|
// The gcode parser position circumvented by the pull-off maneuver, so sync position vectors.
|
||||||
sys_sync_current_position();
|
sys_sync_current_position();
|
||||||
|
|
||||||
// If hard limits feature enabled, re-enable hard limits pin change register after homing cycle.
|
// If hard limits feature enabled, re-enable hard limits pin change register after homing cycle.
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "defaults.h"
|
||||||
|
|
||||||
#define false 0
|
#define false 0
|
||||||
#define true 1
|
#define true 1
|
||||||
|
Loading…
Reference in New Issue
Block a user