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

    Read total layers from gcode

    Scheduled Pinned Locked Moved
    Firmware wishlist
    3
    7
    753
    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.
    • Jackalundefined
      Jackal
      last edited by

      I believe RRF currently uses object height, first layer height and layer height to calculate total number of layers. However it is not incorrect for variable layer height prints.

      Some slicers (at least in PrusaSlicer and Cura but not Kisslicer) can output total number of layers in the gcode file, will it be possible for RRF to parse that similar to reading other info from file?

      SIamundefined 1 Reply Last reply Reply Quote 0
      • SIamundefined
        SIam @Jackal
        last edited by

        @jackalin RFF 3.3 + the firmware reads only the Layers from the G-Code and does not calculate it anymore

        Hypercube-Evolution-Hybrid, Piezo Orion, Orbiter
        Duet WiFi 1.02 or later + DueX5
        RepRapFirmware for Duet 2 WiFi/Ethernet 3.4.0beta4 (2021-09-27 11:30:36)
        Duet WiFi Server: 1.26
        Duet Web Control 3.4.0beta4 (2021-09-27)

        Jackalundefined 1 Reply Last reply Reply Quote 0
        • Jackalundefined
          Jackal @SIam
          last edited by Jackal

          @siam Are you sure? I am printing a file with 295 layers but DWC is showing total of 140 layers. I am using RRF 3.3RC2.

          First layer height 0.2 and total height is 27.980, which sounds like it calculated total layers from that.

          SIamundefined 1 Reply Last reply Reply Quote 0
          • SIamundefined
            SIam @Jackal
            last edited by

            @jackal yes see this post : https://forum.duet3d.com/post/231157

            Hypercube-Evolution-Hybrid, Piezo Orion, Orbiter
            Duet WiFi 1.02 or later + DueX5
            RepRapFirmware for Duet 2 WiFi/Ethernet 3.4.0beta4 (2021-09-27 11:30:36)
            Duet WiFi Server: 1.26
            Duet Web Control 3.4.0beta4 (2021-09-27)

            Jackalundefined 1 Reply Last reply Reply Quote 0
            • Jackalundefined
              Jackal @SIam
              last edited by Jackal

              @siam I believe what it means is that the current layer number is read from the file, but it does not say the 'total number of layers' is read from the file.

              If I haven't read from the wrong branch of code, here is what's in RFF for reading number of layers

              unsigned int GCodeFileInfo::GetNumLayers() const noexcept
              {
              	if (layerHeight <= 0.0) { return 0; }
              	const float nl = (firstLayerHeight > 0.0)
              						? (objectHeight - firstLayerHeight)/layerHeight + 1
              							: objectHeight/layerHeight;
              	return (unsigned int)lrintf(max<float>(nl, 0.0));
              }
              
              SIamundefined 1 Reply Last reply Reply Quote 0
              • SIamundefined
                SIam @Jackal
                last edited by

                @jackal OK in this case the total layers will be calculated i was thinking that this will read from the file too because of the calculating problems what would be makes more sense

                Hypercube-Evolution-Hybrid, Piezo Orion, Orbiter
                Duet WiFi 1.02 or later + DueX5
                RepRapFirmware for Duet 2 WiFi/Ethernet 3.4.0beta4 (2021-09-27 11:30:36)
                Duet WiFi Server: 1.26
                Duet Web Control 3.4.0beta4 (2021-09-27)

                1 Reply Last reply Reply Quote 0
                • AfroHorseundefined
                  AfroHorse
                  last edited by AfroHorse

                  I've just done the same investigation and come to the same conclusion looking at DWC and how it grabs the info from the RRF printmonitor.

                  DWC uses the height of the object to calculate total layers at https://github.com/Duet3D/DuetWebControl/blob/1121469e780d213df0cda6e85fbf1bb2000a8c33/src/store/machine/modelItems.js#L435. After some scanning around, it doesn't look like RRF passes back numLayers hence always dropping into this approximation logic. Please correct me if I am wrong on this.

                  Given it is dropping into that approximation, the specific issue is that height is not calculated correctly where there is a none print move. This is especially prevalent when you have ending GCode to move the extruder out of the way of the printed part. The logic to calculate the height is done in the printmonitor code at https://github.com/Duet3D/RepRapFirmware/blob/123d4362a04a709103971dd10b94e916b8790ef8/src/PrintMonitor.cpp#L145.

                  Must admit that having the height parsing logic look forward for subsequent extrusions would likely cause parsing to slow down considerably. Given this, I wonder if implementing the parsing of numLayers to pull it out of the GCode header with a specific format is the best way to go.

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