FRANK RUIZ Posted May 13, 2023 Report Posted May 13, 2023 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. Quote
NewVeganic Posted May 13, 2023 Report Posted May 13, 2023 If result = Saturday or Sunday then result := result + 2days? Quote
pturmel Posted May 13, 2023 Report Posted May 13, 2023 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. Quote
NewVeganic Posted May 13, 2023 Report Posted May 13, 2023 Yeah, obviously. I was giving the original poster a hint. No point considering all use cases and no reason to be a clever clogs. Quote
pturmel Posted May 13, 2023 Report Posted May 13, 2023 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. Quote
FRANK RUIZ Posted May 15, 2023 Author Report Posted May 15, 2023 (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 May 15, 2023 by FRANK RUIZ Quote
pturmel Posted May 15, 2023 Report Posted May 15, 2023 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.) Quote
FRANK RUIZ Posted May 17, 2023 Author Report Posted May 17, 2023 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.