Removed “from what i can tell” garbage from the code and actually added few small tweaks to add wipes and when needed so print does not start or end oozing filament.
Tested with PLA. Should be same for anything else.
I know there is one floating around already but for some reasons it keeps homing X and Y in a loop while default code works. So i removed junk from default code and all is well.
Start code
M109 S150 ;warm up the nozzle WAIT in case filament is on the nozzle
;===== reset machine status =================
M290 X40 Y40 Z2.6666666 ;not sure what that does
G91 ;Set to relative positioning
M17 Z0.4 ; lower the z-motor current
G1 Z-10 F300 ; Move bed down 10 in case there is something on it
G90 ;Set to Absolute positioning
M17 X1.2 Y1.2 Z0.75 ; reset motor current to default
M960 S5 P1 ; turn on logo lamp ?
G90 ;Set to Absolute positioning
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate
M73.2 R1.0 ;Reset "left time"
M1002 set_gcode_claim_speed_level : 5 ;NONE standard code
M221 X0 Y0 Z0 ; turn off soft endstop to prevent protential logic problem NONE standard code
G29.1 Z{+0.0} ; clear z-trim value first NONE standard code
M204 S10000 ; Set default acceleration
;===== heatbed preheat ====================
M1002 gcode_claim_action : 2 NONE standard code
M140 S[bed_temperature_initial_layer_single] ;set bed temp no wait
M190 S[bed_temperature_initial_layer_single] ;wait for bed temp WAIT
;=============turn on fans to prevent PLA jamming=================
{if filament_type[initial_extruder]=="PLA"}
{if (bed_temperature[initial_extruder] >45)||(bed_temperature_initial_layer[initial_extruder] >45)}
M106 P3 S180
{endif};Prevent PLA from jamming
{endif}
M106 P2 S100 ; turn on big fan ,to cool down toolhead
;===== prepare print temperature and material ==========
M104 S[nozzle_temperature_initial_layer] ;set extruder temp
G91 ;Set relative position
G0 Z10 F1200 ;Raise bed by 10mm
G90 ;Set absolute position
G28 X ;home X
M975 S1 ; turn on what ?
G1 X60 F12000 ;move to parking zone
G1 Y245 ;move to parking zone
G1 Y265 F3000 ;move to parking zone
M620 M ;none standard code
M620 S[initial_extruder]A ; switch material if AMS exist
M109 S[nozzle_temperature_initial_layer]
G1 X120 F12000
G1 X20 Y50 F12000
G1 Y-3
T[initial_extruder]
G1 X54 F12000
G1 Y265
M400
M621 S[initial_extruder]A
M620.1 E F{filament_max_volumetric_speed[initial_extruder]/2.4053*60} T{nozzle_temperature_range_high[initial_extruder]}
M412 S1 ; ===turn on filament runout detection===
M109 S[nozzle_temperature_initial_layer] ;heat up nozzle
G92 E0 ;Reset extruder
G1 E10 F200 ;purge 5mm while dropping temp
M400
M106 P1 S255 ;Fan 100%
M109 S{nozzle_temperature_initial_layer[initial_extruder]-20} ; drop nozzle temp, make filament shink a bit
G92 E0 ;Eeset extruder
G1 E-5 F300 ;retract filament
G1 X70 F9000
G1 X76 F15000
G1 X65 F15000
G1 X76 F15000
G1 X65 F15000; shake to put down garbage
G1 X80 F6000
G1 X95 F15000
G1 X80 F15000
G1 X165 F15000; wipe and shake
M400
M106 P1 S0
;===== prepare print temperature and material end =====
;===== bed leveling ==================================
M1002 judge_flag g29_before_print_flag
M622 J1
M1002 gcode_claim_action : 1
G29 A X{first_layer_print_min[0]} Y{first_layer_print_min[1]} I{first_layer_print_size[0]} J{first_layer_print_size[1]}
M400
M500 ; save cali data
M623
;===== bed leveling end ================================
;===== home after wipe mouth============================
M1002 judge_flag g29_before_print_flag
M622 J0
M1002 gcode_claim_action : 13
G28
M623
;===== home after wipe mouth end =======================
M975 S1 ; turn on vibration supression
;=============turn on fans to prevent PLA jamming=================
{if filament_type[initial_extruder]=="PLA"}
{if (bed_temperature[initial_extruder] >45)||(bed_temperature_initial_layer[initial_extruder] >45)}
M106 P3 S180
{endif};Prevent PLA from jamming
{endif}
M106 P2 S100 ; turn on big fan ,to cool down toolhead
M109 S{nozzle_temperature_initial_layer[initial_extruder]} ; set extrude temp earlier, to reduce wait time
;===== for Textured PEI Plate , lower the nozzle as the nozzle was touching topmost of the texture when homing ==
;curr_bed_type={curr_bed_type}
{if curr_bed_type=="Textured PEI Plate"}
G29.1 Z{-0.04} ; for Textured PEI Plate
{endif}
;========turn off light and wait extrude temperature =============
M1002 gcode_claim_action : 0
M106 S0 ; turn off fan
M106 P2 S0 ; turn off big fan
M106 P3 S0 ; turn off chamber fan
M975 S1 ; turn on mech mode supression
G1 E5 F300 ;push filament out to prevent dry start
End code mostly unchanged.
;===== date: 20230428 =====================
M400 ; wait for buffer to clear
G92 E0 ; zero the extruder
G1 E-0.8 F1800 ; retract
G1 Z{max_layer_z + 0.5} F900 ; lower z a little
G1 X65 Y245 F12000 ; move to safe pos
G1 Y265 F3000
G1 X65 Y245 F12000
G1 Y265 F3000
M140 S0 ; turn off bed
M106 S0 ; turn off fan
M106 P2 S0 ; turn off remote part cooling fan
M106 P3 S0 ; turn off chamber cooling fan
G1 X100 F12000 ; wipe
; pull back filament to AMS
M620 S255
G1 X20 Y50 F12000 ;move to parking zone
G1 Y-3 ;move to parking zone
M109 S180 ; Cool down hotend
T255 ;must be fan related
G1 X65 F12000
G1 Y265
G1 X100 F12000 ; wipe
M621 S255 ;i think its a fan
G1 X65 F12000 ; wipe
G1 X100 F12000 ; wipe
G1 X65 F12000 ; wipe
G1 X100 F12000 ; wipe
M621 S255
M104 S0 ; turn off hotend
M622.1 S1 ; for prev firware, default turned on
M1002 judge_flag timelapse_record_flag
M622 J1
M400 ; wait all motion done
M991 S0 P-1 ;end smooth timelapse at safe pos
M400 S3 ;wait for last picture to be taken
M623; end of "timelapse_record_flag"
M400 ; wait all motion done
M17 S
M17 Z0.4 ; lower z motor current to reduce impact if there is something in the bottom
{if (max_layer_z + 100.0) < 250}
G1 Z{max_layer_z + 100.0} F600
G1 Z{max_layer_z +98.0}
{else}
G1 Z250 F600
G1 Z248
{endif}
M400 P100
M17 R ; restore z current
M220 S100 ; Reset feedrate magnitude
M201.2 K1.0 ; Reset acc magnitude
M73.2 R1.0 ;Reset left time magnitude
M1002 set_gcode_claim_speed_level : 0
M17 X0.8 Y0.8 Z0.5 ; lower motor current to 45% power