Bug fixes.

- G38.x was not printing correctly in the $G g-code state reports. Now
fixed.

- When investigating the above issue, it was noticed that G38.x
wouldn’t show at all, but instead a G0 would be printed. This was
unlike the v0.9j master build. It turned out volatile variables do not
like to be defined inside a C struct. These are undefined on how to be
handled. Once pulled out, all weird issues went away.

- Also changed two ‘sizeof()’ statements in the mc_probe() and
probe_state_monitor() functions to be more robust later on.

- Updated the commit logs to individual files for each minor release.
Forgot to update the generating script to account for this.
This commit is contained in:
Sonny Jeon 2015-09-30 21:32:58 -06:00
commit b9c3461932
15 changed files with 183 additions and 142 deletions

View File

@ -1,83 +1,3 @@
----------------
Date: 2015-09-05
Author: Sonny Jeon
Subject: Parking motion bug fix.
- Parking motion would intermittently complete the queued tool path
upon resuming in certain scenarios. Now fixed.
----------------
Date: 2015-08-29
Author: Sonny Jeon
Subject: Optional line number reporting bug fix.
- Fixed a bug where it would not compile when USE_LINE_NUMBERS was
enabled.
----------------
Date: 2015-08-27
Author: Sonny Jeon
Subject: Update README
----------------
Date: 2015-08-27
Author: Sonny Jeon
Subject: v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm $ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpms.
- If the new max rpm $ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now cant
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
----------------
Date: 2015-08-14
Author: Sonny Jeon

View File

@ -0,0 +1,17 @@
----------------
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
Author: Sonny Jeon
Subject: Version bump to v0.9j
- Version bump requested by OEMs to easily determine whether the
firmware supports the new EEPROM reset feature. Other than that, no
significant changes.

View File

@ -0,0 +1,104 @@
----------------
Date: 2015-09-24
Author: Sonny Jeon
Subject: Updated G28/G30 intermediate motion behavior.
- G28 and G30s behavior has been updated from the old NIST g-code
standard to LinuxCNCs. Previously when an intermediate motion was
programmed, the NIST standard would move all axes to the final G28/30
stored coordinates. LinuxCNC states it only moves the axes specified in
the command.
For example, suppose G28s stored position is (x,y,z) = (1,2,3) for
simplicity, and we want to do an automated z-axis tool retraction and
then park at the x,y location. `G28 G91 Z5` will first move the Z axis
5mm(or inches) up, then move Z to position 3 in machine coordinates.
Next, the command `G28 G91 X0 Y0` would skip the intermediate move
since distance is zero, but then move only the x and y axes to machine
coordinates 1 and 2, respectively. The z-axis wouldnt move in this
case, since it wasnt specified.
This change is intended to make Grbl more LinuxCNC compatible while
making commands, like the shown tool retraction, much easier to
implement.
----------------
Date: 2015-09-05
Author: Sonny Jeon
Subject: Parking motion bug fix.
- Parking motion would intermittently complete the queued tool path
upon resuming in certain scenarios. Now fixed.
----------------
Date: 2015-08-29
Author: Sonny Jeon
Subject: Optional line number reporting bug fix.
- Fixed a bug where it would not compile when USE_LINE_NUMBERS was
enabled.
----------------
Date: 2015-08-27
Author: Sonny Jeon
Subject: Update README
----------------
Date: 2015-08-27
Author: Sonny Jeon
Subject: v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm $ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpms.
- If the new max rpm $ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now cant
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.

View File

@ -1044,7 +1044,7 @@ uint8_t gc_execute_line(char *line)
protocol_buffer_synchronize(); // Sync and finish all remaining buffered motions before moving on.
if (gc_state.modal.program_flow == PROGRAM_FLOW_PAUSED) {
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.
}
} else { // == PROGRAM_FLOW_COMPLETED

View File

@ -23,7 +23,7 @@
// Grbl versioning system
#define GRBL_VERSION "1.0b"
#define GRBL_VERSION_BUILD "20150924"
#define GRBL_VERSION_BUILD "20150930"
// Define standard libraries used by Grbl.
#include <avr/io.h>

View File

@ -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
// limit setting if their limits are constantly triggering after a reset and move their axes.
if (sys.state != STATE_ALARM) {
if (!(sys.rt_exec_alarm)) {
if (!(sys_rt_exec_alarm)) {
#ifdef HARD_LIMIT_FORCE_STATE_CHECK
// Check limit pin state.
if (limits_get_state()) {
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
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
}
}
@ -122,11 +122,11 @@ uint8_t limits_get_state()
{
WDTCSR &= ~(1<<WDIE); // Disable watchdog timer.
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.
if (limits_get_state()) {
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.
// 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
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 && (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.
protocol_execute_realtime();
return;
} else {
// 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;
}
}
@ -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
// enter alarm mode.
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 {
protocol_execute_realtime();
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.
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
return;
}

View File

@ -77,8 +77,8 @@ int main(void)
// Reset system variables.
sys.abort = false;
sys.rt_exec_state = 0;
sys.rt_exec_alarm = 0;
sys_rt_exec_state = 0;
sys_rt_exec_alarm = 0;
sys.suspend = false;
// Start Grbl main loop. Processes program inputs and executes them.

View File

@ -220,7 +220,7 @@ void mc_homing_cycle()
#ifdef LIMITS_TWO_SWITCHES_ON_AXES
if (limits_get_state()) {
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;
}
#endif
@ -276,7 +276,7 @@ void mc_homing_cycle()
// After syncing, check if probe is already triggered. If so, halt and issue alarm.
// NOTE: This probe initialization error applies to all probing cycles.
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();
}
if (sys.abort) { return; } // Return if system reset has been issued.
@ -289,10 +289,10 @@ void mc_homing_cycle()
#endif
// 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.
bit_true_atomic(sys.rt_exec_state, EXEC_CYCLE_START);
bit_true_atomic(sys_rt_exec_state, EXEC_CYCLE_START);
do {
protocol_execute_realtime();
if (sys.abort) { return; } // Check for system abort
@ -301,13 +301,13 @@ void mc_homing_cycle()
// Probing cycle complete!
// Set state variables and error out, if the probe failed and cycle with error is enabled.
if (sys.probe_state == PROBE_ACTIVE) {
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); }
if (sys_probe_state == PROBE_ACTIVE) {
if (is_no_error) { memcpy(sys.probe_position, sys.position, sizeof(sys.position)); }
else { bit_true_atomic(sys_rt_exec_alarm, EXEC_ALARM_PROBE_FAIL); }
} else {
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
if (sys.abort) { return; } // Check for system abort
@ -365,8 +365,8 @@ void mc_parking_motion(float *parking_target, float feed_rate)
void mc_reset()
{
// Only this function can set the system reset. Helps prevent multiple kill calls.
if (bit_isfalse(sys.rt_exec_state, EXEC_RESET)) {
bit_true_atomic(sys.rt_exec_state, EXEC_RESET);
if (bit_isfalse(sys_rt_exec_state, EXEC_RESET)) {
bit_true_atomic(sys_rt_exec_state, EXEC_RESET);
// Kill spindle and coolant.
spindle_stop();
@ -378,8 +378,8 @@ void mc_reset()
// violated, by which, all bets are off.
if ((sys.state & (STATE_CYCLE | STATE_HOMING)) ||
(sys.step_control & (STEP_CONTROL_EXECUTE_HOLD | STEP_CONTROL_EXECUTE_PARK))) {
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); }
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); }
st_go_idle(); // Force kill steppers. Position has likely been lost.
}
}

View File

@ -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.
void probe_state_monitor()
{
if (sys.probe_state == PROBE_ACTIVE) {
if (sys_probe_state == PROBE_ACTIVE) {
if (probe_get_state()) {
sys.probe_state = PROBE_OFF;
memcpy(sys.probe_position, sys.position, sizeof(float)*N_AXIS);
bit_true(sys.rt_exec_state, EXEC_MOTION_CANCEL);
sys_probe_state = PROBE_OFF;
memcpy(sys.probe_position, sys.position, sizeof(sys.position));
bit_true(sys_rt_exec_state, EXEC_MOTION_CANCEL);
}
}
}

View File

@ -51,7 +51,7 @@ void protocol_main_loop()
// All systems go! But first check for safety door.
sys.state = STATE_IDLE;
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.
}
system_execute_startup(line); // Execute startup script.
@ -190,7 +190,7 @@ void protocol_buffer_synchronize()
// 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
// 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); }
// This function is the general interface to Grbl's real-time command execution system. It is called
@ -202,7 +202,7 @@ void protocol_auto_cycle_start() { bit_true_atomic(sys.rt_exec_state, EXEC_CYCLE
// handles them, removing the need 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 recalculating the buffer upon a feedhold or overrides.
// 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.
void protocol_execute_realtime()
{
@ -217,7 +217,7 @@ void protocol_execute_realtime()
void protocol_exec_rt_system()
{
uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times.
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
// 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
@ -237,7 +237,7 @@ void protocol_exec_rt_system()
// Halt everything upon a critical event flag. Currently hard and soft limits flag this.
if (rt_exec & EXEC_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 {
// Block everything, except reset and status reports, until user issues reset or power
// cycles. Hard limits typically occur while unattended or not paying attention. Gives
@ -246,17 +246,17 @@ void protocol_exec_rt_system()
// lost, streaming could cause a serious crash if it continues afterwards.
// 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();
// 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
}
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) {
// Execute system abort.
@ -268,7 +268,7 @@ void protocol_exec_rt_system()
// Execute and serial print status
if (rt_exec & EXEC_STATUS_REPORT) {
report_realtime_status();
bit_false_atomic(sys.rt_exec_state,EXEC_STATUS_REPORT);
bit_false_atomic(sys_rt_exec_state,EXEC_STATUS_REPORT);
}
// NOTE: The math involved to calculate the hold should be low enough for most, if not all,
@ -340,7 +340,7 @@ void protocol_exec_rt_system()
}
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.
@ -380,7 +380,7 @@ void protocol_exec_rt_system()
}
}
}
bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_START);
bit_false_atomic(sys_rt_exec_state,EXEC_CYCLE_START);
}
if (rt_exec & EXEC_CYCLE_STOP) {
@ -399,7 +399,7 @@ void protocol_exec_rt_system()
sys.suspend = SUSPEND_DISABLE;
sys.state = STATE_IDLE;
}
bit_false_atomic(sys.rt_exec_state,EXEC_CYCLE_STOP);
bit_false_atomic(sys_rt_exec_state,EXEC_CYCLE_STOP);
}
}
@ -544,7 +544,7 @@ static void protocol_exec_rt_suspend()
if (bit_isfalse(sys.suspend,SUSPEND_RESTART_RETRACT)) {
sys.suspend |= SUSPEND_RESTORE_COMPLETE;
bit_true_atomic(sys.rt_exec_state,EXEC_CYCLE_START); // Set to resume program.
bit_true_atomic(sys_rt_exec_state,EXEC_CYCLE_START); // Set to resume program.
}
}

View File

@ -337,7 +337,7 @@ void report_gcode_modes()
case MOTION_MODE_NONE : printPgmString(PSTR("G80")); break;
default:
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"));

View File

@ -89,7 +89,7 @@ void serial_write(uint8_t data) {
// Wait until there is space in the buffer
while (next_head == serial_tx_buffer_tail) {
// 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
@ -164,10 +164,10 @@ ISR(SERIAL_RX)
// 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.
switch (data) {
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_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_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_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_RESET: mc_reset(); break; // Call motion control reset routine.
default: // Write character to buffer
next_head = serial_rx_buffer_head + 1;

View File

@ -229,7 +229,7 @@ void st_go_idle()
// Set stepper driver idle state, disabled or enabled, depending on settings and circumstances.
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
// stop and not drift from residual inertial forces at the end of the last movement.
delay_ms(settings.stepper_idle_lock_time);
@ -349,7 +349,7 @@ ISR(TIMER1_COMPA_vect)
} else {
// Segment buffer empty. Shutdown.
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.
}
}

View File

@ -49,13 +49,13 @@ ISR(CONTROL_INT_vect)
if (bit_istrue(pin,bit(RESET_BIT))) {
mc_reset();
} 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
} 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 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
}
}

View File

@ -85,19 +85,19 @@ typedef struct {
uint8_t suspend; // System suspend bitflag variable that manages holds, cancels, and safety door.
uint8_t step_control;
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.
// 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.
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;
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
void system_init();