|
@@ -198,6 +198,9 @@ int EtoPPressure=0;
|
198
|
198
|
//===========================================================================
|
199
|
199
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
200
|
200
|
static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
201
|
+#ifdef DELTA
|
|
202
|
+static float delta[3] = {0.0, 0.0, 0.0};
|
|
203
|
+#endif
|
201
|
204
|
static float offset[3] = {0.0, 0.0, 0.0};
|
202
|
205
|
static bool home_all_axis = true;
|
203
|
206
|
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
|
@@ -806,8 +809,8 @@ void process_commands()
|
806
|
809
|
destination[i] = current_position[i];
|
807
|
810
|
}
|
808
|
811
|
feedrate = 0.0;
|
809
|
|
- home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
|
810
|
|
-
|
|
812
|
+ home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])))
|
|
813
|
+ || ((code_seen(axis_codes[0])) && (code_seen(axis_codes[1])) && (code_seen(axis_codes[2])));
|
811
|
814
|
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
|
812
|
815
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
813
|
816
|
HOMEAXIS(Z);
|
|
@@ -836,6 +839,10 @@ void process_commands()
|
836
|
839
|
feedrate = 0.0;
|
837
|
840
|
st_synchronize();
|
838
|
841
|
endstops_hit_on_purpose();
|
|
842
|
+
|
|
843
|
+ current_position[X_AXIS] = destination[X_AXIS];
|
|
844
|
+ current_position[Y_AXIS] = destination[Y_AXIS];
|
|
845
|
+ current_position[Z_AXIS] = destination[Z_AXIS];
|
839
|
846
|
}
|
840
|
847
|
#endif
|
841
|
848
|
|
|
@@ -847,14 +854,14 @@ void process_commands()
|
847
|
854
|
if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
|
848
|
855
|
HOMEAXIS(Y);
|
849
|
856
|
}
|
850
|
|
-
|
|
857
|
+
|
851
|
858
|
#if Z_HOME_DIR < 0 // If homing towards BED do Z last
|
852
|
859
|
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
|
853
|
860
|
HOMEAXIS(Z);
|
854
|
861
|
}
|
855
|
862
|
#endif
|
856
|
|
-
|
857
|
|
- if(code_seen(axis_codes[X_AXIS]))
|
|
863
|
+
|
|
864
|
+ if(code_seen(axis_codes[X_AXIS]))
|
858
|
865
|
{
|
859
|
866
|
if(code_value_long() != 0) {
|
860
|
867
|
current_position[X_AXIS]=code_value()+add_homeing[0];
|
|
@@ -872,8 +879,12 @@ void process_commands()
|
872
|
879
|
current_position[Z_AXIS]=code_value()+add_homeing[2];
|
873
|
880
|
}
|
874
|
881
|
}
|
875
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
876
|
|
-
|
|
882
|
+ #ifdef DELTA
|
|
883
|
+ calculate_delta(current_position);
|
|
884
|
+ plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
|
|
885
|
+ #else
|
|
886
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
887
|
+ #endif
|
877
|
888
|
#ifdef ENDSTOPS_ONLY_FOR_HOMING
|
878
|
889
|
enable_endstops(false);
|
879
|
890
|
#endif
|
|
@@ -2051,11 +2062,64 @@ void clamp_to_software_endstops(float target[3])
|
2051
|
2062
|
}
|
2052
|
2063
|
}
|
2053
|
2064
|
|
|
2065
|
+#ifdef DELTA
|
|
2066
|
+void calculate_delta(float cartesian[3])
|
|
2067
|
+{
|
|
2068
|
+ delta[X_AXIS] = sqrt(sq(DELTA_DIAGONAL_ROD)
|
|
2069
|
+ - sq(DELTA_TOWER1_X-cartesian[X_AXIS])
|
|
2070
|
+ - sq(DELTA_TOWER1_Y-cartesian[Y_AXIS])
|
|
2071
|
+ ) + cartesian[Z_AXIS];
|
|
2072
|
+ delta[Y_AXIS] = sqrt(sq(DELTA_DIAGONAL_ROD)
|
|
2073
|
+ - sq(DELTA_TOWER2_X-cartesian[X_AXIS])
|
|
2074
|
+ - sq(DELTA_TOWER2_Y-cartesian[Y_AXIS])
|
|
2075
|
+ ) + cartesian[Z_AXIS];
|
|
2076
|
+ delta[Z_AXIS] = sqrt(sq(DELTA_DIAGONAL_ROD)
|
|
2077
|
+ - sq(DELTA_TOWER3_X-cartesian[X_AXIS])
|
|
2078
|
+ - sq(DELTA_TOWER3_Y-cartesian[Y_AXIS])
|
|
2079
|
+ ) + cartesian[Z_AXIS];
|
|
2080
|
+ /*
|
|
2081
|
+ SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);
|
|
2082
|
+ SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]);
|
|
2083
|
+ SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]);
|
|
2084
|
+
|
|
2085
|
+ SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]);
|
|
2086
|
+ SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]);
|
|
2087
|
+ SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]);
|
|
2088
|
+ */
|
|
2089
|
+}
|
|
2090
|
+#endif
|
|
2091
|
+
|
2054
|
2092
|
void prepare_move()
|
2055
|
2093
|
{
|
2056
|
2094
|
clamp_to_software_endstops(destination);
|
2057
|
2095
|
|
2058
|
2096
|
previous_millis_cmd = millis();
|
|
2097
|
+#ifdef DELTA
|
|
2098
|
+ float difference[NUM_AXIS];
|
|
2099
|
+ for (int8_t i=0; i < NUM_AXIS; i++) {
|
|
2100
|
+ difference[i] = destination[i] - current_position[i];
|
|
2101
|
+ }
|
|
2102
|
+ float cartesian_mm = sqrt(sq(difference[X_AXIS]) +
|
|
2103
|
+ sq(difference[Y_AXIS]) +
|
|
2104
|
+ sq(difference[Z_AXIS]));
|
|
2105
|
+ if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); }
|
|
2106
|
+ if (cartesian_mm < 0.000001) { return; }
|
|
2107
|
+ float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
|
|
2108
|
+ int steps = max(1, int(DELTA_SEGMENTS_PER_SECOND * seconds));
|
|
2109
|
+ // SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
|
|
2110
|
+ // SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds);
|
|
2111
|
+ // SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps);
|
|
2112
|
+ for (int s = 1; s <= steps; s++) {
|
|
2113
|
+ float fraction = float(s) / float(steps);
|
|
2114
|
+ for(int8_t i=0; i < NUM_AXIS; i++) {
|
|
2115
|
+ destination[i] = current_position[i] + difference[i] * fraction;
|
|
2116
|
+ }
|
|
2117
|
+ calculate_delta(destination);
|
|
2118
|
+ plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],
|
|
2119
|
+ destination[E_AXIS], feedrate*feedmultiply/60/100.0,
|
|
2120
|
+ active_extruder);
|
|
2121
|
+ }
|
|
2122
|
+#else
|
2059
|
2123
|
// Do not use feedmultiply for E or Z only moves
|
2060
|
2124
|
if( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
|
2061
|
2125
|
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()
|
2063
|
2127
|
else {
|
2064
|
2128
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
2065
|
2129
|
}
|
|
2130
|
+#endif
|
2066
|
2131
|
for(int8_t i=0; i < NUM_AXIS; i++) {
|
2067
|
2132
|
current_position[i] = destination[i];
|
2068
|
2133
|
}
|
|
@@ -2305,4 +2370,5 @@ bool setTargetedHotend(int code){
|
2305
|
2370
|
}
|
2306
|
2371
|
}
|
2307
|
2372
|
return false;
|
2308
|
|
-}
|
|
2373
|
+}
|
|
2374
|
+
|