Usage Counter for Motors in hours

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
cell85
Posts: 8
Joined: Tue May 07, 2013 6:35 pm
Location: Germany
Been thanked: 2 times

Usage Counter for Motors in hours

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Usage Counter for Motors in hours

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

cell85
Posts: 8
Joined: Tue May 07, 2013 6:35 pm
Location: Germany
Been thanked: 2 times

Re: Usage Counter for Motors in hours

Post by cell85 »

Good idea! I will do it so.

Post Reply