Переглянути джерело

Trim Adjustments for Delta Configurations

Shane Francis 9 роки тому
джерело
коміт
4c8330c15c
2 змінених файлів з 72 додано та 35 видалено
  1. 32
    15
      Marlin/Marlin.h
  2. 40
    20
      Marlin/Marlin_main.cpp

+ 32
- 15
Marlin/Marlin.h Переглянути файл

@@ -260,23 +260,40 @@ extern float min_pos[3]; // axis[n].min_pos
260 260
 extern float max_pos[3]; // axis[n].max_pos
261 261
 extern bool axis_known_position[3]; // axis[n].is_known
262 262
 
263
-#if ENABLED(DELTA) || ENABLED(SCARA)
263
+#if ENABLED(DELTA)
264
+  extern float delta[3];
265
+  extern float endstop_adj[3]; // axis[n].endstop_adj
266
+  extern float delta_radius;
267
+  #ifndef DELTA_RADIUS_TRIM_TOWER_1
268
+    #define DELTA_RADIUS_TRIM_TOWER_1 0.0
269
+  #endif
270
+  #ifndef DELTA_RADIUS_TRIM_TOWER_2
271
+    #define DELTA_RADIUS_TRIM_TOWER_2 0.0
272
+  #endif
273
+  #ifndef DELTA_RADIUS_TRIM_TOWER_3
274
+    #define DELTA_RADIUS_TRIM_TOWER_3 0.0
275
+  #endif
276
+  extern float delta_diagonal_rod;
277
+  #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER_1
278
+    #define DELTA_DIAGONAL_ROD_TRIM_TOWER_1 0.0
279
+  #endif
280
+  #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER_2
281
+    #define DELTA_DIAGONAL_ROD_TRIM_TOWER_2 0.0
282
+  #endif
283
+  #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER_3
284
+    #define DELTA_DIAGONAL_ROD_TRIM_TOWER_3 0.0
285
+  #endif
286
+  extern float delta_segments_per_second;
264 287
   void calculate_delta(float cartesian[3]);
265
-  #if ENABLED(DELTA)
266
-    extern float delta[3];
267
-    extern float endstop_adj[3]; // axis[n].endstop_adj
268
-    extern float delta_radius;
269
-    extern float delta_diagonal_rod;
270
-    extern float delta_segments_per_second;
271
-    void recalc_delta_settings(float radius, float diagonal_rod);
272
-    #if ENABLED(AUTO_BED_LEVELING_FEATURE)
273
-      extern int delta_grid_spacing[2];
274
-      void adjust_delta(float cartesian[3]);
275
-    #endif
276
-  #elif ENABLED(SCARA)
277
-    extern float axis_scaling[3];  // Build size scaling
278
-    void calculate_SCARA_forward_Transform(float f_scara[3]);
288
+  void recalc_delta_settings(float radius, float diagonal_rod);
289
+  #if ENABLED(AUTO_BED_LEVELING_FEATURE)
290
+    extern int delta_grid_spacing[2];
291
+    void adjust_delta(float cartesian[3]);
279 292
   #endif
293
+#elif ENABLED(SCARA)
294
+  extern float axis_scaling[3];  // Build size scaling
295
+  void calculate_delta(float cartesian[3]);
296
+  void calculate_SCARA_forward_Transform(float f_scara[3]);
280 297
 #endif
281 298
 
282 299
 #if ENABLED(Z_DUAL_ENDSTOPS)

+ 40
- 20
Marlin/Marlin_main.cpp Переглянути файл

@@ -351,20 +351,31 @@ bool target_direction;
351 351
 #endif
352 352
 
353 353
 #if ENABLED(DELTA)
354
+
355
+  #define TOWER_1 X_AXIS
356
+  #define TOWER_2 Y_AXIS
357
+  #define TOWER_3 Z_AXIS
358
+
354 359
   float delta[3] = { 0 };
355 360
   #define SIN_60 0.8660254037844386
356 361
   #define COS_60 0.5
357 362
   float endstop_adj[3] = { 0 };
358 363
   // these are the default values, can be overriden with M665
359 364
   float delta_radius = DELTA_RADIUS;
360
-  float delta_tower1_x = -SIN_60 * delta_radius; // front left tower
361
-  float delta_tower1_y = -COS_60 * delta_radius;
362
-  float delta_tower2_x =  SIN_60 * delta_radius; // front right tower
363
-  float delta_tower2_y = -COS_60 * delta_radius;
364
-  float delta_tower3_x = 0;                      // back middle tower
365
-  float delta_tower3_y = delta_radius;
365
+  float delta_tower1_x = -SIN_60 * (delta_radius + DELTA_RADIUS_TRIM_TOWER_1); // front left tower
366
+  float delta_tower1_y = -COS_60 * (delta_radius + DELTA_RADIUS_TRIM_TOWER_1);
367
+  float delta_tower2_x =  SIN_60 * (delta_radius + DELTA_RADIUS_TRIM_TOWER_2); // front right tower
368
+  float delta_tower2_y = -COS_60 * (delta_radius + DELTA_RADIUS_TRIM_TOWER_2);
369
+  float delta_tower3_x = 0;                                                    // back middle tower
370
+  float delta_tower3_y = (delta_radius + DELTA_RADIUS_TRIM_TOWER_3);
366 371
   float delta_diagonal_rod = DELTA_DIAGONAL_ROD;
367
-  float delta_diagonal_rod_2 = sq(delta_diagonal_rod);
372
+  float delta_diagonal_rod_trim_tower_1 = DELTA_DIAGONAL_ROD_TRIM_TOWER_1;
373
+  float delta_diagonal_rod_trim_tower_2 = DELTA_DIAGONAL_ROD_TRIM_TOWER_2;
374
+  float delta_diagonal_rod_trim_tower_3 = DELTA_DIAGONAL_ROD_TRIM_TOWER_3;
375
+  float delta_diagonal_rod_2_tower_1 = sq(delta_diagonal_rod + delta_diagonal_rod_trim_tower_1);
376
+  float delta_diagonal_rod_2_tower_2 = sq(delta_diagonal_rod + delta_diagonal_rod_trim_tower_2);
377
+  float delta_diagonal_rod_2_tower_3 = sq(delta_diagonal_rod + delta_diagonal_rod_trim_tower_3);
378
+  //float delta_diagonal_rod_2 = sq(delta_diagonal_rod);
368 379
   float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
369 380
   #if ENABLED(AUTO_BED_LEVELING_FEATURE)
370 381
     int delta_grid_spacing[2] = { 0, 0 };
@@ -4491,11 +4502,17 @@ inline void gcode_M206() {
4491 4502
    *    L = diagonal rod
4492 4503
    *    R = delta radius
4493 4504
    *    S = segments per second
4505
+   *    A = Alpha (Tower 1) diagonal rod trim
4506
+   *    B = Beta (Tower 2) diagonal rod trim
4507
+   *    C = Gamma (Tower 3) diagonal rod trim
4494 4508
    */
4495 4509
   inline void gcode_M665() {
4496 4510
     if (code_seen('L')) delta_diagonal_rod = code_value();
4497 4511
     if (code_seen('R')) delta_radius = code_value();
4498 4512
     if (code_seen('S')) delta_segments_per_second = code_value();
4513
+    if (code_seen('A')) delta_diagonal_rod_trim_tower_1 = code_value();
4514
+    if (code_seen('B')) delta_diagonal_rod_trim_tower_2 = code_value();
4515
+    if (code_seen('C')) delta_diagonal_rod_trim_tower_3 = code_value();
4499 4516
     recalc_delta_settings(delta_radius, delta_diagonal_rod);
4500 4517
   }
4501 4518
   /**
@@ -6249,25 +6266,28 @@ void clamp_to_software_endstops(float target[3]) {
6249 6266
 #if ENABLED(DELTA)
6250 6267
 
6251 6268
   void recalc_delta_settings(float radius, float diagonal_rod) {
6252
-    delta_tower1_x = -SIN_60 * radius;  // front left tower
6253
-    delta_tower1_y = -COS_60 * radius;
6254
-    delta_tower2_x =  SIN_60 * radius;  // front right tower
6255
-    delta_tower2_y = -COS_60 * radius;
6256
-    delta_tower3_x = 0.0;               // back middle tower
6257
-    delta_tower3_y = radius;
6258
-    delta_diagonal_rod_2 = sq(diagonal_rod);
6269
+    delta_tower1_x = -SIN_60 * (radius + DELTA_RADIUS_TRIM_TOWER_1);  // front left tower
6270
+    delta_tower1_y = -COS_60 * (radius + DELTA_RADIUS_TRIM_TOWER_1);
6271
+    delta_tower2_x =  SIN_60 * (radius + DELTA_RADIUS_TRIM_TOWER_2);  // front right tower
6272
+    delta_tower2_y = -COS_60 * (radius + DELTA_RADIUS_TRIM_TOWER_2);
6273
+    delta_tower3_x = 0.0;                                             // back middle tower
6274
+    delta_tower3_y = (radius + DELTA_RADIUS_TRIM_TOWER_3);
6275
+    delta_diagonal_rod_2_tower_1 = sq(delta_diagonal_rod + delta_diagonal_rod_trim_tower_1);
6276
+    delta_diagonal_rod_2_tower_2 = sq(delta_diagonal_rod + delta_diagonal_rod_trim_tower_2);
6277
+    delta_diagonal_rod_2_tower_3 = sq(delta_diagonal_rod + delta_diagonal_rod_trim_tower_3);
6259 6278
   }
6260 6279
 
6261 6280
   void calculate_delta(float cartesian[3]) {
6262
-    delta[X_AXIS] = sqrt(delta_diagonal_rod_2
6281
+
6282
+    delta[TOWER_1] = sqrt(delta_diagonal_rod_2_tower_1
6263 6283
                          - sq(delta_tower1_x-cartesian[X_AXIS])
6264 6284
                          - sq(delta_tower1_y-cartesian[Y_AXIS])
6265 6285
                          ) + cartesian[Z_AXIS];
6266
-    delta[Y_AXIS] = sqrt(delta_diagonal_rod_2
6286
+    delta[TOWER_2] = sqrt(delta_diagonal_rod_2_tower_2
6267 6287
                          - sq(delta_tower2_x-cartesian[X_AXIS])
6268 6288
                          - sq(delta_tower2_y-cartesian[Y_AXIS])
6269 6289
                          ) + cartesian[Z_AXIS];
6270
-    delta[Z_AXIS] = sqrt(delta_diagonal_rod_2
6290
+    delta[TOWER_3] = sqrt(delta_diagonal_rod_2_tower_3
6271 6291
                          - sq(delta_tower3_x-cartesian[X_AXIS])
6272 6292
                          - sq(delta_tower3_y-cartesian[Y_AXIS])
6273 6293
                          ) + cartesian[Z_AXIS];
@@ -6276,9 +6296,9 @@ void clamp_to_software_endstops(float target[3]) {
6276 6296
     SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]);
6277 6297
     SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]);
6278 6298
 
6279
-    SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]);
6280
-    SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]);
6281
-    SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]);
6299
+    SERIAL_ECHOPGM("delta a="); SERIAL_ECHO(delta[TOWER_1]);
6300
+    SERIAL_ECHOPGM(" b="); SERIAL_ECHO(delta[TOWER_2]);
6301
+    SERIAL_ECHOPGM(" c="); SERIAL_ECHOLN(delta[TOWER_3]);
6282 6302
     */
6283 6303
   }
6284 6304
 

Завантаження…
Відмінити
Зберегти