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

Read total layers from gcode

Scheduled Pinned Locked Moved
Firmware wishlist
3
7
732
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.
  • undefined
    Jackal
    last edited by 27 May 2021, 16:53

    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?

    undefined 1 Reply Last reply 27 May 2021, 16:55 Reply Quote 0
    • undefined
      SIam @Jackal
      last edited by 27 May 2021, 16:55

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

      undefined 1 Reply Last reply 27 May 2021, 16:58 Reply Quote 0
      • undefined
        Jackal @SIam
        last edited by Jackal 27 May 2021, 16:58

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

        undefined 1 Reply Last reply 27 May 2021, 17:04 Reply Quote 0
        • undefined
          SIam @Jackal
          last edited by 27 May 2021, 17:04

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

          undefined 1 Reply Last reply 27 May 2021, 17:08 Reply Quote 0
          • undefined
            Jackal @SIam
            last edited by Jackal 27 May 2021, 17:08

            @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));
            }
            
            undefined 1 Reply Last reply 27 May 2021, 17:24 Reply Quote 0
            • undefined
              SIam @Jackal
              last edited by 27 May 2021, 17:24

              @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
              • undefined
                AfroHorse
                last edited by AfroHorse 7 Nov 2021, 10:14 11 Jul 2021, 10:03

                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