Welcome! Log In Create A New Profile

Advanced

Usage status collection

Posted by evo85210 
Usage status collection
May 27, 2019 06:08AM
I'm wondering what the best way to locally collect usage status (number of prints printed on that printer).
I'm reading into EEPROM, and it seems like that's the only way to keep count, as it's the only way to keep data persistent when after a power down.
but i'm concerned about the finite write cycles of EEPROM, 100 000 cycles doesn't seem like that many, especially if i'm writing a new value after every print.
also the marlin firmware i'm using right now uses the EEPROM to keep some important machine settings, and I don't know which addresses these information is being saved at, I don't want to accidentally overwrite the existing machine settings.

Can someone advise me on "the best/your recommended" method of achieving this without killing my board within a few months?
Re: Usage status collection
May 27, 2019 07:39AM
100 000 / 365 = 274 prints a day for a year

so lets say you do manage 12 prints a day, that is 22 years worth...

I don't think your going to have an issue...

Edited 1 time(s). Last edit at 05/27/2019 07:56AM by Dust.
Re: Usage status collection
May 28, 2019 12:39AM
fair point, I should've done the calculation first.

How would i check where the EEPROM have an empty slot i can write values to?
I tried
serialprintPGM(eeprom_read_byte(uint8_t *0));
but it returns gibberish
⸮M⸮Q⸮W⸮[⸮_⸮e⸮i⸮m⸮s⸮w⸮{⸮(⸮-⸮2⸮<⸮FĿ⸮P⸮X⸮`⸮j⸮t⸮~čėĿġīĵ⸮J⸮;;⸮n⸮⸮⸮⸮⸮/=lt1⸮⸮V⸮=⸮=

and if I want to write a value to eeprom (let's say at 0), do i simply do
eeprom_write_byte (0, variable)

note: i made a hex file using avrdude, and I see that there's lots of empty slots "F", but I don't know how to read what the address/position of each empty slot is

Edited 1 time(s). Last edit at 05/28/2019 12:56AM by evo85210.
Attachments:
open | download - eeprom_backup_file.hex (9.6 KB)
Re: Usage status collection
May 28, 2019 01:08AM
The positions of the data move, depending on what features are enabled. Only the compiler knows where exactly they are

I believe the first 100 bytes of eeprom in marlin are not used
Re: Usage status collection
May 28, 2019 05:20AM
So I've gone thru my firmware and found that indeed the first 100 bytes seems to be empty
#define EEPROM_OFFSET 100
#define EEPROM_VERSION "V21"
#ifdef EEPROM_SETTINGS
void Config_StoreSettings() 
{
  char ver[4]= "000";
  int i=EEPROM_OFFSET;
  EEPROM_WRITE_VAR(i,ver); // invalidate data first

with further testing, even tho serialprint will give me gibberish for some unknown reason. if I simply use the read variable to do a comparison, it'll work.

the following code write "same", proving I've successfully written and read data.
bool test = true;
    EEPROM.write(0, test);
    bool verify;
    verify= EEPROM.read(0);
    if(verify){
    serialprintPGM(PSTR("same"));
    }else{
      serialprintPGM(PSTR("problem"));
    }

So now my only problem is, how to I do the serial print?? so I can actually read the counter value?


So now i'm trying to figure out how to read and write values to the first 100 bytes (adding the following code into ultralcd_implementation_hitachi_HD44780.h)
#include
void counting() {
uint8_t prints =5;
EEPROM.write(0, prints);
serialprintPGM( EEPROM.read(0));

will return gibberish
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮1⸮⸮r⸮⸮⸮⸮⸮/⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮àݠ⸮⸮⸮[⸮^⸮M⸮Q⸮W⸮b⸮f⸮l⸮p⸮t⸮z⸮
I've also tried (code that i found in ConfigurationStore.cpp)
EEPROM_WRITE_VAR(0, prints);
EEPROM_READ_VAR(0, prints);

and it give me an error
exit status 1
'EEPROM_WRITE_VAR' was not declared in this scope

I've tried adding
#include ConfigurationStore.cpp
#include ConfigurationStore.h

but it still tells me not declared.

what am i missing?


Edited 1 time(s). Last edit at 05/28/2019 06:02AM by evo85210.
Re: Usage status collection
May 28, 2019 08:10AM
your trying to print a string, but your passing it an array of characters....
It needs to be null terminated to be a string
Sorry, only registered users may post in this forum.

Click here to login