Browse Source

Merge branch 'deltabot' into Marlin_v1

Erik van der Zalm 11 years ago
parent
commit
6f4a6e531c
3 changed files with 120 additions and 12 deletions
  1. 43
    4
      Marlin/Configuration.h
  2. 3
    0
      Marlin/Marlin.h
  3. 74
    8
      Marlin/Marlin_main.cpp

+ 43
- 4
Marlin/Configuration.h View File

63
 
63
 
64
 #define POWER_SUPPLY 1
64
 #define POWER_SUPPLY 1
65
 
65
 
66
+
67
+//===========================================================================
68
+//============================== Delta Settings =============================
69
+//===========================================================================
70
+// Enable DELTA kinematics
71
+#define DELTA
72
+
73
+// Make delta curves from many straight lines (linear interpolation).
74
+// This is a trade-off between visible corners (not enough segments)
75
+// and processor overload (too many expensive sqrt calls).
76
+#define DELTA_SEGMENTS_PER_SECOND 200
77
+
78
+// Center-to-center distance of the holes in the diagonal push rods.
79
+#define DELTA_DIAGONAL_ROD 250.0 // mm
80
+
81
+// Horizontal offset from middle of printer to smooth rod center.
82
+#define DELTA_SMOOTH_ROD_OFFSET 175.0 // mm
83
+
84
+// Horizontal offset of the universal joints on the end effector.
85
+#define DELTA_EFFECTOR_OFFSET 33.0 // mm
86
+
87
+// Horizontal offset of the universal joints on the carriages.
88
+#define DELTA_CARRIAGE_OFFSET 18.0 // mm
89
+
90
+// Effective horizontal distance bridged by diagonal push rods.
91
+#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET)
92
+
93
+// Effective X/Y positions of the three vertical towers.
94
+#define SIN_60 0.8660254037844386
95
+#define COS_60 0.5
96
+#define DELTA_TOWER1_X -SIN_60*DELTA_RADIUS // front left tower
97
+#define DELTA_TOWER1_Y -COS_60*DELTA_RADIUS
98
+#define DELTA_TOWER2_X SIN_60*DELTA_RADIUS // front right tower
99
+#define DELTA_TOWER2_Y -COS_60*DELTA_RADIUS
100
+#define DELTA_TOWER3_X 0.0 // back middle tower
101
+#define DELTA_TOWER3_Y DELTA_RADIUS
102
+
66
 //===========================================================================
103
 //===========================================================================
67
 //=============================Thermal Settings  ============================
104
 //=============================Thermal Settings  ============================
68
 //===========================================================================
105
 //===========================================================================
128
 // PID settings:
165
 // PID settings:
129
 // Comment the following line to disable PID and enable bang-bang.
166
 // Comment the following line to disable PID and enable bang-bang.
130
 #define PIDTEMP
167
 #define PIDTEMP
131
-#define BANG_MAX 256 // limits current to nozzle while in bang-bang mode; 256=full current
132
-#define PID_MAX 256 // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 256=full current
168
+#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current
169
+#define PID_MAX 255 // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
133
 #ifdef PIDTEMP
170
 #ifdef PIDTEMP
134
   //#define PID_DEBUG // Sends debug data to the serial port.
171
   //#define PID_DEBUG // Sends debug data to the serial port.
135
   //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
172
   //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
172
 
209
 
173
 // This sets the max power delived to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option.
210
 // This sets the max power delived to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option.
174
 // all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
211
 // all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
175
-// setting this to anything other than 256 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did,
212
+// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did,
176
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
213
 // so you shouldn't use it unless you are OK with PWM on your bed.  (see the comment on enabling PIDTEMPBED)
177
-#define MAX_BED_POWER 256 // limits duty cycle to bed; 256=full current
214
+#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
178
 
215
 
179
 #ifdef PIDTEMPBED
216
 #ifdef PIDTEMPBED
180
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
217
 //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
287
 //#define BED_CENTER_AT_0_0  // If defined, the center of the bed is at (X=0, Y=0)
324
 //#define BED_CENTER_AT_0_0  // If defined, the center of the bed is at (X=0, Y=0)
288
 
325
 
289
 //Manual homing switch locations:
326
 //Manual homing switch locations:
327
+// For deltabots this means top and center of the cartesian print volume.
290
 #define MANUAL_X_HOME_POS 0
328
 #define MANUAL_X_HOME_POS 0
291
 #define MANUAL_Y_HOME_POS 0
329
 #define MANUAL_Y_HOME_POS 0
292
 #define MANUAL_Z_HOME_POS 0
330
 #define MANUAL_Z_HOME_POS 0
331
+//#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
293
 
332
 
294
 //// MOVEMENT SETTINGS
333
 //// MOVEMENT SETTINGS
295
 #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
334
 #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E

+ 3
- 0
Marlin/Marlin.h View File

157
 void ClearToSend();
157
 void ClearToSend();
158
 
158
 
159
 void get_coordinates();
159
 void get_coordinates();
160
+#ifdef DELTA
161
+void calculate_delta(float cartesian[3]);
162
+#endif
160
 void prepare_move();
163
 void prepare_move();
161
 void kill();
164
 void kill();
162
 void Stop();
165
 void Stop();

+ 74
- 8
Marlin/Marlin_main.cpp View File

198
 //===========================================================================
198
 //===========================================================================
199
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
199
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
200
 static float destination[NUM_AXIS] = {  0.0, 0.0, 0.0, 0.0};
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
 static float offset[3] = {0.0, 0.0, 0.0};
204
 static float offset[3] = {0.0, 0.0, 0.0};
202
 static bool home_all_axis = true;
205
 static bool home_all_axis = true;
203
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
206
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
806
         destination[i] = current_position[i];
809
         destination[i] = current_position[i];
807
       }
810
       }
808
       feedrate = 0.0;
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
       #if Z_HOME_DIR > 0                      // If homing away from BED do Z first
814
       #if Z_HOME_DIR > 0                      // If homing away from BED do Z first
812
       if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
815
       if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
813
         HOMEAXIS(Z);
816
         HOMEAXIS(Z);
836
         feedrate = 0.0;
839
         feedrate = 0.0;
837
         st_synchronize();
840
         st_synchronize();
838
         endstops_hit_on_purpose();
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
       #endif
847
       #endif
841
 
848
 
847
       if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
854
       if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
848
         HOMEAXIS(Y);
855
         HOMEAXIS(Y);
849
       }
856
       }
850
-
857
+      
851
       #if Z_HOME_DIR < 0                      // If homing towards BED do Z last
858
       #if Z_HOME_DIR < 0                      // If homing towards BED do Z last
852
       if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
859
       if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
853
         HOMEAXIS(Z);
860
         HOMEAXIS(Z);
854
       }
861
       }
855
       #endif
862
       #endif
856
-
857
-      if(code_seen(axis_codes[X_AXIS]))
863
+      
864
+      if(code_seen(axis_codes[X_AXIS])) 
858
       {
865
       {
859
         if(code_value_long() != 0) {
866
         if(code_value_long() != 0) {
860
           current_position[X_AXIS]=code_value()+add_homeing[0];
867
           current_position[X_AXIS]=code_value()+add_homeing[0];
872
           current_position[Z_AXIS]=code_value()+add_homeing[2];
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
       #ifdef ENDSTOPS_ONLY_FOR_HOMING
888
       #ifdef ENDSTOPS_ONLY_FOR_HOMING
878
         enable_endstops(false);
889
         enable_endstops(false);
879
       #endif
890
       #endif
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
 void prepare_move()
2092
 void prepare_move()
2055
 {
2093
 {
2056
   clamp_to_software_endstops(destination);
2094
   clamp_to_software_endstops(destination);
2057
 
2095
 
2058
   previous_millis_cmd = millis();
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
   // Do not use feedmultiply for E or Z only moves
2123
   // Do not use feedmultiply for E or Z only moves
2060
   if( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
2124
   if( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
2061
       plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
2125
       plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
2063
   else {
2127
   else {
2064
     plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
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
   for(int8_t i=0; i < NUM_AXIS; i++) {
2131
   for(int8_t i=0; i < NUM_AXIS; i++) {
2067
     current_position[i] = destination[i];
2132
     current_position[i] = destination[i];
2068
   }
2133
   }
2305
     }
2370
     }
2306
   }
2371
   }
2307
   return false;
2372
   return false;
2308
-}
2373
+}
2374
+

Loading…
Cancel
Save