axis_steps_per_unit => axis_steps_per_mm

2.0.x
Scott Lahteine 9 years ago
parent 446515ab79
commit 72c6f2923f

@ -426,7 +426,7 @@
*/
#if ENABLED(ADVANCE)
#define EXTRUSION_AREA (0.25 * (D_FILAMENT) * (D_FILAMENT) * M_PI)
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS] / (EXTRUSION_AREA))
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_mm[E_AXIS] / (EXTRUSION_AREA))
#endif
#if ENABLED(ULTIPANEL) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)

@ -156,7 +156,7 @@
* M84 - Disable steppers until next move,
* or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout.
* M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
* M92 - Set planner.axis_steps_per_unit - same syntax as G92
* M92 - Set planner.axis_steps_per_mm - same syntax as G92
* M104 - Set extruder target temp
* M105 - Read current temp
* M106 - Fan on
@ -1675,7 +1675,7 @@ static void setup_for_endstop_move() {
* is not where we said to go.
*/
long stop_steps = stepper.position(Z_AXIS);
float mm = start_z - float(start_steps - stop_steps) / planner.axis_steps_per_unit[Z_AXIS];
float mm = start_z - float(start_steps - stop_steps) / planner.axis_steps_per_mm[Z_AXIS];
current_position[Z_AXIS] = mm;
#if ENABLED(DEBUG_LEVELING_FEATURE)
@ -5147,15 +5147,15 @@ inline void gcode_M92() {
if (i == E_AXIS) {
float value = code_value_per_axis_unit(i);
if (value < 20.0) {
float factor = planner.axis_steps_per_unit[i] / value; // increase e constants if M92 E14 is given for netfab.
float factor = planner.axis_steps_per_mm[i] / value; // increase e constants if M92 E14 is given for netfab.
planner.max_e_jerk *= factor;
planner.max_feedrate[i] *= factor;
planner.max_acceleration_steps_per_s2[i] *= factor;
}
planner.axis_steps_per_unit[i] = value;
planner.axis_steps_per_mm[i] = value;
}
else {
planner.axis_steps_per_unit[i] = code_value_per_axis_unit(i);
planner.axis_steps_per_mm[i] = code_value_per_axis_unit(i);
}
}
}
@ -5190,9 +5190,9 @@ static void report_current_position() {
SERIAL_EOL;
SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:");
SERIAL_PROTOCOL(delta[X_AXIS] / 90 * planner.axis_steps_per_unit[X_AXIS]);
SERIAL_PROTOCOL(delta[X_AXIS] / 90 * planner.axis_steps_per_mm[X_AXIS]);
SERIAL_PROTOCOLPGM(" Psi+Theta:");
SERIAL_PROTOCOL((delta[Y_AXIS] - delta[X_AXIS]) / 90 * planner.axis_steps_per_unit[Y_AXIS]);
SERIAL_PROTOCOL((delta[Y_AXIS] - delta[X_AXIS]) / 90 * planner.axis_steps_per_mm[Y_AXIS]);
SERIAL_EOL; SERIAL_EOL;
#endif
}
@ -5347,7 +5347,7 @@ inline void gcode_M201() {
#if 0 // Not used for Sprinter/grbl gen6
inline void gcode_M202() {
for (int8_t i = 0; i < NUM_AXIS; i++) {
if (code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value_axis_units(i) * planner.axis_steps_per_unit[i];
if (code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value_axis_units(i) * planner.axis_steps_per_mm[i];
}
}
#endif
@ -8209,8 +8209,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
}
float oldepos = current_position[E_AXIS], oldedes = destination[E_AXIS];
planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS],
destination[E_AXIS] + (EXTRUDER_RUNOUT_EXTRUDE) * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_unit[E_AXIS],
(EXTRUDER_RUNOUT_SPEED) / 60. * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_unit[E_AXIS], active_extruder);
destination[E_AXIS] + (EXTRUDER_RUNOUT_EXTRUDE) * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_mm[E_AXIS],
(EXTRUDER_RUNOUT_SPEED) / 60. * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_mm[E_AXIS], active_extruder);
current_position[E_AXIS] = oldepos;
destination[E_AXIS] = oldedes;
planner.set_e_position_mm(oldepos);

@ -43,7 +43,7 @@
*
* 100 Version (char x4)
*
* 104 M92 XYZE planner.axis_steps_per_unit (float x4)
* 104 M92 XYZE planner.axis_steps_per_mm (float x4)
* 120 M203 XYZE planner.max_feedrate (float x4)
* 136 M201 XYZE planner.max_acceleration_mm_per_s2 (uint32_t x4)
* 152 M204 P planner.acceleration (float)
@ -173,7 +173,7 @@ void Config_StoreSettings() {
char ver[4] = "000";
int i = EEPROM_OFFSET;
EEPROM_WRITE_VAR(i, ver); // invalidate data first
EEPROM_WRITE_VAR(i, planner.axis_steps_per_unit);
EEPROM_WRITE_VAR(i, planner.axis_steps_per_mm);
EEPROM_WRITE_VAR(i, planner.max_feedrate);
EEPROM_WRITE_VAR(i, planner.max_acceleration_mm_per_s2);
EEPROM_WRITE_VAR(i, planner.acceleration);
@ -353,7 +353,7 @@ void Config_RetrieveSettings() {
float dummy = 0;
// version number match
EEPROM_READ_VAR(i, planner.axis_steps_per_unit);
EEPROM_READ_VAR(i, planner.axis_steps_per_mm);
EEPROM_READ_VAR(i, planner.max_feedrate);
EEPROM_READ_VAR(i, planner.max_acceleration_mm_per_s2);
@ -527,7 +527,7 @@ void Config_ResetDefault() {
float tmp2[] = DEFAULT_MAX_FEEDRATE;
long tmp3[] = DEFAULT_MAX_ACCELERATION;
for (uint8_t i = 0; i < NUM_AXIS; i++) {
planner.axis_steps_per_unit[i] = tmp1[i];
planner.axis_steps_per_mm[i] = tmp1[i];
planner.max_feedrate[i] = tmp2[i];
planner.max_acceleration_mm_per_s2[i] = tmp3[i];
#if ENABLED(SCARA)
@ -652,10 +652,10 @@ void Config_PrintSettings(bool forReplay) {
SERIAL_ECHOLNPGM("Steps per unit:");
CONFIG_ECHO_START;
}
SERIAL_ECHOPAIR(" M92 X", planner.axis_steps_per_unit[X_AXIS]);
SERIAL_ECHOPAIR(" Y", planner.axis_steps_per_unit[Y_AXIS]);
SERIAL_ECHOPAIR(" Z", planner.axis_steps_per_unit[Z_AXIS]);
SERIAL_ECHOPAIR(" E", planner.axis_steps_per_unit[E_AXIS]);
SERIAL_ECHOPAIR(" M92 X", planner.axis_steps_per_mm[X_AXIS]);
SERIAL_ECHOPAIR(" Y", planner.axis_steps_per_mm[Y_AXIS]);
SERIAL_ECHOPAIR(" Z", planner.axis_steps_per_mm[Z_AXIS]);
SERIAL_ECHOPAIR(" E", planner.axis_steps_per_mm[E_AXIS]);
SERIAL_EOL;
CONFIG_ECHO_START;

@ -81,7 +81,7 @@ volatile uint8_t Planner::block_buffer_head = 0; // Index of the next
volatile uint8_t Planner::block_buffer_tail = 0;
float Planner::max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
float Planner::axis_steps_per_unit[NUM_AXIS];
float Planner::axis_steps_per_mm[NUM_AXIS];
unsigned long Planner::max_acceleration_steps_per_s2[NUM_AXIS];
unsigned long Planner::max_acceleration_mm_per_s2[NUM_AXIS]; // Use M201 to override by software
@ -549,10 +549,10 @@ void Planner::check_axes_activity() {
// Calculate target position in absolute steps
//this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
long target[NUM_AXIS] = {
lround(x * axis_steps_per_unit[X_AXIS]),
lround(y * axis_steps_per_unit[Y_AXIS]),
lround(z * axis_steps_per_unit[Z_AXIS]),
lround(e * axis_steps_per_unit[E_AXIS])
lround(x * axis_steps_per_mm[X_AXIS]),
lround(y * axis_steps_per_mm[Y_AXIS]),
lround(z * axis_steps_per_mm[Z_AXIS]),
lround(e * axis_steps_per_mm[E_AXIS])
};
long dx = target[X_AXIS] - position[X_AXIS],
@ -574,7 +574,7 @@ void Planner::check_axes_activity() {
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
}
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
if (labs(de) > axis_steps_per_unit[E_AXIS] * (EXTRUDE_MAXLENGTH)) {
if (labs(de) > axis_steps_per_mm[E_AXIS] * (EXTRUDE_MAXLENGTH)) {
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
de = 0; // no difference
SERIAL_ECHO_START;
@ -771,31 +771,31 @@ void Planner::check_axes_activity() {
#if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
float delta_mm[6];
#if ENABLED(COREXY)
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_unit[A_AXIS];
delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_unit[B_AXIS];
delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
delta_mm[Y_HEAD] = dy / axis_steps_per_mm[B_AXIS];
delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_mm[A_AXIS];
delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_mm[B_AXIS];
#elif ENABLED(COREXZ)
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_unit[A_AXIS];
delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_unit[C_AXIS];
delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_mm[A_AXIS];
delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_mm[C_AXIS];
#elif ENABLED(COREYZ)
delta_mm[X_AXIS] = dx / axis_steps_per_unit[A_AXIS];
delta_mm[Y_HEAD] = dy / axis_steps_per_unit[Y_AXIS];
delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_unit[B_AXIS];
delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_unit[C_AXIS];
delta_mm[X_AXIS] = dx / axis_steps_per_mm[A_AXIS];
delta_mm[Y_HEAD] = dy / axis_steps_per_mm[Y_AXIS];
delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_mm[B_AXIS];
delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_mm[C_AXIS];
#endif
#else
float delta_mm[4];
delta_mm[X_AXIS] = dx / axis_steps_per_unit[X_AXIS];
delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
delta_mm[X_AXIS] = dx / axis_steps_per_mm[X_AXIS];
delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
#endif
delta_mm[E_AXIS] = (de / axis_steps_per_unit[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
delta_mm[E_AXIS] = (de / axis_steps_per_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
block->millimeters = fabs(delta_mm[E_AXIS]);
@ -1127,10 +1127,10 @@ void Planner::check_axes_activity() {
apply_rotation_xyz(bed_level_matrix, x, y, z);
#endif
long nx = position[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]),
ny = position[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]),
nz = position[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]),
ne = position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]);
long nx = position[X_AXIS] = lround(x * axis_steps_per_mm[X_AXIS]),
ny = position[Y_AXIS] = lround(y * axis_steps_per_mm[Y_AXIS]),
nz = position[Z_AXIS] = lround(z * axis_steps_per_mm[Z_AXIS]),
ne = position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
stepper.set_position(nx, ny, nz, ne);
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
@ -1141,14 +1141,14 @@ void Planner::check_axes_activity() {
* Directly set the planner E position (hence the stepper E position).
*/
void Planner::set_e_position_mm(const float& e) {
position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]);
position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
stepper.set_e_position(position[E_AXIS]);
}
// Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
void Planner::reset_acceleration_rates() {
for (int i = 0; i < NUM_AXIS; i++)
max_acceleration_steps_per_s2[i] = max_acceleration_mm_per_s2[i] * axis_steps_per_unit[i];
max_acceleration_steps_per_s2[i] = max_acceleration_mm_per_s2[i] * axis_steps_per_mm[i];
}
#if ENABLED(AUTOTEMP)

@ -112,7 +112,7 @@ class Planner {
static volatile uint8_t block_buffer_tail;
static float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
static float axis_steps_per_unit[NUM_AXIS];
static float axis_steps_per_mm[NUM_AXIS];
static unsigned long max_acceleration_steps_per_s2[NUM_AXIS];
static unsigned long max_acceleration_mm_per_s2[NUM_AXIS]; // Use M201 to override by software
@ -134,7 +134,7 @@ class Planner {
/**
* The current position of the tool in absolute steps
* Reclculated if any axis_steps_per_unit are changed by gcode
* Reclculated if any axis_steps_per_mm are changed by gcode
*/
static long position[NUM_AXIS];
@ -212,7 +212,7 @@ class Planner {
* Set the planner.position and individual stepper positions.
* Used by G92, G28, G29, and other procedures.
*
* Multiplies by axis_steps_per_unit[] and does necessary conversion
* Multiplies by axis_steps_per_mm[] and does necessary conversion
* for COREXY / COREXZ / COREYZ to set the corresponding stepper positions.
*
* Clears previous speed values.

@ -754,7 +754,7 @@ float Stepper::get_axis_position_mm(AxisEnum axis) {
#else
axis_steps = position(axis);
#endif
return axis_steps / planner.axis_steps_per_unit[axis];
return axis_steps / planner.axis_steps_per_mm[axis];
}
void Stepper::finish_and_disable() {

@ -243,7 +243,7 @@ class Stepper {
// Triggered position of an axis in mm (not core-savvy)
//
static FORCE_INLINE float triggered_position_mm(AxisEnum axis) {
return endstops_trigsteps[axis] / planner.axis_steps_per_unit[axis];
return endstops_trigsteps[axis] / planner.axis_steps_per_mm[axis];
}
private:

@ -556,7 +556,7 @@ float Temperature::get_pid_output(int e) {
lpq[lpq_ptr++] = 0;
}
if (lpq_ptr >= lpq_len) lpq_ptr = 0;
cTerm[_CTERM_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_unit[E_AXIS]) * PID_PARAM(Kc, e);
cTerm[_CTERM_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_mm[E_AXIS]) * PID_PARAM(Kc, e);
pid_output += cTerm[e];
}
#endif //PID_ADD_EXTRUSION_RATE

@ -1692,14 +1692,14 @@ static void lcd_control_motion_menu() {
MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_acceleration_rates);
MENU_ITEM_EDIT(float5, MSG_A_RETRACT, &planner.retract_acceleration, 100, 99000);
MENU_ITEM_EDIT(float5, MSG_A_TRAVEL, &planner.travel_acceleration, 100, 99000);
MENU_ITEM_EDIT(float52, MSG_XSTEPS, &planner.axis_steps_per_unit[X_AXIS], 5, 9999);
MENU_ITEM_EDIT(float52, MSG_YSTEPS, &planner.axis_steps_per_unit[Y_AXIS], 5, 9999);
MENU_ITEM_EDIT(float52, MSG_XSTEPS, &planner.axis_steps_per_mm[X_AXIS], 5, 9999);
MENU_ITEM_EDIT(float52, MSG_YSTEPS, &planner.axis_steps_per_mm[Y_AXIS], 5, 9999);
#if ENABLED(DELTA)
MENU_ITEM_EDIT(float52, MSG_ZSTEPS, &planner.axis_steps_per_unit[Z_AXIS], 5, 9999);
MENU_ITEM_EDIT(float52, MSG_ZSTEPS, &planner.axis_steps_per_mm[Z_AXIS], 5, 9999);
#else
MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &planner.axis_steps_per_unit[Z_AXIS], 5, 9999);
MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &planner.axis_steps_per_mm[Z_AXIS], 5, 9999);
#endif
MENU_ITEM_EDIT(float51, MSG_ESTEPS, &planner.axis_steps_per_unit[E_AXIS], 5, 9999);
MENU_ITEM_EDIT(float51, MSG_ESTEPS, &planner.axis_steps_per_mm[E_AXIS], 5, 9999);
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &stepper.abort_on_endstop_hit);
#endif

Loading…
Cancel
Save