def cmd_PID_CALIBRATE(self, params):
     heater_name = self.gcode.get_str('HEATER', params)
     target = self.gcode.get_float('TARGET', params)
     write_file = self.gcode.get_int('WRITE_FILE', params, 0)
     pheater = self.printer.lookup_object('heater')
     try:
         heater = pheater.lookup_heater(heater_name)
     except self.printer.config_error as e:
         raise self.gcode.error(str(e))
     print_time = self.printer.lookup_object(
         'toolhead').get_last_move_time()
     calibrate = ControlAutoTune(heater, target)
     old_control = heater.set_control(calibrate)
     try:
         heater.set_temp(print_time, target)
     except heater.error as e:
         heater.set_control(old_control)
         raise self.gcode.error(str(e))
     self.gcode.bg_temp(heater)
     heater.set_control(old_control)
     if write_file:
         calibrate.write_file('/tmp/heattest.txt')
     # Log and report results
     Kp, Ki, Kd = calibrate.calc_final_pid()
     logging.info("Autotune: final: Kp=%f Ki=%f Kd=%f", Kp, Ki, Kd)
     self.gcode.respond_info(
         "PID parameters: pid_Kp=%.3f pid_Ki=%.3f pid_Kd=%.3f\n"
         "The SAVE_CONFIG command will update the printer config file\n"
         "with these parameters and restart the printer." % (Kp, Ki, Kd))
     # Store results for SAVE_CONFIG
     configfile = self.printer.lookup_object('configfile')
     configfile.set(heater_name, 'control', 'pid')
     configfile.set(heater_name, 'pid_Kp', "%.3f" % (Kp, ))
     configfile.set(heater_name, 'pid_Ki', "%.3f" % (Ki, ))
     configfile.set(heater_name, 'pid_Kd', "%.3f" % (Kd, ))
示例#2
0
 def cmd_tempbias_calibrate(self, params):
     heater_name = self.gcode.get_str('HEATER', params)
     target = self.gcode.get_float('TARGET', params)
     write_file = self.gcode.get_int('WRITE_FILE', params, 0)
     pheater = self.printer.lookup_object('heater')
     try:
         heater = pheater.lookup_heater(heater_name)
     except self.printer.config_error as e:
         raise self.gcode.error(str(e))
     print_time = self.printer.lookup_object(
         'toolhead').get_last_move_time()
     calibrate = tempbiasautotune(heater, self, self.printer)
     self.old_control = heater.set_control(calibrate)
     try:
         heater.set_temp(print_time, target)
     except heater.error as e:
         heater.set_control(old_control)
         raise self.gcode.error(str(e))
     self.gcode.bg_temp(heater)
     heater.set_control(self.old_control)
     if write_file:
         calibrate.write_file('/tmp/heattest.txt')
     temp_bias = calibrate.calc_final_bias()
     logging.info("Autotune: final: temp bias =%f", temp_bias)
     self.gcode.respond_info(
         "Temp bias=%.3f\n"
         "To use this parameters, update the printer config file with\n"
         "the above and then issue a RESTART command" % (temp_bias))
示例#3
0
 def cmd_PID_CALIBRATE(self, params):
     heater_name = self.gcode.get_str('HEATER', params)
     target = self.gcode.get_float('TARGET', params)
     write_file = self.gcode.get_int('WRITE_FILE', params, 0)
     try:
         heater = extruder.get_printer_heater(self.printer, heater_name)
     except self.printer.config_error as e:
         raise self.gcode.error(str(e))
     print_time = self.printer.lookup_object(
         'toolhead').get_last_move_time()
     calibrate = ControlAutoTune(heater)
     old_control = heater.set_control(calibrate)
     try:
         heater.set_temp(print_time, target)
     except heater.error as e:
         raise self.gcode.error(str(e))
     self.gcode.bg_temp(heater)
     heater.set_control(old_control)
     if write_file:
         calibrate.write_file('/tmp/heattest.txt')
     Kp, Ki, Kd = calibrate.calc_final_pid()
     logging.info("Autotune: final: Kp=%f Ki=%f Kd=%f", Kp, Ki, Kd)
     self.gcode.respond_info(
         "PID parameters: pid_Kp=%.3f pid_Ki=%.3f pid_Kd=%.3f\n"
         "To use these parameters, update the printer config file with\n"
         "the above and then issue a RESTART command" % (Kp, Ki, Kd))
示例#4
0
文件: gcode.py 项目: tuwwe/klipper
    def set_temp(self, params, is_bed=False, wait=False):
        temp = self.get_float('S', params,
                              0.) if (self.simulate_print is False) else 0.
        if temp == -273.15:
            temp = 0.
        heater = None
        if is_bed:
            heater = self.printer.lookup_object('heater bed', None)
        else:
            index = None
            if 'T' in params:
                index = self.get_int('T', params, None)
            elif 'P' in params:
                index = self.get_int('P', params, None)

            if index is not None:
                e = self.printer.extruder_get(index)
                if e is not None:
                    heater = e.get_heater()
            elif self.extruder is not None:
                heater = self.extruder.get_heater()

        if heater is None:
            if temp > 0.:
                self.respond_error("Heater not configured")
            return
        print_time = self.toolhead.get_last_move_time()
        try:
            heater.set_temp(print_time, temp)
        except heater.error as e:
            raise error(str(e))
        if wait and temp and self.simulate_print is False:
            self.bg_temp(heater)
示例#5
0
 def cmd_PID_CALIBRATE(self, params):
     heater_name = self.gcode.get_str('HEATER', params)
     target = self.gcode.get_float('TARGET', params)
     write_file = self.gcode.get_int('WRITE_FILE', params, 0)
     pheater = self.printer.lookup_object('heater')
     try:
         heater = pheater.lookup_heater(heater_name)
     except self.printer.config_error as e:
         raise self.gcode.error(str(e))
     print_time = self.printer.lookup_object('toolhead').get_last_move_time()
     calibrate = ControlAutoTune(heater, target)
     old_control = heater.set_control(calibrate)
     try:
         heater.set_temp(print_time, target)
     except heater.error as e:
         heater.set_control(old_control)
         raise self.gcode.error(str(e))
     self.gcode.bg_temp(heater)
     heater.set_control(old_control)
     if write_file:
         calibrate.write_file('/tmp/heattest.txt')
     # Log and report results
     Kp, Ki, Kd = calibrate.calc_final_pid()
     logging.info("Autotune: final: Kp=%f Ki=%f Kd=%f", Kp, Ki, Kd)
     self.gcode.respond_info(
         "PID parameters: pid_Kp=%.3f pid_Ki=%.3f pid_Kd=%.3f\n"
         "The SAVE_CONFIG command will update the printer config file\n"
         "with these parameters and restart the printer." % (Kp, Ki, Kd))
     # Store results for SAVE_CONFIG
     configfile = self.printer.lookup_object('configfile')
     configfile.set(heater_name, 'control', 'pid')
     configfile.set(heater_name, 'pid_Kp', "%.3f" % (Kp,))
     configfile.set(heater_name, 'pid_Ki', "%.3f" % (Ki,))
     configfile.set(heater_name, 'pid_Kd', "%.3f" % (Kd,))
示例#6
0
 def cmd_PID_CALIBRATE(self, params):
     heater_name = self.gcode.get_str('HEATER', params)
     target = self.gcode.get_float('TARGET', params)
     write_file = self.gcode.get_int('WRITE_FILE', params, 0)
     pheater = self.printer.lookup_object('heater')
     try:
         heater = pheater.lookup_heater(heater_name)
     except self.printer.config_error as e:
         raise self.gcode.error(str(e))
     print_time = self.printer.lookup_object('toolhead').get_last_move_time()
     calibrate = ControlAutoTune(heater, target)
     old_control = heater.set_control(calibrate)
     try:
         heater.set_temp(print_time, target)
     except heater.error as e:
         heater.set_control(old_control)
         raise self.gcode.error(str(e))
     self.gcode.bg_temp(heater)
     heater.set_control(old_control)
     if write_file:
         calibrate.write_file('/tmp/heattest.txt')
     Kp, Ki, Kd = calibrate.calc_final_pid()
     logging.info("Autotune: final: Kp=%f Ki=%f Kd=%f", Kp, Ki, Kd)
     self.gcode.respond_info(
         "PID parameters: pid_Kp=%.3f pid_Ki=%.3f pid_Kd=%.3f\n"
         "To use these parameters, update the printer config file with\n"
         "the above and then issue a RESTART command" % (Kp, Ki, Kd))
示例#7
0
 def cmd_COOLING_ESTIMATION_CALIBRATE(self, params):
     heater_name = self.gcode.get_str('HEATER', params)
     max_temp = self.gcode.get_float('HOT_TEMP', params)
     min_temp = self.gcode.get_float('COOL_TEMP', params)
     if max_temp <= min_temp:
         self.gcode.respond_error('HOT_TEMP must be equal or greater than COOL_TEMP!')
         return
     if min_temp < self.room_temp:
         self.gcode.respond_error('COOL_TEMP must be equal or greater than room_temp in settings!')
         return
     heater = self._get_heater(heater_name)
     self.printer.lookup_object('toolhead').get_last_move_time()
     heater.set_temp(max_temp)
     self.gcode.wait_for_temperature(heater)
     calibrate = ControlCoolingEstimator(heater, max_temp, min_temp, self.room_temp)
     old_control = heater.set_control(calibrate)
     try:
         heater.set_temp(min_temp)
     except self.printer.command_error as e:
         heater.set_control(old_control)
         raise
     self.gcode.wait_for_temperature(heater)
     heater.set_control(old_control)
     heater.set_temp(0)
     cooling_coef = calibrate.calc_final_coef()
     self.gcode.respond_info(
         "New cooling coef is %.6f\n"
         "The SAVE_CONFIG command will update the printer config file\n"
         "with these parameters and restart the printer." % cooling_coef)
     # Store results for SAVE_CONFIG
     configfile = self.printer.lookup_object('configfile')
     configfile.set("cooling_time", heater_name, "%.6f" % cooling_coef)