Minor bug fixes.
- G38.x was not printing correctly in the $G g-code state reports. Now fixed. - Potential bug regarding volatile variables inside a struct. It has never been a problem in v0.9, but ran into this during v1.0 development. Just to be safe, the fixes are applied here. - Updated pre-built firmwares with these two bug fixes.
This commit is contained in:
parent
90ad129ad2
commit
d226555810
@ -27,8 +27,8 @@ 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-07-17)_
|
* [Grbl v0.9j Atmega328p 16mhz 115200baud with generic defaults](http://bit.ly/1I8Ey4S) _(2015-09-30)_
|
||||||
* [Grbl v0.9j Atmega328p 16mhz 115200baud with ShapeOko2 defaults](http://bit.ly/1OjUSia) _(2015-07-17)_
|
* [Grbl v0.9j Atmega328p 16mhz 115200baud with ShapeOko2 defaults](http://bit.ly/1OjUSia) _(2015-09-30)_
|
||||||
- **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,17 @@
|
|||||||
|
----------------
|
||||||
|
Date: 2015-08-16
|
||||||
|
Author: Sonny Jeon
|
||||||
|
Subject: Update README.md
|
||||||
|
|
||||||
|
----------------
|
||||||
|
Date: 2015-08-14
|
||||||
|
Author: Sonny Jeon
|
||||||
|
Subject: Individual control pin invert compile-option.
|
||||||
|
|
||||||
|
- Control pins may be individually inverted through a
|
||||||
|
CONTROL_INVERT_MASK macro. This mask is define in the cpu_map.h file.
|
||||||
|
|
||||||
|
|
||||||
----------------
|
----------------
|
||||||
Date: 2015-07-17
|
Date: 2015-07-17
|
||||||
Author: Sonny Jeon
|
Author: Sonny Jeon
|
||||||
|
@ -1037,7 +1037,7 @@ uint8_t gc_execute_line(char *line)
|
|||||||
protocol_buffer_synchronize(); // Sync and finish all remaining buffered motions before moving on.
|
protocol_buffer_synchronize(); // Sync and finish all remaining buffered motions before moving on.
|
||||||
if (gc_state.modal.program_flow == PROGRAM_FLOW_PAUSED) {
|
if (gc_state.modal.program_flow == PROGRAM_FLOW_PAUSED) {
|
||||||
if (sys.state != STATE_CHECK_MODE) {
|
if (sys.state != STATE_CHECK_MODE) {
|
||||||
bit_true_atomic(sys.rt_exec_state, EXEC_FEED_HOLD); // Use feed hold for program pause.
|
bit_true_atomic(sys_rt_exec_state, EXEC_FEED_HOLD); // Use feed hold for program pause.
|
||||||
protocol_execute_realtime(); // Execute suspend.
|
protocol_execute_realtime(); // Execute suspend.
|
||||||
}
|
}
|
||||||
} else { // == PROGRAM_FLOW_COMPLETED
|
} else { // == PROGRAM_FLOW_COMPLETED
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
// Grbl versioning system
|
// Grbl versioning system
|
||||||
#define GRBL_VERSION "0.9j"
|
#define GRBL_VERSION "0.9j"
|
||||||
#define GRBL_VERSION_BUILD "20150811"
|
#define GRBL_VERSION_BUILD "20150930"
|
||||||
|
|
||||||
// Define standard libraries used by Grbl.
|
// Define standard libraries used by Grbl.
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
@ -101,16 +101,16 @@ uint8_t limits_get_state()
|
|||||||
// locked out until a homing cycle or a kill lock command. Allows the user to disable the hard
|
// locked out until a homing cycle or a kill lock command. Allows the user to disable the hard
|
||||||
// limit setting if their limits are constantly triggering after a reset and move their axes.
|
// limit setting if their limits are constantly triggering after a reset and move their axes.
|
||||||
if (sys.state != STATE_ALARM) {
|
if (sys.state != STATE_ALARM) {
|
||||||
if (!(sys.rt_exec_alarm)) {
|
if (!(sys_rt_exec_alarm)) {
|
||||||
#ifdef HARD_LIMIT_FORCE_STATE_CHECK
|
#ifdef HARD_LIMIT_FORCE_STATE_CHECK
|
||||||
// Check limit pin state.
|
// Check limit pin state.
|
||||||
if (limits_get_state()) {
|
if (limits_get_state()) {
|
||||||
mc_reset(); // Initiate system kill.
|
mc_reset(); // Initiate system kill.
|
||||||
bit_true_atomic(sys.rt_exec_alarm, (EXEC_ALARM_HARD_LIMIT|EXEC_CRITICAL_EVENT)); // Indicate hard limit critical event
|
bit_true_atomic(sys_rt_exec_alarm, (EXEC_ALARM_HARD_LIMIT|EXEC_CRITICAL_EVENT)); // Indicate hard limit critical event
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
mc_reset(); // Initiate system kill.
|
mc_reset(); // Initiate system kill.
|
||||||
bit_true_atomic(sys.rt_exec_alarm, (EXEC_ALARM_HARD_LIMIT|EXEC_CRITICAL_EVENT)); // Indicate hard limit critical event
|
bit_true_atomic(sys_rt_exec_alarm, (EXEC_ALARM_HARD_LIMIT|EXEC_CRITICAL_EVENT)); // Indicate hard limit critical event
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,11 +122,11 @@ uint8_t limits_get_state()
|
|||||||
{
|
{
|
||||||
WDTCSR &= ~(1<<WDIE); // Disable watchdog timer.
|
WDTCSR &= ~(1<<WDIE); // Disable watchdog timer.
|
||||||
if (sys.state != STATE_ALARM) { // Ignore if already in alarm state.
|
if (sys.state != STATE_ALARM) { // Ignore if already in alarm state.
|
||||||
if (!(sys.rt_exec_alarm)) {
|
if (!(sys_rt_exec_alarm)) {
|
||||||
// Check limit pin state.
|
// Check limit pin state.
|
||||||
if (limits_get_state()) {
|
if (limits_get_state()) {
|
||||||
mc_reset(); // Initiate system kill.
|
mc_reset(); // Initiate system kill.
|
||||||
bit_true_atomic(sys.rt_exec_alarm, (EXEC_ALARM_HARD_LIMIT|EXEC_CRITICAL_EVENT)); // Indicate hard limit critical event
|
bit_true_atomic(sys_rt_exec_alarm, (EXEC_ALARM_HARD_LIMIT|EXEC_CRITICAL_EVENT)); // Indicate hard limit critical event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,17 +225,17 @@ void limits_go_home(uint8_t cycle_mask)
|
|||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ void limits_soft_check(float *target)
|
|||||||
// workspace volume so just come to a controlled stop so position is not lost. When complete
|
// workspace volume so just come to a controlled stop so position is not lost. When complete
|
||||||
// enter alarm mode.
|
// enter alarm mode.
|
||||||
if (sys.state == STATE_CYCLE) {
|
if (sys.state == STATE_CYCLE) {
|
||||||
bit_true_atomic(sys.rt_exec_state, EXEC_FEED_HOLD);
|
bit_true_atomic(sys_rt_exec_state, EXEC_FEED_HOLD);
|
||||||
do {
|
do {
|
||||||
protocol_execute_realtime();
|
protocol_execute_realtime();
|
||||||
if (sys.abort) { return; }
|
if (sys.abort) { return; }
|
||||||
@ -343,7 +343,7 @@ void limits_soft_check(float *target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mc_reset(); // Issue system reset and ensure spindle and coolant are shutdown.
|
mc_reset(); // Issue system reset and ensure spindle and coolant are shutdown.
|
||||||
bit_true_atomic(sys.rt_exec_alarm, (EXEC_ALARM_SOFT_LIMIT|EXEC_CRITICAL_EVENT)); // Indicate soft limit critical event
|
bit_true_atomic(sys_rt_exec_alarm, (EXEC_ALARM_SOFT_LIMIT|EXEC_CRITICAL_EVENT)); // Indicate soft limit critical event
|
||||||
protocol_execute_realtime(); // Execute to enter critical event loop and system abort
|
protocol_execute_realtime(); // Execute to enter critical event loop and system abort
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,8 @@ int main(void)
|
|||||||
|
|
||||||
// Reset system variables.
|
// Reset system variables.
|
||||||
sys.abort = false;
|
sys.abort = false;
|
||||||
sys.rt_exec_state = 0;
|
sys_rt_exec_state = 0;
|
||||||
sys.rt_exec_alarm = 0;
|
sys_rt_exec_alarm = 0;
|
||||||
sys.suspend = false;
|
sys.suspend = false;
|
||||||
|
|
||||||
// Start Grbl main loop. Processes program inputs and executes them.
|
// Start Grbl main loop. Processes program inputs and executes them.
|
||||||
|
@ -227,7 +227,7 @@ void mc_homing_cycle()
|
|||||||
#ifdef LIMITS_TWO_SWITCHES_ON_AXES
|
#ifdef LIMITS_TWO_SWITCHES_ON_AXES
|
||||||
if (limits_get_state()) {
|
if (limits_get_state()) {
|
||||||
mc_reset(); // Issue system reset and ensure spindle and coolant are shutdown.
|
mc_reset(); // Issue system reset and ensure spindle and coolant are shutdown.
|
||||||
bit_true_atomic(sys.rt_exec_alarm, (EXEC_ALARM_HARD_LIMIT|EXEC_CRITICAL_EVENT));
|
bit_true_atomic(sys_rt_exec_alarm, (EXEC_ALARM_HARD_LIMIT|EXEC_CRITICAL_EVENT));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -283,7 +283,7 @@ void mc_homing_cycle()
|
|||||||
// After syncing, check if probe is already triggered. If so, halt and issue alarm.
|
// After syncing, check if probe is already triggered. If so, halt and issue alarm.
|
||||||
// NOTE: This probe initialization error applies to all probing cycles.
|
// NOTE: This probe initialization error applies to all probing cycles.
|
||||||
if ( probe_get_state() ) { // Check probe pin state.
|
if ( probe_get_state() ) { // Check probe pin state.
|
||||||
bit_true_atomic(sys.rt_exec_alarm, EXEC_ALARM_PROBE_FAIL);
|
bit_true_atomic(sys_rt_exec_alarm, EXEC_ALARM_PROBE_FAIL);
|
||||||
protocol_execute_realtime();
|
protocol_execute_realtime();
|
||||||
}
|
}
|
||||||
if (sys.abort) { return; } // Return if system reset has been issued.
|
if (sys.abort) { return; } // Return if system reset has been issued.
|
||||||
@ -296,10 +296,10 @@ void mc_homing_cycle()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Activate the probing state monitor in the stepper module.
|
// Activate the probing state monitor in the stepper module.
|
||||||
sys.probe_state = PROBE_ACTIVE;
|
sys_probe_state = PROBE_ACTIVE;
|
||||||
|
|
||||||
// Perform probing cycle. Wait here until probe is triggered or motion completes.
|
// Perform probing cycle. Wait here until probe is triggered or motion completes.
|
||||||
bit_true_atomic(sys.rt_exec_state, EXEC_CYCLE_START);
|
bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START);
|
||||||
do {
|
do {
|
||||||
protocol_execute_realtime();
|
protocol_execute_realtime();
|
||||||
if (sys.abort) { return; } // Check for system abort
|
if (sys.abort) { return; } // Check for system abort
|
||||||
@ -308,13 +308,13 @@ void mc_homing_cycle()
|
|||||||
// Probing cycle complete!
|
// Probing cycle complete!
|
||||||
|
|
||||||
// Set state variables and error out, if the probe failed and cycle with error is enabled.
|
// Set state variables and error out, if the probe failed and cycle with error is enabled.
|
||||||
if (sys.probe_state == PROBE_ACTIVE) {
|
if (sys_probe_state == PROBE_ACTIVE) {
|
||||||
if (is_no_error) { memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS); }
|
if (is_no_error) { memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS); }
|
||||||
else { bit_true_atomic(sys.rt_exec_alarm, EXEC_ALARM_PROBE_FAIL); }
|
else { bit_true_atomic(sys_rt_exec_alarm, EXEC_ALARM_PROBE_FAIL); }
|
||||||
} else {
|
} else {
|
||||||
sys.probe_succeeded = true; // Indicate to system the probing cycle completed successfully.
|
sys.probe_succeeded = true; // Indicate to system the probing cycle completed successfully.
|
||||||
}
|
}
|
||||||
sys.probe_state = PROBE_OFF; // Ensure probe state monitor is disabled.
|
sys_probe_state = PROBE_OFF; // Ensure probe state monitor is disabled.
|
||||||
protocol_execute_realtime(); // Check and execute run-time commands
|
protocol_execute_realtime(); // Check and execute run-time commands
|
||||||
if (sys.abort) { return; } // Check for system abort
|
if (sys.abort) { return; } // Check for system abort
|
||||||
|
|
||||||
@ -342,8 +342,8 @@ void mc_homing_cycle()
|
|||||||
void mc_reset()
|
void mc_reset()
|
||||||
{
|
{
|
||||||
// Only this function can set the system reset. Helps prevent multiple kill calls.
|
// Only this function can set the system reset. Helps prevent multiple kill calls.
|
||||||
if (bit_isfalse(sys.rt_exec_state, EXEC_RESET)) {
|
if (bit_isfalse(sys_rt_exec_state, EXEC_RESET)) {
|
||||||
bit_true_atomic(sys.rt_exec_state, EXEC_RESET);
|
bit_true_atomic(sys_rt_exec_state, EXEC_RESET);
|
||||||
|
|
||||||
// Kill spindle and coolant.
|
// Kill spindle and coolant.
|
||||||
spindle_stop();
|
spindle_stop();
|
||||||
@ -354,8 +354,8 @@ void mc_reset()
|
|||||||
// the steppers enabled by avoiding the go_idle call altogether, unless the motion state is
|
// the steppers enabled by avoiding the go_idle call altogether, unless the motion state is
|
||||||
// violated, by which, all bets are off.
|
// violated, by which, all bets are off.
|
||||||
if ((sys.state & (STATE_CYCLE | STATE_HOMING)) || (sys.suspend == SUSPEND_ENABLE_HOLD)) {
|
if ((sys.state & (STATE_CYCLE | STATE_HOMING)) || (sys.suspend == SUSPEND_ENABLE_HOLD)) {
|
||||||
if (sys.state == STATE_HOMING) { bit_true_atomic(sys.rt_exec_alarm, EXEC_ALARM_HOMING_FAIL); }
|
if (sys.state == STATE_HOMING) { bit_true_atomic(sys_rt_exec_alarm, EXEC_ALARM_HOMING_FAIL); }
|
||||||
else { bit_true_atomic(sys.rt_exec_alarm, EXEC_ALARM_ABORT_CYCLE); }
|
else { bit_true_atomic(sys_rt_exec_alarm, EXEC_ALARM_ABORT_CYCLE); }
|
||||||
st_go_idle(); // Force kill steppers. Position has likely been lost.
|
st_go_idle(); // Force kill steppers. Position has likely been lost.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,11 @@ uint8_t probe_get_state() { return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask)
|
|||||||
// NOTE: This function must be extremely efficient as to not bog down the stepper ISR.
|
// NOTE: This function must be extremely efficient as to not bog down the stepper ISR.
|
||||||
void probe_state_monitor()
|
void probe_state_monitor()
|
||||||
{
|
{
|
||||||
if (sys.probe_state == PROBE_ACTIVE) {
|
if (sys_probe_state == PROBE_ACTIVE) {
|
||||||
if (probe_get_state()) {
|
if (probe_get_state()) {
|
||||||
sys.probe_state = PROBE_OFF;
|
sys_probe_state = PROBE_OFF;
|
||||||
memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS);
|
memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS);
|
||||||
bit_true(sys.rt_exec_state, EXEC_MOTION_CANCEL);
|
bit_true(sys_rt_exec_state, EXEC_MOTION_CANCEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ void protocol_main_loop()
|
|||||||
} else {
|
} else {
|
||||||
// All systems go! But first check for safety door.
|
// All systems go! But first check for safety door.
|
||||||
if (system_check_safety_door_ajar()) {
|
if (system_check_safety_door_ajar()) {
|
||||||
bit_true(sys.rt_exec_state, EXEC_SAFETY_DOOR);
|
bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
|
||||||
protocol_execute_realtime(); // Enter safety door mode. Should return as IDLE state.
|
protocol_execute_realtime(); // Enter safety door mode. Should return as IDLE state.
|
||||||
} else {
|
} else {
|
||||||
sys.state = STATE_IDLE; // Set system to ready. Clear all state flags.
|
sys.state = STATE_IDLE; // Set system to ready. Clear all state flags.
|
||||||
@ -180,7 +180,7 @@ void protocol_main_loop()
|
|||||||
// define more computationally-expensive volatile variables. This also provides a controlled way to
|
// define more computationally-expensive volatile variables. This also provides a controlled way to
|
||||||
// execute certain tasks without having two or more instances of the same task, such as the planner
|
// execute certain tasks without having two or more instances of the same task, such as the planner
|
||||||
// recalculating the buffer upon a feedhold or override.
|
// recalculating the buffer upon a feedhold or override.
|
||||||
// NOTE: The sys.rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
|
// NOTE: The sys_rt_exec_state variable flags are set by any process, step or serial interrupts, pinouts,
|
||||||
// limit switches, or the main program.
|
// limit switches, or the main program.
|
||||||
void protocol_execute_realtime()
|
void protocol_execute_realtime()
|
||||||
{
|
{
|
||||||
@ -189,7 +189,7 @@ void protocol_execute_realtime()
|
|||||||
do { // If system is suspended, suspend loop restarts here.
|
do { // If system is suspended, suspend loop restarts here.
|
||||||
|
|
||||||
// Check and execute alarms.
|
// Check and execute alarms.
|
||||||
rt_exec = sys.rt_exec_alarm; // Copy volatile sys.rt_exec_alarm.
|
rt_exec = sys_rt_exec_alarm; // Copy volatile sys_rt_exec_alarm.
|
||||||
if (rt_exec) { // Enter only if any bit flag is true
|
if (rt_exec) { // Enter only if any bit flag is true
|
||||||
// System alarm. Everything has shutdown by something that has gone severely wrong. Report
|
// System alarm. Everything has shutdown by something that has gone severely wrong. Report
|
||||||
// the source of the error to the user. If critical, Grbl disables by entering an infinite
|
// the source of the error to the user. If critical, Grbl disables by entering an infinite
|
||||||
@ -209,7 +209,7 @@ void protocol_execute_realtime()
|
|||||||
// Halt everything upon a critical event flag. Currently hard and soft limits flag this.
|
// Halt everything upon a critical event flag. Currently hard and soft limits flag this.
|
||||||
if (rt_exec & EXEC_CRITICAL_EVENT) {
|
if (rt_exec & EXEC_CRITICAL_EVENT) {
|
||||||
report_feedback_message(MESSAGE_CRITICAL_EVENT);
|
report_feedback_message(MESSAGE_CRITICAL_EVENT);
|
||||||
bit_false_atomic(sys.rt_exec_state,EXEC_RESET); // Disable any existing reset
|
bit_false_atomic(sys_rt_exec_state,EXEC_RESET); // Disable any existing reset
|
||||||
do {
|
do {
|
||||||
// Nothing. Block EVERYTHING until user issues reset or power cycles. Hard limits
|
// Nothing. Block EVERYTHING until user issues reset or power cycles. Hard limits
|
||||||
// typically occur while unattended or not paying attention. Gives the user time
|
// typically occur while unattended or not paying attention. Gives the user time
|
||||||
@ -218,17 +218,17 @@ void protocol_execute_realtime()
|
|||||||
// stream could be still engaged and cause a serious crash if it continues afterwards.
|
// stream could be still engaged and cause a serious crash if it continues afterwards.
|
||||||
|
|
||||||
// TODO: Allow status reports during a critical alarm. Still need to think about implications of this.
|
// TODO: Allow status reports during a critical alarm. Still need to think about implications of this.
|
||||||
// if (sys.rt_exec_state & EXEC_STATUS_REPORT) {
|
// if (sys_rt_exec_state & EXEC_STATUS_REPORT) {
|
||||||
// report_realtime_status();
|
// report_realtime_status();
|
||||||
// bit_false_atomic(sys.rt_exec_state,EXEC_STATUS_REPORT);
|
// bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);
|
||||||
// }
|
// }
|
||||||
} while (bit_isfalse(sys.rt_exec_state,EXEC_RESET));
|
} while (bit_isfalse(sys_rt_exec_state,EXEC_RESET));
|
||||||
}
|
}
|
||||||
bit_false_atomic(sys.rt_exec_alarm,0xFF); // Clear all alarm flags
|
bit_false_atomic(sys_rt_exec_alarm,0xFF); // Clear all alarm flags
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check amd execute realtime commands
|
// Check amd execute realtime commands
|
||||||
rt_exec = sys.rt_exec_state; // Copy volatile sys.rt_exec_state.
|
rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state.
|
||||||
if (rt_exec) { // Enter only if any bit flag is true
|
if (rt_exec) { // Enter only if any bit flag is true
|
||||||
|
|
||||||
// Execute system abort.
|
// Execute system abort.
|
||||||
@ -240,7 +240,7 @@ void protocol_execute_realtime()
|
|||||||
// Execute and serial print status
|
// Execute and serial print status
|
||||||
if (rt_exec & EXEC_STATUS_REPORT) {
|
if (rt_exec & EXEC_STATUS_REPORT) {
|
||||||
report_realtime_status();
|
report_realtime_status();
|
||||||
bit_false_atomic(sys.rt_exec_state,EXEC_STATUS_REPORT);
|
bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute hold states.
|
// Execute hold states.
|
||||||
@ -291,7 +291,7 @@ void protocol_execute_realtime()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
bit_false_atomic(sys.rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));
|
bit_false_atomic(sys_rt_exec_state,(EXEC_MOTION_CANCEL | EXEC_FEED_HOLD | EXEC_SAFETY_DOOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
|
// Execute a cycle start by starting the stepper interrupt to begin executing the blocks in queue.
|
||||||
@ -326,7 +326,7 @@ void protocol_execute_realtime()
|
|||||||
sys.suspend = SUSPEND_DISABLE; // Break suspend state.
|
sys.suspend = SUSPEND_DISABLE; // Break suspend state.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);
|
bit_false_atomic(sys_rt_exec_state,EXEC_CYCLE_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
|
// Reinitializes the cycle plan and stepper system after a feed hold for a resume. Called by
|
||||||
@ -348,7 +348,7 @@ void protocol_execute_realtime()
|
|||||||
sys.suspend = SUSPEND_DISABLE;
|
sys.suspend = SUSPEND_DISABLE;
|
||||||
sys.state = STATE_IDLE;
|
sys.state = STATE_IDLE;
|
||||||
}
|
}
|
||||||
bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
|
bit_false_atomic(sys_rt_exec_state,EXEC_CYCLE_STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -398,4 +398,4 @@ void protocol_buffer_synchronize()
|
|||||||
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
|
// when one of these conditions exist respectively: There are no more blocks sent (i.e. streaming
|
||||||
// is finished, single commands), a command that needs to wait for the motions in the buffer to
|
// is finished, single commands), a command that needs to wait for the motions in the buffer to
|
||||||
// execute calls a buffer sync, or the planner buffer is full and ready to go.
|
// execute calls a buffer sync, or the planner buffer is full and ready to go.
|
||||||
void protocol_auto_cycle_start() { bit_true_atomic(sys.rt_exec_state, EXEC_CYCLE_START); }
|
void protocol_auto_cycle_start() { bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); }
|
||||||
|
@ -331,7 +331,7 @@ void report_gcode_modes()
|
|||||||
case MOTION_MODE_NONE : printPgmString(PSTR("G80")); break;
|
case MOTION_MODE_NONE : printPgmString(PSTR("G80")); break;
|
||||||
default:
|
default:
|
||||||
printPgmString(PSTR("G38."));
|
printPgmString(PSTR("G38."));
|
||||||
print_uint8_base10(gc_state.modal.motion - (MOTION_MODE_PROBE_TOWARD+2));
|
print_uint8_base10(gc_state.modal.motion - (MOTION_MODE_PROBE_TOWARD-2));
|
||||||
}
|
}
|
||||||
|
|
||||||
printPgmString(PSTR(" G"));
|
printPgmString(PSTR(" G"));
|
||||||
|
@ -89,7 +89,7 @@ void serial_write(uint8_t data) {
|
|||||||
// Wait until there is space in the buffer
|
// Wait until there is space in the buffer
|
||||||
while (next_head == serial_tx_buffer_tail) {
|
while (next_head == serial_tx_buffer_tail) {
|
||||||
// TODO: Restructure st_prep_buffer() calls to be executed here during a long print.
|
// TODO: Restructure st_prep_buffer() calls to be executed here during a long print.
|
||||||
if (sys.rt_exec_state & EXEC_RESET) { return; } // Only check for abort to avoid an endless loop.
|
if (sys_rt_exec_state & EXEC_RESET) { return; } // Only check for abort to avoid an endless loop.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store data and advance head
|
// Store data and advance head
|
||||||
@ -164,10 +164,10 @@ ISR(SERIAL_RX)
|
|||||||
// Pick off realtime command characters directly from the serial stream. These characters are
|
// Pick off realtime command characters directly from the serial stream. These characters are
|
||||||
// not passed into the buffer, but these set system state flag bits for realtime execution.
|
// not passed into the buffer, but these set system state flag bits for realtime execution.
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case CMD_STATUS_REPORT: bit_true_atomic(sys.rt_exec_state, EXEC_STATUS_REPORT); break; // Set as true
|
case CMD_STATUS_REPORT: bit_true_atomic(sys_rt_exec_state, EXEC_STATUS_REPORT); break; // Set as true
|
||||||
case CMD_CYCLE_START: bit_true_atomic(sys.rt_exec_state, EXEC_CYCLE_START); break; // Set as true
|
case CMD_CYCLE_START: bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START); break; // Set as true
|
||||||
case CMD_FEED_HOLD: bit_true_atomic(sys.rt_exec_state, EXEC_FEED_HOLD); break; // Set as true
|
case CMD_FEED_HOLD: bit_true_atomic(sys_rt_exec_state, EXEC_FEED_HOLD); break; // Set as true
|
||||||
case CMD_SAFETY_DOOR: bit_true_atomic(sys.rt_exec_state, EXEC_SAFETY_DOOR); break; // Set as true
|
case CMD_SAFETY_DOOR: bit_true_atomic(sys_rt_exec_state, EXEC_SAFETY_DOOR); break; // Set as true
|
||||||
case CMD_RESET: mc_reset(); break; // Call motion control reset routine.
|
case CMD_RESET: mc_reset(); break; // Call motion control reset routine.
|
||||||
default: // Write character to buffer
|
default: // Write character to buffer
|
||||||
next_head = serial_rx_buffer_head + 1;
|
next_head = serial_rx_buffer_head + 1;
|
||||||
|
@ -218,7 +218,7 @@ void st_go_idle()
|
|||||||
|
|
||||||
// Set stepper driver idle state, disabled or enabled, depending on settings and circumstances.
|
// Set stepper driver idle state, disabled or enabled, depending on settings and circumstances.
|
||||||
bool pin_state = false; // Keep enabled.
|
bool pin_state = false; // Keep enabled.
|
||||||
if (((settings.stepper_idle_lock_time != 0xff) || sys.rt_exec_alarm) && sys.state != STATE_HOMING) {
|
if (((settings.stepper_idle_lock_time != 0xff) || sys_rt_exec_alarm) && sys.state != STATE_HOMING) {
|
||||||
// Force stepper dwell to lock axes for a defined amount of time to ensure the axes come to a complete
|
// Force stepper dwell to lock axes for a defined amount of time to ensure the axes come to a complete
|
||||||
// stop and not drift from residual inertial forces at the end of the last movement.
|
// stop and not drift from residual inertial forces at the end of the last movement.
|
||||||
delay_ms(settings.stepper_idle_lock_time);
|
delay_ms(settings.stepper_idle_lock_time);
|
||||||
@ -338,7 +338,7 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
} else {
|
} else {
|
||||||
// Segment buffer empty. Shutdown.
|
// Segment buffer empty. Shutdown.
|
||||||
st_go_idle();
|
st_go_idle();
|
||||||
bit_true_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP); // Flag main program for cycle end
|
bit_true_atomic(sys_rt_exec_state,EXEC_CYCLE_STOP); // Flag main program for cycle end
|
||||||
return; // Nothing to do but exit.
|
return; // Nothing to do but exit.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,13 +49,13 @@ ISR(CONTROL_INT_vect)
|
|||||||
if (bit_istrue(pin,bit(RESET_BIT))) {
|
if (bit_istrue(pin,bit(RESET_BIT))) {
|
||||||
mc_reset();
|
mc_reset();
|
||||||
} else if (bit_istrue(pin,bit(CYCLE_START_BIT))) {
|
} else if (bit_istrue(pin,bit(CYCLE_START_BIT))) {
|
||||||
bit_true(sys.rt_exec_state, EXEC_CYCLE_START);
|
bit_true(sys_rt_exec_state, EXEC_CYCLE_START);
|
||||||
#ifndef ENABLE_SAFETY_DOOR_INPUT_PIN
|
#ifndef ENABLE_SAFETY_DOOR_INPUT_PIN
|
||||||
} else if (bit_istrue(pin,bit(FEED_HOLD_BIT))) {
|
} else if (bit_istrue(pin,bit(FEED_HOLD_BIT))) {
|
||||||
bit_true(sys.rt_exec_state, EXEC_FEED_HOLD);
|
bit_true(sys_rt_exec_state, EXEC_FEED_HOLD);
|
||||||
#else
|
#else
|
||||||
} else if (bit_istrue(pin,bit(SAFETY_DOOR_BIT))) {
|
} else if (bit_istrue(pin,bit(SAFETY_DOOR_BIT))) {
|
||||||
bit_true(sys.rt_exec_state, EXEC_SAFETY_DOOR);
|
bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ uint8_t system_execute_line(char *line)
|
|||||||
sys.state = STATE_IDLE;
|
sys.state = STATE_IDLE;
|
||||||
// Don't run startup script. Prevents stored moves in startup from causing accidents.
|
// Don't run startup script. Prevents stored moves in startup from causing accidents.
|
||||||
if (system_check_safety_door_ajar()) { // Check safety door switch before returning.
|
if (system_check_safety_door_ajar()) { // Check safety door switch before returning.
|
||||||
bit_true(sys.rt_exec_state, EXEC_SAFETY_DOOR);
|
bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
|
||||||
protocol_execute_realtime(); // Enter safety door mode.
|
protocol_execute_realtime(); // Enter safety door mode.
|
||||||
}
|
}
|
||||||
} // Otherwise, no effect.
|
} // Otherwise, no effect.
|
||||||
@ -175,7 +175,7 @@ uint8_t system_execute_line(char *line)
|
|||||||
|
|
||||||
// TODO: Likely not required.
|
// TODO: Likely not required.
|
||||||
if (system_check_safety_door_ajar()) { // Check safety door switch before homing.
|
if (system_check_safety_door_ajar()) { // Check safety door switch before homing.
|
||||||
bit_true(sys.rt_exec_state, EXEC_SAFETY_DOOR);
|
bit_true(sys_rt_exec_state, EXEC_SAFETY_DOOR);
|
||||||
protocol_execute_realtime(); // Enter safety door mode.
|
protocol_execute_realtime(); // Enter safety door mode.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,20 +72,20 @@ typedef struct {
|
|||||||
uint8_t abort; // System abort flag. Forces exit back to main loop for reset.
|
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 state; // Tracks the current state of Grbl.
|
||||||
uint8_t suspend; // System suspend bitflag variable that manages holds, cancels, and safety door.
|
uint8_t suspend; // System suspend bitflag variable that manages holds, cancels, and safety door.
|
||||||
|
|
||||||
volatile uint8_t rt_exec_state; // Global realtime executor bitflag variable for state management. See EXEC bitmasks.
|
|
||||||
volatile uint8_t rt_exec_alarm; // Global realtime executor bitflag variable for setting various alarms.
|
|
||||||
|
|
||||||
int32_t position[N_AXIS]; // Real-time machine (aka home) position vector in steps.
|
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.
|
// NOTE: This may need to be a volatile variable, if problems arise.
|
||||||
|
|
||||||
uint8_t homing_axis_lock; // Locks axes when limits engage. Used as an axis motion mask in the stepper ISR.
|
|
||||||
volatile uint8_t probe_state; // Probing state value. Used to coordinate the probing cycle with stepper ISR.
|
|
||||||
int32_t probe_position[N_AXIS]; // Last probe position in machine coordinates and steps.
|
int32_t probe_position[N_AXIS]; // Last probe position in machine coordinates and steps.
|
||||||
uint8_t probe_succeeded; // Tracks if last probing cycle was successful.
|
uint8_t probe_succeeded; // Tracks if last probing cycle was successful.
|
||||||
|
uint8_t homing_axis_lock; // Locks axes when limits engage. Used as an axis motion mask in the stepper ISR.
|
||||||
} system_t;
|
} system_t;
|
||||||
extern system_t sys;
|
extern system_t sys;
|
||||||
|
|
||||||
|
volatile uint8_t sys_probe_state; // Probing state value. Used to coordinate the probing cycle with stepper ISR.
|
||||||
|
volatile uint8_t sys_rt_exec_state; // Global realtime executor bitflag variable for state management. See EXEC bitmasks.
|
||||||
|
volatile uint8_t sys_rt_exec_alarm; // Global realtime executor bitflag variable for setting various alarms.
|
||||||
|
|
||||||
|
|
||||||
// Initialize the serial protocol
|
// Initialize the serial protocol
|
||||||
void system_init();
|
void system_init();
|
||||||
|
Loading…
Reference in New Issue
Block a user