Go Down

Topic: Find the run time of a machine (Read 414 times) previous topic - next topic

Jeevaa

I have a machine, where i calculate no of rotations of a shaft using proximity induction sensor to find the production. I also want to calculate total runtime of a machine. So help me to calculate the runtime of a machine...

PaulRB

#1
Nov 22, 2019, 08:03 am Last Edit: Nov 22, 2019, 08:09 am by PaulRB
Simple. Just use millis() function. The only moderately difficult part will be detecting when the machine has stopped. You will need to set a timeout period after each detection to determine when the machine has stopped.

Will you need to keep the total long-term running time of the machine, even if the Arduino it switched off?

Post the code you have now and we can suggest changes to it.

Read the forum guide in the "please read" sticky post before you post your code.

Jeevaa

This is the basic structure of my code


const int proximity = 2;
int rotation=0;
int prod_conv;
float production;
int sensorState;

void setup()
{
  pinMode(proximity, INPUT);
 
}

void loop()
{
  sensorState = digitalRead(proximity);
  if (sensorState != 0)
  {
  rotation = rotation+1; //to find no of rotations
  }
  if( rotation%8==0)
  {
  prod_conv = rotation/8; //for every 8 rotation prod_conv increases
  }
  production = prod_conv*433.2; //here 433.2 is a constant

}

PaulRB

Read the forum guide in the "please read" sticky post before you post your code.

gilshultz

Consider using a RTC (Real Time Clock) that has backed up RAM as well.  For me I would use Unix time as it is very easy to work with. Save the start in backed up ram and EEPROM if you like. Then every so often you can save in battery memory then maybe once an hour or so save it in EEPROM as well.
Good Luck & Have Fun!
Gil

Jeevaa



[/quote]
Consider using a RTC (Real Time Clock) that has backed up RAM as well.  For me I would use Unix time as it is very easy to work with. Save the start in backed up ram and EEPROM if you like. Then every so often you can save in battery memory then maybe once an hour or so save it in EEPROM as well.
Good Luck & Have Fun!
Gil
I am new to Arduino,so can you give some examples

Paul__B

Then every so often you can save in battery memory then maybe once an hour or so save it in EEPROM as well.
If you have a RTC with BBRAM, why would you need to consign it to EEPROM?

Go Up