2014-01-11 04:22:10 +01:00
|
|
|
/*
|
|
|
|
system.c - Handles system level commands and real-time processes
|
2015-02-16 01:36:08 +01:00
|
|
|
Part of Grbl
|
2014-01-11 04:22:10 +01:00
|
|
|
|
2015-01-15 06:14:52 +01:00
|
|
|
Copyright (c) 2014-2015 Sungeun K. Jeon
|
2014-01-11 04:22:10 +01:00
|
|
|
|
|
|
|
Grbl is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Grbl is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-02-10 16:25:09 +01:00
|
|
|
#include "grbl.h"
|
2014-01-11 04:22:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
void system_init()
|
|
|
|
{
|
2015-01-17 16:12:37 +01:00
|
|
|
CONTROL_DDR &= ~(CONTROL_MASK); // Configure as input pins
|
|
|
|
#ifdef DISABLE_CONTROL_PIN_PULL_UP
|
|
|
|
CONTROL_PORT &= ~(CONTROL_MASK); // Normal low operation. Requires external pull-down.
|
|
|
|
#else
|
|
|
|
CONTROL_PORT |= CONTROL_MASK; // Enable internal pull-up resistors. Normal high operation.
|
|
|
|
#endif
|
|
|
|
CONTROL_PCMSK |= CONTROL_MASK; // Enable specific pins of the Pin Change Interrupt
|
|
|
|
PCICR |= (1 << CONTROL_INT); // Enable Pin Change Interrupt
|
2014-01-11 04:22:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Pin change interrupt for pin-out commands, i.e. cycle start, feed hold, and reset. Sets
|
2015-01-15 06:14:52 +01:00
|
|
|
// only the realtime command execute variable to have the main program execute these when
|
|
|
|
// its ready. This works exactly like the character-based realtime commands when picked off
|
2014-01-11 04:22:10 +01:00
|
|
|
// directly from the incoming serial data stream.
|
2015-01-17 16:12:37 +01:00
|
|
|
ISR(CONTROL_INT_vect)
|
2014-01-11 04:22:10 +01:00
|
|
|
{
|
2015-01-17 16:12:37 +01:00
|
|
|
uint8_t pin = (CONTROL_PIN & CONTROL_MASK);
|
|
|
|
#ifndef INVERT_CONTROL_PIN
|
|
|
|
pin ^= CONTROL_MASK;
|
|
|
|
#endif
|
|
|
|
// Enter only if any CONTROL pin is detected as active.
|
|
|
|
if (pin) {
|
|
|
|
if (bit_istrue(pin,bit(RESET_BIT))) {
|
2014-01-11 04:22:10 +01:00
|
|
|
mc_reset();
|
2015-01-17 16:12:37 +01:00
|
|
|
} else if (bit_istrue(pin,bit(CYCLE_START_BIT))) {
|
2015-01-15 06:14:52 +01:00
|
|
|
bit_true(sys.rt_exec_state, EXEC_CYCLE_START);
|
2015-02-12 05:19:00 +01:00
|
|
|
#ifndef ENABLE_SAFETY_DOOR_INPUT_PIN
|
|
|
|
} else if (bit_istrue(pin,bit(FEED_HOLD_BIT))) {
|
|
|
|
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);
|
|
|
|
#endif
|
G38.2 probe feature rough draft installed. Working but needs testing.
- G38.2 straight probe now supported. Rough draft. May be tweaked more
as testing ramps up.
- G38.2 requires at least one axis word. Multiple axis words work too.
When commanded, the probe cycle will move at the last ‘F’ feed rate
specified in a straight line.
- During a probe cycle: If the probe pin goes low (normal high), Grbl
will record that immediate position and engage a feed hold. Meaning
that the CNC machine will move a little past the probe switch point, so
keep federates low to stop sooner. Once stopped, Grbl will issue a move
to go back to the recorded probe trigger point.
- During a probe cycle: If the probe switch does not engage by the time
the machine has traveled to its target coordinates, Grbl will issue an
ALARM and the user will be forced to reset Grbl. (Currently G38.3 probe
without error isn’t supported, but would be easy to implement later.)
- After a successful probe, Grbl will send a feedback message
containing the recorded probe coordinates in the machine coordinate
system. This is as the g-code standard on probe parameters specifies.
- The recorded probe parameters are retained in Grbl memory and can be
viewed with the ‘$#’ print parameters command. Upon a power-cycle, not
a soft-reset, Grbl will re-zero these values.
- Moved ‘$#’ command to require IDLE or ALARM mode, because it accesses
EEPROM to fetch the coordinate system offsets.
- Updated the Grbl version to v0.9d.
- The probe cycle is subject to change upon testing or user-feedback.
2014-03-01 06:03:26 +01:00
|
|
|
}
|
2014-01-11 04:22:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-12 05:19:00 +01:00
|
|
|
// Returns if safety door is ajar(T) or closed(F), based on pin state.
|
|
|
|
uint8_t system_check_safety_door_ajar()
|
|
|
|
{
|
|
|
|
#ifdef ENABLE_SAFETY_DOOR_INPUT_PIN
|
|
|
|
#ifdef INVERT_CONTROL_PIN
|
|
|
|
return(bit_istrue(CONTROL_PIN,bit(SAFETY_DOOR_BIT)));
|
|
|
|
#else
|
|
|
|
return(bit_isfalse(CONTROL_PIN,bit(SAFETY_DOOR_BIT)));
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
return(false); // Input pin not enabled, so just return that it's closed.
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-11 04:22:10 +01:00
|
|
|
// Executes user startup script, if stored.
|
|
|
|
void system_execute_startup(char *line)
|
|
|
|
{
|
|
|
|
uint8_t n;
|
|
|
|
for (n=0; n < N_STARTUP_LINE; n++) {
|
|
|
|
if (!(settings_read_startup_line(n, line))) {
|
|
|
|
report_status_message(STATUS_SETTING_READ_FAIL);
|
|
|
|
} else {
|
|
|
|
if (line[0] != 0) {
|
|
|
|
printString(line); // Echo startup line to indicate execution.
|
|
|
|
report_status_message(gc_execute_line(line));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Directs and executes one line of formatted input from protocol_process. While mostly
|
|
|
|
// incoming streaming g-code blocks, this also executes Grbl internal commands, such as
|
|
|
|
// settings, initiating the homing cycle, and toggling switch states. This differs from
|
2015-01-15 06:14:52 +01:00
|
|
|
// the realtime command module by being susceptible to when Grbl is ready to execute the
|
2014-01-11 04:22:10 +01:00
|
|
|
// next line during a cycle, so for switches like block delete, the switch only effects
|
|
|
|
// the lines that are processed afterward, not necessarily real-time during a cycle,
|
|
|
|
// since there are motions already stored in the buffer. However, this 'lag' should not
|
|
|
|
// be an issue, since these commands are not typically used during a cycle.
|
|
|
|
uint8_t system_execute_line(char *line)
|
|
|
|
{
|
|
|
|
uint8_t char_counter = 1;
|
|
|
|
uint8_t helper_var = 0; // Helper variable
|
|
|
|
float parameter, value;
|
|
|
|
switch( line[char_counter] ) {
|
2014-02-09 18:46:34 +01:00
|
|
|
case 0 : report_grbl_help(); break;
|
2015-02-24 02:45:26 +01:00
|
|
|
case '$': case 'G': case 'C': case 'X':
|
|
|
|
if ( line[(char_counter+1)] != 0 ) { return(STATUS_INVALID_STATEMENT); }
|
|
|
|
switch( line[char_counter] ) {
|
|
|
|
case '$' : // Prints Grbl settings
|
|
|
|
if ( sys.state & (STATE_CYCLE | STATE_HOLD) ) { return(STATUS_IDLE_ERROR); } // Block during cycle. Takes too long to print.
|
|
|
|
else { report_grbl_settings(); }
|
|
|
|
break;
|
|
|
|
case 'G' : // Prints gcode parser state
|
|
|
|
// TODO: Move this to realtime commands for GUIs to request this data during suspend-state.
|
|
|
|
report_gcode_modes();
|
|
|
|
break;
|
|
|
|
case 'C' : // Set check g-code mode [IDLE/CHECK]
|
|
|
|
// Perform reset when toggling off. Check g-code mode should only work if Grbl
|
|
|
|
// is idle and ready, regardless of alarm locks. This is mainly to keep things
|
|
|
|
// simple and consistent.
|
|
|
|
if ( sys.state == STATE_CHECK_MODE ) {
|
|
|
|
mc_reset();
|
|
|
|
report_feedback_message(MESSAGE_DISABLED);
|
|
|
|
} else {
|
|
|
|
if (sys.state) { return(STATUS_IDLE_ERROR); } // Requires no alarm mode.
|
|
|
|
sys.state = STATE_CHECK_MODE;
|
|
|
|
report_feedback_message(MESSAGE_ENABLED);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'X' : // Disable alarm lock [ALARM]
|
|
|
|
if (sys.state == STATE_ALARM) {
|
|
|
|
report_feedback_message(MESSAGE_ALARM_UNLOCK);
|
|
|
|
sys.state = STATE_IDLE;
|
|
|
|
// 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.
|
|
|
|
bit_true(sys.rt_exec_state, EXEC_SAFETY_DOOR);
|
|
|
|
protocol_execute_realtime(); // Enter safety door mode.
|
|
|
|
}
|
|
|
|
} // Otherwise, no effect.
|
|
|
|
break;
|
|
|
|
// case 'J' : break; // Jogging methods
|
|
|
|
// TODO: Here jogging can be placed for execution as a seperate subprogram. It does not need to be
|
|
|
|
// susceptible to other realtime commands except for e-stop. The jogging function is intended to
|
|
|
|
// be a basic toggle on/off with controlled acceleration and deceleration to prevent skipped
|
|
|
|
// steps. The user would supply the desired feedrate, axis to move, and direction. Toggle on would
|
|
|
|
// start motion and toggle off would initiate a deceleration to stop. One could 'feather' the
|
|
|
|
// motion by repeatedly toggling to slow the motion to the desired location. Location data would
|
|
|
|
// need to be updated real-time and supplied to the user through status queries.
|
|
|
|
// More controlled exact motions can be taken care of by inputting G0 or G1 commands, which are
|
|
|
|
// handled by the planner. It would be possible for the jog subprogram to insert blocks into the
|
|
|
|
// block buffer without having the planner plan them. It would need to manage de/ac-celerations
|
|
|
|
// on its own carefully. This approach could be effective and possibly size/memory efficient.
|
|
|
|
// }
|
|
|
|
// break;
|
2014-02-09 18:46:34 +01:00
|
|
|
}
|
2015-02-24 02:45:26 +01:00
|
|
|
break;
|
2014-01-11 04:22:10 +01:00
|
|
|
default :
|
|
|
|
// Block any system command that requires the state as IDLE/ALARM. (i.e. EEPROM, homing)
|
|
|
|
if ( !(sys.state == STATE_IDLE || sys.state == STATE_ALARM) ) { return(STATUS_IDLE_ERROR); }
|
|
|
|
switch( line[char_counter] ) {
|
G38.2 probe feature rough draft installed. Working but needs testing.
- G38.2 straight probe now supported. Rough draft. May be tweaked more
as testing ramps up.
- G38.2 requires at least one axis word. Multiple axis words work too.
When commanded, the probe cycle will move at the last ‘F’ feed rate
specified in a straight line.
- During a probe cycle: If the probe pin goes low (normal high), Grbl
will record that immediate position and engage a feed hold. Meaning
that the CNC machine will move a little past the probe switch point, so
keep federates low to stop sooner. Once stopped, Grbl will issue a move
to go back to the recorded probe trigger point.
- During a probe cycle: If the probe switch does not engage by the time
the machine has traveled to its target coordinates, Grbl will issue an
ALARM and the user will be forced to reset Grbl. (Currently G38.3 probe
without error isn’t supported, but would be easy to implement later.)
- After a successful probe, Grbl will send a feedback message
containing the recorded probe coordinates in the machine coordinate
system. This is as the g-code standard on probe parameters specifies.
- The recorded probe parameters are retained in Grbl memory and can be
viewed with the ‘$#’ print parameters command. Upon a power-cycle, not
a soft-reset, Grbl will re-zero these values.
- Moved ‘$#’ command to require IDLE or ALARM mode, because it accesses
EEPROM to fetch the coordinate system offsets.
- Updated the Grbl version to v0.9d.
- The probe cycle is subject to change upon testing or user-feedback.
2014-03-01 06:03:26 +01:00
|
|
|
case '#' : // Print Grbl NGC parameters
|
2014-05-26 00:05:28 +02:00
|
|
|
if ( line[++char_counter] != 0 ) { return(STATUS_INVALID_STATEMENT); }
|
G38.2 probe feature rough draft installed. Working but needs testing.
- G38.2 straight probe now supported. Rough draft. May be tweaked more
as testing ramps up.
- G38.2 requires at least one axis word. Multiple axis words work too.
When commanded, the probe cycle will move at the last ‘F’ feed rate
specified in a straight line.
- During a probe cycle: If the probe pin goes low (normal high), Grbl
will record that immediate position and engage a feed hold. Meaning
that the CNC machine will move a little past the probe switch point, so
keep federates low to stop sooner. Once stopped, Grbl will issue a move
to go back to the recorded probe trigger point.
- During a probe cycle: If the probe switch does not engage by the time
the machine has traveled to its target coordinates, Grbl will issue an
ALARM and the user will be forced to reset Grbl. (Currently G38.3 probe
without error isn’t supported, but would be easy to implement later.)
- After a successful probe, Grbl will send a feedback message
containing the recorded probe coordinates in the machine coordinate
system. This is as the g-code standard on probe parameters specifies.
- The recorded probe parameters are retained in Grbl memory and can be
viewed with the ‘$#’ print parameters command. Upon a power-cycle, not
a soft-reset, Grbl will re-zero these values.
- Moved ‘$#’ command to require IDLE or ALARM mode, because it accesses
EEPROM to fetch the coordinate system offsets.
- Updated the Grbl version to v0.9d.
- The probe cycle is subject to change upon testing or user-feedback.
2014-03-01 06:03:26 +01:00
|
|
|
else { report_ngc_parameters(); }
|
|
|
|
break;
|
2014-02-09 18:46:34 +01:00
|
|
|
case 'H' : // Perform homing cycle [IDLE/ALARM]
|
2014-01-11 04:22:10 +01:00
|
|
|
if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) {
|
2015-01-15 06:14:52 +01:00
|
|
|
sys.state = STATE_HOMING; // Set system state variable
|
2014-01-11 04:22:10 +01:00
|
|
|
// Only perform homing if Grbl is idle or lost.
|
2015-02-12 05:19:00 +01:00
|
|
|
|
|
|
|
// TODO: Likely not required.
|
|
|
|
if (system_check_safety_door_ajar()) { // Check safety door switch before homing.
|
|
|
|
bit_true(sys.rt_exec_state, EXEC_SAFETY_DOOR);
|
|
|
|
protocol_execute_realtime(); // Enter safety door mode.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-11 04:22:10 +01:00
|
|
|
mc_homing_cycle();
|
2015-01-15 06:14:52 +01:00
|
|
|
if (!sys.abort) { // Execute startup scripts after successful homing.
|
|
|
|
sys.state = STATE_IDLE; // Set to IDLE when complete.
|
|
|
|
st_go_idle(); // Set steppers to the settings idle state before returning.
|
|
|
|
system_execute_startup(line);
|
|
|
|
}
|
2014-01-11 04:22:10 +01:00
|
|
|
} else { return(STATUS_SETTING_DISABLED); }
|
|
|
|
break;
|
2014-02-09 18:46:34 +01:00
|
|
|
case 'I' : // Print or store build info. [IDLE/ALARM]
|
2014-01-11 04:22:10 +01:00
|
|
|
if ( line[++char_counter] == 0 ) {
|
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.
2014-08-04 05:10:27 +02:00
|
|
|
settings_read_build_info(line);
|
|
|
|
report_build_info(line);
|
2014-02-19 15:21:40 +01:00
|
|
|
} else { // Store startup line [IDLE/ALARM]
|
2014-05-26 00:05:28 +02:00
|
|
|
if(line[char_counter++] != '=') { return(STATUS_INVALID_STATEMENT); }
|
2014-01-11 04:22:10 +01:00
|
|
|
helper_var = char_counter; // Set helper variable as counter to start of user info line.
|
|
|
|
do {
|
|
|
|
line[char_counter-helper_var] = line[char_counter];
|
|
|
|
} while (line[char_counter++] != 0);
|
|
|
|
settings_store_build_info(line);
|
|
|
|
}
|
2015-06-18 17:23:17 +02:00
|
|
|
break;
|
|
|
|
case 'R' : // Restore defaults [IDLE/ALARM]
|
|
|
|
if (line[++char_counter] != 'S') { return(STATUS_INVALID_STATEMENT); }
|
|
|
|
if (line[++char_counter] != 'T') { return(STATUS_INVALID_STATEMENT); }
|
2015-06-20 18:27:24 +02:00
|
|
|
if (line[++char_counter] != '=') { return(STATUS_INVALID_STATEMENT); }
|
|
|
|
if (line[char_counter+2] != 0) { return(STATUS_INVALID_STATEMENT); }
|
|
|
|
switch (line[++char_counter]) {
|
|
|
|
case '$': settings_restore(SETTINGS_RESTORE_DEFAULTS); break;
|
|
|
|
case '#': settings_restore(SETTINGS_RESTORE_PARAMETERS); break;
|
|
|
|
case '*': settings_restore(SETTINGS_RESTORE_ALL); break;
|
|
|
|
default: return(STATUS_INVALID_STATEMENT);
|
|
|
|
}
|
2015-06-18 17:23:17 +02:00
|
|
|
report_feedback_message(MESSAGE_RESTORE_DEFAULTS);
|
2015-06-20 18:27:24 +02:00
|
|
|
mc_reset(); // Force reset to ensure settings are initialized correctly.
|
2015-06-18 17:23:17 +02:00
|
|
|
break;
|
2014-02-09 18:46:34 +01:00
|
|
|
case 'N' : // Startup lines. [IDLE/ALARM]
|
2014-01-11 04:22:10 +01:00
|
|
|
if ( line[++char_counter] == 0 ) { // Print startup lines
|
|
|
|
for (helper_var=0; helper_var < N_STARTUP_LINE; helper_var++) {
|
|
|
|
if (!(settings_read_startup_line(helper_var, line))) {
|
|
|
|
report_status_message(STATUS_SETTING_READ_FAIL);
|
|
|
|
} else {
|
|
|
|
report_startup_line(helper_var,line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-02-19 15:21:40 +01:00
|
|
|
} else { // Store startup line [IDLE Only] Prevents motion during ALARM.
|
2014-02-09 18:46:34 +01:00
|
|
|
if (sys.state != STATE_IDLE) { return(STATUS_IDLE_ERROR); } // Store only when idle.
|
2014-01-11 04:22:10 +01:00
|
|
|
helper_var = true; // Set helper_var to flag storing method.
|
|
|
|
// No break. Continues into default: to read remaining command characters.
|
|
|
|
}
|
2014-02-09 18:46:34 +01:00
|
|
|
default : // Storing setting methods [IDLE/ALARM]
|
2014-01-11 04:22:10 +01:00
|
|
|
if(!read_float(line, &char_counter, ¶meter)) { return(STATUS_BAD_NUMBER_FORMAT); }
|
2014-05-26 00:05:28 +02:00
|
|
|
if(line[char_counter++] != '=') { return(STATUS_INVALID_STATEMENT); }
|
2014-01-11 04:22:10 +01:00
|
|
|
if (helper_var) { // Store startup line
|
|
|
|
// Prepare sending gcode block to gcode parser by shifting all characters
|
|
|
|
helper_var = char_counter; // Set helper variable as counter to start of gcode block
|
|
|
|
do {
|
|
|
|
line[char_counter-helper_var] = line[char_counter];
|
|
|
|
} while (line[char_counter++] != 0);
|
|
|
|
// Execute gcode block to ensure block is valid.
|
|
|
|
helper_var = gc_execute_line(line); // Set helper_var to returned status code.
|
|
|
|
if (helper_var) { return(helper_var); }
|
|
|
|
else {
|
|
|
|
helper_var = trunc(parameter); // Set helper_var to int value of parameter
|
|
|
|
settings_store_startup_line(helper_var,line);
|
|
|
|
}
|
|
|
|
} else { // Store global setting.
|
|
|
|
if(!read_float(line, &char_counter, &value)) { return(STATUS_BAD_NUMBER_FORMAT); }
|
2014-09-20 16:50:27 +02:00
|
|
|
if((line[char_counter] != 0) || (parameter > 255)) { return(STATUS_INVALID_STATEMENT); }
|
Settings refactoring. Bug fixes. Misc new features.
This is likely the last major change to the v0.9 code base before push
to master. Only two minor things remain on the agenda (CoreXY support,
force clear EEPROM, and an extremely low federate bug).
- NEW! Grbl is now compile-able and may be flashed directly through the
Arduino IDE. Only minor changes were required for this compatibility.
See the Wiki to learn how to do it.
- New status reporting mask to turn on and off what Grbl sends back.
This includes machine coordinates, work coordinates, serial RX buffer
usage, and planner buffer usage. Expandable to more information on user
request, but that’s it for now.
- Settings have been completely renumbered to allow for future new
settings to be installed without having to constantly reshuffle and
renumber all of the settings every time.
- All settings masks have been standardized to mean bit 0 = X, bit 1 =
Y, and bit 2 = Z, to reduce confusion on how they work. The invert
masks used by the internal Grbl system were updated to accommodate this
change as well.
- New invert probe pin setting, which does what it sounds like.
- Fixed a probing cycle bug, where it would freeze intermittently, and
removed some redundant code.
- Homing may now be set to the origin wherever the limit switches are.
Traditionally machine coordinates should always be in negative space,
but when limit switches on are on the opposite side, the machine
coordinate would be set to -max_travel for the axis. Now you can always
make it [0,0,0] via a compile-time option in config.h. (Soft limits
routine was updated to account for this as well.)
- Probe coordinate message immediately after a probing cycle may now
be turned off via a compile-time option in config.h. By default the
probing location is always reported.
- Reduced the N_ARC_CORRECTION default value to reflect the changes in
how circles are generated by an arc tolerance, rather than a fixed arc
segment setting.
- Increased the incoming line buffer limit from 70 to 80 characters.
Had some extra memory space to invest into this.
- Fixed a bug where tool number T was not being tracked and reported
correctly.
- Added a print free memory function for debugging purposes. Not used
otherwise.
- Realtime rate report should now work during feed holds, but it hasn’t
been tested yet.
- Updated the streaming scripts with MIT-license and added the simple
streaming to the main stream.py script to allow for settings to be sent.
- Some minor code refactoring to improve flash efficiency. Reduced the
flash by several hundred KB, which was re-invested in some of these new
features.
2014-07-26 23:01:34 +02:00
|
|
|
return(settings_store_global_setting((uint8_t)parameter, value));
|
2014-01-11 04:22:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(STATUS_OK); // If '$' command makes it to here, then everything's ok.
|
|
|
|
}
|
2015-01-15 06:14:52 +01:00
|
|
|
|
|
|
|
|
2015-02-05 03:12:30 +01:00
|
|
|
// Returns machine position of axis 'idx'. Must be sent a 'step' array.
|
|
|
|
// NOTE: If motor steps and machine position are not in the same coordinate frame, this function
|
|
|
|
// serves as a central place to compute the transformation.
|
2015-01-15 06:14:52 +01:00
|
|
|
float system_convert_axis_steps_to_mpos(int32_t *steps, uint8_t idx)
|
|
|
|
{
|
2015-01-17 16:12:37 +01:00
|
|
|
float pos;
|
2015-01-15 06:14:52 +01:00
|
|
|
#ifdef COREXY
|
|
|
|
if (idx==A_MOTOR) {
|
2015-01-17 16:12:37 +01:00
|
|
|
pos = 0.5*((steps[A_MOTOR] + steps[B_MOTOR])/settings.steps_per_mm[idx]);
|
2015-05-23 19:57:30 +02:00
|
|
|
} else if (idx==B_MOTOR) {
|
2015-01-17 16:12:37 +01:00
|
|
|
pos = 0.5*((steps[A_MOTOR] - steps[B_MOTOR])/settings.steps_per_mm[idx]);
|
2015-05-23 19:57:30 +02:00
|
|
|
} else {
|
|
|
|
pos = steps[idx]/settings.steps_per_mm[idx];
|
2015-01-15 06:14:52 +01:00
|
|
|
}
|
|
|
|
#else
|
2015-01-17 16:12:37 +01:00
|
|
|
pos = steps[idx]/settings.steps_per_mm[idx];
|
2015-01-15 06:14:52 +01:00
|
|
|
#endif
|
2015-01-17 16:12:37 +01:00
|
|
|
return(pos);
|
2015-01-15 06:14:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void system_convert_array_steps_to_mpos(float *position, int32_t *steps)
|
|
|
|
{
|
|
|
|
uint8_t idx;
|
|
|
|
for (idx=0; idx<N_AXIS; idx++) {
|
|
|
|
position[idx] = system_convert_axis_steps_to_mpos(steps, idx);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|