Page 1 of 1

Usage Counter for Motors in hours

Posted: Wed May 08, 2013 9:46 am
by cell85
Hi,

I recently posted my Question in the german forum but I think I will try it internationally (please forgive me my bad english).

I want to develop a Motor counter on my MIAC (later on a custom PICmicro Board), that counts the usage of up to 4 motors in hours. The resolution should be 1sec or max. 10 seconds .
So I would need a interrupt that comes every 1 or 10 seconds and increment my counter variable (unsigned long int myMotor1CounterInSeconds) if the motor is active.

I also would like to backup the counter values in my EEPROM area so if the MIAC remembers his counter values in case of reset or power loss.

Would this a possible way? or is their a better one? :roll:

Code: Select all

Start->VarInit->Check if there are values >0 in EEPROM
-> if yes take this values as countervariables - else go on 
-> generate interrupt every x seconds 
-> while [ calculate seconds in hours and -> output on display + gui ] 

Interrupt routine:  
Motor1 acitve? if yes counter1++ if not go one ->   
Motor2 acitve? if yes counter2++ if not go one ->  
Motor3 acitve? if yes counter3++ if not go one ->  
Motor4 acitve? if yes counter4++ if not go one ]
If I want to backup the values into the 256byte eeprom, do I have to disable all Interrupts for this procedure?

Thank you for your help.
Sven

Re: Usage Counter for Motors in hours

Posted: Wed May 08, 2013 11:03 am
by Benj
Hello Sven,

The EEPROM has a erase / write cycle count of around 100,000 iteration so it may be worth interrupting every second but only storing to the EEPROM every 5 or 10 minutes to allow the EEPROM to remain in working order.

The code for the EEPROM automatically disabled your interrupts and then re-enables them so you should not have to worry about this at all.

Maybe only need to check the EEPROM for valid counts at the start of your program as you will always return here on a reset etc.

Re: Usage Counter for Motors in hours

Posted: Wed May 08, 2013 11:06 am
by cell85
Good idea! I will do it so.