Go Down

Topic: Data Tracking with Machine Status Light on CNC machine. (Read 933 times) previous topic - next topic


Jan 08, 2013, 06:36 am Last Edit: Jan 08, 2013, 06:41 am by vennishmuthu Reason: 1
My project deals with counting number of parts produced and to record the time and time duration when a CNC machine stops and starts  and i need to do this with my Adruino UNO or Leonardo.

A Machine Status light is a tower of GREEN, YELLOW, & RED lights kept above a machine to observe the status of operation.

The logic is simple i need to count the number of components produced in a CNC tracking the glowing of GREEN light.Say the greeen light glows for 180sec. So that whenever green glows for 180sec  the count should updated.

Also if YELLOW and RED light glows for some duration the time duration it had glowed should also be noted.

GREEN : The CNC program is running , i.e cycle is running
YELLOW : The CNC machine is stopped for loading and unloading the workpiece.
RED : The CNC is stopped and no operation should take place.

Please could someone help me with the LOGIC.(Programming part)


Please could someone help me with the LOGIC.(Programming part)

That is trivial. Note when the transition from green off to green on happens. Note when the transition from yellow off to yellow on happens. Note when the transition from red off to red on occurs.

Note when the transition from yellow on to yellow off occurs. When that happens, also increment the total yellow time and reset/clear the yellow on time.

Do the same for the red transition to off.

Periodically, see what time it is. If the green light is on, and has been on for more than 180 seconds, reset the green on time to now, and increment the part count.


How significant is the "180 seconds"? What does it mean if the LED only glows for 179 seconds, or 17 seconds? You may want to consider making your criteria for incrementing the parts count more flexible.
I only provide help via the forum - please do not contact me for private consultancy.


Unless the machine only makes one part, I don't see the relevance of the 180s at all. As far as I can see, any transition from green on to yellow on means a part has been completed. In addition, any transition triggers adding accumulated time to the relevant total and resetting the clock for the new state that was entered.


how can i reset the millis() ?
i have done for RED
the folloing is the program for it...

unsigned long time, previous, key;
int red = 2;
int row = 0;

void setup(){
void loop()
   while(digitalRead(red) == LOW);
Serial.print("DATA,TIME,"); Serial.print("ON,"); Serial.print("RED,");Serial.println("  ");

  time = millis();
   while(digitalRead(red) == HIGH);
   previous = millis();
     key =  previous  - time ;
    Serial.print("DATA,TIME,"); Serial.print("OFF,"); Serial.print("RED,");Serial.println(key/1000);



  //prints time since program started


Go Up