Topic: DMD0507

Example 4 - Parallel Processing with Stage Programming


As the previous examples have shown, stage programming is an excellent method for handling sequential operations. But many control processes consist of multiple sequential operations that can operate in parallel. Parallel processing can greatly speed up the total time needed to perform control operations because the various sequential operations can run simultaneously.

SFC-Style Implementation

Instead of using the state transition diagrams of the previous examples, parallel processes are better drawn as SFCs (sequential function charts). This is because the SFC language is inherently parallel, where multiple control flows can be active at once.

 

Two of the basic components of SFC diagrams are the Steps and Transitions which will translate easily to Stages and Jumps in stage programming.

 

The Selective Branch operation also easily translates easily into stage programming's Jump instruction.

 

But SFC has another construct, called the Simultaneous Branch, which is the SFC method of describing parallel processing, and it is this construct that is the main subject of this chapter. There are two additional stage programming instructions that are used to implement an SFC-style simultaneous branch operation.

 

 

Parallel Processing Instructions

Implementing an SFC-like simultaneous branch in the Do-more controller is done through two stage programming instructions, one that initiates the execution of multiple pathways, and one that brings the multiple pathways back together.

 

The Jump to Multiple Stages (SGDIVRG) instruction is used to start the execution of multiple parallel processing paths. This instruction transitions from one stage to multiple stages by disabling the Stage which contains the Jump to Multiple Stages instruction and enabling all of the target Stages that are specified in the Jump to Multiple Stages instruction.

 

Note: Since this instruction performs a "Jump" operation, it functions with the same constraints as the singular Jump to Stage (JMP) instruction. These constraints were discussed in detail in the Stage Transition Instructions section.

 

The Converge Multiple Stages to SG (SGCONVRG) instruction is used to coordinate the transition conditions from multiple stages. This instruction is a Stage that is enabled when all of the stages in the From Stages list are enabled and the Then converge when parameter is non-zero (TRUE, ON).

 

When all of the From Stages are enabled and the Then converge when parameter is non-zero (TRUE, ON), the SGCONVRG Stage itself is enabled, and at that point all of the stages in the From Stages list will be disabled.

 

Note: If a parallel pathway needs to complete before "converging", that pathway needs to jump to an empty "dummy"' stage and the SGCONVRG instruction needs to reference that empty stage. This will demonstrated in the example below.

 

 

 

 

A Simple Example with Timers

At this point a simple example of implementing a simultaneous branch in a stage program is in order.

 

The following example has three parallel branches beginning at Stage S10, S20 and S30, and ending at S19, S29 and S39 respectively.

 

When Input X0 is energized, the Jump to Multiple Stages (SGDIVRG) is executed, which executes the three Jumps to the starting stage of each parallel branch.

 

Each branch begins with a Stage that contains a self-resetting Timer that begins timing when that stage is enabled. Each Timer has a different preset value so that the branches will complete at different times.

 

When the Timer Preset is reached, a Jump to the ending stage in that branch is executed.

 

The Converge Multiple Stages to SG (SGCONVRG) waits until all three branches have completed, that is, they have all executed the Jump to the last stage in their respective branch and the Then converge when parameter is non-zero (ON, TRUE). At that point the instruction effectively Jumps from the ending stages in the three branches to the stage in the SGCONVRG instruction.

 

The converging stage has a fourth time that begins timing. When it reaches it's preset value it causes a Jump back to the beginning stage and the process starts again. If input X0 is still energized, the whole process will repeat.

 

 

To those familiar with SFC programming it is obvious from this example that stage programming does not offer a true SFC implementation, it can only approximate some of the functionality. But it is also clear that stage programming can provide a reasonable amount of SFC-style functionality with minimal effort.

 

Using the Project Browser for Status

The Project Browser is a great tool for monitoring the steps and transitions in stage programs.

 

The Control Logic group of the Project Browser contains entries for each Program code block in the Do-more project.

 

Expanding each Program code block will display an icon for each of the Stages contained within the Program code block, and an icon for each rung of ladder logic within each stage.

 

With Status enabled (Debug-> All Status On), stages that are enabled will have their icons appear with reverse video background, stages that are disabled will have their icons appear with the normal background.

 

The status information at this level provides a high-level overview of the process. This can make finding processes that are "stuck" a very quick operation.


Stage Programming Concepts

Introduction

 

Example 1 - A Simple 2-State Process

 

Stage Transition Instructions

 

Example 2 - A Lamp On/Off Controller

 

Example 3 - A Garage Door Opener
 

Example 4 - Parallel Processing

 

Review - Steps to Writing Successful Stage Programs

Stage Instructions in the Do-more Controller

 


Copyright © Host Engineering, Inc. ALL RIGHTS RESERVED