Counting each hour of Shift

backendcode

Member
Join Date
Aug 2017
Location
brampton
Posts
249
Hello Beautiful people,

I am making a hourly production table for HMI. I am having an issue to count the each hour of my shift. for example, morning shift start from 7 am to 3 pm, the parts made in first hour of shift will move to first element of an array and 2nd hour of shift production, i will move to 2nd element of array and so on.

I tried the logic and everything seems to be ok but my shift hour counter is not increasing.

I attached my logic and please have a look and see what I am doing wrong on rung 11.

https://ibb.co/kUFg8y (PLC LOGIC)

Thank you for the help in advance :)

Thank you again,
 
I think you have a problem in the one shot as it has to see the condition change.

The first condition remains high for the morning shift and since you are looking for a NEQ, the condition is always true. So it counts one time, but then DATE_TIME.HOUR has to be equal to 3 (or 15) before it will count again.

Additionally, why does the PLC need to know that the morning shift does X parts? Or in other words, the people reading the parts per hour will know that it was the shift A or B that did them... so I think you are making the logic more complicated than it has to be... but I'm not the customer.

Instead of that complex logic why not something like this:

if DATE_TIMER.HOUR <> previous_Hour then CTU HOUR_COUNTER
previous_Hour := DATE_TIME.HOUR

I don't have a ladder editor, but it should be easy to translate. This would only be true for one cycle meaning that you could get rid of your one shot. Also, the second line must always be called, it is not a conditional of the first line.
 
The one shot in rung 11 will only fire once current time not equal to 3. Both Sources will have to be equal before false transition happens. So it would only happen once a day. If you want to count hours of a shift you'll need to capture previous hour to compare to current hour to be able to count.

Add a rung below your counter and MOV Date hour to Previous Hour. This will allow count to happen before update of previous hour by NEQ instruction.
 
Last edited:
Your rung 11 is not quite right. The way you using NEQ instruction will not increment your counter.

Even if the Date_Time.Hour will change it is still not equal to Morning.Shift_End_Hours so this will not increment your counter (it will increment it only once)
 
CWAL61, Thank you for the reply and Yes, I changed shift end hours to 15 from 3. Good catch ehh :)

And yes your idea is working! for the testing purpose i just used minutes to see if my counter increase or no and seems like it worked. here is the logic as you suggested.

https://ibb.co/do2pvd

Thank you for the help :) much appreciated
 
I think you have a problem in the one shot as it has to see the condition change.

The first condition remains high for the morning shift and since you are looking for a NEQ, the condition is always true. So it counts one time, but then DATE_TIME.HOUR has to be equal to 3 (or 15) before it will count again.

Additionally, why does the PLC need to know that the morning shift does X parts? Or in other words, the people reading the parts per hour will know that it was the shift A or B that did them... so I think you are making the logic more complicated than it has to be... but I'm not the customer.

Instead of that complex logic why not something like this:

if DATE_TIMER.HOUR <> previous_Hour then CTU HOUR_COUNTER
previous_Hour := DATE_TIME.HOUR

I don't have a ladder editor, but it should be easy to translate. This would only be true for one cycle meaning that you could get rid of your one shot. Also, the second line must always be called, it is not a conditional of the first line.

Exactly, but afternoon shift supervisor and team wants to see how much parts were made in previous shift so anyone can walk in to HMI during anytime and see those numbers. But i agree with you and it shouldn't be that complicated. Anyways thank you for the help and my counter is working now! see my previous reply with attached logic.

Thank you,
 
The one shot in rung 11 will only fire once current time not equal to 3. Both Sources will have to be equal before false transition happens. So it would only happen once a day. If you want to count hours of a shift you'll need to capture previous hour to compare to current hour to be able to count.

Add a rung below your counter and MOV Date hour to Previous Hour. This will allow count to happen before update of previous hour by NEQ instruction.

CWAL61, Thank you for the reply and Yes, I changed shift end hours to 15 from 3. Good catch ehh

And yes your idea is working! for the testing purpose i just used minutes to see if my counter increase or no and seems like it worked. here is the logic as you suggested.

https://ibb.co/do2pvd

Thank you for the help much appreciated
 
Your rung 11 is not quite right. The way you using NEQ instruction will not increment your counter.

Even if the Date_Time.Hour will change it is still not equal to Morning.Shift_End_Hours so this will not increment your counter (it will increment it only once)

Thank you for the reply and you are correct! It is working now!

https://ibb.co/do2pvd

As suggested by other forum member. Thank you again for the input :)
 
You should be able to use GSV to get the system time information from the PLC. I would look at getting hours and minutes if you want to control this for 3 shifts. It is easiest to work with the 24 hour time system in this case. First shift will be 7 to 15, or 0700 to 1500. You could modify rung 13 to watch for minutes EQU 0, add a one shot, and at the top of every hour the data will me moved. You could do something similar with total shift data. Watch for hour EQU 7, 15, or 23 (or whatever the start of the next shift will be), with a one shot and the total shift data can be moved. You can add a RES in the corresponding rungs to clear the variables as needed. A few quick Google searches will reveal how to use the GSV and maybe some programming examples.

On a side note, the current CTU will not function correctly since it can only change states from false to true once a day at 7AM. But, if you monitor the system time variables, rungs 10, 11, and 12 are not needed. This is all, of course, assuming your PLC has a RTC.
 
You should be able to use GSV to get the system time information from the PLC. I would look at getting hours and minutes if you want to control this for 3 shifts. It is easiest to work with the 24 hour time system in this case. First shift will be 7 to 15, or 0700 to 1500. You could modify rung 13 to watch for minutes EQU 0, add a one shot, and at the top of every hour the data will me moved. You could do something similar with total shift data. Watch for hour EQU 7, 15, or 23 (or whatever the start of the next shift will be), with a one shot and the total shift data can be moved. You can add a RES in the corresponding rungs to clear the variables as needed. A few quick Google searches will reveal how to use the GSV and maybe some programming examples.

On a side note, the current CTU will not function correctly since it can only change states from false to true once a day at 7AM. But, if you monitor the system time variables, rungs 10, 11, and 12 are not needed. This is all, of course, assuming your PLC has a RTC.

Hey MikeyN, Thank you for the great advice. Yes, I am using GSV to get the system time and value and Please look into my above reply and counter is working too and I am planing to use FIFO and use an array of 8 elements and move the hourly data to individual element of my array and display on HMI.

Thank you again,
 
Exactly, but afternoon shift supervisor and team wants to see how much parts were made in previous shift so anyone can walk in to HMI during anytime and see those numbers. But i agree with you and it shouldn't be that complicated. Anyways thank you for the help and my counter is working now! see my previous reply with attached logic.

Thank you,

I was thinking along the lines of a histogram per hour for a day, but it makes sense in your case I suppose.
 

Similar Topics

Hello I am looking for tips on how to count the duration of a given function and then how to display it on the hmi panel in the hh:mm:ss format...
Replies
4
Views
1,687
Guys, I know it will be silly but can't get my head around it. I have 3 conveyors, every one on a separate servo drive, and 2...
Replies
25
Views
3,468
The 1734-IB8 has no hardware counting function correct? I am trying to find something to substitute in for a 5069-IB16F (since lead times are...
Replies
3
Views
1,389
Been scratching my head at what I thought should be a relatively simple task. I need to count how many rows a .csv file has, so I can later read...
Replies
6
Views
2,512
Hi All, I need to count my Contactor switching times. There are lots of them so I created a template logic with local variables in FC2000. Now I...
Replies
10
Views
2,096
Back
Top Bottom