Minor bug fixes.

- Bug fix for step and direction invert masks not immediately being in
effect. Now regenerates the masks when a user changes this setting.

- Bug fix for probing cycle. G-code standard mandates that there is an
error if the probe is already triggered when the cycle is commanded.
However, Grbl may have motions to pull off a previous probing cycle in
queue and can falsely lead to errors. To fix this, the triggered check
is performed within the probing cycle itself, right after the planner
buffer is synced. If there is an error, it will now alarm out as a
probe fail.
This commit is contained in:
Sonny Jeon 2014-08-01 08:29:35 -06:00
parent a396adf60e
commit 5c0d311d92
9 changed files with 41 additions and 17 deletions

View File

@ -795,10 +795,11 @@ uint8_t gc_execute_line(char *line)
break; break;
case MOTION_MODE_PROBE: case MOTION_MODE_PROBE:
// [G38 Errors]: Target is same current. No axis words. Cutter compensation is enabled. Feed rate // [G38 Errors]: Target is same current. No axis words. Cutter compensation is enabled. Feed rate
// is undefined. Probe is triggered. // is undefined. Probe is triggered. NOTE: Probe check moved to probe cycle. Instead of returning
// an error, it issues an alarm to prevent further motion to the probe. It's also done there to
// allow the planner buffer to empty and move off the probe trigger before another probing cycle.
if (!axis_words) { FAIL(STATUS_GCODE_NO_AXIS_WORDS); } // [No axis words] if (!axis_words) { FAIL(STATUS_GCODE_NO_AXIS_WORDS); } // [No axis words]
if (gc_check_same_position(gc_state.position, gc_block.values.xyz)) { FAIL(STATUS_GCODE_INVALID_TARGET); } // [Invalid target] if (gc_check_same_position(gc_state.position, gc_block.values.xyz)) { FAIL(STATUS_GCODE_INVALID_TARGET); } // [Invalid target]
if (probe_get_state()) { FAIL(STATUS_GCODE_PROBE_TRIGGERED); } // [Probe triggered]
break; break;
} }
} }

View File

@ -276,7 +276,14 @@ void mc_homing_cycle()
void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate) void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate)
#endif #endif
{ {
protocol_buffer_synchronize(); // Finish all queued commands and empty planner buffer. // Finish all queued commands and empty planner buffer before starting probe cycle.
protocol_buffer_synchronize();
// After syncing, check if probe is already triggered. If so, halt and issue alarm.
if (probe_get_state()) {
bit_true_atomic(sys.execute, EXEC_CRIT_EVENT);
protocol_execute_runtime();
}
if (sys.abort) { return; } // Return if system reset has been issued. if (sys.abort) { return; } // Return if system reset has been issued.
// Setup and queue probing motion. Auto cycle-start should not start the cycle. // Setup and queue probing motion. Auto cycle-start should not start the cycle.

View File

@ -29,6 +29,7 @@
#define X_AXIS 0 // Axis indexing value. Must start with 0 and be continuous. #define X_AXIS 0 // Axis indexing value. Must start with 0 and be continuous.
#define Y_AXIS 1 #define Y_AXIS 1
#define Z_AXIS 2 #define Z_AXIS 2
// #define A_AXIS 3
#define MM_PER_INCH (25.40) #define MM_PER_INCH (25.40)
#define INCH_PER_MM (0.0393701) #define INCH_PER_MM (0.0393701)

View File

@ -50,9 +50,8 @@
#define STATUS_GCODE_INVALID_TARGET 33 #define STATUS_GCODE_INVALID_TARGET 33
#define STATUS_GCODE_ARC_RADIUS_ERROR 34 #define STATUS_GCODE_ARC_RADIUS_ERROR 34
#define STATUS_GCODE_NO_OFFSETS_IN_PLANE 35 #define STATUS_GCODE_NO_OFFSETS_IN_PLANE 35
#define STATUS_GCODE_PROBE_TRIGGERED 36 #define STATUS_GCODE_UNUSED_WORDS 36
#define STATUS_GCODE_UNUSED_WORDS 37 #define STATUS_GCODE_G43_DYNAMIC_AXIS_ERROR 37
#define STATUS_GCODE_G43_DYNAMIC_AXIS_ERROR 38
// Define Grbl alarm codes. Less than zero to distinguish alarm error from status error. // Define Grbl alarm codes. Less than zero to distinguish alarm error from status error.
#define ALARM_LIMIT_ERROR -1 #define ALARM_LIMIT_ERROR -1

View File

@ -25,6 +25,7 @@
#include "protocol.h" #include "protocol.h"
#include "report.h" #include "report.h"
#include "limits.h" #include "limits.h"
#include "stepper.h"
settings_t settings; settings_t settings;
@ -194,8 +195,14 @@ uint8_t settings_store_global_setting(uint8_t parameter, float value) {
if (int_value < 3) { return(STATUS_SETTING_STEP_PULSE_MIN); } if (int_value < 3) { return(STATUS_SETTING_STEP_PULSE_MIN); }
settings.pulse_microseconds = int_value; break; settings.pulse_microseconds = int_value; break;
case 1: settings.stepper_idle_lock_time = int_value; break; case 1: settings.stepper_idle_lock_time = int_value; break;
case 2: settings.step_invert_mask = int_value; break; case 2:
case 3: settings.dir_invert_mask = int_value; break; settings.step_invert_mask = int_value;
st_generate_step_dir_invert_masks(); // Regenerate step and direction port invert masks.
break;
case 3:
settings.dir_invert_mask = int_value;
st_generate_step_dir_invert_masks(); // Regenerate step and direction port invert masks.
break;
case 4: // Reset to ensure change. Immediate re-init may cause problems. case 4: // Reset to ensure change. Immediate re-init may cause problems.
if (int_value) { settings.flags |= BITFLAG_INVERT_ST_ENABLE; } if (int_value) { settings.flags |= BITFLAG_INVERT_ST_ENABLE; }
else { settings.flags &= ~BITFLAG_INVERT_ST_ENABLE; } else { settings.flags &= ~BITFLAG_INVERT_ST_ENABLE; }

View File

@ -24,7 +24,7 @@
#define GRBL_VERSION "0.9g" #define GRBL_VERSION "0.9g"
#define GRBL_VERSION_BUILD "20140725" #define GRBL_VERSION_BUILD "20140801"
// Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl // Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl
// when firmware is upgraded. Always stored in byte 0 of eeprom // when firmware is upgraded. Always stored in byte 0 of eeprom

View File

@ -439,6 +439,19 @@ ISR(TIMER0_OVF_vect)
#endif #endif
// Generates the step and direction port invert masks used in the Stepper Interrupt Driver.
void st_generate_step_dir_invert_masks()
{
uint8_t idx;
step_port_invert_mask = 0;
dir_port_invert_mask = 0;
for (idx=0; idx<N_AXIS; idx++) {
if (bit_istrue(settings.step_invert_mask,bit(idx))) { step_port_invert_mask |= get_step_pin_mask(idx); }
if (bit_istrue(settings.dir_invert_mask,bit(idx))) { dir_port_invert_mask |= get_direction_pin_mask(idx); }
}
}
// Reset and clear stepper subsystem variables // Reset and clear stepper subsystem variables
void st_reset() void st_reset()
{ {
@ -455,14 +468,7 @@ void st_reset()
segment_next_head = 1; segment_next_head = 1;
busy = false; busy = false;
// Setup step and direction port invert masks. st_generate_step_dir_invert_masks();
uint8_t idx;
step_port_invert_mask = 0;
dir_port_invert_mask = 0;
for (idx=0; idx<N_AXIS; idx++) {
if (bit_istrue(settings.step_invert_mask,bit(idx))) { step_port_invert_mask |= get_step_pin_mask(idx); }
if (bit_istrue(settings.dir_invert_mask,bit(idx))) { dir_port_invert_mask |= get_direction_pin_mask(idx); }
}
// Initialize step and direction port pins. // Initialize step and direction port pins.
STEP_PORT = (STEP_PORT & ~STEP_MASK) | step_port_invert_mask; STEP_PORT = (STEP_PORT & ~STEP_MASK) | step_port_invert_mask;

View File

@ -35,6 +35,9 @@ void st_wake_up();
// Immediately disables steppers // Immediately disables steppers
void st_go_idle(); void st_go_idle();
// Generate the step and direction port invert masks.
void st_generate_step_dir_invert_masks();
// Reset the stepper subsystem variables // Reset the stepper subsystem variables
void st_reset(); void st_reset();

0
test/gcode/braid_cut2d.nc Executable file → Normal file
View File