Followers 0

# FX5 48H SHIFT WITH SELECTABLE DATE SKIP CALCULATION

## 9 posts in this topic

Hello all,

I have the need for PLC to calculate a giving time shift pattern, so if I start Monday 8am on a 24h prod basis, and the production run is 48h, the PLC should tell HMI finish time is Wednesday 8am, that is ok, the problem is, Production stops from Saturday 8 am, and starts again Monday 8am. Thus if I start prod run on Friday 8am, PLC should tell HMI (Got2000), production finish time should be Tuesday 8 am.

I can read RTC, compare, do maths, but how can I miss or not take into account Saturdays from 8 am till Monday 8 am...that is my problem.

Any thoughts, ideas, are all welcome.

Thanks.

#### Share this post

##### Share on other sites

If result = Saturday or Sunday then result := result + 2days?

#### Share this post

##### Share on other sites
1 hour ago, NewVeganic said:

If result = ....

Insufficient.  What if the run is 72 hours starting on Friday?  That simplistic approach would fail.

I would divide the runtime by 5 days, keeping quotient and remainder separate.  Advance the date by weeks with the quotient.  Then advance by hours with the remainder.  If the hour-of-week of the endpoint is less than the hour-of-week of the start point, add another 48 hours.  Where hour-of-week is the difference to that week's Monday 8am.

#### Share this post

##### Share on other sites

Yeah, obviously. I was giving the original poster a hint. No point considering all use cases and no reason to be a clever clogs.

#### Share this post

##### Share on other sites
19 minutes ago, NewVeganic said:

Yeah, obviously. I was giving the original poster a hint.

Your "hint" wasn't obvious to me.  Maybe the tone of voice in your head as you typed it would have made it obvious, if I could have heard it.

This is a technical site frequented by many people all over the world, most with a literal mindset.  Mark your humor or satire if you do not wish to be misunderstood.

#### Share this post

##### Share on other sites

Posted (edited)

On 13/05/2023 at 4:43 PM, pturmel said:

Insufficient.  What if the run is 72 hours starting on Friday?  That simplistic approach would fail.

I would divide the runtime by 5 days, keeping quotient and remainder separate.  Advance the date by weeks with the quotient.  Then advance by hours with the remainder.  If the hour-of-week of the endpoint is less than the hour-of-week of the start point, add another 48 hours.  Where hour-of-week is the difference to that week's Monday 8am.

Thanks a million, you are correct! Thanks for the idea, the problem is for example.

I have 300h production run. we work Monday to Friday 24h, Saturday only 8h, nothing Sunday. So Mon-Friday 24h each day+ 8 hours Saturday is 128 h each week for production.

so if at 00.00 h Monday I start 300h production, the PLC should work out end of production on as Tuesday (3rd Tuesday after 2 full weeks of production) at 19.52h.

my calculations are as follows: Production hours per week 128. Production Run is 300, 300/128= 2.34 weeks. 0.34*128=43.52h=>full Monday (24h) + 19.52 on Tuesday= finish production run. but if I start production on Monday at 8h, calculations would be same, just add to the finish time 8h.

do you agree?

Edited by FRANK RUIZ

#### Share this post

##### Share on other sites
1 hour ago, FRANK RUIZ said:

at 00.00 h Monday I start

Well, that is part of the weekend, so all bets are off.  But otherwise, seems right.  (I did not audit your math closely.)

thanks.

#### Share this post

##### Share on other sites

I managed to get a bit further, but I think I might do another thing.

I am toying with the idea of allocating 24 to each day, other than saturday 8 and sunday 0 h.

with TRD I know what day of week the production starts, if I then start dropping hours into each day according to production plan, that will accurately tell me the expected end of production.

So for 72h starting at 8 am on Monday, means 16h prod Mon, 24 Tue, 24 wed + 8 Thursday = 72. so the PLC should be able to tell me that is 8 am on Thursday, my problem is still on runs that overlap 1 week, or the skip the weekends, how can I tell is the Monday of following week, or the Thursday in 2 weeks time....

1 person likes this

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
Followers 0