From f495cf40e82bb32a86d7b623d6f7fb8481f350bf Mon Sep 17 00:00:00 2001 From: Terje Io Date: Wed, 14 Apr 2021 13:30:34 +0200 Subject: [PATCH] added some crossbar types, fixed bug in check mode handling on program complete --- config.h | 7 +++++-- crossbar.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ gcode.c | 6 +++--- grbl.h | 2 +- hal.h | 2 +- 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/config.h b/config.h index 2c1662b..d961916 100644 --- a/config.h +++ b/config.h @@ -32,7 +32,7 @@ // Number of axes supported: minimum 3, maximum 6 // If more than 3 axes are required a compliant driver must be provided -//#define N_AXIS 3 // Number of axes +#define N_AXIS 3 // Number of axes // Defines compatibility level with the grbl 1.1 protocol. // Additional G- and M-codes are not disabled except when level is set to >= 10. @@ -201,6 +201,7 @@ // crash due to the lack of available RAM or if the CPU is having trouble keeping up with planning // new incoming motions as they are executed. // #define BLOCK_BUFFER_SIZE 36 // Uncomment to override default in planner.h. +#define BLOCK_BUFFER_SIZE 512 // Governs the size of the intermediary step segment buffer between the step execution algorithm // and the planner blocks. Each segment is set of steps executed at a constant velocity over a @@ -369,6 +370,7 @@ // limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a // homing cycle while on the limit switch and not have to move the machine off of it. //#define DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES // Default disabled. Uncomment to enable. +#define DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES // By default, Grbl disables feed rate overrides for all G38.x probe cycle commands. Although this // may be different than some pro-class machine control, it's arguable that it should be this way. @@ -465,7 +467,7 @@ #endif // Max number of entries in log for PID data reporting, to be used for tuning -//#define PID_LOG 1000 // Default disabled. Uncomment to enable. +#define PID_LOG 1000 // Default disabled. Uncomment to enable. //#define DEFAULT_X_STEPS_PER_MM 250.0f //#define DEFAULT_Y_STEPS_PER_MM 250.0f @@ -579,6 +581,7 @@ // for professional CNC machines, regardless of where the limit switches are located. Set this // define to 1 to force Grbl to always set the machine origin at the homed location despite switch orientation. //#define HOMING_FORCE_SET_ORIGIN // Default disabled. Uncomment to enable. +#define HOMING_FORCE_SET_ORIGIN 1 // To prevent the homing cycle from racking the dual axis, when one limit triggers before the // other due to switch failure or noise, the homing cycle will automatically abort if the second diff --git a/crossbar.h b/crossbar.h index 1b650b2..70949a9 100644 --- a/crossbar.h +++ b/crossbar.h @@ -24,6 +24,60 @@ #ifndef _CROSSBAR_H_ #define _CROSSBAR_H_ +typedef enum { + Input_Probe = 0, + Input_Reset, + Input_FeedHold, + Input_CycleStart, + Input_SafetyDoor, + Input_LimitsOverride, + Input_EStop, + Input_ModeSelect, + Input_LimitX, + Input_LimitX_Max, + Input_LimitY, + Input_LimitY_Max, + Input_LimitZ, + Input_LimitZ_Max, + Input_LimitA, + Input_LimitA_Max, + Input_LimitB, + Input_LimitB_Max, + Input_LimitC, + Input_LimitC_Max, + Input_KeypadStrobe, + Input_QEI_A, + Input_QEI_B, + Input_QEI_Select, + Input_QEI_Index, + Input_SpindleIndex, + Input_Aux0, + Input_Aux1, + Input_Aux2, + Input_Aux3 +} pin_function_t; + +typedef enum { + IRQ_Mode_None = 0b00, + IRQ_Mode_Change = 0b01, + IRQ_Mode_Rising = 0b10, + IRQ_Mode_Falling = 0b11 +} pin_irq_mode_t; + +typedef enum { + PinGroup_Control = (1<<0), + PinGroup_Limit = (1<<1), + PinGroup_Probe = (1<<2), + PinGroup_Keypad = (1<<3), + PinGroup_MPG = (1<<4), + PinGroup_QEI = (1<<5), + PinGroup_QEI_Select = (1<<6), + PinGroup_SpindlePulse = (1<<7), + PinGroup_SpindleIndex = (1<<8), + PinGroup_AuxInput = (1<<9), + PinGroup_AuxOutput = (1<<10) +} pin_group_t; + typedef bool (*xbar_get_value_ptr)(void); typedef void (*xbar_set_value_ptr)(bool on); typedef void (*xbar_event_ptr)(bool on); diff --git a/gcode.c b/gcode.c index df927e0..c2b86e8 100644 --- a/gcode.c +++ b/gcode.c @@ -2725,11 +2725,11 @@ status_code_t gc_execute_block(char *block, char *message) hal.coolant.set_state(gc_state.modal.coolant); sys.report.spindle = On; // Set to report change immediately sys.report.coolant = On; // ... - - if(grbl.on_program_completed) - grbl.on_program_completed(gc_state.modal.program_flow); } + if(grbl.on_program_completed) + grbl.on_program_completed(gc_state.modal.program_flow, check_mode); + // Clear any pending output commands while(output_commands) { output_command_t *next = output_commands->next; diff --git a/grbl.h b/grbl.h index 46556f3..7499b19 100644 --- a/grbl.h +++ b/grbl.h @@ -34,7 +34,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_VERSION_BUILD "20210313" +#define GRBL_VERSION_BUILD "20210408" // The following symbols are set here if not already set by the compiler or in config.h // Do NOT change here! diff --git a/hal.h b/hal.h index 1b6de67..4b85925 100644 --- a/hal.h +++ b/hal.h @@ -340,7 +340,7 @@ typedef struct { typedef void (*on_state_change_ptr)(sys_state_t state); typedef void (*on_probe_completed_ptr)(void); -typedef void (*on_program_completed_ptr)(program_flow_t program_flow); +typedef void (*on_program_completed_ptr)(program_flow_t program_flow, bool check_mode); typedef void (*on_execute_realtime_ptr)(sys_state_t state); typedef void (*on_unknown_accessory_override_ptr)(uint8_t cmd); typedef void (*on_report_options_ptr)(bool newopt);