Pages: [1]   Go Down
Author Topic: Data Tracking with Machine Status Light on CNC machine.  (Read 817 times)
0 Members and 1 Guest are viewing this topic.
Chennai, Tamil Nadu, India
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino ROCKS!!...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
« Last Edit: January 08, 2013, 12:41:29 am by vennishmuthu » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12534
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

I only provide help via the forum - please do not contact me for private consultancy.

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Chennai, Tamil Nadu, India
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino ROCKS!!...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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(){
  pinMode(red,INPUT);
  Serial.begin(9600);
  Serial.println("LABEL,Time,Status,Colour,Total");
}
void loop()
{
   while(digitalRead(red) == LOW);
   delay(400);
   {
 Serial.print("DATA,TIME,"); Serial.print("ON,"); Serial.print("RED,");Serial.println("  ");
 row++;

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



row++;

 

 
   
}
  //prints time since program started



 
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how can i reset the millis() ?
Reset the Arduino.

What's with
     the random
  indenting?
                                      Code that
                runs all




over the place


                         is really hard to read.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12534
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how can i reset the millis() ?

Probably, resetting the value of millis() is not the best way to achieve your goal. What are you trying to achieve?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how can i reset the millis() ?

You don't, although I can see how you might have interpreted my remarks that way. What I was trying to say was that on each transition, you need to store the value of millis at that time, so that you calculate how much time was spent in that state when the next transition occurs. You can see a simple version of this kind of usage (without the time summation) in the blink without delay example.
Logged

Pages: [1]   Go Up
Jump to: