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

    NUM_LAYERS in G-code

    Scheduled Pinned Locked Moved
    Duet Web Control
    2
    4
    246
    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.
    • vcapra1undefined
      vcapra1
      last edited by

      I've seen some posts here about the number of layers being incorrect, and I'm having the same problem. It seems that if there is a comment in the G-code file like the following:

      ;NUM_LAYERS:120
      

      then it will use that for the total number of layers. Though in testing, that does not seem to be a thing. I've tried with firmware 3.3.0 and also 3.4.0-rc1. In general, it simply takes the last Z move, divides it by the layer height that it thinks is being used, and uses that as the number of layers. This does not work because I move the head up by a bit at the end of the print to avoid crashing into the print, and also some prints have variable layer sizes.

      Another issue is that when running a second print, it will not update the total layer count. So if I print one file with 100 layers, and then a second file with 200 layers, during the entirety of the second print, it will read "Layer X of 100".

      Here's a simple file demonstrating the problems: Shape-Box.gcode. This file specifies the number of layers as 50, yet it says 53 layers the entire time. Additionally, if I then print a cube that is twice as bit (with 100 layers), it will still say there are 53 layers until I refresh the interface, then it will update to 103.

      vcapra1undefined 1 Reply Last reply Reply Quote 0
      • vcapra1undefined
        vcapra1 @vcapra1
        last edited by

        Actually, after looking at https://github.com/Duet3D/RepRapFirmware/blob/51e5b27066627850a8c9d55bf14c6fe656c7af70/src/Storage/FileInfoParser.cpp, it looks like the NUM_LAYERS comment is only checked in the file footer, and I was including this at the top of the file.

        dc42undefined 1 Reply Last reply Reply Quote 0
        • dc42undefined
          dc42 administrators @vcapra1
          last edited by

          @vcapra1 some slicers use variable layer height. I think that is why RRF only looks for NUM_LAYERS in the footer, because the slicer may not know the number of layers until the end. If you find any slicers that put that comment or a similar one at the start by default, let us know.

          Duet WiFi hardware designer and firmware engineer
          Please do not ask me for Duet support via PM or email, use the forum
          http://www.escher3d.com, https://miscsolutions.wordpress.com

          vcapra1undefined 1 Reply Last reply Reply Quote 0
          • vcapra1undefined
            vcapra1 @dc42
            last edited by

            @dc42 That makes sense. PrusaSlicer can put it in at the beginning using custom g-code (which is what I was doing), but it doesn't by default. So I agree it's better to check just the end. Thanks for your reply!

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