Probing cycle and view build info bug fixes.

- Probing cycle would drop into a QUEUED state, if multiple G38.2 are
sent. It would not honor the auto cycle start flags. To fix, the auto
cycle start state is saved at the beginning of the probing cycle and
restored at the end, since the feed hold it uses to stop a triggered
probe will disable the auto start flag. For now it’s a patch, rather
than a permanent fix.

- protocol_buffer_synchronize() also has a failure case. Auto cycle
start does not get executed when the system is waiting in here, so if
it’s in a QUEUED state already, it won’t resume. Patched here, but not
fully resolved.

- Fixed a problem with the “view build info” command. The EEPROM write
would do weird things and corrupt the EEPROM. Not sure exactly what
caused it, but it’s likely a compiler problem with an improperly
defined EEPROM address. It didn’t have enough room to store a full
string. To fix, the build info EEPROM range was increased and the max
number of STARTUP_BLOCKS was reduced to 2 from 3.

- Lastly, when a $I view build info is used for the first time, it
would normally show an EEPROM read error, since it wasn’t cleared or
wasn’t therein the first place. It will now not show that error. A
patch rather than a permanent fix again.
This commit is contained in:
Sonny Jeon 2014-08-03 21:10:27 -06:00
parent 5c0d311d92
commit 469399fcd5
6 changed files with 28 additions and 45 deletions

View File

@ -86,10 +86,10 @@
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
// and addresses are defined in settings.h. With the current settings, up to 3 startup blocks may
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
// be stored and executed in order. These startup blocks would typically be used to set the g-code
// parser state depending on user preferences.
#define N_STARTUP_LINE 2 // Integer (1-3)
#define N_STARTUP_LINE 2 // Integer (1-2)
// Number of floating decimal points printed by Grbl for certain value types. These settings are
// determined by realistic and commonly observed values in CNC machines. For example, position

View File

@ -276,8 +276,12 @@ void mc_homing_cycle()
void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate)
#endif
{
// TODO: Need to update this cycle so it obeys a non-auto cycle start.
if (sys.state == STATE_CHECK_MODE) { return; }
// Finish all queued commands and empty planner buffer before starting probe cycle.
protocol_buffer_synchronize();
uint8_t auto_start_state = sys.auto_start; // Store run state
// After syncing, check if probe is already triggered. If so, halt and issue alarm.
if (probe_get_state()) {
@ -292,11 +296,10 @@ void mc_homing_cycle()
#else
mc_line(target, feed_rate, invert_feed_rate);
#endif
// Activate the probing monitor in the stepper module.
// NOTE: Parser error-checking ensures the probe isn't already closed/triggered.
sys.probe_state = PROBE_ACTIVE;
// Activate the probing monitor in the stepper module.
sys.probe_state = PROBE_ACTIVE;
// Perform probing cycle. Wait here until probe is triggered or motion completes.
bit_true_atomic(sys.execute, EXEC_CYCLE_START);
do {
@ -304,7 +307,7 @@ void mc_homing_cycle()
if (sys.abort) { return; } // Check for system abort
} while ((sys.state != STATE_IDLE) && (sys.state != STATE_QUEUED));
// If motion completes without probe triggering, error out.
// Probing motion complete. If the probe has not been triggered, error out.
if (sys.probe_state == PROBE_ACTIVE) { bit_true_atomic(sys.execute, EXEC_CRIT_EVENT); }
protocol_execute_runtime(); // Check and execute run-time commands
if (sys.abort) { return; } // Check for system abort
@ -313,24 +316,8 @@ void mc_homing_cycle()
st_reset(); // Reest step segment buffer.
plan_reset(); // Reset planner buffer. Zero planner positions. Ensure probing motion is cleared.
plan_sync_position(); // Sync planner position to current machine position.
// Probing motion is complete, but we'll pull-off triggered probe to the trigger location since
// we had to decelerate a little beyond it to stop the machine in a controlled manner.
uint8_t idx;
for(idx=0; idx<N_AXIS; idx++){
// NOTE: The target[] variable updated here will be sent back and synced with the g-code parser.
target[idx] = (float)sys.probe_position[idx]/settings.steps_per_mm[idx];
}
#ifdef USE_LINE_NUMBERS
mc_line(target, feed_rate, invert_feed_rate, line_number);
#else
mc_line(target, feed_rate, invert_feed_rate);
#endif
// Execute pull-off motion and wait until it completes.
bit_true_atomic(sys.execute, EXEC_CYCLE_START);
protocol_buffer_synchronize();
if (sys.abort) { return; } // Return if system reset has been issued.
sys.auto_start = auto_start_state; // Restore run state.
#ifdef MESSAGE_PROBE_COORDINATES
// All done! Output the probe position as message.

View File

@ -277,6 +277,8 @@ void protocol_execute_runtime()
// during a synchronize call, if it should happen. Also, waits for clean cycle end.
void protocol_buffer_synchronize()
{
// If system is queued, ensure cycle resumes if the auto start flag is present.
protocol_auto_cycle_start();
// Check and set auto start to resume cycle after synchronize and caller completes.
if (sys.state == STATE_CYCLE) { sys.auto_start = true; }
while (plan_get_current_block() || (sys.state == STATE_CYCLE)) {

View File

@ -33,7 +33,7 @@ settings_t settings;
// Method to store startup lines into EEPROM
void settings_store_startup_line(uint8_t n, char *line)
{
uint16_t addr = n*(LINE_BUFFER_SIZE+1)+EEPROM_ADDR_STARTUP_BLOCK;
uint32_t addr = n*(LINE_BUFFER_SIZE+1)+EEPROM_ADDR_STARTUP_BLOCK;
memcpy_to_eeprom_with_checksum(addr,(char*)line, LINE_BUFFER_SIZE);
}
@ -48,7 +48,7 @@ void settings_store_build_info(char *line)
// Method to store coord data parameters into EEPROM
void settings_write_coord_data(uint8_t coord_select, float *coord_data)
{
uint16_t addr = coord_select*(sizeof(float)*N_AXIS+1) + EEPROM_ADDR_PARAMETERS;
uint32_t addr = coord_select*(sizeof(float)*N_AXIS+1) + EEPROM_ADDR_PARAMETERS;
memcpy_to_eeprom_with_checksum(addr,(char*)coord_data, sizeof(float)*N_AXIS);
}
@ -105,15 +105,14 @@ void settings_reset() {
// Reads startup line from EEPROM. Updated pointed line string data.
uint8_t settings_read_startup_line(uint8_t n, char *line)
{
uint16_t addr = n*(LINE_BUFFER_SIZE+1)+EEPROM_ADDR_STARTUP_BLOCK;
uint32_t addr = n*(LINE_BUFFER_SIZE+1)+EEPROM_ADDR_STARTUP_BLOCK;
if (!(memcpy_from_eeprom_with_checksum((char*)line, addr, LINE_BUFFER_SIZE))) {
// Reset line with default value
line[0] = 0; // Empty line
settings_store_startup_line(n, line);
return(false);
} else {
return(true);
}
return(true);
}
@ -124,25 +123,23 @@ uint8_t settings_read_build_info(char *line)
// Reset line with default value
line[0] = 0; // Empty line
settings_store_build_info(line);
return(false);
} else {
return(true);
// No error. Usually only happens once when called for first time.
}
return(true);
}
// Read selected coordinate data from EEPROM. Updates pointed coord_data value.
uint8_t settings_read_coord_data(uint8_t coord_select, float *coord_data)
{
uint16_t addr = coord_select*(sizeof(float)*N_AXIS+1) + EEPROM_ADDR_PARAMETERS;
uint32_t addr = coord_select*(sizeof(float)*N_AXIS+1) + EEPROM_ADDR_PARAMETERS;
if (!(memcpy_from_eeprom_with_checksum((char*)coord_data, addr, sizeof(float)*N_AXIS))) {
// Reset with default zero vector
clear_vector_float(coord_data);
settings_write_coord_data(coord_select,coord_data);
return(false);
} else {
return(true);
}
return(true);
}

View File

@ -50,10 +50,10 @@
// NOTE: The Atmega328p has 1KB EEPROM. The upper half is reserved for parameters and
// the startup script. The lower half contains the global settings and space for future
// developments.
#define EEPROM_ADDR_GLOBAL 1
#define EEPROM_ADDR_PARAMETERS 512
#define EEPROM_ADDR_STARTUP_BLOCK 768
#define EEPROM_ADDR_BUILD_INFO 992
#define EEPROM_ADDR_GLOBAL 1U
#define EEPROM_ADDR_PARAMETERS 512U
#define EEPROM_ADDR_STARTUP_BLOCK 768U
#define EEPROM_ADDR_BUILD_INFO 942U
// Define EEPROM address indexing for coordinate parameters
#define N_COORDINATE_SYSTEM 6 // Number of supported work coordinate systems (from index 1)

View File

@ -145,11 +145,8 @@ uint8_t system_execute_line(char *line)
break;
case 'I' : // Print or store build info. [IDLE/ALARM]
if ( line[++char_counter] == 0 ) {
if (!(settings_read_build_info(line))) {
report_status_message(STATUS_SETTING_READ_FAIL);
} else {
report_build_info(line);
}
settings_read_build_info(line);
report_build_info(line);
} else { // Store startup line [IDLE/ALARM]
if(line[char_counter++] != '=') { return(STATUS_INVALID_STATEMENT); }
helper_var = char_counter; // Set helper variable as counter to start of user info line.