Пример #1
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))
Пример #2
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, ))
Пример #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
 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)
Пример #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))