cura: properly working dual extrusion plugin
authorClinton Ebadi <clinton@unknownlamer.org>
Sun, 14 Aug 2016 22:04:32 +0000 (18:04 -0400)
committerClinton Ebadi <clinton@unknownlamer.org>
Sun, 14 Aug 2016 22:04:32 +0000 (18:04 -0400)
No longer relies on custom gcode to function and is mostly safe for
human consumption.

 * Injects M109 commands before unspooling a newly activated hotend to
   ensure printing temperature is hit. This will occur over the priming
   tower if it is enabled and eliminates oozing over the print.

 * Unconditionally cools inactive hotend even if the estimated layer
   time is less than the preheat time. The hotend instead reheats once
   the active hotend is up to temperature, preventing some ooze and
   potential heat creep at the expense of some print time.

 * The extruder can be raised by a configurable amount while waiting for
   the active extruder to fully reheat after tool change.

cura/dual_temp_lower.py

index 6d27bb6..d516f63 100644 (file)
@@ -4,6 +4,7 @@
 #Type: postprocess
 #Param: coolTemperatureDifference(float:50.0) Drop idle nozzle temperature (C)
 #Param: heatupTimeDelay(float:20.0) Heatup nozzle before use (sec)
 #Type: postprocess
 #Param: coolTemperatureDifference(float:50.0) Drop idle nozzle temperature (C)
 #Param: heatupTimeDelay(float:20.0) Heatup nozzle before use (sec)
+#Param: zHop(float:0.0) Raise Z when reheating active extruder (mm)
 
 
 __copyright__ = "Copyright (C) 2013 David Braam, Copyright (C) 2016 Clinton Ebadi <clinton@unknownlamer.org> - Released under terms of the AGPLv3 License"
 
 
 __copyright__ = "Copyright (C) 2013 David Braam, Copyright (C) 2016 Clinton Ebadi <clinton@unknownlamer.org> - Released under terms of the AGPLv3 License"
@@ -31,6 +32,7 @@ x = 0.
 y = 0.
 e = 0.
 feedrate = float(profile.getProfileSetting('print_speed'))
 y = 0.
 e = 0.
 feedrate = float(profile.getProfileSetting('print_speed'))
+wipeTowerP = profile.getProfileSetting('wipe_tower') == 'True'
 currentSectionType = 'CUSTOM'
 activeExtruder = -1
 
 currentSectionType = 'CUSTOM'
 activeExtruder = -1
 
@@ -53,7 +55,6 @@ with open(filename, "w") as f:
                 f.write (line)
         while idx < len(lines):
                line = lines[idx]
                 f.write (line)
         while idx < len(lines):
                line = lines[idx]
-                heatupBlocked = False
                if getValue(line, 'T', None) is not None and getValue(line, 'M', None) is None:
                        nextExtruder = getValue(line, 'T', None)
                        printTime = 0.0
                if getValue(line, 'T', None) is not None and getValue(line, 'M', None) is None:
                        nextExtruder = getValue(line, 'T', None)
                        printTime = 0.0
@@ -74,28 +75,34 @@ with open(filename, "w") as f:
                                        x = nx
                                        y = ny
                                        z = nz
                                        x = nx
                                        y = ny
                                        z = nz
-                       heatupTime = printTime - heatupTimeDelay
+                       heatupTime = max (printTime - heatupTimeDelay, 0.0)
+                        heatupBlocked = True # do not reheat until active extruder is heated
                        x = sx
                        y = sy
                        z = sz
                        x = sx
                        y = sy
                        z = sz
-                       if heatupTime > 0.0:
-                               f.write("M104 T%d S%d\n" % (nextExtruder, coolTemperature))
-                               f.write("T%d\n" % (activeExtruder))
-                       else:
-                               heatupTime = printTime / 2
-                                # clinton: custom gcode sets cooltemp, need to counteract that for short layers
-                                #f.write("M104 T%d S%d\n" % (nextExtruder, printTemperature - coolTemperatureDifference/2))
-                               #f.write("T%d\n" % (activeExtruder))
+
+                       f.write("M104 T%d S%d\n" % (nextExtruder, coolTemperature))
+                       f.write("T%d\n" % (activeExtruder))
+
                        printTime = 0.0
                        for n in xrange(startIdx, idx):
                                line = lines[n]
                                if line.startswith(';'):
                                        f.write(line)
                        printTime = 0.0
                        for n in xrange(startIdx, idx):
                                line = lines[n]
                                if line.startswith(';'):
                                        f.write(line)
-                                        if (line == ';HEATER_BLOCKED\n'):
-                                                heatupBlocked = True
-                                        elif (line == ';HEATER_UNBLOCKED\n'):
-                                                heatupBlocked = False
                                        continue
                                        continue
+                                # find where the newly activated extruder is unspooled and block until fully reheated
+                                if getValue(line, 'G', None) is not None and getValue (line, 'E', 666) == 0.0:
+                                        # todo: if wipeTowerP, only
+                                        # wait for a few degrees below
+                                        # printTemperature and allow
+                                        # it to finish heating while
+                                        # priming
+                                        if zHop > 0.0:
+                                                f.write ("G91\nG0 Z%.3f\n" % zHop)
+                                        f.write("M109 T%d S%d\n" % (activeExtruder, printTemperature))
+                                        if zHop > 0.0:
+                                                f.write ("G0 Z%.3f\nG90\n" % -zHop)
+                                        heatupBlocked = False
                                if heatupTime is not None:
                                        g = getValue(line, 'G', None)
                                        if g == 0 or g == 1:
                                if heatupTime is not None:
                                        g = getValue(line, 'G', None)
                                        if g == 0 or g == 1:
@@ -113,8 +120,7 @@ with open(filename, "w") as f:
                                                z = nz
                                f.write(line)
                        f.write(lines[idx])
                                                z = nz
                                f.write(line)
                        f.write(lines[idx])
-                        heatupBlocked = False
-                       startIdx = idx + 1
+                        startIdx = idx + 1
                        activeExtruder = nextExtruder
                idx += 1
        for n in xrange(startIdx, idx):
                        activeExtruder = nextExtruder
                idx += 1
        for n in xrange(startIdx, idx):