def updateStatus(self, status): self.printerState = status["state"] self.pState.set_value( "%8s" % self.stateNames[status["state"]]) self.pState.update() self.updateTemps(status["t0"], status["t1"], status["targetT1"]) self.swapSize.set_value( "%8s" % str(status["Swap"])) self.swapSize.update() self.sdrSize.set_value( "%8s" % str(status["SDReader"])) self.sdrSize.update() self.sbSisze.set_value( "%8s" % str(status["StepBuffer"])) self.sbSisze.update() self.underrun.set_value( "%8s" % str(status["StepBufUnderRuns"])) self.underrun.update() st = status["targetExtrusionSpeed"] sa = status["actualExtrusionSpeed"] grip = 100.0 if st: grip = (sa*100.0) / st rt = st * MatProfile.getMatArea() ra = sa * MatProfile.getMatArea() self.extRate.set_value( "%8.1f / %4.1f" % (ra, rt) ) self.extRate.update() self.extGrip.set_value( "%4.1f %%" % grip ) self.extGrip.update()
def prime(parser): planner = parser.planner # printer = planner.printer parser.execute_line("G0 F%f Y0 Z%f" % (planner.HOMING_FEEDRATE[X_AXIS]*60, ddprintconstants.PRIMING_HEIGHT)) pos = parser.getRealPos() aFilament = MatProfile.getMatArea() parser.execute_line("G0 F%f A%f" % ( ((ddprintconstants.PRIMING_MM3_PER_SEC / aFilament) * 60), pos[A_AXIS] + (ddprintconstants.PRIMING_MM3 / aFilament))) # Set E to 0 current_position = parser.getRealPos() current_position[A_AXIS] = 0.0 parser.set_position(current_position) # # Retract # # parser.execute_line("G10") # Wipe priming material if not ultigcode flavor if not parser.ultiGcodeFlavor: # parser.execute_line("G10") # parser.execute_line("G0 F%f X50 Z0.5" % (planner.HOMING_FEEDRATE[X_AXIS]*60)) parser.execute_line("G0 F9000 X20 Z0.1")
def printTempTable(printer, temp, tempTable): of = open("/tmp/temptable_printer.txt", "w") of.write("# xxx mat, nozzle, settings...\n") of.write("# basetemp: %d, autoTempFactor: %f\n" % (temp, 0)) of.write("# temp rate steprate timer\n") print "TempTable (basetemp: %d):" % temp mmpermm3 = 1 / MatProfile.getMatArea() spm = PrinterProfile.getStepsPerMM(A_AXIS) for timerValue in tempTable: steprate = fTimer / timerValue speed = (steprate / spm) / mmpermm3 print " Temp: %d, max extrusion: %.1f mm³/s, steps/s: %d, timervalue: %d" % (temp, speed, int(steprate), timerValue) of.write("%d %4.1f %d %d\n" % (temp, speed, int(steprate), timerValue)) temp += 2 of.close()
def preParse(self, fn): # Copy file to prevet problems with overwritten files # while reading. tmpfname = ("/tmp/%d_" % id(fn)) + os.path.basename(fn) shutil.copyfile(fn, tmpfname) f = open(fn) print "Unlinking temp. copy of gcode input: ", tmpfname os.unlink(tmpfname) self.numParts = 0 print "pre-parsing ", fn for line in f: line = line.strip() if line.startswith(";"): upperLine = line.upper() # Cura: "LAYER:" if "LAYER:" in upperLine: layerNum = getCuraLayer(line) if layerNum == 1: self.numParts += 1 self.planner.newPart(self.numParts) # # Simplify3D: "; LAYER " # elif "; LAYER " in upperLine: # layerNum = getSimplifyLayer(line) # if layerNum == 1: # self.numParts += 1 # self.planner.newPart(self.numParts) # Simplify3D: "; skirt " elif upperLine.startswith("; SKIRT"): self.numParts += 1 self.planner.newPart(self.numParts) # ;FLAVOR:UltiGCode elif "FLAVOR:ULTIGCODE" in upperLine: self.ultiGcodeFlavor = True # To compute extrude length from volume (see getValues()): # V = A * h, h = V / A, A = pi/4 * diameter² # self.e_to_filament_length *= 4 / (math.pi * pow(MatProfile.getMatDiameter(), 2)) aFilament = MatProfile.getMatArea() self.e_to_filament_length = self.e_to_filament_length / aFilament print "pre-parsing # parts:", self.numParts f.seek(0) # rewind return f
def preParse(self, fn): # Copy file to prevet problems with overwritten files # while reading. tmpfname = ("/tmp/%d_" % id(fn)) + os.path.basename(fn) shutil.copyfile(fn, tmpfname) f = open(tmpfname) print "Unlinking temp. copy of gcode input: ", tmpfname os.unlink(tmpfname) self.numParts = 0 print "pre-parsing ", fn, tmpfname for line in f: line = line.strip() if line.startswith(";"): upperLine = line.upper() # Cura: "LAYER:" layerNum = getCuraLayer(line) if layerNum == 1: self.numParts += 1 self.planner.newPart(self.numParts) # layerNum = getSimplifyLayer(line) # if layerNum == 1: # self.numParts += 1 # self.planner.newPart(self.numParts) # Simplify3D: "; skirt " if upperLine.startswith("; SKIRT"): self.numParts += 1 self.planner.newPart(self.numParts) # ;FLAVOR:UltiGCode elif "FLAVOR:ULTIGCODE" in upperLine: self.ultiGcodeFlavor = True # To compute extrude length from volume (see getValues()): # V = A * h, h = V / A, A = pi/4 * diameter² aFilament = MatProfile.getMatArea() self.e_to_filament_length = self.e_to_filament_length / aFilament print "pre-parsing # parts:", self.numParts f.seek(0) # rewind return f
def stat(self, move): # Do not count very small moves, the computation of the extrusion rate is inaccurate because of the # discretization in the gcodeparser (map float values to discrete stepper values). if move.distance3 < 0.1: return # Get maximum extrusion rate, take plateau speed into account only # length of max constant speed: reachedEExtrusion = move.topSpeed.speed( ).eSpeed * MatProfile.getMatArea() if reachedEExtrusion > self.maxRate: # print "New max reachedEExtrusion: ", reachedEExtrusion, "mm³/s" self.maxRate = reachedEExtrusion self.move = move self.max10.append(reachedEExtrusion) if len(self.max10) > 10: self.max10 = self.max10[1:]
def stat(self, move): # Do not count very small moves, the computation of the extrusion rate is inaccurate because of the # discretization in the gcodeparser (map float values to discrete stepper values). if move.distance3 < 0.1: return # Get maximum extrusion rate, take plateau speed into account only # length of max constant speed: reachedESpeed = abs( move.getReachedSpeedV()[util.A_AXIS] ) # [mm/s] reachedEExtrusion = reachedESpeed * MatProfile.getMatArea() if reachedEExtrusion > self.maxRate: # print "New max reachedEExtrusion: ", reachedEExtrusion, "mm³/s" self.maxRate = reachedEExtrusion self.move = move self.max10.append(reachedEExtrusion) if len(self.max10) > 10: self.max10 = self.max10[1:]
def genTempTable(printer): baseTemp = MatProfile.getHotendBaseTemp() area04 = pow(0.4, 2)*math.pi/4 extrusionLow = MatProfile.getBaseExtrusionRate() * (NozzleProfile.getArea() / area04) f = MatProfile.getAutoTempFactor() mmpermm3 = 1 / MatProfile.getMatArea() spm = PrinterProfile.getStepsPerMM(A_AXIS) of = open("/tmp/temptable0.txt", "w") of.write("# xxx mat, nozzle, settings...\n") of.write("# basetemp: %d, autoTempFactor: %f\n" % (baseTemp, f)) of.write("# temp rate steprate timer\n") print "TempTable (basetemp: %d):" % baseTemp table = [] for i in range(NExtrusionLimit): t = baseTemp + i*2 dspeed = i*2 / f speed = extrusionLow + dspeed steprate = speed * mmpermm3 * spm tvs = 1.0/steprate timerValue = int(fTimer / steprate) print " Temp: %d, max extrusion: %.1f mm³/s, steps/s: %d, steprate: %d us, timervalue: %d" % (t, speed, int(steprate), int(tvs*1000000), timerValue) table.append(timerValue) of.write("%d %4.1f %d %d\n" % (t, speed, int(steprate), timerValue)) of.close() return (baseTemp, table)
def __init__(self, comment, # stepped_point, displacement_vector, displacement_vector_steps, feedrate, # mm/s ): self.comment=comment self.displacement_vector3=displacement_vector[:3] self.displacement_vector_steps3=displacement_vector_steps[:3] self.extrusion_displacement_raw = displacement_vector[3:] self.extrusion_displacement_steps_raw = displacement_vector_steps[3:] # # Move distance in XYZAB plane # self.distance = displacement_vector.len5() # # Move distance in XYZ plane # self.distance3 = displacement_vector.len3() # self.eOnly = self.displacement_vector3 == 3*[0] self.eOnly = self.distance3 == 0 # # Limit feedrate by maximum extrusion rate # self.feedrateS = feedrate # mm/s # Do not count very small moves, the computation of the extrusion rate is inaccurate because of the # discretization in the gcodeparser (map float values to discrete stepper values). if self.distance3 >= 0.1 and self.isExtrudingMove(A_AXIS) or self.isExtrudingMove(B_AXIS): matArea = MatProfile.getMatArea() assert(not self.eOnly) t = self.distance3 / feedrate extrusionVolume = displacement_vector[A_AXIS] * matArea extrusionRate = extrusionVolume / t # print "extrusionRate:", displacement_vector[A_AXIS], t, extrusionRate if extrusionRate > NozzleProfile.getNetMaxExtrusionRate(): print "Warning, extrusion rate to high: %.1f mm³/s, Move: '%s', len: %.3f., extrusionVolume: %.5f" % (extrusionRate, comment, self.distance3, extrusionVolume) # xxx feedrate adjust disabled ### print "Warning, extrusion rate to high: %.1f mm³/s, reducing to %.1f mm³/s, Move: '%s', len: %.3f., extrusionVolume: %.5f" % (extrusionRate, NozzleProfile.getNetMaxExtrusionRate(), comment, self.distance3, extrusionVolume) ### self.feedrateS = feedrate * (NozzleProfile.getNetMaxExtrusionRate() / extrusionRate) # print "Adjusted feedrate: ", feedrate, self.feedrateS self.trueStartSpeed = self.nominalStartSpeed = None self.trueEndSpeed = self.nominalEndSpeed = None self.accelData = AccelData() self.stepData = StepData() self.lastMove = None self.nextMove = None self.moveNumber = 0 # debug self.state = 0 # 1: joined, 2: accel planned, 3: steps planned self.streamed = False # Time for the three phases of this move self.accelTime = 0 self.linearTime = 0 self.deccelTime = 0
def measureTempFlowrateCurve(args, parser): def writeDataSet(f, dataSet): for dataStr in dataSet: f.write(dataStr) f.write("\n") f.write("E\n") fssteps_per_mm = 265.0 # xxx hardcoded, get from profile or printer... planner = parser.planner printer = planner.printer printer.commandInit(args) ddhome.home(parser, args.fakeendstop) # Disable flowrate limit printer.sendCommandParamV(CmdEnableFRLimit, [packedvalue.uint8_t(0)]) # Move to mid-position printer.sendPrinterInit() feedrate = PrinterProfile.getMaxFeedrate(X_AXIS) parser.execute_line("G0 F%d X%f Y%f" % (feedrate*60, planner.MAX_POS[X_AXIS]/2, planner.MAX_POS[Y_AXIS]/2)) planner.finishMoves() printer.sendCommandParamV(CmdMove, [MoveTypeNormal]) printer.sendCommand(CmdEOT) printer.waitForState(StateIdle) current_position = parser.getRealPos() apos = current_position[A_AXIS] t1 = MatProfile.getHotendBaseTemp() # start temperature area04 = pow(0.4, 2)*math.pi/4 flowrate = MatProfile.getBaseExtrusionRate() * (NozzleProfile.getArea() / area04) aFilament = MatProfile.getMatArea() print "t1: ", t1 print "flowrate: ", flowrate print "aFilament: ", aFilament print "feedrate: ", flowrate / aFilament # xxx todo if using small nozzles assert(flowrate > 2) f = open("temp-flowrate-curve.gnuplot", "w") f.write(""" set grid set yrange [0:35] # Startwert steigung a=0.5 # Startwert y-achse b=5 f(x)=b+a*(x-%d) fit f(x) "-" using 1:3 noerror via a,b\n""" % t1) dataSet = [] printer.sendCommandParamV(CmdFanSpeed, [packedvalue.uint8_t(100)]) retracted = False while t1 <= MatProfile.getHotendMaxTemp(): print "Heating:", t1 printer.heatUp(HeaterEx1, t1, wait=t1) # time.sleep(10) # temp settle wait = 5 while wait: time.sleep(1) temps = printer.getTemps() if abs(t1 - int(temps[HeaterEx1])) <= 1: wait -= 1 else: wait = 5 print "temp wait: ", wait flowrate -= 1 ratio = 1.0 while ratio >= 0.9: feedrate = flowrate / aFilament # distance = 5 * feedrate # xxx distance = 50 apos += distance print "Feedrate for flowrate:", feedrate, flowrate printer.sendPrinterInit() if retracted: parser.execute_line("G11") parser.execute_line("G0 F%d %s%f" % (feedrate*60, dimNames[A_AXIS], apos)) parser.execute_line("G10") planner.finishMoves() printer.sendCommand(CmdEOT) printer.sendCommandParamV(CmdMove, [MoveTypeNormal]) printer.waitForState(StateIdle) time.sleep(0.25) fssteps = printer.getFilSensor() fsdist = fssteps / fssteps_per_mm ratio = fsdist / distance actualFlowrate = flowrate * ratio print "t1, flowrate, fsdist, distance, ratio:", t1, flowrate, fsdist, distance, ratio flowrate += 1 retracted = True print "Feeder grip:", t1, flowrate-1, ratio dataStr = "%f %f %.2f %.3f" % (t1, flowrate - 1, actualFlowrate, ratio) f.write(dataStr + "\n") f.flush() dataSet.append(dataStr) t1 += 2 # next temp f.write("E\n") f.write(""" plot "-" using 1:2 with linespoints title "Target Flowrate", \\ "-" using 1:3 with linespoints title "Actual Flowrate", \\ "-" using 1:3 with linespoints smooth bezier title "Actual Flowrate smooth", \\ f(x) title sprintf("y=B+A*x, A=%.2f, B=%.1f, TempFactor 1/A: %.2f", a, b, 1/a)\n""") writeDataSet(f, dataSet) writeDataSet(f, dataSet) writeDataSet(f, dataSet) f.close() printer.coolDown(HeaterEx1) # Enable flowrate limit printer.sendCommandParamV(CmdEnableFRLimit, [packedvalue.uint8_t(1)])