RSLogix 5000, How to identify operating overlap

Join Date
Jul 2021
Location
perth
Posts
185
Hey All.

I am working on my home automation system (again). I want to tinker around with my irrigation system.

The system itself is pretty simple. Glorified garden timer really. But i was asking myself recently. Say for example it was a really sophisticated system with like 16 different start times.

Assuming that i have a memory of a fish (which is more true than false), how would i know if a program i am setting overlaps with another program?

eg. Program 1. Start irrigation at 1200hrs, run for 30min, then stop.

If i completely forgot that the system would be running between 1200hrs and 1230hrs, and i decided to set a second program;

eg. Program 2. Start 1220hrs, run for 30min, then stop.

There is an obvious overlap here.

Is there a way that i could program my PLC to automatically identify this overlap and somehow give me a message? Even if it were a simple output or something? To highlight that there is an overlap?

I was thinking the solution would involve being creative with arrays or something.

Any creative ideas would be much appreciated :).
 
Have each program set a bit when it is running. Use the bit to disable the calls to the other programs.

If you're just changing a timer setting for each program, you could just move the time delay setting into one timer and have one easy program? What kind of controller are you working with?
 
Have each program set a bit when it is running. Use the bit to disable the calls to the other programs.

My bad, I'm thinking SLC logic.

You can use the bit to JMP to LBL of last rung of program with a NOP (no operation output) effectively not running any of the code in that particular program. Instead of a NOP you could also use a ... dummy bit :ROFLMAO:

But honestly, you could also set an array with timer settings needed for each "recipe" and have one program. You just move the timer settings into each timer depending on recipe called. I was always taught to code to least experienced person who may have to troubleshoot. Keep it as simple as possible... so you don't get a call at 1am on equipment being down šŸ™ƒ
 
Is there a way that i could program my PLC to automatically identify this overlap and somehow give me a message? Even if it were a simple output or something? To highlight that there is an overlap?


At least the way I am reading that is to learn if there are time overlaps occurring so that you can find and eliminate them.



Have each program set a bit when it is running. If there are ever two (or more) bits active at the same time latch a bit/send a message. If you want to get fancy also grab the system time that the latch occurs.
 
If you have a start time and duration for each program you are scheduling, then you can compute the end time as well. Then, assuming your programs' start times, stop times and durations are in some form of array structure, you could use a File Search and Compare (FSC) instruction to check if there is any overlap.

The expression for the FSC may look something like this:
((NewProgram.StartTime > Program[x].StartTime AND NewProgram.StartTime < Program[x].EndTime) OR (NewProgram.EndTime > Program[x].StartTime AND NewProgram.EndTime < Program[x].EndTime))

This would set the Found (.FD) bit of the instruction to true if a result is found. Then you can use the index pointer (x) to reference the program guilty of the overlap if necessary. if .DN goes true without .FD going true, no overlap exists.


The FSC instruction has come in quite handy on a couple of jobs for this sort of data validation work. It takes a few extra rungs of logic to properly manage the instruction, but quite powerful once it is set up.
 
Keep the start/stop times in an array and sort by ascending start time. If the start time for any given interval is less than (earlier) than the stop time for the previous element, then there is an overlap.

Here's a python implementation:

Code:
from datetime import datetime

def find_overlaps(intervals):
    overlaps = []
    intervals = sorted(intervals, key=lambda x: x[0])  # sort by start time
    
    for i in range(1, len(intervals)):
        if intervals[i][0] < intervals[i-1][1]:  # check if the start time of the current interval is less than the end time of the previous interval
            overlaps.append((i-1, i))

     return overlaps
And an example:

Code:
intervals = [(datetime(2023, 4, 13, 13, 30), datetime(2023, 4, 13, 14, 30)),
             (datetime(2023, 4, 13, 14, 0), datetime(2023, 4, 13, 15, 0)),
             (datetime(2023, 4, 13, 15, 30), datetime(2023, 4, 13, 16, 30)),
             (datetime(2023, 4, 13, 16, 0), datetime(2023, 4, 13, 17, 0))]

overlaps = find_overlaps(intervals)

if len(overlaps) <= 0:
    print("no overlaps detected")
else:
    for overlap in overlaps:
        print(f"intervals {overlap[0]} and {overlap[1]} are overlapping")
        print(f"element {overlap[1]} start time [{intervals[overlap[1]][0]}] overlaps with element {overlap[0]} end time [{intervals[overlap[0]][1]}] ")
        print()
Returns:
Code:
intervals 0 and 1 are overlapping 
element 1 start time [2023-04-13 14:00:00] overlaps with element 0 end time [2023-04-13 14:30:00]   

intervals 2 and 3 are overlapping 
element 3 start time [2023-04-13 16:00:00] overlaps with element 2 end time [2023-04-13 16:30:00]
 
...you could use a File Search and Compare (FSC) instruction to check if there is any overlap.

Hey CK. I think your solution describes the problem accurately.

I have a start time and an end time.

I do not want a start time to begin when another operation has already begun, but has not yet finished.

I do not want a finish time to occur when another operation has already begun, but has not yet finished.


The expression for the FSC may look something like this:
((NewProgram.StartTime > Program[x].StartTime AND NewProgram.StartTime < Program[x].EndTime) OR (NewProgram.EndTime > Program[x].StartTime AND NewProgram.EndTime < Program[x].EndTime))




I have never used and FSC instruction before. So this will be another learning experience for me.

To confirm, this is using ladder logic yes? It sounds like it when you mentioned "extra rungs". I just want to confirm which language we are using before i go down the rabbit hole. ie. ladder as opposed to functional block.


This would set the Found (.FD) bit of the instruction to true if a result is found. Then you can use the index pointer (x) to reference the program guilty of the overlap if necessary. if .DN goes true without .FD going true, no overlap exists.

I am hoping there is a way for a popup to appear, maybe through FTView, which will warn me that a schedule i have punched in will overlap with another pre existing schedule which will then prompt me to resolve the overlap before it actually occurs.
 
I have never used and FSC instruction before. So this will be another learning experience for me.

It was for me as well. There are some very detailed videos on YouTube that were quite helpful for me.

To confirm, this is using ladder logic yes? It sounds like it when you mentioned "extra rungs". I just want to confirm which language we are using before i go down the rabbit hole. ie. ladder as opposed to functional block.

Correct. ~99% of my Rockwell experience is with ladder logic. I actually am not sure that this instruction is available in function block. Someone with more experience with FBD may be able to clarify.

I am hoping there is a way for a popup to appear, maybe through FTView, which will warn me that a schedule i have punched in will overlap with another pre existing schedule which will then prompt me to resolve the overlap before it actually occurs.

If you have an HMI of some sort, this shouldn't be too difficult. You could have a time entry screen to input start time as well as either end time or duration, then have a "check for overlaps" pushbutton that runs the FSC and displays results on the HMI in whatever format you see fit. If the check has been completed and no overlaps are found, then an "add to schedule" pushbutton could appear that, when pressed, adds the desired program to the schedule. Of course, all of the specifics of the programming would depend entirely on your program and data structure, but the capability is there.
 
great. i will give it a try. likely not until May when i have more time up my sleeve. But i will definitely give this FSC a try.

Thank you again.
 
What I did some time ago was compare the stop time of the previous entry & if the start time was before that forced it back to the stop time of the previous and pop up a warning that stayed on for a few seconds, so in effect you could not overlap, however, it would mean it would give a continuous enable of the two fields as one session. Not perfect but simple & easy to code.
 

Similar Topics

Hi folks, in the alarm manager of Rslogix 5000, the tag-based alarm has been created. But when I tried to change the condition, it was found the...
Replies
2
Views
157
I am completely stuck on building a ladder program that requires a start button to be pressed 3 times to turn on motor 1. Then motor 2 starts...
Replies
20
Views
578
First off, I'm a hobbyist-level programmer, and this program isn't controlling anything anything that could even remotely be considered "life...
Replies
18
Views
518
Hello all, I have a question in regards to RSlogix 5000. I am having issues with the program force closing when I try to make online edits. We...
Replies
0
Views
123
Back
Top Bottom