diff --git a/M300_UC.ver/MGC.cfg b/M300_UC.ver/MGC.cfg new file mode 100644 index 0000000..3dae200 --- /dev/null +++ b/M300_UC.ver/MGC.cfg @@ -0,0 +1,41 @@ +[gcode_macro MGC] #MECHANICAL_GANTRY_CALIBRATION +gcode: + {% set align_current = params.CURRENT|default(0.25)|float %} ; Settings for current regulation ; 전류 세팅 + {% set printing_current = params.CURRENT|default(1.1)|float %} ; Settings for current regulation ; 전류 세팅 + {% set z_max = printer.toolhead.axis_maximum.z %} + {% set fast_move_z = printer.configfile.settings["printer"].max_z_velocity %} + {% set fast_move = printer.configfile.settings["printer"].max_velocity %} + M117 {printer.homed_axes} + {% if printer.homed_axes != 'xyz' %} + {% endif %} + + G90 + G0 Z{z_max -10} F{fast_move_z * 60 } ; go to the Z-max at speed max z speed; Z축 풀사이즈에서 -10으로 60mm/sec으로 이동 + + ### Drop the current ; 전류 하강 + SET_TMC_CURRENT STEPPER=stepper_z CURRENT={align_current} ; drop current on Z0 stepper ; Z0모터 전류 하강 + SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={align_current} ; drop current on Z1 stepper ; Z0모터 전류 하강 + SET_TMC_CURRENT STEPPER=stepper_z2 CURRENT={align_current} ; drop current on Z2 stepper ; Z0모터 전류 하강 + G4 P200 ; 200mm/s wait ; 0.2초대기 + + ### Move the bed-plate to the bottom for calibration correction ; 베드플레이트 하단부로 이동하여 위치 보정 + SET_KINEMATIC_POSITION Z={z_max - 50} ; [M300/M400 스토퍼 장착] - Z축 풀사이즈보다 50mm 강제로 이동 + G1 Z{z_max -2} F{6 * 60} ; try to move up + G4 P200 ; 200mm/s wait ; 0.2초대기 + G1 Z{z_max -10} F{6 * 60} ; move down + G4 P200 ; 200mm/s wait ; 0.2초대기 + + ### Current reset ; 전류 초기화 + SET_TMC_CURRENT STEPPER=stepper_z CURRENT={printing_current} + SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={printing_current} + SET_TMC_CURRENT STEPPER=stepper_z2 CURRENT={printing_current} + G1 Z{z_max -20} F{900} ; 20mm 위로 이동 + G4 P200 ; 200mm/s wait ; 0.2초대기 + G28 Z ; Z축만 홈으로 이동 + +[gcode_macro G34] +gcode: + MGC + +[force_move] +enable_force_move: true ; enable FORCE_MOVE and SET_KINEMATIC_POSITION \ No newline at end of file diff --git a/M300_UC.ver/drivers.cfg b/M300_UC.ver/drivers.cfg new file mode 100644 index 0000000..0858874 --- /dev/null +++ b/M300_UC.ver/drivers.cfg @@ -0,0 +1,96 @@ +##################################################################### +# ★M1★ A Motor (전면에서 좌, 후면에서 우) +##################################################################### + +[tmc5160 stepper_x] +cs_pin: PD9 +interpolate: true +run_current: 2.0 +sense_resistor: 0.075 +stealthchop_threshold: 0 +spi_software_mosi_pin: PB15 +spi_software_miso_pin: PB14 +spi_software_sclk_pin: PB13 + +##################################################################### +# ★M2★ B motor (전면에서 우, 후면에서 좌) +##################################################################### + +[tmc5160 stepper_y] +cs_pin: PD8 +interpolate: true +run_current: 2.0 +sense_resistor: 0.075 +stealthchop_threshold: 0 +spi_software_mosi_pin: PB15 +spi_software_miso_pin: PB14 +spi_software_sclk_pin: PB13 + +##################################################################### +##################################################################### +##################################################################### + +# Back +# X(0),Y(MAX) +# |------------------------| +# | | Z2 | | +# | ------ | +# | | +# Left | | Right +# | | +# | | +# | | +# |----- -----| +# | Z0 | | Z1 | +# |------------------------| +# X(0),Y(0) X(MAX),Y(0) +# Front + +##################################################################### +# ★M3★ Z motor-0 +##################################################################### + +[tmc2209 stepper_z] +uart_pin: PB10 +run_current: 0.6 +sense_resistor: 0.110 +interpolate: true +stealthchop_threshold: 0 + +##################################################################### +# ★M4★ Z motor-1 +##################################################################### + +[tmc2209 stepper_z1] +uart_pin: PB2 +run_current: 0.6 +sense_resistor: 0.110 +interpolate: true +stealthchop_threshold: 0 + +##################################################################### +# ★M5★ Z motor-2 +##################################################################### + +[tmc2209 stepper_z2] +uart_pin: PA6 +run_current: 0.6 +sense_resistor: 0.110 +interpolate: true +stealthchop_threshold: 0 + +##################################################################### +# CANBus Extruder +##################################################################### + +[tmc2209 extruder] +uart_pin: Momentool:PA15 +sense_resistor: 0.110 +interpolate: true +run_current: 0.60 +stealthchop_threshold: 0 +driver_TBL: 0 +driver_HEND: 6 +driver_HSTRT: 7 +driver_TOFF: 4 + diff --git a/M300_UC.ver/drivers_v2.cfg b/M300_UC.ver/drivers_v2.cfg new file mode 100644 index 0000000..7f80c14 --- /dev/null +++ b/M300_UC.ver/drivers_v2.cfg @@ -0,0 +1,98 @@ +##################################################################### +# ★M1★ A Motor (전면에서 좌, 후면에서 우) +##################################################################### + +[tmc5160 stepper_x] +cs_pin: PD9 +interpolate: true +run_current: 2.0 +sense_resistor: 0.075 +stealthchop_threshold: 0 +spi_software_mosi_pin: PB15 +spi_software_miso_pin: PB14 +spi_software_sclk_pin: PB13 + +##################################################################### +# ★M2★ B motor (전면에서 우, 후면에서 좌) +##################################################################### + +[tmc5160 stepper_y] +cs_pin: PD8 +interpolate: true +run_current: 2.0 +sense_resistor: 0.075 +stealthchop_threshold: 0 +spi_software_mosi_pin: PB15 +spi_software_miso_pin: PB14 +spi_software_sclk_pin: PB13 + +##################################################################### +##################################################################### +##################################################################### + +# Back +# X(0),Y(MAX) +# |------------------------| +# | | Z2 | | +# | ------ | +# | | +# Left | | Right +# | | +# | | +# | | +# |----- -----| +# | Z0 | | Z1 | +# |------------------------| +# X(0),Y(0) X(MAX),Y(0) +# Front + +##################################################################### +# ★M3★ Z motor-0 +##################################################################### + +[tmc2209 stepper_z] +uart_pin: PB10 +run_current: 0.6 +sense_resistor: 0.110 +interpolate: true +stealthchop_threshold: 0 + +##################################################################### +# ★M4★ Z motor-1 +##################################################################### + +[tmc2209 stepper_z1] +uart_pin: PB2 +run_current: 0.6 +sense_resistor: 0.110 +interpolate: true +stealthchop_threshold: 0 + +##################################################################### +# ★M5★ Z motor-2 +##################################################################### + +[tmc2209 stepper_z2] +uart_pin: PA6 +run_current: 0.6 +sense_resistor: 0.110 +interpolate: true +stealthchop_threshold: 0 + +##################################################################### +# CANBus Extruder +##################################################################### + +### 모멘트루더 ### +### Momentruder ### +[tmc2209 extruder] +uart_pin: Momentool:PA15 +sense_resistor: 0.110 +interpolate: False +run_current: 0.85 +stealthchop_threshold: 0 +driver_TBL: 0 +driver_HEND: 6 +driver_HSTRT: 7 +driver_TOFF: 4 + diff --git a/M300_UC.ver/fans.cfg b/M300_UC.ver/fans.cfg new file mode 100644 index 0000000..40eb8f6 --- /dev/null +++ b/M300_UC.ver/fans.cfg @@ -0,0 +1,65 @@ +##################################################################### +# Fan +##################################################################### + +[heater_fan hotend_fan] #Hotend FAN +pin: Momentool: PA0 +max_power: 1.0 +kick_start_time: 0.5 +heater: extruder +heater_temp: 50.0 + +[fan_generic Parts_fan] #Parts FAN / P0 +pin: Momentool: PA1 +cycle_time: 0.01 +hardware_pwm: false + +[fan_generic Exhaust_fan] #Exhaust fan / P3 +pin: PA3 +cycle_time: 0.01 +hardware_pwm: false + +################################################################################ +#When using the auxiliary fan, [heater_fan controller_fan] should be annotated.# +#보조팬을 사용할 경우, [heater_fan controller_fan]를 주석처리해야 한다.############ +################################################################################ +#[fan_generic Auxiliary_fan] #Auxiliary fan / P2 +#pin: PA4 +#cycle_time: 0.01 +#hardware_pwm: false + +[heater_fan controller_fan] #Driver FAN / +pin: PA4 +max_power: 1.0 +kick_start_time: 0.5 +fan_speed: 0.8 +heater: heater_bed +heater_temp: 40.0 + +[gcode_macro M106] +gcode: + {% set P = params.P | default(0) | int %} + {% set S = params.S | default(255) | int %} + {% set speed = S / 255 %} + {% if P == 0 %} + SET_FAN_SPEED FAN=Parts_fan SPEED={speed} + {% elif P == 2 %} + SET_FAN_SPEED FAN=Auxiliary_fan SPEED={speed} + {% elif P == 3 %} + SET_FAN_SPEED FAN=Exhaust_fan SPEED={speed} + {% endif %} + +[gcode_macro M107] +gcode: + {% set fan = params.P | default(0) | int %} + {% if fan == 0 %} + SET_FAN_SPEED FAN=Parts_fan SPEED=0 + {% elif fan == 2 %} + SET_FAN_SPEED FAN=Auxiliary_fan SPEED=0 + {% elif fan == 3 %} + SET_FAN_SPEED FAN=Exhaust_fan SPEED=0 + {% else %} + SET_FAN_SPEED FAN=Parts_fan SPEED=0 + SET_FAN_SPEED FAN=Auxiliary_fan SPEED=0 + SET_FAN_SPEED FAN=Exhaust_fan SPEED=0 + {% endif %} diff --git a/M300_UC.ver/macros.cfg b/M300_UC.ver/macros.cfg new file mode 100644 index 0000000..96f78b5 --- /dev/null +++ b/M300_UC.ver/macros.cfg @@ -0,0 +1,348 @@ +[gcode_macro PRINT_START] +gcode: + M204 X Y S15000 + M117 Z_Calbrating... + STATUS_CALIBRATING_Z #ToolHead LED + M117 Tilting... + Z_TILT_ADJUST + M117 Meshing... + STATUS_MESHING #ToolHead LED + BED_MESH_CLEAR + BED_MESH_CALIBRATE + G1 Z10 F2400 + G1 X-30 Y50 F27000 + SKEW_PROFILE LOAD=my_skew + +[gcode_macro PURGE] +gcode: + M117 Cleaning... + G1 Z0.1 F1000 + G92 E0 + G1 X-30 Y50 E6.0 F120 + G1 X-15 Y50 F6000 + G92 E0 + INNER_LED_OFF + INNER_LED_ON + G1 Z0.3 F1000 + G1 E10.0 F150 + G92 E0 + G1 X-15 Y100 E6.05 + G92 E0 + G1 X-10 Y100 E0.55 + G92 E0 + G1 X-10 Y80 E2.38 + G92 E0 + G1 X-20 Y80 E1.15 + G92 E0 + M117 Printing... + +[gcode_macro echo_moment_vars] +description: Echo MomentOS variables to the console. +gcode: + {% for var, value in printer["gcode_macro Moment"].items() %} + {action_respond_info(var ~ ": " ~ value)} + {% endfor %} + +[gcode_macro ECHO_MOMENTOS_VARS] +description: Echo MomentOS variables to the console. +gcode: + {% for var, value in printer["gcode_macro MomentOS"].items() %} + {action_respond_info(var ~ ": " ~ value)} + {% endfor %} + +[gcode_macro MomentOS] +description: MomentOS variable storage macro, will echo variables to the console when run. +variable_relative_extrusion: False +variable_force_absolute_position: False +variable_preheat_extruder: True +variable_preheat_extruder_temp: 150 +variable_calibrate_bed_mesh: True +variable_nozzle_priming: "primeblob" +variable_nozzle_prime_start_x: "max" # min, max or number +variable_nozzle_prime_start_y: "min" # min, max or number +variable_nozzle_prime_direction: "auto" # auto, forwards, backwards +variable_filament_unload_length: 130 +variable_filament_unload_speed: 6000 +variable_filament_load_length: 80 +variable_filament_load_speed: 20 +variable_start_print_park_in: "back" +variable_end_print_park_in: "back" +variable_pause_print_park_in: "front" +variable_macro_travel_speed: 150 +variable_macro_z_speed: 15 +variable_end_print_park_z_hop: 20 +variable_homing: "endstops" +variable_z_probe: "static" +variable_safe_home_x: "middle" +variable_safe_home_y: "middle" +variable_stowable_probe_stop_on_error: False +gcode: + ECHO_MOMENTOS_VARS + +[gcode_macro PAUSE] +description: Pauses the printer +rename_existing: PAUSE_BASE +variable_extrude: 1.5 +gcode: + M117 Pause... + SAVE_GCODE_STATE NAME=PAUSE_state + # Define park positions + {% set E = printer["gcode_macro PAUSE"].extrude|float %} + {% set speed = printer["gcode_macro MomentOS"].macro_travel_speed|float * 60 %} + {% set z_speed = printer["gcode_macro MomentOS"].macro_z_speed|float * 60 %} + # Calculate safe Z position + {% set max_z = printer.toolhead.axis_maximum.z|float %} + {% set act_z = printer.toolhead.position.z|float %} + {% if act_z < (max_z - 20.0) %} + {% set z_safe = 20.0 %} + {% else %} + {% set z_safe = max_z - act_z %} + {% endif %} + PAUSE_BASE + G91 + # Retract + {% if printer.extruder.can_extrude|lower == 'true' %} + G1 E-{E} F2100 + {% else %} + {action_respond_info("Extruder not hot enough")} + {% endif %} + # Move to park position + {% if "xyz" in printer.toolhead.homed_axes %} + G1 Z{z_safe} F{z_speed} + _PARK LOCATION={printer["gcode_macro MomentOS"].pause_print_park_in} X={printer["gcode_macro MomentOS"].pause_print_park_x} + {% else %} + {action_respond_info("Printer not homed")} + {% endif %} + +[gcode_macro RESUME] +description: Resumes the print if the printer is paused. +rename_existing: RESUME_BASE +gcode: + M117 Printing... + STATUS_PRINTING + {% set E = printer["gcode_macro PAUSE"].extrude|float %} + # Prime + {% if printer.extruder.can_extrude|lower == 'true' %} + G91 + G1 E{E} F2100 + G90 + {% else %} + {action_respond_info("Extruder not hot enough")} + {% endif %} + RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 + RESUME_BASE + +[gcode_macro CANCEL_PRINT] +description: Cancels the printer +rename_existing: CANCEL_PRINT_BASE +gcode: + M117 Cancel... + END_PRINT + CLEAR_PAUSE + CANCEL_PRINT_BASE + +[gcode_macro END_PRINT] +description: End print procedure, use this in your Slicer. +gcode: + SAVE_GCODE_STATE NAME=end_print_state + {% set z_max = printer.toolhead.axis_maximum.z %} + G92 E0 + G0 E-1.0 F6000 ; rectract + G1 Z{z_max} ; move Z max + G28 X ; move X home + G28 Y ; move Y home + G92 E0 + G1 E5 F3600 ; extrude + M107 ; parts fan off (on is M106) + M84 ; motor off + M104 S0 ; hotend off + M140 S0 ; bed off + G91 ; relative positioning + BED_MESH_CLEAR + STATUS_READY + INNER_LED_OFF + INNER_LED_ON + SET_TMC_CURRENT STEPPER=stepper_z CURRENT=0.6 + SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT=0.6 + SET_TMC_CURRENT STEPPER=stepper_z2 CURRENT=0.6 + SET_SKEW CLEAR=1 + M106 P3 S51 #(SET_FAN_SPEED FAN=Exhaust_fan SPEED=0.2) + #M106 P2 S0 #(SET_FAN_SPEED FAN=Auxiliary_fan SPEED=0) + M117 Finished... + RESTORE_GCODE_STATE NAME=end_print_state + +[gcode_macro _END_PRINT_PARK] +gcode: + _PARK LOCATION={printer["gcode_macro MomentOS"].end_print_park_in} X={printer["gcode_macro MomentOS"].end_print_park_x} + +[gcode_macro _PARK] +gcode: + {% set speed = printer["gcode_macro MomentOS"].macro_travel_speed|float * 60 %} + # Get X position + {% if params.X != '' %} + {% if params.X|float >= printer.toolhead.axis_minimum.x + 5 and params.X|float <= printer.toolhead.axis_maximum.x - 5 %} + {% set safe_x = params.X|float %} + {% else %} + {action_respond_info('The requested X co-ordinate is outside the defined axis bounds - using defaults')} + {% set safe_x = printer.toolhead.axis_maximum.x / 2 %} + {% endif %} + {% else %} + {% set safe_x = printer.toolhead.axis_maximum.x / 2 %} + {% endif %} + # Get Y position + {% if params.LOCATION|default('back')|lower == 'back' %} + {% set y = printer.toolhead.axis_maximum.y - 5 %} + {% elif params.LOCATION|lower == 'front' %} + {% set y = printer.toolhead.axis_minimum.y + 5 %} + {% elif params.LOCATION|lower == 'center' %} + {% set y = printer.toolhead.axis_maximum.y / 2 %} + {% endif %} + G90 + G0 X{safe_x} Y{y} F{speed} + +[gcode_macro M600] +description: Executes a color change by pausing the printer an unloading the filament. +gcode: + PAUSE + UNLOAD_FILAMENT + M117 Please load new filament and resume + +[gcode_macro M601] +description: Puase macro +gcode: + PAUSE + UNLOAD_FILAMENT + M117 Please load new filament and resume + +[gcode_macro UNLOAD_FILAMENT] +description: Unloads the filament. The function is applied to the screen. +gcode: + SAVE_GCODE_STATE NAME=unload_state + {% set current_temp = printer.extruder.temperature %} + {% if current_temp >= 215 %} + {% set unload_speed = printer["gcode_macro MomentOS"].filament_unload_speed|float * 60 %} + {% set unload_length = printer["gcode_macro MomentOS"].filament_unload_length|float %} + STATUS_LOAD_UNLOAD + M117 Unloading filament... + G92 E0 #Reset the current position of the extruder. Unloading without this command may cause a lot of motor spinning or an "extrude only move too long" error. + G0 E5 F3600 # Push back the filament to smash any stringing + G0 E-45 F6000 # Extract back fast into the cold zone + # Start - Cooling, hardening, shaping filament process + G4 P15000 # Wait for 15 seconds + # End - Cooling, hardening, shaping filament process + G0 E-{unload_length} F{unload_speed} # Extract quickly to ensure no seals or blockages. + STATUS_READY + M117 Filament unloaded... + {% endif %} + RESTORE_GCODE_STATE NAME=unload_state + +[gcode_macro LOAD_FILAMENT] +description: Loads new filament. The function is applied to the screen. +gcode: + SAVE_GCODE_STATE NAME=load_state + {% set current_temp = printer.extruder.temperature %} + {% if current_temp < 215 %} + M117 Heating... + M104 S215 + TEMPERATURE_WAIT SENSOR=extruder MINIMUM=215 + {% endif %} + {% set load_speed = printer["gcode_macro MomentOS"].filament_load_speed|float * 60 %} + {% set load_length = printer["gcode_macro MomentOS"].filament_load_length|float %} + M117 Loading filament... + STATUS_LOAD_UNLOAD + G92 E0 #Reset the current position of the extruder. Unloading without this command may cause a lot of motor spinning or an "extrude only move too long" error. + G0 E{load_length} F{load_speed} # Load the filament into the hotend area. + G4 P1000 # Wait a secod + G0 E100 F100 # Purge + #M400 # Wait for purge to complete + STATUS_READY + M117 Filament loaded... + RESTORE_GCODE_STATE NAME=load_state + +##################################################################### +# Inner LED Macro +##################################################################### + +[gcode_macro INNER_LED_SEMI_HEATING] +gcode: + SET_LED LED="Inner_LED" RED=1 GREEN=0.2 BLUE=0 WHITE=0 SYNC=0 TRANSMIT=1 + +[gcode_macro INNER_LED_HEATING] +gcode: + SET_LED LED="Inner_LED" RED=1 GREEN=0 BLUE=0 WHITE=0 SYNC=0 TRANSMIT=1 + +[gcode_macro INNER_LED_ON] +gcode: + SET_LED LED="Inner_LED" RED=0.5 GREEN=0.5 BLUE=0.5 WHITE=1 SYNC=0 TRANSMIT=1 + +[gcode_macro INNER_LED_OFF] +gcode: + SET_LED LED="Inner_LED" RED=0 GREEN=0 BLUE=0 WHITE=0 SYNC=0 TRANSMIT=1 + +##################################################################### +# Toolhead LED Macro +##################################################################### + +[gcode_macro TOOLHEAD_LED_ON] +gcode: + SET_LED LED="Toolhead_LED" RED=0.5 GREEN=0.5 BLUE=0.5 WHITE=1 + +[gcode_macro TOOLHEAD_LED_OFF] +gcode: + SET_LED LED="Toolhead_LED" RED=0 GREEN=0 BLUE=0 WHITE=0 + + +##################################################################### +# PID +##################################################################### + +[gcode_macro PID_Hotend230] +gcode: + PID_CALIBRATE HEATER=extruder TARGET=230 + +[gcode_macro PID_Hotend280] +gcode: + PID_CALIBRATE HEATER=extruder TARGET=280 + +[gcode_macro PID_Bed_Heater60] +gcode: + PID_CALIBRATE HEATER=heater_bed TARGET=60 + +[gcode_macro PID_Bed_Heater100] +gcode: + PID_CALIBRATE HEATER=heater_bed TARGET=100 + +##################################################################### +# R&D +##################################################################### + +[gcode_macro Calibration_IS_X] +gcode: + TEST_RESONANCES AXIS=X + +[gcode_macro Calibration_IS_Y] +gcode: + TEST_RESONANCES AXIS=Y + +[gcode_macro Auto_Calibration_IS_XY] +gcode: + SHAPER_CALIBRATE + +##################################################################### +# ETC +##################################################################### + +[gcode_macro T0] +gcode: + +[gcode_macro PROBE_ACCURACY_Samples] +gcode: + M140 S60 + M104 S150 + M190 S60 + M109 S150 + G28 + PROBE_ACCURACY samples=100 + G1 Z50 F2400 + M104 S0 + M140 S0 diff --git a/M300_UC.ver/motors.cfg b/M300_UC.ver/motors.cfg new file mode 100644 index 0000000..b2c034b --- /dev/null +++ b/M300_UC.ver/motors.cfg @@ -0,0 +1,135 @@ +##################################################################### +# ★M1★ A Motor (전면에서 좌, 후면에서 우) +##################################################################### + +[stepper_x] +step_pin: PC8 +dir_pin: !PC9 +enable_pin: !PA15 +rotation_distance: 40 +microsteps: 16 +full_steps_per_rotation: 200 +endstop_pin: !Momentool:PB6 +position_endstop: 340 +position_min: -30 +position_max: 340 +homing_speed: 150 +second_homing_speed: 15.0 +homing_retract_dist: 5 + +##################################################################### +# ★M2★ B motor (전면에서 우, 후면에서 좌) +##################################################################### + +[stepper_y] +step_pin: PA10 +dir_pin: !PA14 +enable_pin: !PA13 +rotation_distance: 40 +microsteps: 16 +full_steps_per_rotation: 200 +endstop_pin: !PD3 +position_endstop: 346 +position_max: 346 +homing_speed: 150 +second_homing_speed: 15.0 +homing_retract_dist: 5 + +##################################################################### +##################################################################### +##################################################################### + + +# Back +# X(0),Y(MAX) +# |------------------------| +# | | Z2 | | +# | ------ | +# | | +# Left | | Right +# | | +# | | +# | | +# |----- -----| +# | Z0 | | Z1 | +# |------------------------| +# X(0),Y(0) X(MAX),Y(0) +# Front + +##################################################################### +# ★M3★ Z motor-0 +##################################################################### + +[stepper_z] +step_pin: PC6 +dir_pin: !PC7 +enable_pin: !PA9 +microsteps: 16 +rotation_distance: 4 +full_steps_per_rotation: 200 +endstop_pin: probe:z_virtual_endstop +position_min: -5 +position_max: 305 +homing_speed: 15 +second_homing_speed: 3.0 +homing_retract_dist: 5 + +##################################################################### +# ★M4★ Z motor-1 +##################################################################### + +[stepper_z1] +step_pin: PB12 +dir_pin: !PB11 +enable_pin: !PA8 +microsteps: 16 +rotation_distance: 4 +full_steps_per_rotation: 200 + +##################################################################### +# ★M5★ Z motor-2 +##################################################################### + +[stepper_z2] +step_pin: PB0 +dir_pin: !PB1 +enable_pin: !PC4 +microsteps: 16 +rotation_distance: 4 +full_steps_per_rotation: 200 + +##################################################################### +# CANBus Extruder +##################################################################### + +[extruder] +step_pin: Momentool:PD0 +dir_pin: Momentool:PD1 +enable_pin: !Momentool:PD2 +############################################################################################# +### rotation_distance는 기계요소의 비율을 조정한 것이기 때문에 추후에도 수정하지 말 것. ########## +### rotation_distance is a ratio of the extruder mechanical elements, so never modify it. ### +rotation_distance: 3.9793 +############################################################################################# +gear_ratio: 10:10 +microsteps: 16 +full_steps_per_rotation: 200 +nozzle_diameter: 0.400 +filament_diameter: 1.750 +heater_pin: Momentool:PB13 +sensor_type: PT1000 +sensor_pin: Momentool:PA3 +min_temp: 0 +max_temp: 400 +min_extrude_temp: 140 +pressure_advance: 0.05 +pressure_advance_smooth_time: 0.05 +max_extrude_only_distance: 1500 +max_extrude_cross_section: 1500 +max_extrude_only_velocity: 100 +max_extrude_only_accel: 10000 + +[verify_heater extruder] +check_gain_time: 50 +max_error: 240 + diff --git a/M300_UC.ver/motors_v2.cfg b/M300_UC.ver/motors_v2.cfg new file mode 100644 index 0000000..07e4691 --- /dev/null +++ b/M300_UC.ver/motors_v2.cfg @@ -0,0 +1,136 @@ +##################################################################### +# ★M1★ A Motor (전면에서 좌, 후면에서 우) +##################################################################### + +[stepper_x] +step_pin: PC8 +dir_pin: !PC9 +enable_pin: !PA15 +rotation_distance: 40 +microsteps: 16 +full_steps_per_rotation: 200 +endstop_pin: !Momentool:PB6 +position_endstop: 340 +position_min: -30 +position_max: 340 +homing_speed: 150 +second_homing_speed: 15.0 +homing_retract_dist: 5 + +##################################################################### +# ★M2★ B motor (전면에서 우, 후면에서 좌) +##################################################################### + +[stepper_y] +step_pin: PA10 +dir_pin: !PA14 +enable_pin: !PA13 +rotation_distance: 40 +microsteps: 16 +full_steps_per_rotation: 200 +endstop_pin: !PD3 +position_endstop: 346 +position_max: 346 +homing_speed: 150 +second_homing_speed: 15.0 +homing_retract_dist: 5 + +##################################################################### +##################################################################### +##################################################################### + + +# Back +# X(0),Y(MAX) +# |------------------------| +# | | Z2 | | +# | ------ | +# | | +# Left | | Right +# | | +# | | +# | | +# |----- -----| +# | Z0 | | Z1 | +# |------------------------| +# X(0),Y(0) X(MAX),Y(0) +# Front + +##################################################################### +# ★M3★ Z motor-0 +##################################################################### + +[stepper_z] +step_pin: PC6 +dir_pin: !PC7 +enable_pin: !PA9 +microsteps: 16 +rotation_distance: 4 +full_steps_per_rotation: 200 +endstop_pin: probe:z_virtual_endstop +position_min: -5 +position_max: 305 +homing_speed: 15 +second_homing_speed: 3.0 +homing_retract_dist: 5 + +##################################################################### +# ★M4★ Z motor-1 +##################################################################### + +[stepper_z1] +step_pin: PB12 +dir_pin: !PB11 +enable_pin: !PA8 +microsteps: 16 +rotation_distance: 4 +full_steps_per_rotation: 200 + +##################################################################### +# ★M5★ Z motor-2 +##################################################################### + +[stepper_z2] +step_pin: PB0 +dir_pin: !PB1 +enable_pin: !PC4 +microsteps: 16 +rotation_distance: 4 +full_steps_per_rotation: 200 + +##################################################################### +# CANBus Extruder +##################################################################### + +[extruder] +step_pin: Momentool:PD0 +dir_pin: Momentool:PD1 +enable_pin: !Momentool:PD2 +############################################################################################# +### rotation_distance는 기계요소의 비율을 조정한 것이기 때문에 추후에도 수정하지 말 것. ########## +### rotation_distance is a ratio of the extruder mechanical elements, so never modify it. ### +### 모멘트루더 ### +### Momentruder ### +rotation_distance: 4.637 +############################################################################################# +microsteps: 16 +full_steps_per_rotation: 200 +nozzle_diameter: 0.400 +filament_diameter: 1.750 +heater_pin: Momentool:PB13 +sensor_type: PT1000 +sensor_pin: Momentool:PA3 +min_temp: 0 +max_temp: 400 +min_extrude_temp: 140 +pressure_advance: 0.05 +pressure_advance_smooth_time: 0.05 +max_extrude_only_distance: 1500 +max_extrude_cross_section: 1500 +max_extrude_only_velocity: 100 +max_extrude_only_accel: 10000 + +[verify_heater extruder] +check_gain_time: 50 +max_error: 240 + diff --git a/M300_UC.ver/print_area-mesh.cfg b/M300_UC.ver/print_area-mesh.cfg new file mode 100644 index 0000000..4a0faef --- /dev/null +++ b/M300_UC.ver/print_area-mesh.cfg @@ -0,0 +1,141 @@ +# Setting based on kamp. +# Thank you kyleisah for contributing to the Moment 3D printer. + +[gcode_macro BED_MESH_CALIBRATE] +rename_existing: _BED_MESH_CALIBRATE +gcode: + {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Gather all object points + {% set bed_mesh_min = printer.configfile.settings.bed_mesh.mesh_min %} # Get bed mesh min from printer.cfg + {% set bed_mesh_max = printer.configfile.settings.bed_mesh.mesh_max %} # Get bed mesh max from printer.cfg + {% set probe_count = printer.configfile.settings.bed_mesh.probe_count %} # Get probe count from printer.cfg + {% set meshing_settings = printer["gcode_macro _meshing_Settings"] %} # Pull variables from _meshing_Settings + {% set mesh_margin = meshing_settings.mesh_margin | float %} # Pull mesh margin setting from _meshing_Settings + {% set fuzz_amount = meshing_settings.fuzz_amount | float %} # Pull fuzz amount setting from _meshing_Settings + {% set probe_count = probe_count if probe_count|length > 1 else probe_count * 2 %} # If probe count is only a single number, convert it to 2. E.g. probe_count:7 = 7,7 + {% set max_probe_point_distance_x = ( bed_mesh_max[0] - bed_mesh_min[0] ) / (probe_count[0] - 1) %} # Determine max probe point distance + {% set max_probe_point_distance_y = ( bed_mesh_max[1] - bed_mesh_min[1] ) / (probe_count[1] - 1) %} # Determine max probe point distance + {% set x_min = all_points | map(attribute=0) | min | default(bed_mesh_min[0]) %} # Set x_min from smallest object x point + {% set y_min = all_points | map(attribute=1) | min | default(bed_mesh_min[1]) %} # Set y_min from smallest object y point + {% set x_max = all_points | map(attribute=0) | max | default(bed_mesh_max[0]) %} # Set x_max from largest object x point + {% set y_max = all_points | map(attribute=1) | max | default(bed_mesh_max[1]) %} # Set y_max from largest object y point + + {% set fuzz_range = range((0) | int, (fuzz_amount * 100) | int + 1) %} # Set fuzz_range between 0 and fuzz_amount + {% set adapted_x_min = x_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt x_min to margin and fuzz constraints + {% set adapted_y_min = y_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt y_min to margin and fuzz constraints + {% set adapted_x_max = x_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt x_max to margin and fuzz constraints + {% set adapted_y_max = y_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt y_max to margin and fuzz constraints + + {% set adapted_x_min = [adapted_x_min , bed_mesh_min[0]] | max %} # Compare adjustments to defaults and choose max + {% set adapted_y_min = [adapted_y_min , bed_mesh_min[1]] | max %} # Compare adjustments to defaults and choose max + {% set adapted_x_max = [adapted_x_max , bed_mesh_max[0]] | min %} # Compare adjustments to defaults and choose min + {% set adapted_y_max = [adapted_y_max , bed_mesh_max[1]] | min %} # Compare adjustments to defaults and choose min + + {% set points_x = (((adapted_x_max - adapted_x_min) / max_probe_point_distance_x) | round(method='ceil') | int) + 1 %} # Define probe_count's x point count and round up + {% set points_y = (((adapted_y_max - adapted_y_min) / max_probe_point_distance_y) | round(method='ceil') | int) + 1 %} # Define probe_count's y point count and round up + + {% if (([points_x, points_y]|max) > 6) %} # + {% set algorithm = "bicubic" %} # + {% set min_points = 4 %} # + {% else %} # Calculate if algorithm should be bicubic or lagrange + {% set algorithm = "lagrange" %} # + {% set min_points = 3 %} # + {% endif %} # + + {% set points_x = [points_x , min_points]|max %} # Set probe_count's x points to fit the calculated algorithm + {% set points_y = [points_y , min_points]|max %} # Set probe_count's y points to fit the calculated algorithm + {% set points_x = [points_x , probe_count[0]]|min %} + {% set points_y = [points_y , probe_count[1]]|min %} + + {% if verbose_enable == True %} # If verbose is enabled, print information about meshing's calculations + {% if printer.exclude_object.objects != [] %} + + { action_respond_info( "Algorithm: {}.".format( + (algorithm), + )) } + + { action_respond_info("Default probe count: {},{}.".format( + (probe_count[0]), + (probe_count[1]), + )) } + + { action_respond_info("Adapted probe count: {},{}.".format( + (points_x), + (points_y), + )) } + + {action_respond_info("Default mesh bounds: {}, {}.".format( + (bed_mesh_min[0],bed_mesh_min[1]), + (bed_mesh_max[0],bed_mesh_max[1]), + )) } + + {% if mesh_margin > 0 %} + {action_respond_info("Mesh margin is {}, mesh bounds extended by {}mm.".format( + (mesh_margin), + (mesh_margin), + )) } + {% else %} + {action_respond_info("Mesh margin is 0, margin not increased.")} + {% endif %} + + {% if fuzz_amount > 0 %} + {action_respond_info("Mesh point fuzzing enabled, points fuzzed up to {}mm.".format( + (fuzz_amount), + )) } + {% else %} + {action_respond_info("Fuzz amount is 0, mesh points not fuzzed.")} + {% endif %} + + { action_respond_info("Adapted mesh bounds: {}, {}.".format( + (adapted_x_min, adapted_y_min), + (adapted_x_max, adapted_y_max), + )) } + + {action_respond_info("meshing adjustments successful!")} + + {% else %} + + {action_respond_info("No objects detected! Check your gcode and make sure that EXCLUDE_OBJECT_DEFINE is happening before BED_MESH_CALIBRATE is called. Defaulting to regular meshing.")} + G4 P5000 # Wait 5 seconds to make error more visible + {% endif %} + + {% endif %} + + {% if probe_dock_enable == True %} + {attach_macro} # Attach/deploy a probe if the probe is stored somewhere outside of the print area + {% endif %} + + _BED_MESH_CALIBRATE mesh_min={adapted_x_min},{adapted_y_min} mesh_max={adapted_x_max},{adapted_y_max} ALGORITHM={algorithm} PROBE_COUNT={points_x},{points_y} + + {% if probe_dock_enable == True %} + {detach_macro} # Detach/stow a probe if the probe is stored somewhere outside of the print area + {% endif %} + +[gcode_macro _meshing_Settings] +description: This macro contains all adjustable settings for meshing + +# The following variables are settings for meshing as a whole. +variable_verbose_enable: True # Set to True to enable meshing information output when running. This is useful for debugging. + +# The following variables are for adjusting adaptive mesh settings for meshing. +variable_mesh_margin: 0 # Expands the mesh size in millimeters if desired. Leave at 0 to disable. +variable_fuzz_amount: 0 # Slightly randomizes mesh points to spread out wear from nozzle-based probes. Leave at 0 to disable. + +# The following variables are for those with a dockable probe like Klicky, Euclid, etc. # ---------------- Attach Macro | Detach Macro +variable_probe_dock_enable: False # Set to True to enable the usage of a dockable probe. # --------------------------------------------- +variable_attach_macro: 'Attach_Probe' # The macro that is used to attach the probe. # Klicky Probe: 'Attach_Probe' | 'Dock_Probe' +variable_detach_macro: 'Dock_Probe' # The macro that is used to store the probe. # Euclid Probe: 'Deploy_Probe' | 'Stow_Probe' + # Legacy Gcode: 'M401' | 'M402' +# The following variables are for adjusting adaptive purge settings for meshing. +variable_purge_height: 0.8 # Z position of nozzle during purge, default is 0.8. +variable_tip_distance: 0 # Distance between tip of filament and nozzle before purge. Should be similar to PRINT_END final retract amount. +variable_purge_margin: 10 # Distance the purge will be in front of the print area, default is 10. +variable_purge_amount: 30 # Amount of filament to be purged prior to printing. +variable_flow_rate: 12 # Flow rate of purge in mm3/s. Default is 12. + +# The following variables are for adjusting the Smart Park feature for meshing, which will park the printhead near the print area at a specified height. +variable_smart_park_height: 10 # Z position for Smart Park, default is 10. + +gcode: # Gcode section left intentionally blank. Do not disturb. + + {action_respond_info(" Running the meshing_Settings macro does nothing, it is only used for storing meshing settings. ")} + diff --git a/M300_UC.ver/printer_settings.cfg b/M300_UC.ver/printer_settings.cfg new file mode 100644 index 0000000..b697995 --- /dev/null +++ b/M300_UC.ver/printer_settings.cfg @@ -0,0 +1,175 @@ +[exclude_object] + +[skew_correction] + +[gcode_arcs] +resolution: 0.5 + +[idle_timeout] +timeout: 432000 #5days + +[mcu] +serial: /dev/serial/by-id/usb-Klipper_stm32g0b1xx_momentOS-if00 + +[mcu Momentool] +serial: /dev/serial/by-id/usb-Klipper_stm32g0b1xx_Momentool_T0-if00 + +[adxl345] +cs_pin: Momentool: PB12 +spi_software_sclk_pin: Momentool:PB10 +spi_software_mosi_pin: Momentool:PB11 +spi_software_miso_pin: Momentool:PB2 + +[resonance_tester] +accel_chip: adxl345 +probe_points: + 150, 150, 20 + +[printer] +kinematics: corexy +max_velocity: 1000 +max_accel: 20000 +max_z_velocity: 50 +max_z_accel: 800 +square_corner_velocity: 5 + +##################################################################### +# Bed +##################################################################### + +[heater_bed] +heater_pin: PA5 +sensor_type: Generic 3950 +sensor_pin: PA0 +min_temp: 0 +max_temp: 130 + +##################################################################### +# Filament sensor +##################################################################### + +[filament_switch_sensor Runout_Sensor] +switch_pin: !PC2 +insert_gcode: + M117 Insert Detected +runout_gcode: + M601 + +##################################################################### +# Probe +##################################################################### + +[probe] +pin: Momentool:PB9 +x_offset: 0 +y_offset: 0 +#z_offset: Do not touch / 건들지 말 것. +speed: 8 +lift_speed: 8 +samples: 2 +samples_result: median +sample_retract_dist: 3.0 +samples_tolerance: 0.01 +samples_tolerance_retries: 5 +activate_gcode: + {% set PROBE_TEMP = 150 %} # PEI의 유리전이온도(Tg)는 215임. + {% set MAX_TEMP = PROBE_TEMP + 5 %} + {% set ACTUAL_TEMP = printer.extruder.temperature %} + {% set TARGET_TEMP = printer.extruder.target %} + + {% if TARGET_TEMP > PROBE_TEMP %} + { action_respond_info('Extruder temperature target of %.1fC is too high, lowering to %.1fC' % (TARGET_TEMP, PROBE_TEMP)) } + M109 S{ PROBE_TEMP } + {% else %} + {% if ACTUAL_TEMP > MAX_TEMP %} + { action_respond_info('Extruder temperature %.1fC is still too high, waiting until below %.1fC' % (ACTUAL_TEMP, MAX_TEMP)) } + TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={ MAX_TEMP } + {% endif %} + {% endif %} + +[safe_z_home] +home_xy_position: 150, 150 +speed: 300 +z_hop: 20 + +# Back +# X(0),Y(MAX) +# |------------------------| +# | | Z2 | | +# | ------ | +# | | +# Left | | Right +# | | +# | | +# | | +# |----- -----| +# | Z0 | | Z1 | +# |------------------------| +# X(0),Y(0) X(MAX),Y(0) +# Front + +[z_tilt] +z_positions: + 0, 0 #Left Front (Z0) + 300, 0 #Right Front (Z2) + 150, 300 #Center Back (Z1) +points: + 0, 0 #Left Front (Z0) + 300, 0 #Right Front (Z2) + 150, 300 #Center Back (Z1) +speed: 400 +horizontal_move_z: 10 +retries: 8 +retry_tolerance: 0.03 + +[gcode_macro Z_TILT_ADJUST] +rename_existing: BASE_Z_TILT_ADJUST +gcode: + MGC + BASE_Z_TILT_ADJUST + +[bed_mesh] +speed: 500 +horizontal_move_z: 2 +mesh_min: 0, 0 +mesh_max: 300, 300 +mesh_pps: 2, 2 +probe_count: 10, 10 +fade_start: 1 +fade_end: 10 +fade_target: 0 +algorithm: bicubic + +##################################################################### +# PCB Temp Monitoring +##################################################################### + +[temperature_sensor Calculator] +sensor_type: temperature_host +min_temp: 10 +max_temp: 100 + +[temperature_sensor MCU] +sensor_type: temperature_mcu +min_temp: 0 +max_temp: 100 + +[temperature_sensor CanBus] +sensor_type: temperature_mcu +sensor_mcu: Momentool +min_temp: 0 +max_temp: 120 +#STM32G0B1 works at 125C. Limited to 120°C for safety reasons. + +##################################################################### +# LED +##################################################################### + +[neopixel Inner_LED] +pin: PC11 +chain_count: 18 +color_order: GRBW +initial_RED: 0.5 +initial_GREEN: 0.5 +initial_BLUE: 0.5 +initial_WHITE: 1.0 diff --git a/M300_UC.ver/test_speed.cfg b/M300_UC.ver/test_speed.cfg new file mode 100644 index 0000000..bb77fce --- /dev/null +++ b/M300_UC.ver/test_speed.cfg @@ -0,0 +1,123 @@ +[gcode_macro TEST_SPEED] +# Home, get position, throw around toolhead, home again. +# If MCU stepper positions (first line in GET_POSITION) are greater than a full step different (your number of microsteps), then skipping occured. +# We only measure to a full step to accomodate for endstop variance. +# Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10 + +description: Test for max speed and acceleration parameters for the printer. Procedure: Home -> ReadPositionFromMCU -> MovesToolhead@Vel&Accel -> Home -> ReadPositionfromMCU + +gcode: + # Speed + {% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %} + # Iterations + {% set iterations = params.ITERATIONS|default(5)|int %} + # Acceleration + {% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %} + # Minimum Cruise Ratio + {% set min_cruise_ratio = params.MIN_CRUISE_RATIO|default(0.5)|float %} + # Bounding inset for large pattern (helps prevent slamming the toolhead into the sides after small skips, and helps to account for machines with imperfectly set dimensions) + {% set bound = params.BOUND|default(20)|int %} + # Size for small pattern box + {% set smallpatternsize = SMALLPATTERNSIZE|default(20)|int %} + + # Large pattern + # Max positions, inset by BOUND + {% set x_min = printer.toolhead.axis_minimum.x + bound %} + {% set x_max = printer.toolhead.axis_maximum.x - bound %} + {% set y_min = printer.toolhead.axis_minimum.y + bound %} + {% set y_max = printer.toolhead.axis_maximum.y - bound %} + + # Small pattern at center + # Find X/Y center point + {% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %} + {% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %} + + # Set small pattern box around center point + {% set x_center_min = x_center - (smallpatternsize/2) %} + {% set x_center_max = x_center + (smallpatternsize/2) %} + {% set y_center_min = y_center - (smallpatternsize/2) %} + {% set y_center_max = y_center + (smallpatternsize/2) %} + + # Save current gcode state (absolute/relative, etc) + SAVE_GCODE_STATE NAME=TEST_SPEED + + # Output parameters to g-code terminal + { action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) } + + # Home and get position for comparison later: + M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 + G28 + # QGL if not already QGLd (only if QGL section exists in config) + {% if printer.configfile.settings.quad_gantry_level %} + {% if printer.quad_gantry_level.applied == False %} + QUAD_GANTRY_LEVEL + G28 Z + {% endif %} + {% endif %} + # Move 50mm away from max position and home again (to help with hall effect endstop accuracy - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/24) + G90 + G1 X{printer.toolhead.axis_maximum.x-50} Y{printer.toolhead.axis_maximum.y-50} F{30*60} + M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 + G28 X Y + G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60} + G4 P1000 + GET_POSITION + + # Go to starting position + G0 X{x_min} Y{y_min} Z{bound + 10} F{speed*60} + + # Set new limits + {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %} + SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} MINIMUM_CRUISE_RATIO={min_cruise_ratio} + {% else %} + SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2} + {% endif %} + + {% for i in range(iterations) %} + # Large pattern diagonals + G0 X{x_min} Y{y_min} F{speed*60} + G0 X{x_max} Y{y_max} F{speed*60} + G0 X{x_min} Y{y_min} F{speed*60} + G0 X{x_max} Y{y_min} F{speed*60} + G0 X{x_min} Y{y_max} F{speed*60} + G0 X{x_max} Y{y_min} F{speed*60} + + # Large pattern box + G0 X{x_min} Y{y_min} F{speed*60} + G0 X{x_min} Y{y_max} F{speed*60} + G0 X{x_max} Y{y_max} F{speed*60} + G0 X{x_max} Y{y_min} F{speed*60} + + # Small pattern diagonals + G0 X{x_center_min} Y{y_center_min} F{speed*60} + G0 X{x_center_max} Y{y_center_max} F{speed*60} + G0 X{x_center_min} Y{y_center_min} F{speed*60} + G0 X{x_center_max} Y{y_center_min} F{speed*60} + G0 X{x_center_min} Y{y_center_max} F{speed*60} + G0 X{x_center_max} Y{y_center_min} F{speed*60} + + # Small pattern box + G0 X{x_center_min} Y{y_center_min} F{speed*60} + G0 X{x_center_min} Y{y_center_max} F{speed*60} + G0 X{x_center_max} Y{y_center_max} F{speed*60} + G0 X{x_center_max} Y{y_center_min} F{speed*60} + {% endfor %} + + # Restore max speed/accel/accel_to_decel to their configured values + {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %} + SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} MINIMUM_CRUISE_RATIO={printer.configfile.settings.printer.minimum_cruise_ratio} + {% else %} + SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel} + {% endif %} + + # Re-home and get position again for comparison: + M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 + G28 # This is a full G28 to fix an issue with CoreXZ - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/12 + # Go to XY home positions (in case your homing override leaves it elsewhere) + G90 + G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60} + G4 P1000 + GET_POSITION + + # Restore previous gcode state (absolute/relative, etc) + RESTORE_GCODE_STATE NAME=TEST_SPEED \ No newline at end of file diff --git a/M300_UC.ver/timelapse.cfg b/M300_UC.ver/timelapse.cfg new file mode 100644 index 0000000..e5543c8 --- /dev/null +++ b/M300_UC.ver/timelapse.cfg @@ -0,0 +1,424 @@ +# Timelapse klipper macro definition +# +# Copyright (C) 2021 Christoph Frei +# Copyright (C) 2021 Alex Zellner +# +# This file may be distributed under the terms of the GNU GPLv3 license +# +# Macro version 1.14 +# + +##### DO NOT CHANGE ANY MACRO!!! ##### + +########################################################################## +# # +# GET_TIMELAPSE_SETUP: Print the Timelapse setup to console # +# # +########################################################################## + +[gcode_macro GET_TIMELAPSE_SETUP] +description: Print the Timelapse setup +gcode: + {% set tl = printer['gcode_macro TIMELAPSE_TAKE_FRAME'] %} + {% set output_txt = ["Timelapse Setup:"] %} + {% set _dummy = output_txt.append("enable: %s" % tl.enable) %} + {% set _dummy = output_txt.append("park: %s" % tl.park.enable) %} + {% if tl.park.enable %} + {% set _dummy = output_txt.append("park position: %s time: %s s" % (tl.park.pos, tl.park.time)) %} + {% set _dummy = output_txt.append("park cord x:%s y:%s dz:%s" % (tl.park.coord.x, tl.park.coord.y, tl.park.coord.dz)) %} + {% set _dummy = output_txt.append("travel speed: %s mm/s" % tl.speed.travel) %} + {% endif %} + {% set _dummy = output_txt.append("fw_retract: %s" % tl.extruder.fw_retract) %} + {% if not tl.extruder.fw_retract %} + {% set _dummy = output_txt.append("retract: %s mm speed: %s mm/s" % (tl.extruder.retract, tl.speed.retract)) %} + {% set _dummy = output_txt.append("extrude: %s mm speed: %s mm/s" % (tl.extruder.extrude, tl.speed.extrude)) %} + {% endif %} + {% set _dummy = output_txt.append("verbose: %s" % tl.verbose) %} + {action_respond_info(output_txt|join("\n"))} + +################################################################################################ +# # +# Use _SET_TIMELAPSE_SETUP [ENABLE=value] [VERBOSE=value] [PARK_ENABLE=value] [PARK_POS=value] # +# [PARK_TIME=value] [CUSTOM_POS_X=value] [CUSTOM_POS_Y=value] # +# [CUSTOM_POS_DZ=value][TRAVEL_SPEED=value] [RETRACT_SPEED=value] # +# [EXTRUDE_SPEED=value] [EXTRUDE_DISTANCE=value] # +# [RETRACT_DISTANCE=value] [FW_RETRACT=value] # +# # +################################################################################################ + +[gcode_macro _SET_TIMELAPSE_SETUP] +description: Set user parameters for timelapse +gcode: + {% set tl = printer['gcode_macro TIMELAPSE_TAKE_FRAME'] %} + ##### get min and max bed size ##### + {% set min = printer.toolhead.axis_minimum %} + {% set max = printer.toolhead.axis_maximum %} + {% set round_bed = True if printer.configfile.settings.printer.kinematics is in ['delta','polar','rotary_delta','winch'] + else False %} + {% set park = {'min' : {'x': (min.x / 1.42)|round(3) if round_bed else min.x|round(3), + 'y': (min.y / 1.42)|round(3) if round_bed else min.y|round(3)}, + 'max' : {'x': (max.x / 1.42)|round(3) if round_bed else max.x|round(3), + 'y': (max.y / 1.42)|round(3) if round_bed else max.y|round(3)}, + 'center': {'x': (max.x-(max.x-min.x)/2)|round(3), + 'y': (max.y-(max.y-min.y)/2)|round(3)}} %} + ##### set new values ##### + {% if params.ENABLE %} + {% if params.ENABLE|lower is in ['true', 'false'] %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=enable VALUE={True if params.ENABLE|lower == 'true' else False} + {% else %} + {action_raise_error("ENABLE=%s not supported. Allowed values are [True, False]" % params.ENABLE|capitalize)} + {% endif %} + {% endif %} + {% if params.VERBOSE %} + {% if params.VERBOSE|lower is in ['true', 'false'] %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=verbose VALUE={True if params.VERBOSE|lower == 'true' else False} + {% else %} + {action_raise_error("VERBOSE=%s not supported. Allowed values are [True, False]" % params.VERBOSE|capitalize)} + {% endif %} + {% endif %} + {% if params.CUSTOM_POS_X %} + {% if params.CUSTOM_POS_X|float >= min.x and params.CUSTOM_POS_X|float <= max.x %} + {% set _dummy = tl.park.custom.update({'x':params.CUSTOM_POS_X|float|round(3)}) %} + {% else %} + {action_raise_error("CUSTOM_POS_X=%s must be within [%s - %s]" % (params.CUSTOM_POS_X, min.x, max.x))} + {% endif %} + {% endif %} + {% if params.CUSTOM_POS_Y %} + {% if params.CUSTOM_POS_Y|float >= min.y and params.CUSTOM_POS_Y|float <= max.y %} + {% set _dummy = tl.park.custom.update({'y':params.CUSTOM_POS_Y|float|round(3)}) %} + {% else %} + {action_raise_error("CUSTOM_POS_Y=%s must be within [%s - %s]" % (params.CUSTOM_POS_Y, min.y, max.y))} + {% endif %} + {% endif %} + {% if params.CUSTOM_POS_DZ %} + {% if params.CUSTOM_POS_DZ|float >= min.z and params.CUSTOM_POS_DZ|float <= max.z %} + {% set _dummy = tl.park.custom.update({'dz':params.CUSTOM_POS_DZ|float|round(3)}) %} + {% else %} + {action_raise_error("CUSTOM_POS_DZ=%s must be within [%s - %s]" % (params.CUSTOM_POS_DZ, min.z, max.z))} + {% endif %} + {% endif %} + {% if params.PARK_ENABLE %} + {% if params.PARK_ENABLE|lower is in ['true', 'false'] %} + {% set _dummy = tl.park.update({'enable':True if params.PARK_ENABLE|lower == 'true' else False}) %} + {% else %} + {action_raise_error("PARK_ENABLE=%s not supported. Allowed values are [True, False]" % params.PARK_ENABLE|capitalize)} + {% endif %} + {% endif %} + {% if params.PARK_POS %} + {% if params.PARK_POS|lower is in ['center','front_left','front_right','back_left','back_right','custom','x_only','y_only'] %} + {% set dic = {'center' : {'x': park.center.x , 'y': park.center.y , 'dz': 1 }, + 'front_left' : {'x': park.min.x , 'y': park.min.y , 'dz': 0 }, + 'front_right' : {'x': park.max.x , 'y': park.min.y , 'dz': 0 }, + 'back_left' : {'x': park.min.x , 'y': park.max.y , 'dz': 0 }, + 'back_right' : {'x': park.max.x , 'y': park.max.y , 'dz': 0 }, + 'custom' : {'x': tl.park.custom.x, 'y': tl.park.custom.y, 'dz': tl.park.custom.dz}, + 'x_only' : {'x': tl.park.custom.x, 'y': 'none' , 'dz': tl.park.custom.dz}, + 'y_only' : {'x': 'none' , 'y': tl.park.custom.y, 'dz': tl.park.custom.dz}} %} + {% set _dummy = tl.park.update({'pos':params.PARK_POS|lower}) %} + {% set _dummy = tl.park.update({'coord':dic[tl.park.pos]}) %} + {% else %} + {action_raise_error("PARK_POS=%s not supported. Allowed values are [CENTER, FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, CUSTOM, X_ONLY, Y_ONLY]" + % params.PARK_POS|upper)} + {% endif %} + {% endif %} + {% if params.PARK_TIME %} + {% if params.PARK_TIME|float >= 0.0 %} + {% set _dummy = tl.park.update({'time':params.PARK_TIME|float|round(3)}) %} + {% else %} + {action_raise_error("PARK_TIME=%s must be a positive number" % params.PARK_TIME)} + {% endif %} + {% endif %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=park VALUE="{tl.park}" + {% if params.TRAVEL_SPEED %} + {% if params.TRAVEL_SPEED|float > 0.0 %} + {% set _dummy = tl.speed.update({'travel':params.TRAVEL_SPEED|float|round(3)}) %} + {% else %} + {action_raise_error("TRAVEL_SPEED=%s must be larger than 0" % params.TRAVEL_SPEED)} + {% endif %} + {% endif %} + {% if params.RETRACT_SPEED %} + {% if params.RETRACT_SPEED|float > 0.0 %} + {% set _dummy = tl.speed.update({'retract':params.RETRACT_SPEED|float|round(3)}) %} + {% else %} + {action_raise_error("RETRACT_SPEED=%s must be larger than 0" % params.RETRACT_SPEED)} + {% endif %} + {% endif %} + {% if params.EXTRUDE_SPEED %} + {% if params.EXTRUDE_SPEED|float > 0.0 %} + {% set _dummy = tl.speed.update({'extrude':params.EXTRUDE_SPEED|float|round(3)}) %} + {% else %} + {action_raise_error("EXTRUDE_SPEED=%s must be larger than 0" % params.EXTRUDE_SPEED)} + {% endif %} + {% endif %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=speed VALUE="{tl.speed}" + {% if params.EXTRUDE_DISTANCE %} + {% if params.EXTRUDE_DISTANCE|float >= 0.0 %} + {% set _dummy = tl.extruder.update({'extrude':params.EXTRUDE_DISTANCE|float|round(3)}) %} + {% else %} + {action_raise_error("EXTRUDE_DISTANCE=%s must be specified as positiv number" % params.EXTRUDE_DISTANCE)} + {% endif %} + {% endif %} + {% if params.RETRACT_DISTANCE %} + {% if params.RETRACT_DISTANCE|float >= 0.0 %} + {% set _dummy = tl.extruder.update({'retract':params.RETRACT_DISTANCE|float|round(3)}) %} + {% else %} + {action_raise_error("RETRACT_DISTANCE=%s must be specified as positiv number" % params.RETRACT_DISTANCE)} + {% endif %} + {% endif %} + {% if params.FW_RETRACT %} + {% if params.FW_RETRACT|lower is in ['true', 'false'] %} + {% if 'firmware_retraction' in printer.configfile.settings %} + {% set _dummy = tl.extruder.update({'fw_retract': True if params.FW_RETRACT|lower == 'true' else False}) %} + {% else %} + {% set _dummy = tl.extruder.update({'fw_retract':False}) %} + {% if params.FW_RETRACT|capitalize == 'True' %} + {action_raise_error("[firmware_retraction] not defined in printer.cfg. Can not enable fw_retract")} + {% endif %} + {% endif %} + {% else %} + {action_raise_error("FW_RETRACT=%s not supported. Allowed values are [True, False]" % params.FW_RETRACT|capitalize)} + {% endif %} + {% endif %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=extruder VALUE="{tl.extruder}" + {% if printer.configfile.settings['gcode_macro pause'] is defined %} + {% set _dummy = tl.macro.update({'pause': printer.configfile.settings['gcode_macro pause'].rename_existing}) %} + {% endif %} + {% if printer.configfile.settings['gcode_macro resume'] is defined %} + {% set _dummy = tl.macro.update({'resume': printer.configfile.settings['gcode_macro resume'].rename_existing}) %} + {% endif %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=macro VALUE="{tl.macro}" + +########################################################################## +# # +# TIMELAPSE_TAKE_FRAME: take the next picture # +# # +########################################################################## + +######################### definition ######################### +## enable: enable or disable the next frame. Valid inputs: [True, False] +## takingframe: internal use. Valid inputs: [True, False] +## +## park.enable: enable or disable to park the head while taking a picture. Valid inputs: [True, False] +## park.pos : used position for parking. Valid inputs: [center, front_left, front_right, back_left, back_right, custom, x_only, y_only] +## park.time : used for the debug macro. Time in s +## park.custom.x, park.custom.y: coordinates of the custom parkposition. Unit [mm] +## park.custom.dz : custom z hop for the picture. Unit [mm] +## park.coord : internal use +## +## extruder.fw_retract: enable disable fw retraction [True,False] +## extruder.extrude : filament extruded at the end of park. Unit [mm] +## extruder.retract : filament retract at the start of park. Unit [mm] +## +## speed.travel : used speed for travel from and to the park positon. Unit: [mm/min] +## speed.retract: used speed for retract [mm/min] +## speed.extrude: used speed for extrude [mm/min] +## +## verbose: Enable mesage output of TIMELAPSE_TAKE_FRAME +## +## restore.absolute.coordinates: internal use +## restore.absolute.extrude : internal use +## restore.speed : internal use +## restore.e : internal use +## restore.factor.speed : internal use +## restore.factor.extrude : internal use +## +## macro.pause : internal use +## macro.resume : internal use +## +## is_paused: internal use +############################################################### +[gcode_macro TIMELAPSE_TAKE_FRAME] +description: Take Timelapse shoot +variable_enable: False +variable_takingframe: False +variable_park: {'enable': False, + 'pos' : 'center', + 'time' : 0.1, + 'custom': {'x': 0, 'y': 0, 'dz': 0}, + 'coord' : {'x': 0, 'y': 0, 'dz': 0}} +variable_extruder: {'fw_retract': False, + 'retract': 1.0, + 'extrude': 1.0} +variable_speed: {'travel': 100, + 'retract': 15, + 'extrude': 15} +variable_verbose: True +variable_restore: {'absolute': {'coordinates': True, 'extrude': True}, 'speed': 1500, 'e':0, 'factor': {'speed': 1.0, 'extrude': 1.0}} +variable_macro: {'pause': 'PAUSE', 'resume': 'RESUME'} +variable_is_paused: False +gcode: + {% set hyperlapse = True if params.HYPERLAPSE and params.HYPERLAPSE|lower =='true' else False %} + {% if enable %} + {% if (hyperlapse and printer['gcode_macro HYPERLAPSE'].run) or + (not hyperlapse and not printer['gcode_macro HYPERLAPSE'].run) %} + {% if park.enable %} + {% set pos = {'x': 'X' + park.coord.x|string if park.pos != 'y_only' else '', + 'y': 'Y' + park.coord.y|string if park.pos != 'x_only' else '', + 'z': 'Z'+ [printer.gcode_move.gcode_position.z + park.coord.dz, printer.toolhead.axis_maximum.z]|min|string} %} + {% set restore = {'absolute': {'coordinates': printer.gcode_move.absolute_coordinates, + 'extrude' : printer.gcode_move.absolute_extrude}, + 'speed' : printer.gcode_move.speed, + 'e' : printer.gcode_move.gcode_position.e, + 'factor' : {'speed' : printer.gcode_move.speed_factor, + 'extrude': printer.gcode_move.extrude_factor}} %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=restore VALUE="{restore}" + {% if not printer[printer.toolhead.extruder].can_extrude %} + {% if verbose %}{action_respond_info("Timelapse: Warning, minimum extruder temperature not reached!")}{% endif %} + {% else %} + {% if extruder.fw_retract %} + G10 + {% else %} + M83 ; insure relative extrusion + G0 E-{extruder.retract} F{speed.retract * 60} + {% endif %} + {% endif %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=is_paused VALUE=True + {macro.pause} ; execute the klipper PAUSE command + SET_GCODE_OFFSET X=0 Y=0 ; this will insure that the head parks always at the same position in a multi setup + G90 ; insure absolute move + {% if "xyz" not in printer.toolhead.homed_axes %} + {% if verbose %}{action_respond_info("Timelapse: Warning, axis not homed yet!")}{% endif %} + {% else %} + G0 {pos.x} {pos.y} {pos.z} F{speed.travel * 60} + {% endif %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=takingframe VALUE=True + UPDATE_DELAYED_GCODE ID=_WAIT_TIMELAPSE_TAKE_FRAME DURATION=0.5 + M400 + {% endif %} + _TIMELAPSE_NEW_FRAME HYPERLAPSE={hyperlapse} + {% endif %} + {% else %} + {% if verbose %}{action_respond_info("Timelapse: disabled, take frame ignored")}{% endif %} + {% endif %} + +[gcode_macro _TIMELAPSE_NEW_FRAME] +description: action call for timelapse shoot. must be a seperate macro +gcode: + {action_call_remote_method("timelapse_newframe", + macropark=printer['gcode_macro TIMELAPSE_TAKE_FRAME'].park, + hyperlapse=params.HYPERLAPSE)} + +[delayed_gcode _WAIT_TIMELAPSE_TAKE_FRAME] +gcode: + {% set tl = printer['gcode_macro TIMELAPSE_TAKE_FRAME'] %} + {% set factor = {'speed': printer.gcode_move.speed_factor, 'extrude': printer.gcode_move.extrude_factor} %} + {% if tl.takingframe %} + UPDATE_DELAYED_GCODE ID=_WAIT_TIMELAPSE_TAKE_FRAME DURATION=0.5 + {% else %} + {tl.macro.resume} VELOCITY={tl.speed.travel} ; execute the klipper RESUME command + SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=is_paused VALUE=False + {% if not printer[printer.toolhead.extruder].can_extrude %} + {action_respond_info("Timelapse: Warning minimum extruder temperature not reached!")} + {% else %} + {% if tl.extruder.fw_retract %} + G11 + {% else %} + G0 E{tl.extruder.extrude} F{tl.speed.extrude * 60} + G0 F{tl.restore.speed} + {% if tl.restore.absolute.extrude %} + M82 + G92 E{tl.restore.e} + {% endif %} + {% endif %} + {% endif %} + {% if tl.restore.factor.speed != factor.speed %} M220 S{(factor.speed*100)|round(0)} {% endif %} + {% if tl.restore.factor.extrude != factor.extrude %} M221 S{(factor.extrude*100)|round(0)} {% endif %} + {% if not tl.restore.absolute.coordinates %} G91 {% endif %} + {% endif %} + +#################################################################################################### +# # +# HYPERLAPSE: Starts or stops a Hyperlapse video # +# Usage: HYPERLAPSE ACTION=START [CYCLE=time] starts a hyperlapse with cycle time (default 30 sec) # +# HYPERLAPSE ACTION=STOP stops the hyperlapse recording # +# # +#################################################################################################### + +######################### definition ######################### +## cycle: cycle time in seconds +## run: internal use [True/False] +############################################################### +[gcode_macro HYPERLAPSE] +description: Start/Stop a hyperlapse recording +variable_cycle: 0 +variable_run: False +gcode: + {% set cycle = params.CYCLE|default(30)|int %} + {% if params.ACTION and params.ACTION|lower == 'start' %} + {action_respond_info("Hyperlapse: frames started (Cycle %d sec)" % cycle)} + SET_GCODE_VARIABLE MACRO=HYPERLAPSE VARIABLE=run VALUE=True + SET_GCODE_VARIABLE MACRO=HYPERLAPSE VARIABLE=cycle VALUE={cycle} + UPDATE_DELAYED_GCODE ID=_HYPERLAPSE_LOOP DURATION={cycle} + TIMELAPSE_TAKE_FRAME HYPERLAPSE=True + {% elif params.ACTION and params.ACTION|lower == 'stop' %} + {% if run %}{action_respond_info("Hyperlapse: frames stopped")}{% endif %} + SET_GCODE_VARIABLE MACRO=HYPERLAPSE VARIABLE=run VALUE=False + UPDATE_DELAYED_GCODE ID=_HYPERLAPSE_LOOP DURATION=0 + {% else %} + {action_raise_error("Hyperlapse: No valid input parameter + Use: + - HYPERLAPSE ACTION=START [CYCLE=time] + - HYPERLAPSE ACTION=STOP")} + {% endif %} + +[delayed_gcode _HYPERLAPSE_LOOP] +gcode: + UPDATE_DELAYED_GCODE ID=_HYPERLAPSE_LOOP DURATION={printer["gcode_macro HYPERLAPSE"].cycle} + TIMELAPSE_TAKE_FRAME HYPERLAPSE=True + +########################################################################## +# # +# TIMELAPSE_RENDER: Render the video at print end # +# # +########################################################################## + +######################### definition ######################### +## render: internal use. Valid inputs: [True, False] +## run_identifier: internal use. Valid input [0 .. 3] +############################################################### +[gcode_macro TIMELAPSE_RENDER] +description: Render Timelapse video and wait for the result +variable_render: False +variable_run_identifier: 0 +gcode: + {action_respond_info("Timelapse: Rendering started")} + {action_call_remote_method("timelapse_render", byrendermacro="True")} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_RENDER VARIABLE=render VALUE=True + {printer.configfile.settings['gcode_macro pause'].rename_existing} ; execute the klipper PAUSE command + UPDATE_DELAYED_GCODE ID=_WAIT_TIMELAPSE_RENDER DURATION=0.5 + +[delayed_gcode _WAIT_TIMELAPSE_RENDER] +gcode: + {% set ri = printer['gcode_macro TIMELAPSE_RENDER'].run_identifier % 4 %} + SET_GCODE_VARIABLE MACRO=TIMELAPSE_RENDER VARIABLE=run_identifier VALUE={ri + 1} + {% if printer['gcode_macro TIMELAPSE_RENDER'].render %} + M117 Rendering {['-','\\','|','/'][ri]} + UPDATE_DELAYED_GCODE ID=_WAIT_TIMELAPSE_RENDER DURATION=0.5 + {% else %} + {action_respond_info("Timelapse: Rendering finished")} + M117 + {printer.configfile.settings['gcode_macro resume'].rename_existing} ; execute the klipper RESUME command + {% endif %} + +########################################################################## +# # +# TEST_STREAM_DELAY: Helper macro to find stream and park delay # +# # +########################################################################## + +[gcode_macro TEST_STREAM_DELAY] +description: Helper macro to find stream and park delay +gcode: + {% set min = printer.toolhead.axis_minimum %} + {% set max = printer.toolhead.axis_maximum %} + {% set act = printer.toolhead.position %} + {% set tl = printer['gcode_macro TIMELAPSE_TAKE_FRAME'] %} + {% if act.z > 5.0 %} + G0 X{min.x + 5.0} F{tl.speed.travel|int * 60} + G0 X{(max.x-min.x)/2} + G4 P{tl.park.time|float * 1000} + _TIMELAPSE_NEW_FRAME HYPERLAPSE=FALSE + G0 X{max.x - 5.0} + {% else %} + {action_raise_error("Toolhead z %.3f to low. Please place head above z = 5.0" % act.z)} + {% endif %} diff --git a/M300_UC.ver/tool_head_leds.cfg b/M300_UC.ver/tool_head_leds.cfg new file mode 100644 index 0000000..5dfa6b0 --- /dev/null +++ b/M300_UC.ver/tool_head_leds.cfg @@ -0,0 +1,163 @@ +# Setting based on voron. +# Thank you voron for contributing to the moment 3D printer. + +##################################################################### +# LED Configuration +##################################################################### + +[neopixel Toolhead_LED] +pin: Momentool: PD3 +chain_count: 2 +color_order: GRBW, GRBW +initial_RED: 0.5 +initial_GREEN: 0.5 +initial_BLUE: 0.5 +initial_WHITE: 1.0 + +[gcode_macro _toolhead_vars] +variable_colors: { + 'logo': { + 'busy': {'r': 0.4, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'calibrating_z': {'r': 0.2, 'g': 1.0, 'b': 0.0, 'w': 0.0}, + 'heating': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'homing': {'r': 0.0, 'g': 0.6, 'b': 0.2, 'w': 0.0}, + 'leveling': {'r': 0.5, 'g': 0.1, 'b': 0.4, 'w': 0.0}, + 'meshing': {'r': 0.8, 'g': 0.0, 'b': 0.35, 'w': 0.0}, + 'off': {'r': 0.0, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'printing': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'standby': {'r': 0.5, 'g': 0.5, 'b': 0.5, 'w': 0.1}, + 'load_unload': {'r': 1.0, 'g': 1.0, 'b': 0.0, 'w':0.0}, + }, + 'nozzle': { + 'heating': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w':0.0}, + 'off': {'r': 0.0, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'on': {'r': 0.5, 'g': 0.5, 'b': 0.5, 'w':1.0}, + 'standby': {'r': 0.5, 'g': 0.5, 'b': 0.5, 'w':0.5}, + 'printing': {'r': 0.5, 'g': 0.5, 'b': 0.5, 'w':1.0}, + 'load_unload': {'r': 1.0, 'g': 1.0, 'b': 0.0, 'w':0.0}, + }, + 'thermal': { + 'hot': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w': 0.0}, + 'cold': {'r': 0.3, 'g': 0.0, 'b': 0.3, 'w': 0.0} + } + } +variable_logo_led_name: "Toolhead_LED" +variable_logo_idx: "1" +variable_nozzle_led_name: "Toolhead_LED" +variable_nozzle_idx: "2" +gcode: + +[gcode_macro _set_toolhead_leds] +gcode: + {% set red = params.RED|default(0)|float %} + {% set green = params.GREEN|default(0)|float %} + {% set blue = params.BLUE|default(0)|float %} + {% set white = params.WHITE|default(0)|float %} + {% set led = params.LED|string %} + {% set idx = (params.IDX|string).split(',') %} + {% set transmit_last = params.TRANSMIT|default(1) %} + + {% for led_index in idx %} + {% set transmit=transmit_last if loop.last else 0 %} + set_led led={led} red={red} green={green} blue={blue} white={white} index={led_index} transmit={transmit} + {% endfor %} + +[gcode_macro _set_toolhead_leds_by_name] +gcode: + {% set leds_name = params.LEDS %} + {% set color_name = params.COLOR %} + {% set color = printer["gcode_macro _toolhead_vars"].colors[leds_name][color_name] %} + {% set led = printer["gcode_macro _toolhead_vars"][leds_name + "_led_name"] %} + {% set idx = printer["gcode_macro _toolhead_vars"][leds_name + "_idx"] %} + {% set transmit = params.TRANSMIT|default(1) %} + + _set_toolhead_leds led={led} red={color.r} green={color.g} blue={color.b} white={color.w} idx="{idx}" transmit={transmit} + +[gcode_macro _set_logo_leds] +gcode: + {% set red = params.RED|default(0)|float %} + {% set green = params.GREEN|default(0)|float %} + {% set blue = params.BLUE|default(0)|float %} + {% set white = params.WHITE|default(0)|float %} + {% set led = printer["gcode_macro _toolhead_vars"].logo_led_name %} + {% set idx = printer["gcode_macro _toolhead_vars"].logo_idx %} + {% set transmit=params.TRANSMIT|default(1) %} + + _set_toolhead_leds led={led} red={red} green={green} blue={blue} white={white} idx="{idx}" transmit={transmit} + +[gcode_macro _set_nozzle_leds] +gcode: + {% set red = params.RED|default(0)|float %} + {% set green = params.GREEN|default(0)|float %} + {% set blue = params.BLUE|default(0)|float %} + {% set white = params.WHITE|default(0)|float %} + {% set led = printer["gcode_macro _toolhead_vars"].nozzle_led_name %} + {% set idx = printer["gcode_macro _toolhead_vars"].nozzle_idx %} + {% set transmit=params.TRANSMIT|default(1) %} + + _set_toolhead_leds led={led} red={red} green={green} blue={blue} white={white} idx="{idx}" transmit={transmit} + +[gcode_macro set_logo_leds_off] +gcode: + {% set transmit=params.TRANSMIT|default(1) %} + _set_logo_leds red=0 blue=0 green=0 white=0 transmit={transmit} + +[gcode_macro set_nozzle_leds_on] +gcode: + {% set transmit=params.TRANSMIT|default(1) %} + _set_toolhead_leds_by_name leds="nozzle" color="on" transmit={transmit} + +[gcode_macro set_nozzle_leds_off] +gcode: + {% set transmit=params.TRANSMIT|default(1) %} + _set_toolhead_leds_by_name leds="nozzle" color="off" transmit={transmit} + +[gcode_macro status_off] +gcode: + set_logo_leds_off transmit=0 + set_nozzle_leds_off + +[gcode_macro status_ready] +gcode: + _set_toolhead_leds_by_name leds="logo" color="standby" transmit=0 + _set_toolhead_leds_by_name leds="nozzle" color="standby" transmit=1 + +[gcode_macro status_busy] +gcode: + _set_toolhead_leds_by_name leds="logo" color="busy" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_heating] +gcode: + _set_toolhead_leds_by_name leds="logo" color="heating" transmit=0 + _set_toolhead_leds_by_name leds="nozzle" color="heating" transmit=1 + +[gcode_macro status_leveling] +gcode: + _set_toolhead_leds_by_name leds="logo" color="leveling" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_homing] +gcode: + _set_toolhead_leds_by_name leds="logo" color="homing" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_meshing] +gcode: + _set_toolhead_leds_by_name leds="logo" color="meshing" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_calibrating_z] +gcode: + _set_toolhead_leds_by_name leds="logo" color="calibrating_z" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_printing] +gcode: + _set_toolhead_leds_by_name leds="logo" color="printing" transmit=0 + set_nozzle_leds_on + +[gcode_macro status_load_unload] +gcode: + _set_toolhead_leds_by_name leds="logo" color="load_unload" transmit=0 + _set_toolhead_leds_by_name leds="nozzle" color="load_unload" transmit=1