LESSON

Parallel Element

Description

Here is a detailed explanation of how the Parallel Element functions in a Sequential Function Chart.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] The parallel element is one of the most powerful constructs of sequential function charts. They allow you to contain other SFC elements and execute their logic in parallel. I'll drag one into my chart workspace from the above palette. You can see that it's got this rectangular shape with its bounds represented by the two sections of parallel lines. Additionally, it provides the opportunity to create different branches of logic with the available links. You can do anything that you would do outside of a parallel element, inside of a parallel element, except for using an end step. Also jumps in anchors have a separate namespace inside of a parallel element, so you cannot jump to get out of a parallel element. I'll switch over to my parallel demo chart to see how these work in action. We can see my chart utilizes this parallel element spanning across rows three through 16. Within it, we have three different branches and each of them simply runs for a specified amount of time. On each transition, we have the built-in chart scope, variable running time, setting our transition to true after the branch runs for 10 seconds, 15 seconds, and finally 20 seconds.

[01:10] I'll start this chart up so we can review how it will flow. The flow of the chart won't move beyond the bottom of the parallel until all three sections or as many sections as you have, have reached the bottom of the parallel area. So in this case, we can see the first one reaches the bottom after 10 seconds, the second one after 15 and after 20 seconds, the chart will end as all logic within the parallel has been executed. Now, let's say you would like to end this chart maybe when one or two out of the three branches finish. If I select this parallel element, this can be achieved by making use of this cancel condition. By checking this off, we are telling the chart to cancel any currently running steps, once the condition becomes true. For example, I'll set the condition to be true when, let's say a parallel finish variable is greater than or equal to two. Then I'll define the parallel finish as a chart scope variable in my begin step, and I'll give it a default value of zero. Next, I'll add action steps to the bottom of each branch.

[02:04] I'll give the first action step an OnStart action that increments the parallel finish variable by one. Then I'll copy this script over to the remaining action steps. Finally, I'll save the chart to apply the changes. When I start this chart up and we monitor its flow, you can see that all three charts are running again, and now our parallel finish variable increments as the first branch finishes. Then once the second branch finishes, the third one will cancel ending the chart, since our cancel condition became true. As we are able to run multiple charts like this, the parallel element stands out very distinctly from standard scripting. Using standard scripting, it's very hard to have multiple things running at once unless you get into multi-threaded programming, which is difficult to use as opposed to the parallel element, which is very easy to use.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.