|
|
@ -198,6 +198,9 @@ int EtoPPressure=0;
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
|
|
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
|
|
|
static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
|
|
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 float offset[3] = {0.0, 0.0, 0.0};
|
|
|
|
static bool home_all_axis = true;
|
|
|
|
static bool home_all_axis = true;
|
|
|
|
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
|
|
|
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
|
|
@ -836,6 +839,10 @@ void process_commands()
|
|
|
|
feedrate = 0.0;
|
|
|
|
feedrate = 0.0;
|
|
|
|
st_synchronize();
|
|
|
|
st_synchronize();
|
|
|
|
endstops_hit_on_purpose();
|
|
|
|
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
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
@ -872,8 +879,12 @@ void process_commands()
|
|
|
|
current_position[Z_AXIS]=code_value()+add_homeing[2];
|
|
|
|
current_position[Z_AXIS]=code_value()+add_homeing[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#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]);
|
|
|
|
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
|
|
|
|
#ifdef ENDSTOPS_ONLY_FOR_HOMING
|
|
|
|
enable_endstops(false);
|
|
|
|
enable_endstops(false);
|
|
|
|
#endif
|
|
|
|
#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()
|
|
|
|
void prepare_move()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
clamp_to_software_endstops(destination);
|
|
|
|
clamp_to_software_endstops(destination);
|
|
|
|
|
|
|
|
|
|
|
|
previous_millis_cmd = millis();
|
|
|
|
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
|
|
|
|
// 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])) {
|
|
|
|
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);
|
|
|
|
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 {
|
|
|
|
else {
|
|
|
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
|
|
|
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++) {
|
|
|
|
for(int8_t i=0; i < NUM_AXIS; i++) {
|
|
|
|
current_position[i] = destination[i];
|
|
|
|
current_position[i] = destination[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2306,3 +2371,4 @@ bool setTargetedHotend(int code){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|