The text of a manual · part 7 of 38
DL06 Micro PLC User Manual, Volume 2 of 2, pages 60 to 69
Pages 60 to 69 of 370
The original document is the PDF (6.0 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Page 60
Chapter 7: RLLPLUS Stage Programming
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Add Safety Light Feature Next we will add a safety light feature to the door opener system. It’s best to get the main function working first as we have done, then adding the secondary features. The safety light is standard on many commerciallyavailable garage door openers. It is shown to the right, mounted on the motor housing. The light turns on upon any door activity, remaining on for approximately 3 minutes afterwards. This part of the exercise will demonstrate the use of parallel states in our state diagram. Instead of using the JMP instruction, we’ll use the set and reset commands.
Modify the Block Diagram and State Diagram
Inputs
Outputs
To control the light bulb, we add an output to our Toggle controller block diagram, shown to the right, Y3 is the X0 Y1 Raise light control output. Up limit In the diagram below, we add an additional state Y2 X1 Lower called “LIGHT”. Whenever the garage owner presses the door control switch and releases, the RAISE or LOWER state is active and the LIGHT state is Down limit X2 Y3 simultaneously active. The line to the Light state is Light dashed, because it is not the primary path. We can think of the Light state as a parallel process to the raise and lower state. The paths to the Light state are not a transition (Stage JMP), but a State Set command. In the logic of the Light stage, we will place a three-minute timer. When it expires, timer bit T0 turns on and resets the Light stage. The path out of the Light stage goes nowhere, indicating the Light stage just becomes inactive, and the light goes out! Output equations: Y1 = RAISE Y2 = LOWER Y3 = LIGHT RAISE X1
X0 X0
Push–UP
X0
DOWN
LIGHT
UP
T0
X0 X2
LOWER
Push–DOWN
X0
7–12
Safety light
DL06 Micro PLC User Manual, 3rd Edition Rev. A
X0
Page 61
Chapter 7: RLLPLUS Stage Programming
Using a Timer Inside a Stage The finished modified program is shown to the right. The shaded areas indicate the program additions. In the Push-UP stage S1, we add the Set Stage Bit S6 instruction. When contact X0 closes, we transition from S1 and go to two new active states: S2 and S6. In the PushDOWN state S4, we make the same additions. So, any time someone presses the door control pushbutton, the light turns on. Most new stage programmers would be concerned about where to place the Light Stage in the ladder, and how to number it. The good news is that it doesn’t matter! • Just choose an unused Stage number, and use it for the new stage and as the reference from other stages.
ISG S0
DOWN State
JMP SG S1
Push–UP State S2
X0
JMP S6 SET SG S2
RAISE State
• Placement in the program is not critical, so we place it at the end.
SP1
You might think that each stage has to be directly under the stage that transitions to it. While it is good practice, it is not required (that’s good, because our two locations for the Set S6 instruction make that impossible). Stage numbers and how they are used determines the transition paths. In stage S6, we turn on the safety light by energizing Y3. Special relay contact SP1 is always on. Timer T0 times at 0.1 second per count. To achieve 3 minutes time period, we calculate:
X1
K = 3 min. x 60 sec/min 0.1 sec/count K = 1800 counts
S1
X0
Y1 OUT S3 JMP
SG S3
UP State S4
X0
JMP SG S4
Push–DOWN State S5
X0
JMP S6 SET
SG S5
LOWER State SP1
The timer has power flow whenever stage S6 is active. The corresponding timer bit T0 is set when the timer expires. So three minutes later, T0=1 and the instruction Reset S6 causes the stage to be inactive. While Stage S6 is active and the light is on, stage transitions in the primary path continue normally and independently of Stage 6. That is, the door can go up, down, or whatever, but the light will be on for precisely 3 minutes.
Y2 OUT S0
X2
JMP SG S6
LIGHT State SP1
Y3 OUT TMR T0 K1800
T0
S6 RST
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
7–13
Page 62
Chapter 7: RLLPLUS Stage Programming
Add Emergency Stop Feature
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Some garage door openers today will detect an object under the door. This halts further lowering of the door. Usually implemented with a photocell (“electric-eye”), a door in the process of being lowered will halt and begin raising. We will define our safety feature to work in this way, adding the input from the photocell to the block diagram as shown to the right. X3 will be on if an object is in the path of the door. Next, we make a simple addition to the state transition diagram, shown in shaded areas in the figure below. Note the new transition path at the top of the LOWER state. If we are lowering the door and detect an obstruction (X3), we then jump to the Push-UP State. We do this instead of jumping directly to the RAISE state, to give the Lower output Y2 one scan to turn off, before the Raise output Y1 energizes.
Inputs Toggle
Outputs X0
Y1
Raise
Up limit X1 Down limit X2
Ladder Program
Y2 Y3
Lower Light
Obstruction X3
X0 X0
RAISE
Push–UP
X1
X0
DOWN
X3
LIGHT
UP
T0
X0 X2
X3
LOWER
Push–DOWN
X0
X0
Exclusive Transitions
7–14
It is theoretically possible that the down limit (X2) and the obstruction input (X3) could energize at the same moment. In that case, we would “jump” to the Push-UP and DOWN states simultaneously, which does not make sense. Instead, we give priority to the obstruction by changing the transition condition to the DOWN SG LOWER State S5 state to [X2 AND NOT X3]. This ensures the obstruction event has the priority. The SP1 Y2 modifications we must make to the LOWER Stage OUT (S5) logic are shown to the right. The first rung to DOWN S0 X3 X2 remains unchanged. The second and third rungs JMP implement the transitions we need. Note the opposite relay contact usage for X3, which ensures S2 to Push-UP X3 the stage will execute only one of the JMP JMP instructions.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 63
Chapter 7: RLLPLUS Stage Programming
Stage Program Design Considerations
1 Stage Program Organization 2 The examples so far in this chapter used one self-contained state diagram to represent the main process. However, we can have multiple processes implemented in stages, all in the same ladder program. New stage programmers sometimes try to turn a stage on and off each scan, 3 based on the false assumption that only one stage can be on at a time. For ladder rungs that you want to execute each scan, just put them in a stage that is always on. 4 The following figure shows a typical application. During operation, the primary manufacturing activity Main Process, Powerup Initialization, E-Stop and Alarm Monitoring, 5 and Operator Interface are all running. At powerup, three initial stages shown begin operation. 6 7 8 9 10 In a typical application, the separate stage sequences above operate as follows: • Powerup Initialization – This stage contains ladder rung tasks done just once at powerup. Its last 11 rung resets the stage, so this stage is only active for one scan (or only as many scans that are required). • Main Process –This stage sequence controls the heart of the process or machine. One pass through 12 the sequence represents one part cycle of the machine, or one batch in the process. • E-Stop and Alarm Monitoring –This stage is always active because it is watching for errors that 13 could indicate an alarm condition or require an emergency stop. It is common for this stage to reset stages in the main process or elsewhere, in order to initialize them after an error condition. 14 • Operator Interface –This is another task that must always be active and ready to respond to an operator. It allows an operator interface to change modes, etc. independently of the A current main process step. Although we have separate processes, there can be B coordination among them. For example, in an error condition, the Status Stage may want to automatically switch the operator interface to the C status mode to show error information as shown to the right. The monitor stage could set the stage bit D for Status and Reset the stages Control and Recipe. Main Process
XXX
= ISG
Idle
Powerup Initialization Powerup
Fill
Agitate
E-Stop and Alarm Monitoring
Rinse
Spin
Operator Interface
Monitor
Recipe
Control
Status
Operator Interface
Recipe
Control
Monitor
Status
E-Stop and Alarm Monitoring
DL06 Micro PLC User Manual, 3rd Edition Rev. A
7–15
Page 64
Chapter 7: RLLPLUS Stage Programming
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
How Instructions Work Inside Stages
7–16
We can think of states or stages as simply dividing up our ladder program as depicted in the figure below. Each stage contains only the ladder rungs which are needed for the corresponding state of the process. The logic for transitioning out of a stage is contained within that stage. It’s easy to choose which ladder rungs are active at powerup by using an “initial” stage type (ISG). Stage 0
Stage 1
Stage 2
Most all instructions work just like they do in standard RLL. You can think of a stage just like a miniature RLL program which is either active or inactive. Output Coils – As expected, output coils in active stages will turn on or off outputs according to power flow into the coil. However, note the following: • Outputs work as usual, provided each output reference (such as “Y3”) is used in only one stage. • An output can be referenced from more than one stage, as long as only one of the stages is active at a time. • If an output coil is controlled by more than one stage simultaneously, the active stage nearest the bottom of the program determines the final output status during each scan. Therefore, use the OROUT instruction instead when you want multiple stages to have a logical OR control of an output.
One-Shot or PD coils – Use care if you must use a Positive Differential coil in a stage. Remember that the input to the coil must make a 0–1 transition. If the coil is already energized on the first scan when the stage becomes active, the PD coil will not work. This is because the 0–1 transition did not occur. PD coil alternative: If there is a task which you want to do only once (on 1 scan), it can be placed in a stage which transitions to the next stage on the same scan. Counter – In using a counter inside a stage, the stage must be active for one scan before the input to the counter makes a 0–1 transition. Otherwise, there is no real transition and the counter will not count. The ordinary Counter instruction does have a restriction inside stages: it may not be reset from other stages using the RST instruction for the counter bit. However, the special Stage counter provides a solution (see next paragraph). Stage Counter – The Stage Counter has the benefit that its count may be globally reset from other stages by using the RST instruction. It has a count input, but no reset input. This is the only difference from a standard counter. Drum – Realize that the drum sequencer is its own process, and is a different programming method than stage programming. If you need to use a drum with stages, be sure to place the drum instruction in an ISG stage that is always active.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 65
Chapter 7: RLLPLUS Stage Programming
Using a Stage as a Supervisory Process You may recall the light bulb on-off controller example from earlier in this chapter. For the purpose of illustration, suppose we want to monitor the “productivity” of the lamp process, by counting the number of on-off cycles which occurs. This application will require the addition of a simple counter, but the key decision is in where to put the counter.
Toggle
X0
Ladder Y0 Program
Powerup ISG S0
Supervisor Process
Supervisor
OFF State S1
X0
JMP
Powerup
X0
Push–ON
X0 SG S1
Main Process
OFF
ON
Push–On State S2
X0
JMP
X0
Push–OFF
X0
New stage programming students will typically try to place the counter inside one the the stages of the process they are trying to monitor. The problem with this approach is that the stage is active only part of the time. In order for the counter to count, the count input must transition from off to on at least one scan after its stage activates. Ensuring this requires extra logic that can be tricky. In this case, we only need to add another supervisory stage as shown above, to “watch” the main process. The counter inside the supervisor stage uses the stage bit S1 of the main process as its count input. Stage bits used as a contact let us monitor a process! NOTE: Both the Supervisor stage and the OFF stage are initial stages. The supervisor stage remains active indefinitely.
SG S2
ON State SP1
Y0 OUT
X0
S3 JMP
SG S3
Push–Off State S0
X0
JMP ISG S4
Supervisor State S1 SGCNT
CT0
K5000
Stage Counter The counter in the above example is a special Stage Counter. Note that it does not have a reset input. The count is reset by executing a Reset instruction, naming the counter bit (CT0 in this case). The Stage Counter has the benefit that its count may be globally reset from other stages. The standard Counter instruction does not have this global reset capability. You may still use a regular Counter instruction inside a stage... however, the reset input to the counter is the only way to reset it.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
7–17
Page 66
Chapter 7: RLLPLUS Stage Programming
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Power Flow Transition Technique Our discussion of state transitions has shown how the Stage JMP instruction makes the current stage inactive and the next stage (named in the JMP) active. As an alternative way to enter this in DirectSOFT 5, you may use the power flow method for stage transitions. The main requirement is that the current stage be located directly above the next (jump-to) stage in the ladder program. This arrangement is shown in the diagram below, by stages S0 and S1, respectively. S0
X0
S1
SG S0
SG S0 S1
X0
Equivalent
All other rungs in stage...
JMP X0 SG S1
Power flow transition SG S1
Recall that the Stage JMP instruction may occur anywhere in the current stage, and the result is the same. However, power flow transitions (shown above) must occur as the last rung in a stage. All other rungs in the stage will precede it. The power flow transition method is also achievable on the handheld programmer, by simply following the transition condition with the Stage instruction for the next stage. The power flow transition method does eliminate one Stage JMP instruction, its only advantage. However, it is not as easy to make program changes as using the Stage JMP. Therefore, we advise using Stage JMP transitions for most programmers.
Stage View in DirectSOFT 5
7–18
The Stage View option in DirectSOFT 5 will let you view the ladder program as a flow chart. The figure below shows the symbol convention used in the diagrams. You may find the stage view useful as a tool to verify that your stage program has faithfully reproduced the logic of the state transition diagram you intend to realize. SG
Stage
Transition Logic
Reference to a Stage
J
Jump
S
Set Stage
R
Reset Stage
The following diagram is a typical stage view of a ladder program containing stages. Note the left-to-right direction of the flow chart. ISG SO
J
SG S1
J
SG S2
S
SG S4
J
SG S3
J
SG S5
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 67
Chapter 7: RLLPLUS Stage Programming
Parallel Processing Concepts
1 Parallel Processes 2 Previously in this chapter we discussed how a state may transition to either one state or another, called an exclusive transition. In other cases, we may need to branch simultaneously to two or more parallel processes, as shown below. It is acceptable to use all JMP instructions as 3 shown, or we could use one JMP and a Set Stage bit instruction(s) (at least one must be a JMP, in order to leave S1). Remember that all instructions in a stage execute, even when it 4 transitions (the JMP is not a GOTO). 5 6 7 Note that if we want Stages S2 and S4 to energize exactly on the same scan, both stages must be located below or above Stage S1 in the ladder program (see the explanation at the bottom 8 of page 7–7). Overall, parallel branching is easy! Converging Processes 9 Now we consider the opposite case of parallel branching, which is converging processes. This simply means we stop doing multiple things and continue doing one thing at a time. In the figure below, processes A and B converge when stages S2 and S4 transition to S5 at some 10 point in time. So, S2 and S4 are Convergence Stages. 11 12 13 Convergence Stages (CV) While the converging principle is simple enough, it brings a new complication. As parallel processing completes, the multiple processes almost never finish at the same time. In other 14 words, how can we know whether Stage S2 or S4 will finish last? This is an important point, because we have to decide how to transition to Stage S5. A The solution is to coordinate the transition condition out of convergence stages. We accomplish this with a stage type designed B for this purpose: the Convergence Stage (type CV). In the example to the right, convergence stages S2 and S4 are required to be grouped together as shown. No logic is permitted between CV C stages! The transition condition (X3 in this case) must be located in the last convergence stage. The transition condition only has D power flow when all convergence stages in the group are active. Process A
S2
SG S1
S3
Push–On State
S2
X0
S0
S1
X0
Process B
JMP
S4
S4
S5
JMP
Process A
S1
S2
= Convergence Stage
S6
S5
Process B
S3
S4
CV S2
Convergence Stages
CV S4
X3
S5 CVJMP
SG S5
DL06 Micro PLC User Manual, 3rd Edition Rev. A
7–19
Page 68
Chapter 7: RLLPLUS Stage Programming
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Convergence Jump (CVJMP) Recall the last convergence stage only has power flow when all CV stages in the group are active. To complement the convergence stage, we need a new jump instruction. The Convergence Jump (CVJMP) shown to the right will transition to Stage S5 when X3 is active (as one might expect), but it also automatically resets all convergence stages in the group. This makes the CVJMP jump a very powerful instruction. Note that this instruction may only be used with convergence stages.
CV S2
Convergence Jump
CV S4 X3
S5 CVJMP
SG S5
Convergence Stage Guidelines
7–20
The following summarizes the requirements in the use of convergence stages, including some tips for their effective application: • A convergence stage is to be used as the last stage of a process which is running in parallel to another process or processes. A transition to the convergence stage means that a particular process is through, and represents a waiting point until all other parallel processes also finish. • The maximum number of convergence stages which make up one group is 16. In other words, a maximum of 16 stages can converge into one stage. • Convergence stages of the same group must be placed together in the program, connected on the power rail without any other logic in between. • Within a convergence group, the stages may occur in any order, top to bottom. It does not matter which stage is last in the group, because all convergence stages have to be active before the last stage has power flow. • The last convergence stage of a group may have ladder logic within the stage. However, this logic will not execute until all convergence stages of the group are active. • The convergence jump (CVJMP) is the intended method to be used to transition from the convergence group of stages to the next stage. The CVJMP resets all convergence stages of the group, and energizes the stage named in the jump. • The CVJMP instruction must only be used in a convergence stage, as it is invalid in regular or initial stages. • Convergence Stages or CVJMP instructions may not be used in subroutines or interrupt routines.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 69
Chapter 7: RLLPLUS Stage Programming
RLLPLUS (Stage) Instructions Stage (SG) The Stage instructions are used to create structured RLLPLUS programs. Stages are program segments which can be activated by transitional logic, a jump or a set stage that is executed from an active stage. Stages are deactivated one scan after transitional logic, a jump, or a reset stage instruction is executed. Operand Data Type
SG S aaa
DL06 Range aaa
Stage S
0–1777
The following example is a simple RLLPLUS program. This program utilizes an initial stage, stage, and jump instructions to create a structured program.
Direct SOFT
ISG
Handheld Programmer Keystrokes U
S0
A ISG
0 A
$ STR X0
X1
0
Y0
GX OUT
A
OUT
$
B
S2 SET
0
S1
X SET
SHFT
S RST
$
F
ENT
5
K JMP
B
2
B
1
$
1 C
STR
X2
Y1
2
GX OUT
B
2
C
1 2
SG
OUT
G
$
6
STR S2
X6
Y2 OUT
X7
ENT
1
SG
SG
ENT
C 2
ENT
S1 JMP
SG
ENT
STR
STR
X5
ENT
S1
GX OUT
C
$
H
2
ENT ENT ENT ENT ENT ENT ENT ENT
STR
7
V AND
SHFT
S RST
K JMP
A
ENT
0
B 1
S0
ENT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
JMP
DL06 Micro PLC User Manual, 3rd Edition Rev. A
7–21