Sign in to follow this  
Followers 0
Guest Robert J

Determing Shift Change

7 posts in this topic

Hello, I am "trying" to write code in RSLogix500 for Micro 1500 to determine when a machine has been powered down (main power killed) on one shift and powered up on another shift. The reason for doing this is to reset data if it has went through a shift change. The biggest problem that I am having is our 3rd shift goes through midnight. This means to me that I need to account for a change in month, day and year. Our plant should never work on New Years Eve but I wanted to include it just in case. I have also thought about "cheating"/offsetting the times so that all three shifts occur during the same day. Any advice would be helpfull. Thank you, Robert

Share this post


Link to post
Share on other sites
Use RTC as time reference and write shift number value into a register. On first scan (use rung before the one described) check if shift number was different from current one. If so reset whatever you want... panic mode

Share this post


Link to post
Share on other sites
Thank you, I am doing that but when I get to the 3rd shift that runs through midnight (change of day), end of the month and I hope we never have our people working New Years Eve but change of year, this is where it is getting to be a lot of code (about 50 rungs). Me being a beginner and saying a lot of code I may be way out in left field on this. I am just looking to bounce this topic off the experts in here. Thanks again, Robert

Share this post


Link to post
Share on other sites
I don't know exactly what you are doing, but if you have to subtract hours from hours and days from days to determine a shift change and deal with the rollover back to zero of these values, then there is no easy way to do it and it probably will take 50 rungs. Hours are easy since it is always 24. For days in a month I would suggest a look up table. Use your month number value to point to a table containing the number of days in each month (31,28,31,30,31, etc.)

Share this post


Link to post
Share on other sites
Does the shift start or stop time change? Are there any other limitations? Why do you worry about hollydays etc? Use only hours and maybe minutes. You mingt want to convert everything to minutes for easier comparison. And the logic for this is very simple: if time>=7am and time if time>=4pm and time if shift1 and shift2 then shift=3 if last_shiftshift then reset_all_and__maybe_record_the_timestamp last_shift=shift shift_duration=time - reset_timestamp If you have floating shift times, replace hardcoded time in first two lines with variables and you can adjust everything on fly and by program. Is this something theoretical (exam) or real life situation? panic mode

Share this post


Link to post
Share on other sites
Thank you, I think I have it. I am going to convert the date to the Julian date and then do my compare. This should make things simpler for programing and understanding. When I return from vacation on the 6/16 I will finish the code and If anyone would like it, email me and I will send. Steve- Thanks for your input and what is a look up table? Panic- Thanks for your input. Thanks, Robert

Share this post


Link to post
Share on other sites
What is a look up table? You "look up" a value in a table according to an index number. If your months were numbered 0 to 11 corresponding to Jan to Dec, then you could use that number to reference one of 12 values in a table. The first value in the table would be entry "0", the fourth value would be "3", and the last would be "11". These 12 registers would be preset with the number of days in each month in order from Jan to Dec. You would use indirect addressing to extract the number of days given the month number. For example, if your month number is stored in N7:0 and your look up table is words N14:0 through N14:11, then the number of days in June would be found using address N14:[N7:0] with N7:0 equal to 5. This would actually give you the value in N14:5, hopefully 30. Leap years would be difficult to deal with in this situation.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0