Re: Statistics error...
Maybe start data weren't zeroed. I guess you didn't reset to factory default before run, right? OK; me neither, but i guess you were unlucky in this case...
Re: Statistics error...
Interesting. Was this the first time you looked up the filament statistics?
Re: Statistics error...
Yes, the first time i went into the settings it showed 12KM i'd be lucky to have used 100m.. Still over 1/3 of the roll left.
Re: Statistics error...
I suggest that you perform a reset: power-on printer and press and hold encoder pressed until you hear beep - then select reset statistics.
Re: Statistics error...
They probably sent you one that had previously been relegated to their print farm...

Re: Statistics error...
LOL 😂👍
Re: Statistics error...
Thankyou protoncek,
I will reset the counter 😊
Re: Statistics error...
Hmm, mine is saying over 9 km of filament used (about 30 rolls), but I know for sure it was on 0 when I first checked it.
Re: Statistics error...
Could it be a conversion error somewhere? I know the statistic is stored in centimeters in eeprom, but the printer uses (edit: not microns. microns are micrometers which is m10^-6, we want m10^-5) mm/100 internally. The firmware converts between the two when reading/writing the eeprom as far as I can tell, but maybe a bug has hidden itself in there somewhere?
Does anyone know approximately how much filament is on a 1kg spool, for comparison? My math says around 300 meters, does that sound correct?
Re: Statistics error...
Yeah, about 300 meters.
Re: Statistics error...
Ok, I'm getting really confused.
The filament used eeprom is only read/written at two places in the firmware.
The first is in the save_statistics function:
void save_statistics(unsigned long _total_filament_used, unsigned long _total_print_time) //_total_filament_used unit: mm/100; print time in s
{
[...]
unsigned long _previous_filament = eeprom_read_dword((uint32_t *)EEPROM_FILAMENTUSED); //_previous_filament unit: cm
[...]
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, _previous_filament + (_total_filament_used / 1000));
total_filament_used = 0;
}
Seems fine.
The second is part of the lcd_menu_statistics function:
unsigned long _filament = eeprom_read_dword((uint32_t *)EEPROM_FILAMENTUSED);
[...]
float _filament_m = (float)_filament;
int _filament_km = (_filament >= 100000) ? _filament / 100000 : 0;
if (_filament_km > 0) _filament_m = _filament - (_filament_km * 100000);
[...]
lcd_printPGM(MSG_STATS_TOTALFILAMENT);
lcd.setCursor(17 - strlen(ftostr32ns(_filament_m)), 1);
lcd.print(ftostr32ns(_filament_m));
if (_filament_km > 0)
{
lcd.setCursor(17 - strlen(ftostr32ns(_filament_m)) - 3, 1);
lcd.print("km");
lcd.setCursor(17 - strlen(ftostr32ns(_filament_m)) - 8, 1);
lcd.print(itostr4(_filament_km));
}
[...]
Which seems to have a misnamed variable: _filament_m should probably be named _filament_cm. This shouldn't affect the printer stats, though, and as far as I can tell the calculations between cm, m, and km are correct.
There is a bug though. If the stat is less than 1km it will display the centimeters, but it will be labled m. So if you've actually used 300m filament, it will display it as having used 30000m filament. But that is not the same bug as OP reported, since OP's printer says 12km. If that had been through this bug it would have said 12000m or something.
Re: Statistics error...
The field total_filament_used is also a bit strange. It is read from a few places, but only really written from three.
First:
When stopping a print through the menu, it calls lcd_print_stop, which calls save_statistics, which sets total_filament_used to 0 after saving it to eeprom.
Second:
In get_command, specifically the section that reads from sd card, specifically when the sd card has reached end of file. Then it calls save_statistics which sets total_filament_used etc. This means that printing from usb doesnt save statistics, I think. That may be causing some bugs, possibly? I don't know.
Third:
Finally, the printer executes a G1 command, the following code appears:
if (total_filament_used > ((current_position[E_AXIS] - destination[E_AXIS]) * 100)) { //protection against total_filament_used overflow
total_filament_used = total_filament_used + ((destination[E_AXIS] - current_position[E_AXIS]) * 100);
}
which increments total_filament_used by the e axis distance of the G1 command. (Also the G0 command, since marlin redirects G0 to G1.)
I don't quite understand the "protection against overflow" if statement. current_position and destination are float arrays, so negative values work. current-destination becomes the extruded amount*-1. The factor 100 is just to convert it to the scale total_filament_used uses.
This doesn't protect against overflow, right? It just doesn't increment total_filament_used if the extrusion is negative, i.e. a retraction. total_filament_used is unsigned, so it can't be negative, so that can't be used to check for overflow. Unless that is a bug?
Other than that, I can't see total_filament_used being written anywhere. Which means that it is uninitialized when first used. Which maybe means it doesn't start at zero when you boot your printer? Does anyone know the actual characteristics for uninitialized fields using Einsy boards and whatever compiler is used to build the firmware?
Re: Statistics error...
Does anybody know if that bug has been fixed?
I think I have read somewhere that is has been fixed but not sure anymore.
I have the same issue that my printed length is already at 17km.
I would like to set it to 500meters which is roughly what I have used till now and I think M78 G-Code does clear this values but I don`t wanna loose the used days.
