Bug fixes and more limit configurability
- Strange sizeof() bug in the most recent releases. Manifested as an alarm upon a power up even when homing was disabled. Fixed by declaring sizeof() with struct types, rather than variable names, even though they were validated to give the same value. - Spindle speed zero should disable the spindle. Now fixed. - New configuration option for inverting certain limit pins. Handy for mixed NO and NC switch machines. See config.h for details. - Incremented version and pre-build firmware link.
This commit is contained in:
@@ -27,7 +27,7 @@ Grbl includes full acceleration management with look ahead. That means the contr
|
|||||||
***
|
***
|
||||||
|
|
||||||
_**Master Branch:**_
|
_**Master Branch:**_
|
||||||
* [Grbl v0.9j Atmega328p 16mhz 115200baud with generic defaults](http://bit.ly/1I8Ey4S) _(2015-12-18)_
|
* [Grbl v0.9j Atmega328p 16mhz 115200baud with generic defaults](http://bit.ly/1I8Ey4S) _(2016-03-03)_
|
||||||
- **IMPORTANT INFO WHEN UPGRADING TO GRBL v0.9 :**
|
- **IMPORTANT INFO WHEN UPGRADING TO GRBL v0.9 :**
|
||||||
- Baudrate is now **115200** (Up from 9600).
|
- Baudrate is now **115200** (Up from 9600).
|
||||||
- Homing cycle updated. Located based on switch trigger, rather than release point.
|
- Homing cycle updated. Located based on switch trigger, rather than release point.
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
----------------
|
||||||
|
Date: 2015-12-18
|
||||||
|
Author: Sonny Jeon
|
||||||
|
Subject: Minor bug fixes.
|
||||||
|
|
||||||
|
- Planner was under-estimating maximum speeds through straight
|
||||||
|
junctions in certain cases. The calculations have been updated to be
|
||||||
|
more accurate.
|
||||||
|
|
||||||
|
- Type declaration fix in probe.c.
|
||||||
|
|
||||||
|
- Commit log for v0.9j generated separately from v0.9i’s.
|
||||||
|
|
||||||
|
- Incremented version and updated pre-built firmware link.
|
||||||
|
|
||||||
|
|
||||||
----------------
|
----------------
|
||||||
Date: 2015-09-30
|
Date: 2015-09-30
|
||||||
Author: Sonny Jeon
|
Author: Sonny Jeon
|
||||||
|
|||||||
@@ -126,8 +126,8 @@
|
|||||||
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
|
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
|
||||||
|
|
||||||
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
|
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
|
||||||
// analog pin 5. Only use this option if you require a second coolant control pin.
|
// analog pin 4. Only use this option if you require a second coolant control pin.
|
||||||
// NOTE: The M8 flood coolant control pin on analog pin 4 will still be functional regardless.
|
// NOTE: The M8 flood coolant control pin on analog pin 3 will still be functional regardless.
|
||||||
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
|
// #define ENABLE_M7 // Disabled by default. Uncomment to enable.
|
||||||
|
|
||||||
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
|
// This option causes the feed hold input to act as a safety door switch. A safety door, when triggered,
|
||||||
@@ -157,6 +157,14 @@
|
|||||||
// the CONTROL_INVERT_MASK definition in cpu_map.h files.
|
// the CONTROL_INVERT_MASK definition in cpu_map.h files.
|
||||||
// #define INVERT_ALL_CONTROL_PINS // Default disabled. Uncomment to enable.
|
// #define INVERT_ALL_CONTROL_PINS // Default disabled. Uncomment to enable.
|
||||||
|
|
||||||
|
// Inverts select limit pin states based on the following mask. This effects all limit pin functions,
|
||||||
|
// such as hard limits and homing. However, this is different from overall invert limits setting.
|
||||||
|
// This build option will invert only the limit pins defined here, and then the invert limits setting
|
||||||
|
// will be applied to all of them. This is useful when a user has a mixed set of limit pins with both
|
||||||
|
// normally-open(NO) and normally-closed(NC) switches installed on their machine.
|
||||||
|
// NOTE: PLEASE DO NOT USE THIS, unless you have a situation that needs it.
|
||||||
|
// #define INVERT_LIMIT_PIN_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)) // Default disabled. Uncomment to enable.
|
||||||
|
|
||||||
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
|
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
|
||||||
// for some pre-built electronic boards.
|
// for some pre-built electronic boards.
|
||||||
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
|
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ parser_block_t gc_block;
|
|||||||
|
|
||||||
void gc_init()
|
void gc_init()
|
||||||
{
|
{
|
||||||
memset(&gc_state, 0, sizeof(gc_state));
|
memset(&gc_state, 0, sizeof(parser_state_t));
|
||||||
|
|
||||||
// Load default G54 coordinate system.
|
// Load default G54 coordinate system.
|
||||||
if (!(settings_read_coord_data(gc_state.modal.coord_select,gc_state.coord_system))) {
|
if (!(settings_read_coord_data(gc_state.modal.coord_select,gc_state.coord_system))) {
|
||||||
@@ -80,7 +80,7 @@ uint8_t gc_execute_line(char *line)
|
|||||||
values struct, word tracking variables, and a non-modal commands tracker for the new
|
values struct, word tracking variables, and a non-modal commands tracker for the new
|
||||||
block. This struct contains all of the necessary information to execute the block. */
|
block. This struct contains all of the necessary information to execute the block. */
|
||||||
|
|
||||||
memset(&gc_block, 0, sizeof(gc_block)); // Initialize the parser block struct.
|
memset(&gc_block, 0, sizeof(parser_block_t)); // Initialize the parser block struct.
|
||||||
memcpy(&gc_block.modal,&gc_state.modal,sizeof(gc_modal_t)); // Copy current modes
|
memcpy(&gc_block.modal,&gc_state.modal,sizeof(gc_modal_t)); // Copy current modes
|
||||||
uint8_t axis_command = AXIS_COMMAND_NONE;
|
uint8_t axis_command = AXIS_COMMAND_NONE;
|
||||||
uint8_t axis_0, axis_1, axis_linear;
|
uint8_t axis_0, axis_1, axis_linear;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
// Grbl versioning system
|
// Grbl versioning system
|
||||||
#define GRBL_VERSION "0.9j"
|
#define GRBL_VERSION "0.9j"
|
||||||
#define GRBL_VERSION_BUILD "20151218"
|
#define GRBL_VERSION_BUILD "20160303"
|
||||||
|
|
||||||
// Define standard libraries used by Grbl.
|
// Define standard libraries used by Grbl.
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|||||||
@@ -70,12 +70,15 @@ uint8_t limits_get_state()
|
|||||||
{
|
{
|
||||||
uint8_t limit_state = 0;
|
uint8_t limit_state = 0;
|
||||||
uint8_t pin = (LIMIT_PIN & LIMIT_MASK);
|
uint8_t pin = (LIMIT_PIN & LIMIT_MASK);
|
||||||
|
#ifdef INVERT_LIMIT_PIN_MASK
|
||||||
|
pin ^= INVERT_LIMIT_PIN_MASK;
|
||||||
|
#endif
|
||||||
if (bit_isfalse(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) { pin ^= LIMIT_MASK; }
|
if (bit_isfalse(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) { pin ^= LIMIT_MASK; }
|
||||||
if (pin) {
|
if (pin) {
|
||||||
uint8_t idx;
|
uint8_t idx;
|
||||||
for (idx=0; idx<N_AXIS; idx++) {
|
for (idx=0; idx<N_AXIS; idx++) {
|
||||||
if (pin & get_limit_pin_mask(idx)) { limit_state |= (1 << idx); }
|
if (pin & get_limit_pin_mask(idx)) { limit_state |= (1 << idx); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(limit_state);
|
return(limit_state);
|
||||||
}
|
}
|
||||||
@@ -210,37 +213,37 @@ void limits_go_home(uint8_t cycle_mask)
|
|||||||
|
|
||||||
st_prep_buffer(); // Prep and fill segment buffer from newly planned block.
|
st_prep_buffer(); // Prep and fill segment buffer from newly planned block.
|
||||||
st_wake_up(); // Initiate motion
|
st_wake_up(); // Initiate motion
|
||||||
do {
|
do {
|
||||||
if (approach) {
|
if (approach) {
|
||||||
// Check limit state. Lock out cycle axes when they change.
|
// Check limit state. Lock out cycle axes when they change.
|
||||||
limit_state = limits_get_state();
|
limit_state = limits_get_state();
|
||||||
for (idx=0; idx<N_AXIS; idx++) {
|
for (idx=0; idx<N_AXIS; idx++) {
|
||||||
if (axislock & step_pin[idx]) {
|
if (axislock & step_pin[idx]) {
|
||||||
if (limit_state & (1 << idx)) { axislock &= ~(step_pin[idx]); }
|
if (limit_state & (1 << idx)) { axislock &= ~(step_pin[idx]); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sys.homing_axis_lock = axislock;
|
sys.homing_axis_lock = axislock;
|
||||||
}
|
}
|
||||||
|
|
||||||
st_prep_buffer(); // Check and prep segment buffer. NOTE: Should take no longer than 200us.
|
st_prep_buffer(); // Check and prep segment buffer. NOTE: Should take no longer than 200us.
|
||||||
|
|
||||||
// Exit routines: No time to run protocol_execute_realtime() in this loop.
|
// Exit routines: No time to run protocol_execute_realtime() in this loop.
|
||||||
if (sys_rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET | EXEC_CYCLE_STOP)) {
|
if (sys_rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET | EXEC_CYCLE_STOP)) {
|
||||||
// Homing failure: Limit switches are still engaged after pull-off motion
|
// Homing failure: Limit switches are still engaged after pull-off motion
|
||||||
if ( (sys_rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET)) || // Safety door or reset issued
|
if ( (sys_rt_exec_state & (EXEC_SAFETY_DOOR | EXEC_RESET)) || // Safety door or reset issued
|
||||||
(!approach && (limits_get_state() & cycle_mask)) || // Limit switch still engaged after pull-off motion
|
(!approach && (limits_get_state() & cycle_mask)) || // Limit switch still engaged after pull-off motion
|
||||||
( approach && (sys_rt_exec_state & EXEC_CYCLE_STOP)) ) { // Limit switch not found during approach.
|
( approach && (sys_rt_exec_state & EXEC_CYCLE_STOP)) ) { // Limit switch not found during approach.
|
||||||
mc_reset(); // Stop motors, if they are running.
|
mc_reset(); // Stop motors, if they are running.
|
||||||
protocol_execute_realtime();
|
protocol_execute_realtime();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Pull-off motion complete. Disable CYCLE_STOP from executing.
|
// Pull-off motion complete. Disable CYCLE_STOP from executing.
|
||||||
bit_false_atomic(sys_rt_exec_state,EXEC_CYCLE_STOP);
|
bit_false_atomic(sys_rt_exec_state,EXEC_CYCLE_STOP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (STEP_MASK & axislock);
|
} while (STEP_MASK & axislock);
|
||||||
|
|
||||||
st_reset(); // Immediately force kill steppers and reset step segment buffer.
|
st_reset(); // Immediately force kill steppers and reset step segment buffer.
|
||||||
plan_reset(); // Reset planner buffer to zero planner current position and to clear previous motions.
|
plan_reset(); // Reset planner buffer to zero planner current position and to clear previous motions.
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ int main(void)
|
|||||||
stepper_init(); // Configure stepper pins and interrupt timers
|
stepper_init(); // Configure stepper pins and interrupt timers
|
||||||
system_init(); // Configure pinout pins and pin-change interrupt
|
system_init(); // Configure pinout pins and pin-change interrupt
|
||||||
|
|
||||||
memset(&sys, 0, sizeof(sys)); // Clear all system variables
|
memset(&sys, 0, sizeof(system_t)); // Clear all system variables
|
||||||
sys.abort = true; // Set abort to complete initialization
|
sys.abort = true; // Set abort to complete initialization
|
||||||
sei(); // Enable interrupts
|
sei(); // Enable interrupts
|
||||||
|
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ static void planner_recalculate()
|
|||||||
|
|
||||||
void plan_reset()
|
void plan_reset()
|
||||||
{
|
{
|
||||||
memset(&pl, 0, sizeof(pl)); // Clear planner struct
|
memset(&pl, 0, sizeof(planner_t)); // Clear planner struct
|
||||||
block_buffer_tail = 0;
|
block_buffer_tail = 0;
|
||||||
block_buffer_head = 0; // Empty = tail
|
block_buffer_head = 0; // Empty = tail
|
||||||
next_buffer_head = 1; // plan_next_block_index(block_buffer_head)
|
next_buffer_head = 1; // plan_next_block_index(block_buffer_head)
|
||||||
|
|||||||
@@ -50,17 +50,17 @@ void spindle_stop()
|
|||||||
TCCRA_REGISTER &= ~(1<<COMB_BIT); // Disable PWM. Output voltage is zero.
|
TCCRA_REGISTER &= ~(1<<COMB_BIT); // Disable PWM. Output voltage is zero.
|
||||||
#if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)
|
#if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)
|
||||||
#ifdef INVERT_SPINDLE_ENABLE_PIN
|
#ifdef INVERT_SPINDLE_ENABLE_PIN
|
||||||
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); // Set pin to high
|
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); // Set pin to high
|
||||||
#else
|
#else
|
||||||
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
|
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef INVERT_SPINDLE_ENABLE_PIN
|
#ifdef INVERT_SPINDLE_ENABLE_PIN
|
||||||
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); // Set pin to high
|
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); // Set pin to high
|
||||||
#else
|
#else
|
||||||
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
|
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,33 +95,39 @@ void spindle_set_state(uint8_t state, float rpm)
|
|||||||
uint8_t current_pwm;
|
uint8_t current_pwm;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SPINDLE_RPM_RANGE (SPINDLE_MAX_RPM-SPINDLE_MIN_RPM)
|
if (rpm <= 0.0) { spindle_stop(); } // RPM should never be negative, but check anyway.
|
||||||
if ( rpm < SPINDLE_MIN_RPM ) { rpm = 0; }
|
|
||||||
else {
|
else {
|
||||||
rpm -= SPINDLE_MIN_RPM;
|
#define SPINDLE_RPM_RANGE (SPINDLE_MAX_RPM-SPINDLE_MIN_RPM)
|
||||||
if ( rpm > SPINDLE_RPM_RANGE ) { rpm = SPINDLE_RPM_RANGE; } // Prevent integer overflow
|
if ( rpm < SPINDLE_MIN_RPM ) { rpm = 0; }
|
||||||
}
|
else {
|
||||||
current_pwm = floor( rpm*(PWM_MAX_VALUE/SPINDLE_RPM_RANGE) + 0.5);
|
rpm -= SPINDLE_MIN_RPM;
|
||||||
#ifdef MINIMUM_SPINDLE_PWM
|
if ( rpm > SPINDLE_RPM_RANGE ) { rpm = SPINDLE_RPM_RANGE; } // Prevent integer overflow
|
||||||
if (current_pwm < MINIMUM_SPINDLE_PWM) { current_pwm = MINIMUM_SPINDLE_PWM; }
|
}
|
||||||
#endif
|
current_pwm = floor( rpm*(PWM_MAX_VALUE/SPINDLE_RPM_RANGE) + 0.5);
|
||||||
OCR_REGISTER = current_pwm; // Set PWM pin output
|
#ifdef MINIMUM_SPINDLE_PWM
|
||||||
|
if (current_pwm < MINIMUM_SPINDLE_PWM) { current_pwm = MINIMUM_SPINDLE_PWM; }
|
||||||
|
#endif
|
||||||
|
OCR_REGISTER = current_pwm; // Set PWM pin output
|
||||||
|
|
||||||
// On the Uno, spindle enable and PWM are shared, unless otherwise specified.
|
// On the Uno, spindle enable and PWM are shared, unless otherwise specified.
|
||||||
#if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)
|
#if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)
|
||||||
|
#ifdef INVERT_SPINDLE_ENABLE_PIN
|
||||||
|
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
|
||||||
|
#else
|
||||||
|
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
if (rpm <= 0.0) { spindle_stop(); } // RPM should never be negative, but check anyway.
|
||||||
|
else {
|
||||||
#ifdef INVERT_SPINDLE_ENABLE_PIN
|
#ifdef INVERT_SPINDLE_ENABLE_PIN
|
||||||
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
|
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
|
||||||
#else
|
#else
|
||||||
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
|
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
#ifdef INVERT_SPINDLE_ENABLE_PIN
|
|
||||||
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
|
|
||||||
#else
|
|
||||||
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -451,8 +451,8 @@ void st_reset()
|
|||||||
st_go_idle();
|
st_go_idle();
|
||||||
|
|
||||||
// Initialize stepper algorithm variables.
|
// Initialize stepper algorithm variables.
|
||||||
memset(&prep, 0, sizeof(prep));
|
memset(&prep, 0, sizeof(st_prep_t));
|
||||||
memset(&st, 0, sizeof(st));
|
memset(&st, 0, sizeof(stepper_t));
|
||||||
st.exec_segment = NULL;
|
st.exec_segment = NULL;
|
||||||
pl_block = NULL; // Planner block pointer used by segment buffer
|
pl_block = NULL; // Planner block pointer used by segment buffer
|
||||||
segment_buffer_tail = 0;
|
segment_buffer_tail = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user