Просмотр исходного кода

Improved solution to tool-change bug

Scott Lahteine 8 лет назад
Родитель
Сommit
672e45652e
1 измененных файлов: 16 добавлений и 16 удалений
  1. 16
    16
      Marlin/Marlin_main.cpp

+ 16
- 16
Marlin/Marlin_main.cpp Просмотреть файл

7883
   inline void move_extruder_servo(uint8_t e) {
7883
   inline void move_extruder_servo(uint8_t e) {
7884
     const int angles[2] = SWITCHING_EXTRUDER_SERVO_ANGLES;
7884
     const int angles[2] = SWITCHING_EXTRUDER_SERVO_ANGLES;
7885
     MOVE_SERVO(SWITCHING_EXTRUDER_SERVO_NR, angles[e]);
7885
     MOVE_SERVO(SWITCHING_EXTRUDER_SERVO_NR, angles[e]);
7886
+    delay(500);
7886
   }
7887
   }
7887
 #endif
7888
 #endif
7888
 
7889
 
8029
 
8030
 
8030
           #if ENABLED(SWITCHING_EXTRUDER)
8031
           #if ENABLED(SWITCHING_EXTRUDER)
8031
             // <0 if the new nozzle is higher, >0 if lower. A bigger raise when lower.
8032
             // <0 if the new nozzle is higher, >0 if lower. A bigger raise when lower.
8032
-            float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
8033
-                  z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
8033
+            const float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
8034
+                        z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
8034
 
8035
 
8035
             // Always raise by some amount (destination copied from current_position earlier)
8036
             // Always raise by some amount (destination copied from current_position earlier)
8036
-            float save_Z = destination[Z_AXIS];  // save Z for later on
8037
-            destination[Z_AXIS] += z_raise;
8038
-            planner.buffer_line_kinematic(destination, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
8037
+            current_position[Z_AXIS] += z_raise;
8038
+            planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
8039
             stepper.synchronize();
8039
             stepper.synchronize();
8040
 
8040
 
8041
             move_extruder_servo(active_extruder);
8041
             move_extruder_servo(active_extruder);
8042
-            delay(500);
8043
-
8044
-            // Move back down, if needed
8045
-            if (z_raise != z_diff) {
8046
-              destination[Z_AXIS] = current_position[Z_AXIS] + z_diff;
8047
-              planner.buffer_line_kinematic(destination, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
8048
-              stepper.synchronize();
8049
-            }
8050
-            destination[Z_AXIS] = save_Z;  // restore original Z position so the 'Move to the "old position"' is correct
8051
           #endif
8042
           #endif
8052
 
8043
 
8053
           /**
8044
           /**
8098
             #endif
8089
             #endif
8099
 
8090
 
8100
             // Adjustments to the current position
8091
             // Adjustments to the current position
8101
-            float xydiff[2] = { offset_vec.x, offset_vec.y };
8092
+            const float xydiff[2] = { offset_vec.x, offset_vec.y };
8102
             current_position[Z_AXIS] += offset_vec.z;
8093
             current_position[Z_AXIS] += offset_vec.z;
8103
 
8094
 
8104
           #else // !ABL_PLANAR
8095
           #else // !ABL_PLANAR
8105
 
8096
 
8106
-            float xydiff[2] = {
8097
+            const float xydiff[2] = {
8107
               hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
8098
               hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
8108
               hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
8099
               hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
8109
             };
8100
             };
8170
           prepare_move_to_destination();
8161
           prepare_move_to_destination();
8171
         }
8162
         }
8172
 
8163
 
8164
+        #if ENABLED(SWITCHING_EXTRUDER)
8165
+          // Move back down, if needed. (Including when the new tool is higher.)
8166
+          if (z_raise != z_diff) {
8167
+            destination[Z_AXIS] += z_diff;
8168
+            feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS];
8169
+            prepare_move_to_destination();
8170
+          }
8171
+        #endif
8172
+
8173
       } // (tmp_extruder != active_extruder)
8173
       } // (tmp_extruder != active_extruder)
8174
 
8174
 
8175
       stepper.synchronize();
8175
       stepper.synchronize();

Загрузка…
Отмена
Сохранить