瀏覽代碼

G2/G3 Arcs for Delta

- Update prepare_move_delta to take a target argument
- Add Delta support to plan_arc
Scott Lahteine 10 年之前
父節點
當前提交
5c5936508d
共有 1 個文件被更改,包括 38 次插入18 次删除
  1. 38
    18
      Marlin/Marlin_main.cpp

+ 38
- 18
Marlin/Marlin_main.cpp 查看文件

410
 
410
 
411
 void process_next_command();
411
 void process_next_command();
412
 
412
 
413
+void plan_arc(float target[NUM_AXIS], float *offset, uint8_t clockwise);
414
+
413
 bool setTargetedHotend(int code);
415
 bool setTargetedHotend(int code);
414
 
416
 
415
 void serial_echopair_P(const char *s_P, float v)         { serialprintPGM(s_P); SERIAL_ECHO(v); }
417
 void serial_echopair_P(const char *s_P, float v)         { serialprintPGM(s_P); SERIAL_ECHO(v); }
1895
  * options for G2/G3 arc generation. In future these options may be GCode tunable.
1897
  * options for G2/G3 arc generation. In future these options may be GCode tunable.
1896
  */
1898
  */
1897
 void plan_arc(
1899
 void plan_arc(
1898
-  float *target,    // Destination position
1899
-  float *offset,    // Center of rotation relative to current_position
1900
-  uint8_t clockwise // Clockwise?
1900
+  float target[NUM_AXIS], // Destination position
1901
+  float *offset,          // Center of rotation relative to current_position
1902
+  uint8_t clockwise       // Clockwise?
1901
 ) {
1903
 ) {
1902
 
1904
 
1903
   float radius = hypot(offset[X_AXIS], offset[Y_AXIS]),
1905
   float radius = hypot(offset[X_AXIS], offset[Y_AXIS]),
1957
   float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation
1959
   float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation
1958
   float sin_T = theta_per_segment;
1960
   float sin_T = theta_per_segment;
1959
   
1961
   
1960
-  float arc_target[4];
1962
+  float arc_target[NUM_AXIS];
1961
   float sin_Ti;
1963
   float sin_Ti;
1962
   float cos_Ti;
1964
   float cos_Ti;
1963
   float r_axisi;
1965
   float r_axisi;
1998
     arc_target[E_AXIS] += extruder_per_segment;
2000
     arc_target[E_AXIS] += extruder_per_segment;
1999
 
2001
 
2000
     clamp_to_software_endstops(arc_target);
2002
     clamp_to_software_endstops(arc_target);
2001
-    plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, active_extruder);
2003
+
2004
+    #if defined(DELTA) || defined(SCARA)
2005
+      calculate_delta(arc_target);
2006
+      #ifdef ENABLE_AUTO_BED_LEVELING
2007
+        adjust_delta(arc_target);
2008
+      #endif
2009
+      plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], arc_target[E_AXIS], feed_rate, active_extruder);
2010
+    #else
2011
+      plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, active_extruder);
2012
+    #endif
2002
   }
2013
   }
2014
+
2003
   // Ensure last segment arrives at target location.
2015
   // Ensure last segment arrives at target location.
2004
-  plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate, active_extruder);
2016
+  #if defined(DELTA) || defined(SCARA)
2017
+    calculate_delta(target);
2018
+    #ifdef ENABLE_AUTO_BED_LEVELING
2019
+      adjust_delta(target);
2020
+    #endif
2021
+    plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feed_rate, active_extruder);
2022
+  #else
2023
+    plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate, active_extruder);
2024
+  #endif
2005
 
2025
 
2006
   // As far as the parser is concerned, the position is now == target. In reality the
2026
   // As far as the parser is concerned, the position is now == target. In reality the
2007
   // motion control system might still be processing the action and the real tool position
2027
   // motion control system might still be processing the action and the real tool position
6074
 
6094
 
6075
 #if defined(DELTA) || defined(SCARA)
6095
 #if defined(DELTA) || defined(SCARA)
6076
 
6096
 
6077
-  inline bool prepare_move_delta() {
6097
+  inline bool prepare_move_delta(float target[NUM_AXIS]) {
6078
     float difference[NUM_AXIS];
6098
     float difference[NUM_AXIS];
6079
-    for (int8_t i=0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
6099
+    for (int8_t i=0; i < NUM_AXIS; i++) difference[i] = target[i] - current_position[i];
6080
 
6100
 
6081
     float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
6101
     float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
6082
     if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
6102
     if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
6093
       float fraction = float(s) / float(steps);
6113
       float fraction = float(s) / float(steps);
6094
 
6114
 
6095
       for (int8_t i = 0; i < NUM_AXIS; i++)
6115
       for (int8_t i = 0; i < NUM_AXIS; i++)
6096
-        destination[i] = current_position[i] + difference[i] * fraction;
6116
+        target[i] = current_position[i] + difference[i] * fraction;
6097
 
6117
 
6098
-      calculate_delta(destination);
6118
+      calculate_delta(target);
6099
 
6119
 
6100
       #ifdef ENABLE_AUTO_BED_LEVELING
6120
       #ifdef ENABLE_AUTO_BED_LEVELING
6101
-        adjust_delta(destination);
6121
+        adjust_delta(target);
6102
       #endif
6122
       #endif
6103
 
6123
 
6104
-      //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]);
6105
-      //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]);
6106
-      //SERIAL_ECHOPGM("destination[Z_AXIS]="); SERIAL_ECHOLN(destination[Z_AXIS]);
6124
+      //SERIAL_ECHOPGM("target[X_AXIS]="); SERIAL_ECHOLN(target[X_AXIS]);
6125
+      //SERIAL_ECHOPGM("target[Y_AXIS]="); SERIAL_ECHOLN(target[Y_AXIS]);
6126
+      //SERIAL_ECHOPGM("target[Z_AXIS]="); SERIAL_ECHOLN(target[Z_AXIS]);
6107
       //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]);
6127
       //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]);
6108
       //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
6128
       //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
6109
       //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
6129
       //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
6110
 
6130
 
6111
-      plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder);
6131
+      plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], target[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder);
6112
     }
6132
     }
6113
     return true;
6133
     return true;
6114
   }
6134
   }
6116
 #endif // DELTA || SCARA
6136
 #endif // DELTA || SCARA
6117
 
6137
 
6118
 #ifdef SCARA
6138
 #ifdef SCARA
6119
-  inline bool prepare_move_scara() { return prepare_move_delta(); }
6139
+  inline bool prepare_move_scara(float target[NUM_AXIS]) { return prepare_move_delta(target); }
6120
 #endif
6140
 #endif
6121
 
6141
 
6122
 #ifdef DUAL_X_CARRIAGE
6142
 #ifdef DUAL_X_CARRIAGE
6193
   #endif
6213
   #endif
6194
 
6214
 
6195
   #ifdef SCARA
6215
   #ifdef SCARA
6196
-    if (!prepare_move_scara()) return;
6216
+    if (!prepare_move_scara(destination)) return;
6197
   #elif defined(DELTA)
6217
   #elif defined(DELTA)
6198
-    if (!prepare_move_delta()) return;
6218
+    if (!prepare_move_delta(destination)) return;
6199
   #endif
6219
   #endif
6200
 
6220
 
6201
   #ifdef DUAL_X_CARRIAGE
6221
   #ifdef DUAL_X_CARRIAGE

Loading…
取消
儲存