Start code to account for layer height?
-
I am working on setting my E5+ for duet 6hc and the last step to start a test print is getting the start and stop codes setup. I saw a thread somewhere previously but can't seem to find it again that described automatic adjustment to account for varying layer heights on different prints.
I use Cura for slicer and intend for the bulk of the start/stop code to be macros. Below is the code I'm planning on trying but if anyone has any better implementation, I would appreciate it! Thanks in advance!
Cura start code:
var layerOffset = {initial_layer_height} var HETemp = {material_initial_print_temperature} var BedTemp = {material_bed_temperature_layer_0} call Start Macro
Start Macro
;Print Start ;Adjust Z axis for layer height G31 P500 X{global.probeXoffset} Y{global.probeYoffset} Z{global.probeZoffset+var.layerOffset-0.12} ;subtract the smallest layer height used from Z offset ;Settings M140 S{var.BedTemp} ;Set bed temp M568 P0 S{var.HETemp} ;Set Hotend 1 temp M116 ;Wait for temps G28 ;Home all G29 S1 ;Load bed mesh M376 H4 ;Taper off bed mesh compensation after H mm ;.... adjust to 20x the maximum error of height map ;Prime G1 X8 Y20 Z0.28 F4500 ;Move to start of prime line G92 E0 ;Reset extruder G1 Y200 E15 F1500 ;Prime line 1 G1 X8.4 Y20 E15 F3000 ;Prime Line 2 G92 E0 ;Reset extruder G1 X100 Y100 Z2 F6000 ;Move and over to remove string
-
@dubdub You need to use
global
instead ofvar
, e.g.global layerOffset = {initial_layer_height} global HETemp = {material_initial_print_temperature} global BedTemp = {material_bed_temperature_layer_0} call Start Macro
If you don't need these variables outside of your start macro, you can get away with macro parameters too. For example:
M98 P"my-start-macro.g" H{initial_layer_height} T{material_initial_print_temperature} B{material_bed_temperature_layer_0}
and then access them in your macro via
M140 H{param.B} G10 P0 S{param.T} G1 Z{parm.H}
See also https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands.
-
@chrishamm Oh right, thanks for pointing that out... my late night attempt at cobbling this together had me thinking the start code would be inserted into the print gcode and thus local variables would be fine. At the time I didn't consider that the macro is a separate gcode so as you point out, local variables defined in print gcode wouldn't work for the start macro.
The other consideration I had was trying to keep one time use globals limited and keeping the code as simple as possible. Parameters offers the best simplicity for implementing. Thanks again.
-
@dubdub It seems a little strange adjusting the z offset based on layer height. Why do you need to do that?
-
@gloomyandy With the stock setup on my E5+ I would increase the Z offset depending on layer height so as to not squish the first layer too much. Don't know if your familiar with the stock Creality firmware for E5+ but there was a menu while printing to adjust Z offset, which I would tweak to get the right adhesion without smushing things. Since RRF offers neat customizable functionality, I am aiming to automate what I previously did manually.
The probe offset variable I have puts my nozzle an appropriate distance for printing a "standard" first layer without overly squishing. I probably will need to tweak the way the offset is calculated but the general theory being with this when I print larger layer heights , the Z offset will adjust automatically to get good adhesion without the nozzle being too close.