跳到主要内容

idex

slicer 起始代码 由哔哩哔哩up主 muimoon女士提供:

M190 S【bed_temperature_initial_layer_single】
{if is_extruder_used【0】}
M104 S{first_layer_temperature【0】+standby_temperature_delta} T0
{endif}
{if is_extruder_used【1】}
M104 S{first_layer_temperature【1】+standby_temperature_delta} T1
{endif}

第二个打印头设置

[dual_carriage]
axis: x
step_pin: PA15
dir_pin: PA14
enable_pin: !PA13
rotation_distance: 40
microsteps: 16
full_steps_per_rotation: 200
endstop_pin: ^!PB4
position_endstop: 359.35
position_min: 0
position_max: 360
homing_speed: 50
homing_retract_dist: 5
step_pulse_duration: 0.000004
#--------------------------------------------------------------------
[tmc2209 dual_carriage]
uart_pin: PC10
interpolate: False
run_current: 0.8
sense_resistor: 0.110
stealthchop_threshold: 0

复制或者镜像宏,需要在切片里面引用对应代码

  • ACTIVATE_COPY_MODE复制模式
  • ACTIVATE_MIRROR_MODE镜像模式
[gcode_macro PARK_extruder1]
gcode:
SAVE_GCODE_STATE NAME=park1
G90
G1 X200
RESTORE_GCODE_STATE NAME=park1

[gcode_macro T1]
gcode:
PARK_{printer.toolhead.extruder}
ACTIVATE_EXTRUDER EXTRUDER=extruder1
SET_DUAL_CARRIAGE CARRIAGE=1
SET_GCODE_OFFSET Y=15

# A helper script to activate copy mode
[gcode_macro ACTIVATE_COPY_MODE]
gcode:
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
G1 X0
ACTIVATE_EXTRUDER EXTRUDER=extruder
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
G1 X100
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=COPY
SYNC_EXTRUDER_MOTION EXTRUDER=extruder1 MOTION_QUEUE=extruder

# A helper script to activate mirror mode
[gcode_macro ACTIVATE_MIRROR_MODE]
gcode:
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
G1 X0
ACTIVATE_EXTRUDER EXTRUDER=extruder
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
G1 X200
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=MIRROR
SYNC_EXTRUDER_MOTION EXTRUDER=extruder1 MOTION_QUEUE=extruder
  • 双色配置
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
BASE_CANCEL_PRINT

[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
gcode:
##### set defaults #####
{% set x = params.X|default(100) %} #edit to your park position
{% set y = params.Y|default(100) %} #edit to your park position
{% set lift_z = params.Z|default(50)| float | abs %} #edit to your desired z lift
{% set e = params.E|default(1) %} #edit to your retract length
##### calculate save lift position #####
{% set max_z = (printer.toolhead.axis_maximum.z|float ) %} #leave some room for gcode z offset
{% set act_z = printer.toolhead.position.z|float %}
{% set new_z = act_z + lift_z %}
{% if new_z > max_z %}
new_z = max_z
{% endif %}
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
M83 ; set E to rel mode
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{e} F2100
{% else %}
RESPOND MSG="Extruder not hot enough"
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G0 Z{new_z} X{x} Y{y} F6000
{% else %}
RESPOND MSG="Printer not homed"
{% endif %}


[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
##### set defaults #####
# {% set e = params.E|default(1) %} #edit to your retract length
# M83 ; set E to rel mode
# {% if printer.extruder.can_extrude|lower == 'true' %}
# G1 E-{e} F2100
# {% else %}
# RESPOND MSG="Extruder not hot enough"
# {% endif %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
BASE_RESUME

################################################################################
################################################################################

# Helper script to park the carriage (called from T0 and T1 macros)
[gcode_macro PARK_extruder]
gcode:
RESPOND MSG="Parking the leftmost extruder"
#make sure we move the first carriage
SET_DUAL_CARRIAGE CARRIAGE=0
{% if not "x" in printer.toolhead.homed_axes %}
RESPOND MSG="Homing X"
G28 X
{% endif %}

SAVE_GCODE_STATE NAME=park0
G90
SET_GCODE_OFFSET X=0 Y=0 #Z=0
G1 X{printer.configfile.settings.stepper_x.position_min} F12000
RESTORE_GCODE_STATE NAME=park0

[gcode_macro PARK_extruder1]
gcode:
RESPOND MSG="Parking the rightmost extruder"
#make sure we move the second carriage. After all, we do not know which carriage is active
SET_DUAL_CARRIAGE CARRIAGE=1
{% if not "x" in printer.toolhead.homed_axes %}
RESPOND MSG="Homing X"
G28 X
{% endif %}

SAVE_GCODE_STATE NAME=park1
G90
SET_GCODE_OFFSET X=0 Y=0 #Z=0
G1 X{printer.configfile.settings.dual_carriage.position_max} F12000
RESTORE_GCODE_STATE NAME=park1


[gcode_macro x_xoffset]
# helper script, needed as the variable xoffset will be changed during macro execution
# and macro expansion happens before that
gcode:
{% set offset = printer["gcode_macro set_stepper_x_range"].xoffset %}
RESPOND MSG="Xoffset will be set to: { offset }"
SET_GCODE_OFFSET Y=0 X={ offset } #Z=0



[gcode_macro set_stepper_x_range]
variable_xoffset: 0
variable_range_set: 0
gcode:
RESPOND MSG="Setting leftmost extruder x-axis origin"
# { action_respond_info("Extruder1 temperature target: %s" % printer.extruder1.target ) }
RESPOND MSG="Extruder1 temperature target: { printer.extruder1.target }"
{% if printer.extruder1.target|int > 0 %}
RESPOND MSG="Right hand side extruder active"
#{% set offset= 17 %}
{% set offset= 0 %} #I don't know why it was setting this to 17, but it was messing up my prints sometimes!
{% else %}
{% set offset=0 %}
{% endif %}
SET_GCODE_VARIABLE MACRO=set_stepper_x_range VARIABLE=xoffset VALUE={offset}
RESPOND MSG="X origin for left head will be set to {offset} mm from left end of bed"
#make it known that the range has been set for this print, and should not be re-evaluated again
SET_GCODE_VARIABLE MACRO=set_stepper_x_range VARIABLE=range_set VALUE=1

[gcode_macro clear_stepper_x_range]
gcode:
RESPOND MSG="Clearing the leftmost extruder x-axis printing range"
SET_GCODE_VARIABLE MACRO=set_stepper_x_range VARIABLE=xoffset VALUE=0
#make it known that the range has not been set for this print, and should be re-evaluated again
SET_GCODE_VARIABLE MACRO=set_stepper_x_range VARIABLE=range_set VALUE=0


# Activate the primary extruder
[gcode_macro T0]
gcode:
RESPOND MSG="Selecting tool T0"
home_if_not
{% if printer.toolhead.extruder != "extruder" %}
PARK_{printer.toolhead.extruder}
{% endif %}
ACTIVATE_EXTRUDER EXTRUDER=extruder
SET_DUAL_CARRIAGE CARRIAGE=0
# run the range setting only once, in order not to mis-set it after T1 target temp is set to zero
{% if printer["gcode_macro set_stepper_x_range"].range_set == 0 %}
RESPOND MSG="Lefttmost extruder X-direction movement range not yet set, setting it now"
set_stepper_x_range
{% endif %}
x_xoffset


[gcode_macro T1]
gcode:
RESPOND MSG="Selecting tool T1"
home_if_not
{% if printer.toolhead.extruder != "extruder1" %}
PARK_{printer.toolhead.extruder}
{% endif %}
ACTIVATE_EXTRUDER EXTRUDER=extruder1
SET_DUAL_CARRIAGE CARRIAGE=1

#The X/Y offsets are opposite from the stock firmware method.
#If the E2 prints too far to the left, you must ADD to the X offset.
#If the E2 prints too far downwards, you must ADD to the Y offset.
#The Z offset usually isn't needed. Just calibrate the physical Z adjustment on E2.
SET_GCODE_OFFSET X=3.80 Y=0.50 #Z=0

[gcode_macro home_if_not ]
gcode:
{% if printer.toolhead.homed_axes != 'xyz' %}
G28
{% endif %}

[gcode_macro probeon]
gcode:
SET_GCODE_VARIABLE MACRO=bedmesh VARIABLE=probe_installed VALUE=1
RESPOND MSG="Recorded that you have installed the probe on the left head"

[gcode_macro probeoff]
gcode:
SET_GCODE_VARIABLE MACRO=bedmesh VARIABLE=probe_installed VALUE=0
RESPOND MSG="Recorded that you have uninstalled the probe from the left head"

[gcode_macro PRIME_LINE]
gcode:
RESPOND MSG="Printing a priming line "

{% set x = params.X|default(2)|float %}
{% set y = params.Y|default(70)|float %}
{% set z = params.Z|default(0.2)|float %}
{% set xline = params.XLINE|default(0.8)|float %}
{% set yline = params.YLINE|default(120)|float %}
{% set eMultiplier = 0.15 * z %}
SAVE_GCODE_STATE NAME=prime_line

M117 Prime Line

G90 ; XYZ to abs mode
M83 ; set E to rel mode
# move z axis
G1 Z0.3 F3000 ;Move Z Axis up
# move to prime position
G0 Y{y} Z{z}
G0 X{x} ;Move to start position. Do a square move to avoid hitting the bed's corner clips
G1 Y{y + yline} E{eMultiplier * yline} ;Draw the first line
G1 X{x + xline} E{eMultiplier * xline} ;Move to side a little
G1 Y{y + 20} E{eMultiplier * (yline - 20)} ;Draw the second line, but do not go back to origin to avoid picking the wipeouts
# G1 E-0.5 F300
G1 Z0.5 F3000 ;Move Z Axis up

RESTORE_GCODE_STATE NAME=prime_line

[gcode_macro prepare_toolheads ]
gcode:
RESPOND MSG="Preparing the toolheads"
# BED_MESH_PROFILE LOAD=70c
# Use absolute coordinates
G90
#reset E
G92 E0
#Set extruder to relative mode
M83
home_if_not
# explicitly set the range at the start of each new print
set_stepper_x_range
{% if printer.extruder.target|int > 0 %}
RESPOND MSG="Preparing T0"
T0
SAVE_GCODE_STATE NAME=prime_ext0
#Always print the prime line at the very left of the bed
SET_GCODE_OFFSET X=0 Y=0 Z=0
G0 X-10 Y35 Z0.5 F9000
# prime in air
G1 E5 F300
PRIME_LINE X=3 Y=35 Z=0.2 YLINE=100
RESTORE_GCODE_STATE NAME=prime_ext0
{% endif %}
{% if printer.extruder1.target|int > 0 %}
RESPOND MSG="Preparing T1"
T1
G0 X225 Y35 Z0.5 F9000
G1 E5 F300
PRIME_LINE X=200 Y=35 Z=0.2 YLINE=100
{% endif %}
#set the Tooolhead to what it was when the macro was called.
# At least Ideamaker sets the T0/T1 before calling the user-defined macro,
# so we need to be know which toolhead was set and switch to that before continuing
#Jinja expansion happens befor macro is actually executed, so printer.toolhead.extrude in the conditional
#statement will NOT have been dynamically changed, but is instead the original value at call time.

{% if printer.toolhead.extruder == "extruder1" %}
T1
{% else %}
T0
{% endif %}
#set extruder to abs mode
M82
# {% if ( (printer.extruder.target|int > 0) and (printer.extruder1.target|int > 0) ) %}
# #Two extruders in use, do nothing
# RESPOND MSG="Two heads in use, Ideamaker does not do retracting"
# {% else %}
# #Ideamaker insists on retracting at the start. Now we just make it think it already has. Ugly kluldge, yes.
# RESPOND MSG="One of two heads in use, Ideamaker spoils the print by retracting, so work around it"
# G92 E-0.6
# {% endif %}

[gcode_macro wait_for_temperatures]
gcode:

# Wait for temps. If a target is zero, it will not be waited, actually. So you cannot extrude with very low temperatures :)
M190 S{printer.heater_bed.target}
M109 T0 S{printer.extruder.target}
M109 T1 S{printer.extruder1.target}


[gcode_macro START_PRINT]
# This code assumes that the printhead temperatures and bed temperature targets have been set by the slicer
gcode:
CLEAR_PAUSE
{% if printer["gcode_macro bedmesh"].probe_installed != 0 %}
RESPOND TYPE=error MSG="You could have a probe still on. Remove the probe and run the command 'probeoff' and re-print"
CANCEL_PRINT
{% else %}
T0
home_if_not
wait_for_temperatures
Z_TILT_ADJUST

BED_MESH_LOAD
prepare_toolheads
{% endif %}


[gcode_macro bedmesh]
variable_probe_installed: 1
gcode:
{% if printer["gcode_macro bedmesh"].probe_installed == 0 %}
RESPOND MSG="Install probe and run then command 'probeon'"
{% else %}
RESPOND MSG="Measuring bed mesh with TO, with zero x offset "

home_if_not
Z_TILT_ADJUST
T0
SAVE_GCODE_STATE NAME=bedmesh
#Always measure with raw left head
G90
SET_GCODE_OFFSET X=0
#G0 Z10 F6000
BED_MESH_CALIBRATE
#G0 Y0 Z100 #brian: estaba en 100
G28 X
RESTORE_GCODE_STATE NAME=bedmesh
{% endif %}


[gcode_macro BED_MESH_LOAD]
description: Load an existing bed calibration mesh for the correct temperature
gcode:
##### get target get temperature #####
{% set bed_temp = printer.heater_bed.target|int %}
##### join everything to a single mesh name #####
{% set mesh_name = "MESH-" + bed_temp|string + "C" %}
##### end of definitions #####
{% if printer.configfile.config["bed_mesh " + mesh_name] is defined %}
BED_MESH_PROFILE LOAD={mesh_name}
RESPOND TYPE=echo MSG="Loaded bed mesh profile of {mesh_name} "
{% else %}
RESPOND TYPE=error MSG="Did not find a mesh profile of {mesh_name} "
{% endif %}

[gcode_macro bedmesh_renew]
gcode:
home_if_not
{% set dwell = 60000 %}
{% for t in [50,60,70] %}
{% set mesh_name = "MESH-" + t|string + "C" %}
RESPOND MSG="Heating the bed to {t} C"
M190 S{t}
RESPOND MSG="Settling for {dwell}ms"
G4 P{dwell}
bedmesh
BED_MESH_PROFILE SAVE={mesh_name}
{% endfor %}
SAVE_CONFIG
[gcode_macro END_PRINT]
gcode:

M117 End printing.
G91 ; relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle to release some of the pressure
G1 Z+5 E-2 F1000 ;move Z up a bit and extract a bit more
# T1
# T0
# G90 ; absolute positioning
# G0 Y220 F6000 ; make the printed object accessible
m104 S0 T0 ; turn hotend heating off
m104 S0 T1 ; turn hotend heating off
M140 S0 ; turn hotbed heating off
G90
T0
PARK_extruder1
PARK_extruder
M106 S255 ; turn fan on for cooling
M84 ; steppers off
clear_stepper_x_range
M106 S0 ; turn fan off
SAVE_AT_END

[gcode_macro SEARCH_VARS]
gcode:
{% set search = params.S|lower %}
{% set ns = namespace() %}
{% for item in printer %}
{% if ' ' in item %}
{% set ns.path = ['printer', "['%s']" % (item), ''] %}
{% else %}
{% set ns.path = ['printer.', item, ''] %}
{% endif %}

{% if search in ns.path|lower %}
{ action_respond_info(ns.path|join) }
{% endif %}

{% if printer[item].items() %}
{% for childkey, child in printer[item].items() recursive %}
{% set ns.path = ns.path[:loop.depth|int + 1] %}

{% if ' ' in childkey %}
{% set null = ns.path.append("['%s']" % (childkey)) %}
{% else %}
{% set null = ns.path.append(".%s" % (childkey)) %}
{% endif %}

{% if child is mapping %}
{ loop(child.items()) }
{% else %}
{% if search in ns.path|lower %}
{ action_respond_info("%s : %s" % (ns.path|join, child)) }
{% endif %}
{% endif %}

{% endfor %}
{% endif %}
{% endfor %}

[gcode_macro SAVE_AT_END]
variable_save: 1
gcode:
SET_GCODE_VARIABLE MACRO=SAVE_AT_END VARIABLE=save VALUE=1

[gcode_macro SAVE_IF_SET]
gcode:
{% if printer["gcode_macro SAVE_AT_END"].save == 1 %}
SAVE_CONFIG
{% endif %}

[gcode_macro INITIALIZE_VARIABLE]
gcode:
{% if 'VARIABLE' not in params %}
{action_respond_info("Missing VARIABLE parameter")}
{% elif 'VALUE' not in params %}
{action_respond_info("Missing VALUE parameter")}
{% else %}
{% set svv = printer.save_variables.variables %}
{% if params.VARIABLE not in svv %}
{% set escaped = params.VALUE|replace("\"", "\\\"") %}
SAVE_VARIABLE VARIABLE={params.VARIABLE} VALUE="{escaped}"
{% endif %}
{% endif %}



[gcode_macro WIPE_LINE]
gcode:
{% set z = params.Z|default(0.25)|float %}
{% set n = params.N|default(0.4)|float %}

{% if printer.toolhead.homed_axes != "xyz" %}
{action_respond_info("Please home XYZ first")}
{% elif printer.extruder.temperature < 170 %}
{action_respond_info("Extruder temperature too low")}
{% else %}
SAVE_GCODE_STATE NAME=WIPE_LINE_state
M82
G90
G92 E0
G1 X10 Y20 Z5 F3000
G1 Z{z} F3000
G1 X10 Y150 F1500 E10.83
G1 X{ n + 10.0 } F5000
G1 Y22 F1500 E21.5
G1 Y20 F5000
RESTORE_GCODE_STATE NAME=WIPE_LINE_state MOVE=0
{% endif %}

[gcode_macro PREP_PRINT]
description: Loads and starts the print
variable_x_max: 0
variable_y_max: 0
variable_z_max: 0
variable_nozzle: 0
variable_fila_dia: 0
variable_bed_temp: 0
variable_extruder_temp: 0
variable_chamber_temp: 0
variable_layer_count: 0
variable_tool_changes: 0
variable_cur_layer: 0
variable_num_layers: 0
variable_layer_z: 0
gcode:

M117 Print intializing...

#Get Printer built volume dimensions
{% set X_MAX = printer.toolhead.axis_maximum.x|default(100)|float %}
{% set Y_MAX = printer.toolhead.axis_maximum.y|default(100)|float %}
{% set Z_MAX = printer.toolhead.axis_maximum.z|default(100)|float %}

#Get Nozzle diameter and filament width for conditioning
{% set NOZZLE = printer.extruder.nozzle_diameter|default(0.4)|float %}
{% set FILADIA = printer.extruder.filament_diameter|default(1.64)|float %}

#Set Start coordinates of priming lines
{% set X_START = 10.0|default(10.0)|float %}
{% set Y_START = 20.0|default(20.0)|float %}

#Calculate Primer line extrusion volume and filament length
{% set PRIMER_WIDTH = 0.75 * NOZZLE %}
{% set PRIMER_HEIGHT = 0.70 * NOZZLE %}
{% set PRIMER_SECT = PRIMER_WIDTH * PRIMER_HEIGHT %}
{% set PRIMER_VOL = PRIMER_SECT * (X_MAX - 3 * X_START) %}
{% set FILA_SECT = 3.1415 * ( FILADIA / 2.0)**2 %}
{% set FILA_LENGTH = 1.55 * PRIMER_VOL / FILA_SECT %}
{% set FILAMENT_TYPE = params.FILAMENT|default(PLA)|string %}

#Get Bed, Extruder, and Chamber temperatures from Slicer GCode
{% set BED_TEMP = params.BED|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER|default(210)|float %}
{% set CHAMBER_TEMP = params.CHAMBER|default(50)|float %}

# Get Number of Layers
{% set NUM_LAYERS = params.COUNT|default(0)|float %}
{% set CUR_LAYER = params.NUM|default(0)|float + 1 %}

# Get Number of Tool Changes Required
{% set TOOL_CHANGES = params.TOOLS|default(0)|float %}

# Save print configuration specs for later use
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=x_max VALUE={X_MAX}
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=y_max VALUE={Y_MAX}
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=z_max VALUE={Z_MAX}

SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=nozzle VALUE={NOZZLE}
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=fila_dia VALUE={FILADIA}

SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=bed_temp VALUE={BED_TEMP}
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=extruder_temp VALUE={EXTRUDER_TEMP}
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=chamber_temp VALUE={CHAMBER_TEMP}

SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=cur_layer VALUE={CUR_LAYER}
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=num_layers VALUE={NUM_LAYERS}

SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=tool_changes VALUE={TOOL_CHANGES}

# Turn on the lights!
# I don't have any lights yet... sounds fun though!
#WLED_ON PRESET=1

# Make sure T0 is selected for Z probing
T0
PROBEON

# Begin preheating and prepping for print
G90 ; use absolute coordinates
M83 ; extruder relative mode

M117 Preheating bed for homing...

M104 S{EXTRUDER_TEMP}
G4 S10 ; allow partial nozzle warmup
M190 S{BED_TEMP} ; set final bed temp
#BED_MESH_PROFILE LOAD="default"
BED_MESH_LOAD ; load profile for the specified temp
# BEDMESH ; Make a new bed mesh instead of loading a saved one
M117 Homing all axis...
G28 ; home all axis
M117 Adjusting Z-Tilt...
Z_TILT_ADJUST ; calibrate dual-Z axis


# G1 Z50 F240
# G1 X2 Y10 F3000
M117 Waiting for temperatures to stabilize...

M104 S{EXTRUDER_TEMP} ; set final nozzle temp
G28 X ; park extruders while warming up for wipe
M190 S{BED_TEMP} ; wait for bed temp to stabilize
M109 S{EXTRUDER_TEMP} ; wait for nozzle temp to stabilize

WIPE_LINE

M117 Print Started

[de_macro M1091]
#rename_existing: M99109
gcode:
#Parameters
{% set s = params.S|float %}
{% set set_tool = params.T|default(0)|int %}

M104 {% for p in params %}{'%s%s' % (p, params【p】)}{% endfor %} ; Set hotend temp

{% if s != 0 %}
{% if (set_tool == 0 ) %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={s-3} MAXIMUM={s+3} ; Wait for hotend temp (within 1 degree)
{% else %}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={s-3} MAXIMUM={s+3} ; Wait for hotend temp (within 1 degree)
{% endif %}
{% endif %}