Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Start code to account for layer height?

    Scheduled Pinned Locked Moved
    Using Duet Controllers
    3
    5
    153
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Former User?
      A Former User
      last edited by A Former User

      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
      
      chrishammundefined 1 Reply Last reply Reply Quote 0
      • chrishammundefined
        chrishamm administrators @A Former User
        last edited by

        @dubdub You need to use global instead of var, 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.

        Duet software engineer

        A Former User? gloomyandyundefined 2 Replies Last reply Reply Quote 0
        • A Former User?
          A Former User @chrishamm
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • gloomyandyundefined
            gloomyandy @chrishamm
            last edited by

            @dubdub It seems a little strange adjusting the z offset based on layer height. Why do you need to do that?

            A Former User? 1 Reply Last reply Reply Quote 0
            • A Former User?
              A Former User @gloomyandy
              last edited by

              @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.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Unless otherwise noted, all forum content is licensed under CC-BY-SA