Skip to content

Commit

Permalink
Soft limit handling bug fix
Browse files Browse the repository at this point in the history
- Soft limit errors were stuck in a feed hold without notifying the
user why it was in a hold. When resumed, the soft limit error would
kick in. Issue should be fixed to behave as intended to automatically
hold and issue a soft limit alarm once the machine has come to a stop.
  • Loading branch information
chamnit committed Mar 16, 2016
1 parent da5c65b commit b00d2a1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Grbl includes full acceleration management with look ahead. That means the contr
***

_**Master Branch:**_
* [Grbl v0.9j Atmega328p 16mhz 115200baud with generic defaults](http://bit.ly/1I8Ey4S) _(2016-03-03)_
* [Grbl v0.9j Atmega328p 16mhz 115200baud with generic defaults](http://bit.ly/1I8Ey4S) _(2016-03-16)_
- **IMPORTANT INFO WHEN UPGRADING TO GRBL v0.9 :**
- Baudrate is now **115200** (Up from 9600).
- Homing cycle updated. Located based on switch trigger, rather than release point.
Expand Down
18 changes: 18 additions & 0 deletions doc/log/commit_log_v0.9j.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
----------------
Date: 2016-03-03
Author: Sonny Jeon
Subject: 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.


----------------
Date: 2015-12-18
Author: Sonny Jeon
Expand Down
2 changes: 1 addition & 1 deletion grbl/grbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// Grbl versioning system
#define GRBL_VERSION "0.9j"
#define GRBL_VERSION_BUILD "20160303"
#define GRBL_VERSION_BUILD "20160316"

// Define standard libraries used by Grbl.
#include <avr/io.h>
Expand Down
9 changes: 4 additions & 5 deletions grbl/limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,23 +317,22 @@ void limits_go_home(uint8_t cycle_mask)
void limits_soft_check(float *target)
{
uint8_t idx;
uint8_t soft_limit_error = false;
for (idx=0; idx<N_AXIS; idx++) {

#ifdef HOMING_FORCE_SET_ORIGIN
// When homing forced set origin is enabled, soft limits checks need to account for directionality.
// NOTE: max_travel is stored as negative
if (bit_istrue(settings.homing_dir_mask,bit(idx))) {
if (target[idx] < 0 || target[idx] > -settings.max_travel[idx]) { soft_limit_error = true; }
if (target[idx] < 0 || target[idx] > -settings.max_travel[idx]) { sys.soft_limit = true; }
} else {
if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { soft_limit_error = true; }
if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { sys.soft_limit = true; }
}
#else
// NOTE: max_travel is stored as negative
if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { soft_limit_error = true; }
if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { sys.soft_limit = true; }
#endif

if (soft_limit_error) {
if (sys.soft_limit) {
// Force feed hold if cycle is active. All buffered blocks are guaranteed to be within
// workspace volume so just come to a controlled stop so position is not lost. When complete
// enter alarm mode.
Expand Down
3 changes: 2 additions & 1 deletion grbl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ int main(void)
sys_rt_exec_state = 0;
sys_rt_exec_alarm = 0;
sys.suspend = false;

sys.soft_limit = false;

// Start Grbl main loop. Processes program inputs and executes them.
protocol_main_loop();

Expand Down
3 changes: 1 addition & 2 deletions grbl/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,12 @@ void protocol_execute_realtime()
// cycle reinitializations. The stepper path should continue exactly as if nothing has happened.
// NOTE: EXEC_CYCLE_STOP is set by the stepper subsystem when a cycle or feed hold completes.
if (rt_exec & EXEC_CYCLE_STOP) {
if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR)) {
if (sys.state & (STATE_HOLD | STATE_SAFETY_DOOR) && !(sys.soft_limit)) {
// Hold complete. Set to indicate ready to resume. Remain in HOLD or DOOR states until user
// has issued a resume command or reset.
if (sys.suspend & SUSPEND_ENERGIZE) { // De-energize system if safety door has been opened.
spindle_stop();
coolant_stop();
// TODO: Install parking motion here.
}
bit_true(sys.suspend,SUSPEND_ENABLE_READY);
} else { // Motion is complete. Includes CYCLE, HOMING, and MOTION_CANCEL states.
Expand Down
1 change: 1 addition & 0 deletions grbl/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ typedef struct {
uint8_t abort; // System abort flag. Forces exit back to main loop for reset.
uint8_t state; // Tracks the current state of Grbl.
uint8_t suspend; // System suspend bitflag variable that manages holds, cancels, and safety door.
uint8_t soft_limit; // Tracks soft limit errors for the state machine. (boolean)

int32_t position[N_AXIS]; // Real-time machine (aka home) position vector in steps.
// NOTE: This may need to be a volatile variable, if problems arise.
Expand Down

0 comments on commit b00d2a1

Please sign in to comment.