|
|
|
@ -198,6 +198,9 @@ int EtoPPressure=0;
|
|
|
|
|
//===========================================================================
|
|
|
|
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
|
|
|
|
static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
|
|
|
#ifdef DELTA
|
|
|
|
|
static float delta[3] = {0.0, 0.0, 0.0};
|
|
|
|
|
#endif
|
|
|
|
|
static float offset[3] = {0.0, 0.0, 0.0};
|
|
|
|
|
static bool home_all_axis = true;
|
|
|
|
|
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
|
|
|
@ -806,8 +809,8 @@ void process_commands()
|
|
|
|
|
destination[i] = current_position[i];
|
|
|
|
|
}
|
|
|
|
|
feedrate = 0.0;
|
|
|
|
|
home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
|
|
|
|
|
|
|
|
|
|
home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])))
|
|
|
|
|
|| ((code_seen(axis_codes[0])) && (code_seen(axis_codes[1])) && (code_seen(axis_codes[2])));
|
|
|
|
|
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
|
|
|
|
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
|
|
|
|
HOMEAXIS(Z);
|
|
|
|
@ -836,6 +839,10 @@ void process_commands()
|
|
|
|
|
feedrate = 0.0;
|
|
|
|
|
st_synchronize();
|
|
|
|
|
endstops_hit_on_purpose();
|
|
|
|
|
|
|
|
|
|
current_position[X_AXIS] = destination[X_AXIS];
|
|
|
|
|
current_position[Y_AXIS] = destination[Y_AXIS];
|
|
|
|
|
current_position[Z_AXIS] = destination[Z_AXIS];
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -847,14 +854,14 @@ void process_commands()
|
|
|
|
|
if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
|
|
|
|
|
HOMEAXIS(Y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if Z_HOME_DIR < 0 // If homing towards BED do Z last
|
|
|
|
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
|
|
|
|
HOMEAXIS(Z);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if(code_seen(axis_codes[X_AXIS]))
|
|
|
|
|
|
|
|
|
|
if(code_seen(axis_codes[X_AXIS]))
|
|
|
|
|
{
|
|
|
|
|
if(code_value_long() != 0) {
|
|
|
|
|
current_position[X_AXIS]=code_value()+add_homeing[0];
|
|
|
|
@ -872,8 +879,12 @@ void process_commands()
|
|
|
|
|
current_position[Z_AXIS]=code_value()+add_homeing[2];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
|
|
|
|
|
|
|
#ifdef DELTA
|
|
|
|
|
calculate_delta(current_position);
|
|
|
|
|
plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
|
|
|
|
|
#else
|
|
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef ENDSTOPS_ONLY_FOR_HOMING
|
|
|
|
|
enable_endstops(false);
|
|
|
|
|
#endif
|
|
|
|
@ -2051,11 +2062,64 @@ void clamp_to_software_endstops(float target[3])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DELTA
|
|
|
|
|
void calculate_delta(float cartesian[3])
|
|
|
|
|
{
|
|
|
|
|
delta[X_AXIS] = sqrt(sq(DELTA_DIAGONAL_ROD)
|
|
|
|
|
- sq(DELTA_TOWER1_X-cartesian[X_AXIS])
|
|
|
|
|
- sq(DELTA_TOWER1_Y-cartesian[Y_AXIS])
|
|
|
|
|
) + cartesian[Z_AXIS];
|
|
|
|
|
delta[Y_AXIS] = sqrt(sq(DELTA_DIAGONAL_ROD)
|
|
|
|
|
- sq(DELTA_TOWER2_X-cartesian[X_AXIS])
|
|
|
|
|
- sq(DELTA_TOWER2_Y-cartesian[Y_AXIS])
|
|
|
|
|
) + cartesian[Z_AXIS];
|
|
|
|
|
delta[Z_AXIS] = sqrt(sq(DELTA_DIAGONAL_ROD)
|
|
|
|
|
- sq(DELTA_TOWER3_X-cartesian[X_AXIS])
|
|
|
|
|
- sq(DELTA_TOWER3_Y-cartesian[Y_AXIS])
|
|
|
|
|
) + cartesian[Z_AXIS];
|
|
|
|
|
/*
|
|
|
|
|
SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);
|
|
|
|
|
SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]);
|
|
|
|
|
SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]);
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]);
|
|
|
|
|
SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]);
|
|
|
|
|
SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]);
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void prepare_move()
|
|
|
|
|
{
|
|
|
|
|
clamp_to_software_endstops(destination);
|
|
|
|
|
|
|
|
|
|
previous_millis_cmd = millis();
|
|
|
|
|
#ifdef DELTA
|
|
|
|
|
float difference[NUM_AXIS];
|
|
|
|
|
for (int8_t i=0; i < NUM_AXIS; i++) {
|
|
|
|
|
difference[i] = destination[i] - current_position[i];
|
|
|
|
|
}
|
|
|
|
|
float cartesian_mm = sqrt(sq(difference[X_AXIS]) +
|
|
|
|
|
sq(difference[Y_AXIS]) +
|
|
|
|
|
sq(difference[Z_AXIS]));
|
|
|
|
|
if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); }
|
|
|
|
|
if (cartesian_mm < 0.000001) { return; }
|
|
|
|
|
float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
|
|
|
|
|
int steps = max(1, int(DELTA_SEGMENTS_PER_SECOND * seconds));
|
|
|
|
|
// SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
|
|
|
|
|
// SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds);
|
|
|
|
|
// SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps);
|
|
|
|
|
for (int s = 1; s <= steps; s++) {
|
|
|
|
|
float fraction = float(s) / float(steps);
|
|
|
|
|
for(int8_t i=0; i < NUM_AXIS; i++) {
|
|
|
|
|
destination[i] = current_position[i] + difference[i] * fraction;
|
|
|
|
|
}
|
|
|
|
|
calculate_delta(destination);
|
|
|
|
|
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],
|
|
|
|
|
destination[E_AXIS], feedrate*feedmultiply/60/100.0,
|
|
|
|
|
active_extruder);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
// Do not use feedmultiply for E or Z only moves
|
|
|
|
|
if( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
|
|
|
|
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
|
|
@ -2063,6 +2127,7 @@ void prepare_move()
|
|
|
|
|
else {
|
|
|
|
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
for(int8_t i=0; i < NUM_AXIS; i++) {
|
|
|
|
|
current_position[i] = destination[i];
|
|
|
|
|
}
|
|
|
|
@ -2305,4 +2370,5 @@ bool setTargetedHotend(int code){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|