You are on page 1of 7

#ifdef HOMING_FORCE_SET_ORIGIN

// When homing forced set origin is enabled, soft limits checks need to account for
directionality.

// NOTE: max_travel is stored as negative

if (bit_istrue(settings.homing_dir_mask,bit(idx))) {

if (target[idx] < 0 || target[idx] > -settings.max_travel[idx]) { soft_limit_error = true; }

} else {

if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { soft_limit_error = true; }

#else

// NOTE: max_travel is stored as negative

if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { soft_limit_error = true; }

#endif

if (soft_limit_error) {

// Force feed hold if cycle is active. All buffered blocks are guaranteed to be within

// 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);

do {

protocol_execute_realtime();

if (sys.abort) { return; }

} while ( sys.state != STATE_IDLE );

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

protocol_execute_realtime(); // Execute to enter critical event loop and system abort

return;

set co $mom_sys_control_out

set ci $mom_sys_control_in
MOM_output_literal ";Operación: $mom_operation_name "

MOM_output_literal ";Herramienta: $mom_tool_name"

MOM_set_seq_on

// PB_CMD_machine_time

MOM_set_seq_off

void settings_init() {

if(!read_global_settings()) {

report_status_message(STATUS_SETTING_READ_FAIL);

settings_restore(SETTINGS_RESTORE_ALL); // Force restore all EEPROM data.

report_grbl_settings();

// a system abort and ensuring any active interrupts are cleanly reset.

// Reset Grbl primary systems.

serial_reset_read_buffer(); // Clear serial read buffer

gc_init(); // Set g-code parser to default state

spindle_init();

coolant_init();

limits_init();

probe_init();

plan_reset(); // Clear block buffer and planner variables

st_reset(); // Clear stepper subsystem variables.


// Sync cleared gcode and planner positions to current system position.

plan_sync_position();

gc_sync_position();

// Reset system variables.

sys.abort = false;

sys.rt_exec_state = 0;

sys.rt_exec_alarm = 0;

sys.suspend = false;

// Start Grbl main loop. Processes program inputs and executes them.

protocol_main_loop();

return 0; /* Never reached */

// NOTE: Checking paramater data, startup lines, and build info string should be done here,

// but it seems fairly redundant. Each of these can be manually checked and reset or
restored.

// Check all parameter data into a dummy variable. If error, reset to zero, otherwise do
nothing.

// float coord_data[N_AXIS];

// uint8_t i;

// for (i=0; i<=SETTING_INDEX_NCOORD; i++) {

// if (!settings_read_coord_data(i, coord_data)) {

// report_status_message(STATUS_SETTING_READ_FAIL);

// }

// }

// NOTE: Startup lines are checked and executed by protocol_main_loop at the end of
initialization.

}
// Returns step pin mask according to Grbl internal axis indexing.

uint8_t get_step_pin_mask(uint8_t axis_idx)

if ( axis_idx == X_AXIS ) { return((1<<X_STEP_BIT)); }

if ( axis_idx == Y_AXIS ) { return((1<<Y_STEP_BIT)); }

return((1<<Z_STEP_BIT));

// Returns direction pin mask according to Grbl internal axis indexing.

uint8_t get_direction_pin_mask(uint8_t axis_idx)

if ( axis_idx == X_AXIS ) { return((1<<X_DIRECTION_BIT)); }

if ( axis_idx == Y_AXIS ) { return((1<<Y_DIRECTION_BIT)); }

return((1<<Z_DIRECTION_BIT));

// Returns limit pin mask according to Grbl internal axis indexing.

uint8_t get_limit_pin_mask(uint8_t axis_idx)

if ( axis_idx == X_AXIS ) { return((1<<X_LIMIT_BIT)); }

if ( axis_idx == Y_AXIS ) { return((1<<Y_LIMIT_BIT)); }

return((1<<Z_LIMIT_BIT));

}
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/>.

*/

#ifndef limits_h

#define limits_h
// Initialize the limits module

void limits_init();

// Disables hard limits.

void limits_disable();

// Returns limit state as a bit-wise uint8 variable.

uint8_t limits_get_state();

// Perform one portion of the homing cycle based on the input settings.

void limits_go_home(uint8_t cycle_mask);

// Check for soft limit violations

void limits_soft_check(float *target);

#endif

You might also like