Hard limits, homing direction, pull-off limits after homing, status reports in mm or inches, system alarm, and more.

- Thank you statement added for Alden Hart of Synthetos.

- Hard limits option added, which also works with homing by pulling off
the switches to help prevent unintended triggering. Hard limits use a
interrupt to sense a falling edge pin change and immediately go into
alarm mode, which stops everything and forces the user to issue a reset
(Ctrl-x) or reboot.

- Auto cycle start now a configuration option.

- Alarm mode: A new method to kill all Grbl processes in the event of
something catastrophic or potentially catastropic. Just works with hard
limits for now, but will be expanded to include g-code errors (most
likely) and other events.

- Updated status reports to be configurable in inches or mm mode. Much
more to do here, but this is the first step.

- New settings: auto cycle start, hard limit enable, homing direction
mask (which works the same as the stepper mask), homing pulloff
distance (or distance traveled from homed machine zero to prevent
accidental limit trip).

- Minor memory liberation and calculation speed ups.
This commit is contained in:
Sonny Jeon
2012-10-16 21:29:45 -06:00
parent 34f6d2eb4b
commit df5bb70b25
11 changed files with 193 additions and 83 deletions

View File

@ -35,6 +35,7 @@
#define Z_AXIS 2
#define MM_PER_INCH (25.4)
#define INCH_PER_MM (0.03937)
// Useful macros
#define clear_vector(a) memset(a, 0, sizeof(a))
@ -60,16 +61,29 @@
#define EXEC_CYCLE_STOP bit(2) // bitmask 00000100
#define EXEC_FEED_HOLD bit(3) // bitmask 00001000
#define EXEC_RESET bit(4) // bitmask 00010000
// #define bit(5) // bitmask 00100000
#define EXEC_ALARM bit(5) // bitmask 00100000
// #define bit(6) // bitmask 01000000
// #define bit(7) // bitmask 10000000
// Define bit flag masks for sys.switches. (8 flag limit)
#define BITFLAG_BLOCK_DELETE bit(0)
#define BITFLAG_SINGLE_BLOCK bit(1)
#define BITFLAG_OPT_STOP bit(2)
// #define bit(3)
// #define bit(4)
// #define bit(5)
// #define bit(6)
// #define bit(7)
// Define global system variables
typedef struct {
uint8_t abort; // System abort flag. Forces exit back to main loop for reset.
uint8_t feed_hold; // Feed hold flag. Held true during feed hold. Released when ready to resume.
uint8_t auto_start; // Planner auto-start flag. Toggled off during feed hold. Defaulted by settings.
uint8_t alarm; // Alarm mode. Causes all functions to immediately cease until a system abort
// is issued by the user.
// uint8_t switches; // Switches state bitflag variable. For settings not governed by g-code.
int32_t position[3]; // Real-time machine (aka home) position vector in steps.
// NOTE: This may need to be a volatile variable, if problems arise.
@ -82,6 +96,7 @@ typedef struct {
volatile uint8_t cycle_start; // Cycle start flag. Set by stepper subsystem or main program.
volatile uint8_t execute; // Global system runtime executor bitflag variable. See EXEC bitmasks.
} system_t;
extern system_t sys;