Retract calculation in dimension plugin November 03, 2011 10:40AM |
Registered: 13 years ago Posts: 226 |
G1 X90.2356 Y90.2356 Z0.2 F1800.0 E2.49087 ; end of path G1 F900.0 G1 E1.67293 ; retract G1 F1800.0 ;M103 M82 G1 X90.2356 Y90.2356 Z0.6 F7800.0 ; start of next path G1 F900.0 G1 E2.49087 ; reverse retract G1 F7800.0 G92 E0 ;M101 G1 X109.764 Y90.2356 Z0.6 F1800.0 E0.622717 ; end of first path
G1 X90.23559 Y90.235593 Z0.2 F1800.0 E2.490921 ; end of path G1 F900.0 G1 E2.449254 ; retract G1 F1800.0 ;M103 M82 G1 X90.23559 Y90.235593 Z0.6 F7800.0 ; start of next path G1 F900.0 G1 E0.0 ; NOTE!! My reverse retract is not currently working! G1 F7800.0 G92 E0 ;M101 G1 X109.76441 Y90.235591 Z0.6 F1800.0 E0.62273 ; end of first path
def getDistanceToNextThread(self, lineIndex): 'Get the travel distance to the next thread.' if self.oldLocation == None: return None isActive = False location = self.oldLocation for afterIndex in xrange(lineIndex + 1, len(self.lines)): line = self.lines[afterIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1': if isActive: location = gcodec.getLocationFromSplitLine(location, splitLine) #if self.repository.retractWhenCrossing.value: locationEnclosureIndex = self.getSmallestEnclosureIndex(location.dropAxis()) if locationEnclosureIndex != self.getSmallestEnclosureIndex(self.oldLocation.dropAxis()): return None locationMinusOld = location - self.oldLocation xyTravel = abs(locationMinusOld.dropAxis()) zTravelMultiplied = locationMinusOld.z * self.zDistanceRatio self.timeToNextThread = math.sqrt(xyTravel * xyTravel + zTravelMultiplied * zTravelMultiplied)/ self.feedRateMinute*60 self.autoRetractDistance = self.timeToNextThread * abs(self.repository.oozeRate.value)/60 return math.sqrt(xyTravel * xyTravel + zTravelMultiplied * zTravelMultiplied) elif firstWord == 'M101': isActive = True elif firstWord == 'M103': isActive = False return Noneskeinforge44:
def getDistanceToNextThread(self, lineIndex): 'Get the travel distance to the next thread.' if self.oldLocation == None: return None isActive = False location = self.oldLocation for afterIndex in xrange(lineIndex + 1, len(self.lines)): line = self.lines[afterIndex] splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == 'G1': if isActive: location = gcodec.getLocationFromSplitLine(location, splitLine) if not self.repository.retractWithinIsland.value: locationEnclosureIndex = self.getSmallestEnclosureIndex(location.dropAxis()) if locationEnclosureIndex != self.getSmallestEnclosureIndex(self.oldLocation.dropAxis()): return None locationMinusOld = location - self.oldLocation xyTravel = abs(locationMinusOld.dropAxis()) zTravelMultiplied = locationMinusOld.z * self.zDistanceRatio return math.sqrt(xyTravel * xyTravel + zTravelMultiplied * zTravelMultiplied) elif firstWord == 'M101': isActive = True elif firstWord == 'M103': isActive = False return None
Re: Retract calculation in dimension plugin November 03, 2011 12:04PM |
Registered: 13 years ago Posts: 1,780 |
Re: Retract calculation in dimension plugin November 03, 2011 12:36PM |
Registered: 13 years ago Posts: 226 |
Re: Retract calculation in dimension plugin November 03, 2011 06:38PM |
Registered: 13 years ago Posts: 1,780 |
G1 X90.2356 Y90.2356 Z0.2 F1800.0 E2.49087 ; end of path - Correct G1 F900.0 G1 E1.67293 ; retract - Correct G1 F1800.0 ;M103 M82 G1 X90.2356 Y90.2356 Z0.6 F7800.0 ; start of next path - yes, x, y and z move but nothing extruded G1 F900.0 G1 E2.49087 ; reverse retract - Restart puts it back to where it was at the end of the last path as it should to prepare for next path G1 F7800.0 G92 E0 ; Resets the Extruder back to 0 ;M101 G1 X109.764 Y90.2356 Z0.6 F1800.0 E0.622717 ; end of first path - No. This is the next path where it extrudes 0.622717 mm
Re: Retract calculation in dimension plugin November 04, 2011 07:27AM |
Registered: 13 years ago Posts: 226 |
locationMinusOld = location - self.oldLocation xyTravel = abs(locationMinusOld.dropAxis()) zTravelMultiplied = locationMinusOld.z * self.zDistanceRatio self.timeToNextThread = math.sqrt(xyTravel * xyTravel + zTravelMultiplied * zTravelMultiplied)/ self.feedRateMinute*60 self.autoRetractDistance = self.timeToNextThread * abs(self.repository.oozeRate.value)/60 return math.sqrt(xyTravel * xyTravel + zTravelMultiplied * zTravelMultiplied)Where:
self.oldLocation (90.2356, 90.2356, 0.2) location (109.764, 90.2356, 0.6) locationMinusOld (19.5284, 0.0, 0.4) xyTravel 19.5284 zTravelMultiplied 2.0 self.timeToNextThread 0.654351593021 self.autoRetractDistance 0.817939491276 dist 19.6305477906
self.oldLocation (90.235590035, 90.2355929961, 0.2) location (90.2355900343, 90.2355930354, 0.6) locationMinusOld (-7.0680528097e-10, 3.92932406612e-08, 0.4) xyTravel 3.929959714e-08 zTravelMultiplied 2.0 timeToNextThread 0.0333333333333 retractionExtrusionDistance 0.0416666666667 dist 2.0
Re: Retract calculation in dimension plugin November 04, 2011 07:43AM |
Registered: 13 years ago Posts: 1,780 |
Quote
garyhodgson
In the Dimension plugin, getDistanceToNextThread function, the algorithm calculates the distance from the last location (end of the last path) to the start of the next location (thread) in order to derive how much filament to retract. However, it appears to use the next G1 code it finds after(!) the extruder is active (i.e. after a M101 code is read), which would be the end of the first extruded path. Surely this means that the retraction distance is wrong? I would imagine the retraction distance should be calculated from the end of the last path to the start of the next.
Re: Retract calculation in dimension plugin November 04, 2011 09:00AM |
Registered: 13 years ago Posts: 226 |
dist = math.sqrt(xyTravel * xyTravel + zTravelMultiplied * zTravelMultiplied) dist = math.sqrt(3.9306238598970684e-08 * 3.9306238598970684e-08 + 6.3999999999999995 * 6.3999999999999995) or, dist = math.sqrt(0.00000003930623859897 * 0.00000003930623859897 + 6.3999999999999995 * 6.3999999999999995) dist = 6.3999999999999995
Re: Retract calculation in dimension plugin November 04, 2011 10:18AM |
Registered: 13 years ago Posts: 202 |
Re: Retract calculation in dimension plugin November 04, 2011 04:05PM |
Registered: 13 years ago Posts: 226 |
if isActive: if not self.repository.retractWithinIsland.value: locationEnclosureIndex = self.getSmallestEnclosureIndex(location.dropAxis()) if locationEnclosureIndex != self.getSmallestEnclosureIndex(self.oldLocation.dropAxis()): return None locationMinusOld = location - self.oldLocation xyTravel = abs(locationMinusOld.dropAxis()) zTravelMultiplied = locationMinusOld.z * self.zDistanceRatio return math.sqrt(xyTravel * xyTravel + zTravelMultiplied * zTravelMultiplied) else: location = gcodec.getLocationFromSplitLine(location, splitLine)
Re: Retract calculation in dimension plugin November 04, 2011 06:23PM |
Registered: 13 years ago Posts: 202 |
Re: Retract calculation in dimension plugin November 17, 2011 06:58PM |
Registered: 13 years ago Posts: 202 |
Re: Retract calculation in dimension plugin November 18, 2011 07:02AM |
Registered: 13 years ago Posts: 226 |
# Earlier.... xyTravel = 0 zTravel = 0 ... if isActive: if not self.repository.retractWithinIsland.value: locationEnclosureIndex = self.getSmallestEnclosureIndex(location.dropAxis()) if locationEnclosureIndex != self.getSmallestEnclosureIndex(self.oldLocation.dropAxis()): return None zTravelMultiplied = zTravel * self.zDistanceRatio return math.sqrt(xyTravel * xyTravel + zTravelMultiplied * zTravelMultiplied) else: location = gcodec.getLocationFromSplitLine(location, splitLine) locationMinusOld = location - self.oldLocation xyTravel += abs(locationMinusOld.dropAxis()) zTravel += locationMinusOld.z ... self.oldLocation = location
Re: Retract calculation in dimension plugin November 18, 2011 09:35AM |
Registered: 13 years ago Posts: 202 |
Re: Retract calculation in dimension plugin November 18, 2011 11:12AM |
Registered: 13 years ago Posts: 1,780 |