Lot of refactoring for the future. CoreXY support.
- Rudimentary CoreXY kinematics support. Didn’t test, but homing and feed holds should work. See config.h. Please report successes and issues as we find bugs. - G40 (disable cutter comp) is now “supported”. Meaning that Grbl will no longer issue an error when typically sent in g-code program header. - Refactored coolant and spindle state setting into separate functions for future features. - Configuration option for fixing homing behavior when there are two limit switches on the same axis sharing an input pin. - Created a new “grbl.h” that will eventually be used as the main include file for Grbl. Also will help simply uploading through the Arduino IDE - Separated out the alarms execution flags from the realtime (used be called runtime) execution flag variable. Now reports exactly what caused the alarm. Expandable for new alarms later on. - Refactored the homing cycle to support CoreXY. - Applied @EliteEng updates to Mega2560 support. Some pins were reconfigured. - Created a central step to position and vice versa function. Needed for non-traditional cartesian machines. Should make it easier later. - Removed the new CPU map for the Uno. No longer going to used. There will be only one configuration to keep things uniform.
This commit is contained in:
53
planner.c
53
planner.c
@ -2,7 +2,7 @@
|
||||
planner.c - buffers movement commands and manages the acceleration profile plan
|
||||
Part of Grbl v0.9
|
||||
|
||||
Copyright (c) 2012-2014 Sungeun K. Jeon
|
||||
Copyright (c) 2012-2015 Sungeun K. Jeon
|
||||
|
||||
Grbl is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -284,17 +284,36 @@ uint8_t plan_check_full_buffer()
|
||||
int32_t target_steps[N_AXIS];
|
||||
float unit_vec[N_AXIS], delta_mm;
|
||||
uint8_t idx;
|
||||
#ifdef COREXY
|
||||
target_steps[A_MOTOR] = lround(target[A_MOTOR]*settings.steps_per_mm[A_MOTOR]);
|
||||
target_steps[B_MOTOR] = lround(target[B_MOTOR]*settings.steps_per_mm[B_MOTOR]);
|
||||
block->steps[A_MOTOR] = labs((target_steps[X_AXIS]-pl.position[X_AXIS]) - (target_steps[Y_AXIS]-pl.position[Y_AXIS]));
|
||||
block->steps[B_MOTOR] = labs((target_steps[X_AXIS]-pl.position[X_AXIS]) + (target_steps[Y_AXIS]-pl.position[Y_AXIS]));
|
||||
#endif
|
||||
|
||||
for (idx=0; idx<N_AXIS; idx++) {
|
||||
// Calculate target position in absolute steps. This conversion should be consistent throughout.
|
||||
target_steps[idx] = lround(target[idx]*settings.steps_per_mm[idx]);
|
||||
|
||||
// Number of steps for each axis and determine max step events
|
||||
block->steps[idx] = labs(target_steps[idx]-pl.position[idx]);
|
||||
block->step_event_count = max(block->step_event_count, block->steps[idx]);
|
||||
|
||||
// Compute individual axes distance for move and prep unit vector calculations.
|
||||
// Calculate target position in absolute steps, number of steps for each axis, and determine max step events.
|
||||
// Also, compute individual axes distance for move and prep unit vector calculations.
|
||||
// NOTE: Computes true distance from converted step values.
|
||||
delta_mm = (target_steps[idx] - pl.position[idx])/settings.steps_per_mm[idx];
|
||||
#ifdef COREXY
|
||||
if ( !(idx == A_MOTOR) && !(idx == B_MOTOR) ) {
|
||||
target_steps[idx] = lround(target[idx]*settings.steps_per_mm[idx]);
|
||||
block->steps[idx] = labs(target_steps[idx]-pl.position[idx]);
|
||||
}
|
||||
block->step_event_count = max(block->step_event_count, block->steps[idx]);
|
||||
if (idx == A_MOTOR) {
|
||||
delta_mm = ((target_steps[X_AXIS]-pl.position[X_AXIS]) - (target_steps[Y_AXIS]-pl.position[Y_AXIS]))/settings.steps_per_mm[idx];
|
||||
} else if (idx == B_MOTOR) {
|
||||
delta_mm = ((target_steps[X_AXIS]-pl.position[X_AXIS]) + (target_steps[Y_AXIS]-pl.position[Y_AXIS]))/settings.steps_per_mm[idx];
|
||||
} else {
|
||||
delta_mm = (target_steps[idx] - pl.position[idx])/settings.steps_per_mm[idx];
|
||||
}
|
||||
#else
|
||||
target_steps[idx] = lround(target[idx]*settings.steps_per_mm[idx]);
|
||||
block->steps[idx] = labs(target_steps[idx]-pl.position[idx]);
|
||||
block->step_event_count = max(block->step_event_count, block->steps[idx]);
|
||||
delta_mm = (target_steps[idx] - pl.position[idx])/settings.steps_per_mm[idx];
|
||||
#endif
|
||||
unit_vec[idx] = delta_mm; // Store unit vector numerator. Denominator computed later.
|
||||
|
||||
// Set direction bits. Bit enabled always means direction is negative.
|
||||
@ -403,9 +422,21 @@ uint8_t plan_check_full_buffer()
|
||||
// Reset the planner position vectors. Called by the system abort/initialization routine.
|
||||
void plan_sync_position()
|
||||
{
|
||||
// TODO: For motor configurations not in the same coordinate frame as the machine position,
|
||||
// this function needs to be updated to accomodate the difference.
|
||||
uint8_t idx;
|
||||
for (idx=0; idx<N_AXIS; idx++) {
|
||||
pl.position[idx] = sys.position[idx];
|
||||
#ifdef COREXY
|
||||
if (idx==A_MOTOR) {
|
||||
pl.position[idx] = (sys.position[A_MOTOR] + sys.position[B_MOTOR])/2;
|
||||
} else if (idx==B_MOTOR) {
|
||||
pl.position[idx] = (sys.position[A_MOTOR] - sys.position[B_MOTOR])/2;
|
||||
} else {
|
||||
pl.position[idx] = sys.position[idx];
|
||||
}
|
||||
#else
|
||||
pl.position[idx] = sys.position[idx];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user