Crimson Timer Help

carson

Member
Join Date
Feb 2011
Location
arima
Posts
22
Hi,
I want to create a "Down Timer" when a machine stops the timer should start, however the timer should not start before 7:00 am ;stop recording @ 9:00 am;Start recording @ 9:15 am ;stop recording @ 11:00 am ; start recording @ 12:00 pm; stop recording @ 2:00 pm; start recording @ 2:15 PM Then finally stop recording @ 4:00 pm and reset at the end of the day.
 
Last edited:
That's a little harder than it sounds at first.

This is a good opportunity to learn about the GetNow() function in Crimson 3, which returns the number of seconds since the start of the Unix epoch.

The GetHour function determines the hour of the day from that value.
The GetMinute function determines the minute of the day from that value.

Once you know the current Hour and Minute, you can evaluate those against the start of shift, stop of shift, and break times.

The way I would do this is by running a Crimson 3 Program in the "On Tick" event, which executes every second.

Configure this by going to the Display Pages section of Crimson 3 and clicking on the very top "Pages" icon in the Navigation Pane. That will show you the Global configuration window.
 
// The break times are calculated explicitly to make the IF statements simpler
// and to make it easier to change them.
int Break_AM ;
int Break_PM ;
int Break_Lunch ;
int Shift_On ;

Current_Hour := GetHour(GetNow());
Current_Minute := GetMin(GetNow());

// If it's between 07:00 and 16:00 the production shift is ON
if ((Current_Hour >= 7) && (Current_Hour <=16))
Shift_On := 1;
else Shift_On := 0;

// There's a production break between 09:00 and 09:15
if ((Current_Hour == 9) && (Current_Minute >= 0) && (Current_Minute < 15))
Break_AM := 1;
else Break_AM := 0;

// There's a production break between 11:00 and 11:59
if (Current_Hour == 11)
Break_Lunch := 1;
else Break_Lunch := 0;

// There's a production break betwen 14:00 and 14:15
if ((Current_Hour == 14) && (Current_Minute >= 0) && (Current_Minute < 15))
Break_PM := 1;
else Break_PM := 0;

// If the current time is during the production shift and there are no breaks
// and the Machine is Down, then add 1 to the total Downtime Seconds every time
// this Program executes. This Program should be in the "On Tick" section.

if ((Shift_On) && (!Break_AM) && (!Break_Lunch) && (!Break_PM) && (Machine_Down))
Accumulated_DT_Seconds_Total++ ;

// The DT accumulated counter stops after 16:00, but does not reset until midnight.
// It cannot run between midnight and 06:59.

if (Current_Hour <=6)
Accumulated_DT_Seconds_Total := 0;

// We calculate the accumulated Downtime Hours and Minutes

Accumulated_DT_Hours := Accumulated_DT_Seconds_Total / 3600 ;

Accumulated_DT_Minutes := (ModU32(Accumulated_DT_Seconds_Total, 3600) / 60) ;
 
OK Ken

Here's my stab at it. It runs completely in the emulator so you will not need any hardware to evaluate it. I only tested times between the end of the second shift and quitting time so hopefully there were no errors in my copying and pasting. Also I didn't put provisions in for day change though that would be pretty easy to do.

I still don't agree with tracking the downtime, I think tracking the runtime allows for more flexibility such as accounting of company meetings and other unscheduled "acceptable" down times so my example tracks both runtime during any time of the day and downtime during a single shift excluding lunch and two breaks.
 

Similar Topics

Hi, I want to create a "Down Timer" when a machine stops the timer should start, however the timer should sart @ 7:00 am ;stop @ 9:00 am;Start @...
Replies
9
Views
2,691
Build error occurs with TON ladder logic command. Time Input expected on block. Using Integer Tag under Control Local, and then hard number 19...
Replies
2
Views
750
1- I set details creation to enabled and to the name of a saved widget and set a data element to the page. When binding the widget it makes a page...
Replies
5
Views
2,218
I have an older G310 - so stuck with Crimson 2, but although it is not nearly as cool, I'm doing ok with it. The issue I have is that I have a...
Replies
3
Views
2,488
Hello, I am new to the forum. I have been using the Redlion Crimson 3.0 software for about 3 years. I have never had any luck pausing a timer...
Replies
3
Views
1,864
Back
Top Bottom