j7126 / OctoPrint-Dashboard

A dashboard for Octoprint
GNU Affero General Public License v3.0
288 stars 39 forks source link

[Bug]: Retractions are not counted in total filament used #413

Open vehystrix opened 1 month ago

vehystrix commented 1 month ago

The problem

The filament used counter is incorrect, because it only counts positive values for the extruder. So depending on the model and the retraction settings, the total count will be off by a lot.

To reproduce, I sliced a simple cube with a retraction length set to an absurd 10mm. Total extrusion length (sum of all positive G1 Exxx) of 7358.76547mm Total retraction length (sum of all negative G1 E-xxx) of -3230mm For a net total of 4128.76547mm of filament used

Screenshot of the dashboard when the print is almost done: image

Or, as reported by the slicer: image

The GCODE I used: Cube_0.2mm_PLA_Elegoo Neptune 3 Plus_54m30s.txt

I calculated the totals using the following powershell commands: Extrusion: Get-Content -Path 'Cube_0.2mm_PLA_Elegoo Neptune 3 Plus_54m30s.txt' | Select-String -Pattern 'G1.*E([0-9.]+)' | ForEach-Object {$_.Matches.Groups[1].Value} | Measure-Object -sum Retraction: Get-Content -Path 'Cube_0.2mm_PLA_Elegoo Neptune 3 Plus_54m30s.txt' | Select-String -Pattern 'G1.*E(-[0-9.]+)' | ForEach-Object {$_.Matches.Groups[1].Value} | Measure-Object -sum Net total: Get-Content -Path 'Cube_0.2mm_PLA_Elegoo Neptune 3 Plus_54m30s.txt' | Select-String -Pattern 'G1.*E([-0-9.]+)' | ForEach-Object {$_.Matches.Groups[1].Value} | Measure-Object -sum

I took a quick look at the dashboard code, and from what I can see here only positive values for e are processed for some reason

Version of OctoPrint

1.10.2

Platform

Intel x64

Operating system running OctoPrint

Debian linux

Dashboard version

1.19.12

Python version

3.11.2

Printer model & used firmware incl. version

Neptune 3 Plus on Marlin 2.1.1

Browser and version of browser, operating system running browser

Firefox 131.0.3 on Windows 10

Logs and other files needed for analysis

File uploads & additional information

No response