Programming Basics RLL PLUS
-
Upload
austin-asuquo -
Category
Documents
-
view
228 -
download
0
Transcript of Programming Basics RLL PLUS
-
8/11/2019 Programming Basics RLL PLUS
1/38
110RLLPLUS
Programming Basics
In This Chapter. . . .
Introduction
An Example Machine
An RLL SolutionAn RLLPLUS Solution
Stage Instruction Execution
Activating Stages
Using Outputs in StagesUsing Timers and Counters in Stages
Using Data Instructions in Stages
Using Comparative Contacts in StagesParallel Branching Concepts
Unusual Operations in Stages
Two Ways to View RLLPLUS ProgramsDesigning a Program Using RLLPLUS Instructions
-
8/11/2019 Programming Basics RLL PLUS
2/38
ProgrammingBasics
10--2RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Introduction
If youve ever been around somereallyaccomplished RLL programmers you haveprobably been amazed at how easily they seem to be able to create programs ofincredible complexity. Well, not everyone has years of experience in programmingPLCs. Because of this the DL330P CPU has RLL PLUS instructions that make itconsiderably easier to design and create programming solutions. These instructionsare especially useful to those of you who arent that familiar with the interlockingconcepts commonly used in RLL programs.
You can still use the normal instructions youve already seen, plus you only have tobecome familiar with a few new instructions that help you organize your programintomanageable pieces.
This programming method is similar to Sequential Function Chart programming andliterally allows you to design a flowchart of the program operation sequence and loadit into the CPU! You can expect to see several benefits by using this method.
S Considerably reduced program design time. Weve seen many, many
cases where these few instructions have cut program design time bywell over 50%.
S Shorter, more simple programs. Later in this chapter well show you whyyour programs sometimes end up being a lot larger than you firstanticipated. The RLLPLUS instructions can help make your programssimple for everyone to understand.
S Easier program troubleshooting. How many times have you tried totroubleshoot or modify a program that was written by someone else? Ifyouve done this very often you know its not an easy task. This chapterwill show you a few instructions that will also help with this problem aswell.
The following paragraphs discuss several RLLPLUS
programming concepts. Welluse a simple example to show you how to use the various types of instructions. Also,well show you the equivalent program without RLL PLUS instructions to give you anidea of the differences between the two approaches.
NOTE:The DL330P has several instructions that do not operate quite the same asthe equivalent instructions in the DL330 or DL340. If you want to take advantage ofthe benefits associated with the RLLPLUS instructions, make sure you also take timeto review Chapter 12. This chapter discusses the instructions that are unique ordifferent with the DL330P CPU.
-
8/11/2019 Programming Basics RLL PLUS
3/38
10-RLLPLUS Programming Basics
DL305 User Manual, Rev. D
An Example Machine
Most any application can be described asa sequence of events. The PLC programmerely makes sure the events arecompleted in a specific order. Not onlydoes the program control normaloperation, but it also has to allow formachine failures and emergencyconditions. Consider a simple example.
1. The operator presses the startswitch.
2. The machine checks for a part. If thepart is present, the processcontinues. If not, the conveyor movesuntil a part is present.
3. The part is locked in place with aclamp.
4. The press stamps the part.
5. The clamp is unlocked and thefinished piece is moved out of thepress.
6. The process stops ifthe machine isinone-cycle mode, or the processcontinues if automatic mode isselected.
On/OffSwitch
PartDetection
Sensor
Clamp
Press Arm
Part
The following diagram provides a flowchart of this operations sequence.
Step 7
Step 1
The flowchartbreaks the programinto logical steps
Wait forStart
Step 2
Check forPart
Step 3
Lock theclamp
Step 4
Press thePart
Step 5
Unlockclamp
Step 6
MoveConveyor
CheckMode
OneCycle
Continuous
Inputs Outputs
Start Switch 000 Clamp 020Part Present 001 Press 021Part Locked 002 Conveyor 022Part Unlocked 003Lower Limit 004Upper Limit 005Conveyor Indexed 006One-Cycle Switch 007
Machine Operation
Machine Flowchart
-
8/11/2019 Programming Basics RLL PLUS
4/38
ProgrammingBasics
10--4RLLPLUS Programming Basics
DL305 User Manual, Rev. D
An RLL Solution
Why is RLL so popular? Simple. Beforethe PLC arrived control problems weregenerally solved with hardwired relays
and switches. About 30 years ago peoplestarted experimenting with a way tomake quick and easy changes withoutchanging the actual panel wiring. Thus,the PLC was born. Since the peopledeveloping and using this newtechnology were familiar with the relayand switch solution, it made sense tohave this new technology emulatesomething that was familiar to them.Thats why RLL programs emulate arelay panel solution.
When you supply power to a relay panelthecombination of contact and coil statusdetermines what actions take place.Since the RLL program emulates therelay panel solution, the entire programis scanned left-to-right, top-to-bottom.The program executes the operationssequence when a certain combination ofcontacts are activated. This process isknown as interlocking.
Since many PLCs do not haveinstructions to help manage theoperations sequence, the programmerhas to make sure the program carries outthe correct sequence by adding therequired interlocks. One great thingabout the RLL solution is the individualrungs are easy to understand. Byexamining the contacts you can easilydetermine if the output will be on or off.
Run 1 Cycle RUN
OUT
Start
R UN P re se nt
MCS
Unlocked Clamp
OUT
Stop
Part
160
ReleaseClamp
160 001
003 162
163 011
Clamp
020
000
-- Interlock
Executes all rungs Left to Right, Top to bottom
160
Part
020
Locked Press
OUT
LowerLimit
002 004
Press
021
Part
021
PressComplete
161
Press Complete
OUT
Conveyor
021 006 161Press
Complete
161
LowerLimit
004
Index Press
PressComplete
161
Clamp
OUT
162
ReleaseUpperLimit
005
MCR
Conveyor
OUT
Conveyor
006 022
Run
160
PartUnlocked
003
IndexPressComplete
161Part
Present
001
1 Cycle
OUT
Conveyor
006 163
Index1 Cycle
007
Many accomplished RLL programmers use things such as Master Control Relaysand Subroutines to reduce the amount of interlocking required. However, theseinstructions can sometimes make the program more difficult to understand. Thereare several things you should notice about our simple press program.
S
Most all rungs use some amount of interlocking.S The number of interlocks is usually proportional to the number of tasks
in the operations sequence.
S Most of the instructions are devoted to processing the interlocks. (Plus,since the program is larger, it takes more time to process.)
S It usually requires several attempts until a program is designed that isnot susceptible to inadvertent activation and deactivation.
S The program can be difficult to debug if you do not have a considerableamount of RLL programming experience.
-
8/11/2019 Programming Basics RLL PLUS
5/38
10-RLLPLUS Programming Basics
DL305 User Manual, Rev. D
An RLLPLUS SolutionThe RLLPLUS instructions keep the simplicity of the contacts and coils whileremoving some of the problems associated with the enormous amount of interlocks.There are several RLLPLUS instructions, but the most often used are the Initial Stage(ISG), Stage (SG), and Jump (JMP) instructions. Heres the example press program
created using RLLPLUS instructions. There are two things you should notice.
S Control Relay interlocks are notrequired.
S The program directly follows theflowchart of the press operation.
How can this happen? Simple. Theinterlocks were added to the RLLprogram to keep the outputs from comingon at the improper time. This is becauseevery rung of the RLL program wasexamined on every scan.
The Stage instructions (and the logicbetween the Stage instruction and thenext stage instruction) are notnecessarily examined on every scan.Only stages that are on are examined.
Each stage instruction has a status bitthat is on when the stage is active, andoffwhen the stage is inactive. On every scanthe CPU examines which stage statusbits are on and only examines the logic inthose stages. If a stage is inactive, theCPU skips the logic between that stage
and the next active stage.The following pages will talk aboutseveral different aspects of the CPUexecution for the Stage Instructions. Itwill help to understand the pieces of anindividual stage.
Stage Nomenclature
As we discuss the examples it will benecessary for you to understand thevarious pieces that can make up aprogram stage.
S Stages a instruction that denotesa piece of the program
S Actions an event in the program,such as an output, jump, or someother instruction.
S Transitions the event that causesthe program to move to the nextstage.
ISGS000
Start S1JMP
SGS001
Present S2JMP
Part
001
000
S5JMP
PresentPart
001
SGS002
ClampSET
S4JMP
LockedPart
002
SGS003
Down021
S4JMP
LimitLower
004
Press
SGS004
ClampRST
S5JMP
UnlockedPart
003
020
SGS005
Conveyor022
S6JMP
MovedConveyor
006
Move
SGS006
Cycle S0JMP
One
007
S1JMP
CycleOne
007
Wait for start
Check for a part
Lock the clamp
Press the part
Unlock the clamp
Index the conveyor
One cycle or automatic?
Only executes logic in stages that are activ
LimitTop
005 020
-
8/11/2019 Programming Basics RLL PLUS
6/38
-
8/11/2019 Programming Basics RLL PLUS
7/38
10-RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Since the CPU will only examine the logic in those stages that are active, it isimportant you understand how stages can be turned on and off. There are a fewsimple rules that dictate how this works. This may seem like quite a few things toremember, but its really pretty simple. Well show examples in the following pagesthat show how each of these rules apply to the program execution.
1. Only active stages are executed. If a stage is inactive, the CPU skips thelogic between that stage and the next active stage.
2. You can turn stages on by the following methods.
2.a Initial Stages are automatically turned on when the CPU transitionsfrom Program Mode to Run Mode.
2.b A stage can be turned on when the program jumps from stage to stagewith the Jump (JMP) instruction.
2.c You can use the SET instruction to set a stage status bit just like youwould SET an output.
2.d A stage can be turned on when the program has power flow betweentwo stages that are tied together by a single transition element.
3. You can turn stages off by the following methods.3.a An active stage is automatically turned off if the program jumps from the
active stage to another stage.
3.b You can use the Reset (RST) instruction to turn off a stage just like youuse Reset to turn off an output point.
3.c The current stage is automatically turned off if the program has powerflow between the current stage and the next stage.
A FewSimple Rules forExecution
-
8/11/2019 Programming Basics RLL PLUS
8/38
ProgrammingBasics
10--8RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Activating Stages
Any initial stages (ISG instructions) areautomatically turned on when the CPUgoes from Program Mode to Run Mode.For example, when the CPU executingour example program enters Run Mode,the Initial Stage (ISG 000) will be turnedon automatically. The other stages areoff, so the CPU only scans the portion ofthe program associated with ISG 000.
Since theres only one rung in Stage 0,the CPU continually monitors the startswitch. Nothing else will happen until thestart switch is pressed.
ISGS000
Start S1JMP
SGS001
Present S2JMP
Part
001
000
S5JMP
PresentPart
001
Wait for start
Check for a part
Only executes logic in stages that are active
Although it is unusual, there may be times when you need more than one initial
stage. There is nothing at all wrong with this. If your application has a need for morethan one starting point, you can use more than one initial stage. For example, if youhad three initial stages, then those three stages would all be active when the CPUentered the Run Mode.
Using Initial Stages
-
8/11/2019 Programming Basics RLL PLUS
9/38
10-RLLPLUS Programming Basics
DL305 User Manual, Rev. D
When the operator presses the startswitch input 000 comes on. When 000comes on the CPU executes the Jumpinstruction and jumps to Stage 1.
Now the CPU only scans Stage 1. Stage0 is no longer scanned after the program
jumped to stage 1. This means the Jumpinstruction did two things.
S It activated the destination stage. Inthis case, it activated stage 1.
S It deactivated the stage it camefrom, which was stage 0 in thiscase.
So, you canjump toa stage to turn it on,and when youjump froma stage it turnsoff.
ISGS000
Start S1JMP
SG S001
Present S2JMP
Part
001
000
S5JMP
PresentPart
001
Wait for start
Check for a part
Only executes logic in stages that are activ
SGS002
ClampSET
S3JMP
LockedPart
002
020
Lock the clamp
This example only shows an action that initiates a jump to one destination. You canuse several jumps ORed together if necessary. Examples of this will be shown later.
Theres also another type of Jumpinstruction called a Not Jump. Thisinstruction only works if the inputconditions are not true, whereas theregular JMP instruction only works if theinput conditionsare true.
In the previous example we examined asingle contact to determine which part ofthe program to jump to next. If the part is
present (001 closed), the program jumpsto Stage 2. If a part is not present (001open), the program jumped to Stage 5.We could have used a single contact andthe NJMP instruction.
The program example to the right showshow the NJMP instruction would be usedin this situation. Notice there is one lessinstruction required in this examplecompared to the previous one.
ISGS000
Start S1JMP
SGS001
Present S2JMP
Part
001
000
S5NJMP
Wait for start
Check for a part
Only executes logic in stages that are activ
SGS002
ClampSET
S3JMP
LockedPart
002
020
Lock the clamp
NOTE: We strongly recommend you avoid using the NJMP instruction. This isbecause program debugging can become more difficult, especially for those whoare not so familiar with structured programming concepts.
Using JumpInstructions
-
8/11/2019 Programming Basics RLL PLUS
10/38
ProgrammingBasics
0--10RLLPLUS Programming Basics
DL305 User Manual, Rev. D
When you examine the instruction setmore carefully youll notice the DL330PCPU offers a Set (SET) instruction thatworks similarly to a latching operation.For example, you could use a SETinstruction to latch an output point. The
output point can then be unlatched withthe Reset (RST) instruction.
You can also use a SET instruction to turnon a stage. To show how this works,were going to add a stage to theprogram. You may have noticed theoriginal flowchart did not contain a stopswitch. Well, we dont want to makethese little widgets forever, so wereadding Stage 150, which monitors for astop switch. (This is also a good exampleof how you can skip stage numbers.)
Notice we added a SET instruction in thefirst stage. Now when the start switch ispressed, two stages will be activated.The CPU examines Stage 1, whichmonitors for a part, and it also examinesStage 150, which monitors the stopswitch.
ISGS000
Start S0JMP
SGS001
Present S2JMP
Part
001
000
S5JMP
PresentPart
001
Wait for start
Check for a part
Only executes logic in stages that are active
SGS002
ClampSET
S3JMP
LockedPart
002
020
Lock the clamp
S150
SET
SGS150
Stop
S0 -- S6RST
010
Monitor for stop
S0JMP
020 -- 022RST
We did not absolutely have to use a SET instruction in the example. We could have
used a Jump, since you can jump to more than one stage. We just used a SET toshow how it works.
If you examine Stage 150, youll notice we do three things when the stop switch ispressed.
S The RST 020 -- 022 instruction makes sure all the outputs are turned off.(Well discuss this in more detail in the next section.)
S The RST S0--S6 instruction resets (turns off) stages 0 through 6. Wereset the entire range so that we guarantee we can stop the press nomatter which stage is currently executing. Notice we reset stages thatwere not necessarily turned on with the SET instruction. The Reset(RST) instruction can be used to turn off stages, no matter how theywere turned on. This is especially handy in larger, more complexprograms.
S The program jumps back to Stage 0 and starts over again. Note, justbecause Stage 0 is an initial stage does not mean it can onlybe activeat a transition to Run Mode. You can return to an Initial Stage at anytime. Its just the CPU automaticallyactivates Initial Stages at the RunMode transition.
Using SetInstructions withStages
-
8/11/2019 Programming Basics RLL PLUS
11/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
You do not always have to use a Jumpinstruction to move from stage to stage. Ifyou only move to one stage, instead ofmultiple stages, you can use what it iscalled a power flow transition. Forexample, we used Jump instructions in
our sample program. For those stagesthat did not have multiple transitionpossibilities, we could have just usedpower flow transitions.
Look at Stage 2. Notice how thetransition contact, 002 now is directlyconnected to the next stage, Stage 3.
You can only do this if you are movingfrom one stage to one other stage.
If you examine Stage 1, youll notice wehave to use the Jump instructionsbecause the program can transition to
more than one stage.
SGS001
Present S2JMP
Part
001
S5JMP
PresentPart
001
SGS002
ClampSET
LockedPart
002
SGS003
Down021
LimitLower
004
Press
020
Check for a part
Lock the clamp
Press the part
Only executes logic in stages that are active
ISGS000
Start S1JMP
000
Wait for start
S150
SET
NOTE: We suggest you use Jump Instructions instead of power flow transitions.This is because weve seen many cases where we had to come back and add thingsto the program. If you used Jumps from the beginning, you only have to add anotherJump instruction. If you used power flow transitions, the program edits can take alittle longer.
Power FlowTransitions
-
8/11/2019 Programming Basics RLL PLUS
12/38
ProgrammingBasics
0--12RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Using Outputs in Stages
Since the CPU only examines the logic in stages that are on, you have a lot moreflexibility in how you use outputs with the RLLPLUS instructions. Also, you dont haveto worry about adding several permissive contacts to keep the output from comingon at an inappropriate time. (If the stage is not on,the CPU doesnt even scan thestage, so the output cant possibly be turned on by the logic in that stage.)
If you examine Stage 2, youll notice weuse a SET instruction to clamp the part inplace. Why a set? Simple. If we used aregular output the clamp will bedeactivated when the programtransitions to Stage 3. Remember, whenyou leave a stage the CPU no longerscans that stage until it is turned onagain. So if we had used a regular OUTinstruction, the CPU would have
automatically turned off the output, whichwould have unclamped the part.
The first example shows the programexecution in Stage 2. The secondexample shows what happens on thenext scan after the part is locked. Noticethe clamp output is still on even thoughthe CPU is not scanning this portion ofthe program. This is why we use the SETinstruction in this case. We want theclamp to stay on while the presscompletes the cycle.
The clamp will stay on until the programenters Stage 4. Stage 4 unlocks the partby resetting output 020 when the pressreturns to the top limit.
ISGS000
Start S1JMP
SGS001
Present S2JMP
Part
001
000
S5JMP
PresentPart
001
Wait for start
Check for a part
SGS002
ClampSET
S3JMP
LockedPart
002
020
Lock the clamp
S150SET
SGS003
Down021
S4JMP
LimitLower
004
Press
Press the part
Next Scan after part is locked
SGS002
ClampSET
S3JMP
LockedPart
002
020
Lock the clamp
SGS004
ClampRST
S5JMP
UnlockedPart
003
Unlock the clamp
LimitTop
005 020
Setting Outputswith the SETInstruction
-
8/11/2019 Programming Basics RLL PLUS
13/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
SGS004
S5JMP
UnlockedPart
003
Unlock the clamp
LimitTop
005
One other benefit with RLLPLUS is theability to use the same output in multipleplaces. Instead of using the SETinstruction in Stage 2, we could have justput the clamp output, 020, in all thestages where we wanted the part toremain clamped.
If you examine Stage 2 youll noticeoutput 020 is on because the stage isactive. The next example shows whathappens after the part is locked in place.The program moves to Stage 3 fromStage 2. Notice output 020 is now off inStage 2. However, since we included thesame clamp output in Stage 3, the partremains clamped in place.
The clamp will automatically turn offwhen the program enters Stage 4. Notice
Stage4doesnothavetohaveanykindofReset instruction, since the output isautomatically turned off when theprogram exits Stage 3.
The concept of automatically turning offthe outputs sometimes confuses manypeople. However, the CPU just uses avery simple algorithm to determine if theoutput should be turned off. The followingdiagram shows how this algorithmworks.
ISGS000
Start S1JMP
SGS001
Present S2JMP
Part
001
000
S5JMP
PresentPart
001
Wait for start
Check for a part
SGS002
ClampOUT
S3JMP
LockedPart
002
020
Lock the clamp
S150
SET
SGS003
Down021
S4JMP
LimitLower
004
Press
Press the part
Next Scan after part is locked
SGS002
ClampOUT
S3JMP
LockedPart
002
020
Lock the clamp
ClampOUT020
Stage=On
ExecuteLogic
Yes
No
Examine Logic,AND results
with 0
Any outputson lastscan?
Yes
No
Skip to nextactive stage
Using the OUTInstruction
-
8/11/2019 Programming Basics RLL PLUS
14/38
ProgrammingBasics
0--14RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Theres one more way to control outputswith the Stage instructions. You mayrecall once a stage is turned on, you canonly turn it off by resetting it, or by havinga transition from it, either by a Jump or apower flow.
What happens if you have a stage thatdoes not have any kind of transition?What if it doesnt have a Jump instructionor any other kind of transition contactleading to another stage? Simple. Thestage will stay on until it is reset by someother part of the program that uses aReset instruction.
This makes it easy to use a stage withouta transition to latch an output. Forexample, if you examine Stage 2 youllnotice weve now changed this part of the
program again. Now this stage setsStage 140,which will be used to controlthe clamp.
Notice Stage 140 does not have any typeof transition. The only way to turn off theclamp is to Reset Stage 140. Thisinstruction has now been included inStage 4. So, after the program transitionsto Stage 4, the Reset instruction will turnoff Stage 140.
ISGS000
Start S1JMP
SGS001
Present S2JMP
Part
001
000
S5JMP
PresentPart
001
Wait for start
Check for a part
SGS002
SET
S3JMP
LockedPart
002
S140
Lock the Clamp
S150
SET
SGS003
Down021
S4JMP
LimitLower
004
Press
Press the part
Next Scan after part is locked
SGS002
SET
S3JMP
LockedPart
002
S140
Lock the clamp
SGS140
Clamp020
Clamp
SGS004
ClampRST
S5JMP
UnlockedPart
003
Unlock the clamp
LimitTop
005 S140
Latching Outputswith Stages
-
8/11/2019 Programming Basics RLL PLUS
15/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Using Timers and Counters in Stages
Up to this point weve been using certainevents that triggered the transition fromstage to stage. There will probably bemany cases where the transition shouldbe related to a timer value. For example,if you know the speed of the conveyoryou could use a timer to control theconveyor movement.
If we used this approach we wouldmodify Stage 5 as shown. Notice thetimer does not have a preset value. Thetimer begins incrementing as soon as itbecomes active. Since the timer does nothave a preset value, you do not have atimer contact, so you have to use a
comparative instruction.In the example shown, the conveyor willbe turned on for 5 seconds and then theprogram will jump to the next stage.
Only executes logic in stages that are active
S6JMP
TMR T600
SGS004
ClampRST
S5JMP
UnlockedPart
003
SGS005
Conveyor022
Move
SGS006
Cycle S0JMP
One
007
S1JMP
CycleOne
007
Unlock the clamp
Index the conveyor
One cycle or automatic?
LimitTop
005 020
T600 50
Time BasedTransitions
-
8/11/2019 Programming Basics RLL PLUS
16/38
ProgrammingBasics
0--16RLLPLUS Programming Basics
DL305 User Manual, Rev. D
There will also be times when you needto count things that happen throughoutthe process. For example, you may wantto know the number of parts producedduring any given shift, or you may knowthe presses generally require some type
of maintenance after a certain number ofcycles.
If we wanted to count the number ofwidgets made on our simple press, wecould just add a counter to Stage 4 tomonitor how many times the press isused.Were also going to use the counteras an automatic shutdown when thepress has made 5000 parts so weveadded a new rung in Stage 150 toperform the shutdown operation.
Notice the counter does not have a reset
leg. This is true only when you use acounter with the DL330P. (The otherCPUs have counters with reset legs.)Even though this counter does not have areset leg, it can be reset with a Resetinstruction. This works just like an outputreset, so you could place this resetwherever it is appropriate. Weve placedit in Stage 150 for this example.
When the parts count reaches 5000, theprogram will finish the current cycle,reset the part counter, and jump to Stage
0 to wait for another start cycle. You maynotice we added an additional input, 006.This is what allows the program to finishthe current cycle. (You may recall 006only came on after the part was unlockedand the conveyor was indexed.)
SGS003
Down021
S4JMP
LimitLower
004
Press
Press the part
SGS002
SET
S3JMP
LockedPart
002
S150
Lock the clamp
CNT C600
SGS150 Monitor for stop
S0 -- S6RST
S0JMP
C600RST
Stop
S0 -- S6RST
010
S0JMP
020 -- 022RST
Conveyor
006
IndexC600 K5000Parts Count
Using Counters
-
8/11/2019 Programming Basics RLL PLUS
17/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Using Data Instructions in Stages
Even though there are a few differencesin the way some of the instructionsoperate between the various CPUs,there are many of the normal instructionsthat can be used inside an individualstage. For example, you may need toload data into the accumulator to performsome type of math, or, you may need tostore values into register locations.
If you examine Stage 3, youll noticeweve added a couple of instructions.These instructions store the currentpartscount in a register.
Now the CPU will take the current partscount, stored in R600, and load it into the
accumulator with the DSTR instruction.Then this 4-digit BCD count will bemoved to R400 with the DOUTinstruction.
This is just one example of how you canuse the various types of datainstructions. There are many otherpossibilities. Just remember, if the stageis active, the instructions can beexecuted. If the stage isnt active, theinstructions will not even be examined.
SGS0003
Down021
S4JMP
LimitLower
004
Press
Press the part
SG S0002
SET
S3JMP
LockedPart
002
S150
Lock the clamp
CNT C600
SGS150 Monitor for stop
S0 -- S6RST
S0JMP
CT0RST
Stop
S0 -- S6RST
010
S0JMP
020 -- 021RST
Conveyor
006
Index
DSTR F50R600
DO UT F 60R400
C600 5000Parts Count
-
8/11/2019 Programming Basics RLL PLUS
18/38
ProgrammingBasics
0--18RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Using Comparative Contacts in Stages
You may recall you had to use acomparative instruction with the timers
and counters. The DL330P providesseveral comparative contacts that arevery useful. You can use these contactsto examine the relationship between acounter or timer value and a constant orregister value.
For example, lets assume the pressedwidgets move off the conveyor into aholding bin. The bin can only hold 1000widgets, so well add another counter,C601, to note how many widgets are inthe bin. Also, we want to use different
colored lights mounted on top of thepress to alert a forklift driver the binneeds to be carried to the next operation.Well use the following indicators.
Indicator Meaning Address Stage
Green OK 040 21Yellow Soon 041 22Red Urgent 042 23Reset Emptied 030
Notice weve added a few more stages tomonitor this condition. For this example,assume the press has made 750
widgets. This means the Yellow indicator(Stage 22) should be active.
We also need a way to reset the bincounter whenever the forklift driverempties the bin. If you examine Stage 21through Stage 23, youll notice we resetthe bin counter whenever the bin reset(030) is active.
This example doesnt show it, but youwould also have to make some changesto other parts of the program. Forexample, youd need to modify the Stop
Stage to shut off these stages when themachine was stopped.
SGS0003
Down021
S4JMP
LimitLower
004
Press
Press the part
CNT C600
SGS0020 Monitor lights for forklift
S21RST
S21SET
DSTR F50R600
DO UT F 60R400
R601 500
R601 K499
S22SET
S22RST
R601 K900 S23SET
R601 K899
SGS0021 Bin level OK
040OUT
SGS0022 Empty bin soon
041OUT
CNT C601
EmptiedBin
030
C601RST
SGS0023 Empty bin now
042OUT
EmptiedBin
030
C601RST
S22RST
S23RST
EmptiedBin
030
C601RST
Bin counter
-
8/11/2019 Programming Basics RLL PLUS
19/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Parallel Branching Concepts
As you examined some of the previous examples you saw we could have more thanone stage being processed on any given scan. The CPU scanned the first activestage and then moved on to the next active stage, skipping any inactive stages inbetween. For some complex applications, you can easily have as many parallelpaths as necessary. This is often called branching or divergence.
There are a couple of approaches you can take when you want to turn on more thanone stage. The diagrams shown dont necessarily apply to our press example, butinstead show the various approaches.
S2JMP
In this example, you use one transitioncontact to activate several stages.
S The SET instruction sets a range ofstages. These stages would remainon until they were reset, or, untilany transition instructions contained
within the stages were executed.S There are two Jump instructions,
both activating different stages.
ISGS000
Start
000
Wait for start
Only executes logic in stages that are active
S20 -- S30SET
S50JMP
In this example, notice thestage that getsactivated depends on an extra condition.For example, if the machine was capableof producing three different patterns,there may be a section of program foreach pattern.
There are other types of contacts thatcan be used. For example, you mayrecall we used Comparative contacts in
some earlier examples.
Notice we had to repeat the start switch ina separate rung each time. At first glanceyou would think you could simply haveone Start switch contact and OR theremaining switches. The DL305 CPUsdo supportmidline outputs (which is whatthis is called), but only in an ANDsituation.
ISGS000
Start S100JMP
000
Wait for start
Only executes logic in stages that are active
S200JMP
S300
JMP
Pattern 1
020
Pattern 2
021
Pattern 3
022
Start
000
Start
000
ISGS0000
Start S100JMP
000
Wait for start
S200JMP
S300JMP
Pattern 1
020
Pattern 2
021
Pattern 3
022
You can also use midline outputs tocontrol branching conditions. Heres anexample of branching instructions thatfollow the guidelines for midline outputs.(This example is not for the pressprogram, but merely shows how themidline outputs would appear.)
ISGS000
S100SET
S300JMP
023000
000 001
S200JMP
002
BranchingMethods
-
8/11/2019 Programming Basics RLL PLUS
20/38
ProgrammingBasics
0--20RLLPLUS Programming Basics
DL305 User Manual, Rev. D
There are many times you have to bring parallel branches back together at somepoint in the program. You may recall the stages have status bits associated withthem. You can use this status bit as a contact to easily converge the parallel paths.
To illustrate this method, were going to use a simple press with two stations. Now awidget must get pressed at each station before it is a finished product. Since thereare two stations, we must make sure both operations are complete before we movethe conveyor.
Joining ParallelBranches
-
8/11/2019 Programming Basics RLL PLUS
21/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Heres a flowchart that describes the two-station press. Please note weve changedsome of the stage numbers, input numbers, and output numbers, so they wontnecessarily match the previous examples.
Stage 50Stage 0
Wait forStart
Stage 10
Check forParts inA & B
Stage 20
Lock theclamp
Stage 21
Press thePart
Stage 22
Unlockclamp
Stage 23
Wait forStation B
CheckMode
OneCycle
Continuous
Station A
Stage 30
Lock theclamp
Stage 31
Press thePart
Stage 32
Unlockclamp
Stage 33
Station BFinished
Station B
Stage 40
MoveConveyor
No Part in A
A
No Part in B
Stage150
Check forStop
Reset all stagesJump to Start
B
Program mustconverge into
a single pathagain
Youve already seen how the basic sequence of operations was executed. so wereonly going to show the portions of the program that describe how the branches are
joined together.
-
8/11/2019 Programming Basics RLL PLUS
22/38
ProgrammingBasics
0--22RLLPLUS Programming Basics
DL305 User Manual, Rev. D
If you examine the flowchart youll noticeonce the part is unclamped in station B,the program transitions to Stage 33which indicates Station B is complete.
If you look at that portion of the program
shown here, youll notice there are noother instructions or actions that takeplace in this stage.This iswhy we call it adummy stage. Were just going to usethe status of the stage bit associated withthis dummy stage as a contact elsewherein the program to indicate station B isfinished.
You may be wondering how we can turnoff this stage. Since it does not have anytype of jump or power flow transition, theonly other option is to Reset the stage.Well do this later in the program.
SGS031
Down021
S32JMP
LimitLower
024
Press
Press the part
SGS030
ClampSET
S31JMP
LockedPart
023
020
Lock the clamp
SGS0033 Station B Finished
SGS031
ClampRST
S33JMP
UnlockedPart
023
Unlock the clamp
LimitTop
025 020
Station B
Stage 50Stage 0
Wait forStart
Stage 10
Check forParts inA & B
Stage 20
Lock theclamp
Stage 21
Press thePart
Stage 22
Unlockclamp
Stage 23
Wait forStation B
CheckMode
OneCycle
Continuous
Station A
Stage 30
Lock the
clamp
Stage 31
Press the
Part
Stage 32
Unlock
clamp
Stage 33
Station B
Finished
Station B
Stage 40
MoveConveyor
No Part in A
A
No Part in B
Stage 150
Check forStop
Reset all stagesJump to Start
B
Program mustconverge intoa single pathagain
Using Stage Bitsas Contacts
-
8/11/2019 Programming Basics RLL PLUS
23/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Since each stage has a status bit that iseither on or off, you can use this bit as acontact in the program. If you examineStage 23 youll notice weve used acontact labeled S33. This contactreflects the status of Stage 33, which
indicated Station B was finished.
When S33 is on, the contact labeled S33is also on and the program will transitionto Stage 40. In Stage 40 we use a resetinstruction to reset Stage 33 before wemove the conveyor.
SGS020
ClampSET
S21JMP
LockedPart
002
SGS021
Down021
S22JMP
LimitLower
004
Press
SGS022
ClampRST
S23JMP
UnlockedPart
003
020
SGS040
FinishedRST
S50JMP
MovedConveyor
006
B
SGS050
Cycle S0JMP
One
007
S10JMP
CycleOne
007
Clamp the part
Press the part
Unlock the clamp
Index theconveyor
One cycle or automatic?
Only executes logic in stages that are activ
LimitTop
005 020
Station A
SGS023
S40JMP
FinishedB
S33
Wait for Station B to finish
S33
Conveyor022
Stage ContactExample
-
8/11/2019 Programming Basics RLL PLUS
24/38
ProgrammingBasics
0--24RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Unusual Operations in Stages
Over the last few pages youve learned how the CPU executes the Stageinstructions. However, there are a few unusual circumstances that may not workexactly as the appear.
In the program shown it appears output021 will be turned on at three separatetimes before the program jumps to thenext stage. However, the only time theoutput actually comes on is when thefinal condition has been met.
Why? Remember if you use multipleoutputs in a program, the last rungcontaining the output controls the statusthat will be written to the module. This isno different in a program that usesRLLPLUS instructions.
In this example, the last comparison rungsays the output should be off until thetimer value reaches 90 seconds.
SGS0010
021OUT
T600 K200
T600 K100
T600 900
S20JMP
TMR T600
Finished
001
021OUT
021OUT
T600 K500
In the previous example the same outputwas used multiple times in the samestage. The last use of the outputcontrolled the status of the output.
There may be occasions when you havethe same output in different stages. Eventhough its not advisable to do this innormal RLL programs, this is perfectly
acceptable with a program that usesRLLPLUS instructions. However, if bothstages are active at the same time, thenthe logic in the last stage will control thestatus of the output.
In the example shown, if both stages areactive, then the logic in Stage 70 willcontrol the output status.
SGS0010
021OUT
001
S002JMP
002
SGS070
021OUT
010
S002JMP
006
011
Using the SameOutput MultipleTimes
-
8/11/2019 Programming Basics RLL PLUS
25/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Many normal RLL programs useone-shot instructions. In the DL305instruction set, this instruction is called aSet Out Reset (SET OUT RST).
In the program shown, input 001 will
trigger the SET OUT RST 160instruction, which will in turn activateoutput 021 for one scan.
However, what happens if 001 stays onand Stage 10 is activated, deactivated,and then activated again? At first glanceit appears the one shot only getsexecuted one time since 001 stayed onwhile Stage 10 was turning on and off. Itdoesnt work this way.
The logic in an inactive stage is notexecuted. So even though the stage
became active the SET OUT RSTinstruction did not see an off to ontransition, so the instruction is notexecuted.
The SET OUT RST instruction will workin an active stage as long as the inputtransitions from off to on while the stageis active.
SGS010
160SET OUT RST
001
021OUT
160
SGS0010
001
021OUT
160
One Shot is executed
Stage off,One Shot is not executed
SGS0010
001
021OUT
160
One shot must see off to on
Scan N
Scan N + 10
Scan N + 20
160SET OUT RST
160SET OUT RST
As youve seen in some of the previousexamples, we always placeunconditional outputs immediately
following the Stage Instructions. Theresa reason for doing this.
If you look at the example stage shownhere, the output is placed after a counterbox. The DirectSOFT software and theHandheld Programmer will allow you toenter this as shown. However, the CPUwill only turn on output 021 when thecounter input 001 is turned on. This isbecause the CPUinterprets the output asbeing tied to the counter input leg insteadof the Stage power rail.
You can easily avoid this problem byplacing any unconditional actions at thevery beginning of the stage. Then, theoutput will work the way you expect.
SGS0010
021OUT
S11JMP
001
003
Incorrect Placement
SGS0010
021OUT
Correct Placement
CNT C600
S11JMP
001
003
CNT C600
Using a Set OutReset (SET OUTRST) Instruction
Output Placement
-
8/11/2019 Programming Basics RLL PLUS
26/38
ProgrammingBasics
0--26RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Two Ways to View RLLPLUS Programs
Throughout the example programs, weve consistently shown how the instructionsappear in when viewed as ladder instructions. However, withDirectSOFT, you alsohave the capability to view the program as a flowchart. You can even view theprogram flowchart (in Stage View) and view the ladder program at the same timewith a split screen feature. The DirectSOFT manual provides detailed informationon how to view the programs in this manner.
ISGS0
SGS1
SGS150
SGS2
SGS6
SGS140
SGS3
J
J
J
J
J ISGS0
S
SGS140
R
J
SG Stage Reference toa Stage
J Jump S Set Stage
R Reset Stage
TransitionLogic
ISG S000
Start S1JMP
SGS001
Present S2JMP
Part
001
000
S5JMP
PresentPart
001
SGS002
Clamp
SET
S4JMP
LockedPart
002
SGS003
Down021
S4JMP
LimitLower
004
Press
020
Wait for start
Check for a part
Lock the clamp
Press the part
DirectSOFTStage View
DirectSOFTLadder View
-
8/11/2019 Programming Basics RLL PLUS
27/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Designing a Program Using RLLPLUS Instructions
As with most any application problem, a thorough understanding of the taskscombined with a good plan of execution often results in success. The RLL PLUS
instructions provide an easy way to load the plan of execution directly into the CPU.The easiest way to make sure you understand the tasks is to make a flowchart. Thisis often the most critical part of creating a program that uses RLLPLUS instructions.There are a few simple steps you can follow to create a detailed flowchart.
1. Create a top-level flowchart.
2. Expand the flowchart by adding things that cause the transitions from stepto step.
3. Add any actions that must occur in each step.
4. Add any conditions that control the actions.
5. Add any special monitoring or alarm steps that must be performed.
6. Assign numbers to the stages (steps).
7. Add the I/O instructions and addresses (input contacts, output coils, jumpinstructions, etc.)
8. Enter the program.
The DirectSOFT programming package allows you to quickly and easily createprograms with RLLPLUS instructions. The software has special features that allowyou to create the flowcharts, add the transitions, actions, etc. Even if your programsare fairly small, DirectSOFT can make the job much easier.
Use DirectSOFT toSave Time
-
8/11/2019 Programming Basics RLL PLUS
28/38
ProgrammingBasics
0--28RLLPLUS Programming Basics
DL305 User Manual, Rev. D
There are many different ways to design a flowchart of the application problem, butthere are a few guidelines that will make the job easier.
1. Start with a top-level flowchart that breaks the operation sequence intosimple pieces.
2. Each piece of the top-level flowchart should only represent one action.
Resist the temptation to group several operations into one part of theflowchart.
3. Dont try to add input or output addresses to the flowchart. Only use wordsto describe the things that are taking place.
4. Dont worry about special conditions, such as stop conditions, alarms, etcat this point. These will be added later when you fully understand how themain part of the operations sequence is organized.
You can draw the flowchart horizontally or vertically at any point in the designprocess, the choice is yours. Heres an example top level flowchart for our simpleone-station press.
Wait forStart
The flowchart
breaks the programinto logical steps
Checkfor Part
LockClamp
PressPart
UnlockClamp
MoveConveyor
OneCycle
Continuous
CheckMode
Step 1:Design a Top-levelFlowchart
-
8/11/2019 Programming Basics RLL PLUS
29/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Once you have designed the basic operating sequence you should determine theevents that cause a transition from step to step. During this phase you may findthings need to be added to the flowchart. All youre really doing is adding more detailto thetop-level flowchart. Once again, dont try to useaddresses yet. Concentrate onusing words to describe the events taking place. The following flowchart adds thetransition conditions for our one-station press.
Check Mode
Lock the Clamp
Wait for Start
Check for Part
Press the Part
Unlock the Clamp
Move Conveyor
Press Start Switch
Part in place
Clamp Limit Switch
Press Lower Limit Switch
Unclamp Limit Switch
Conveyor Index Limit Switch
Check 1-cycle Switch ON Check 1-cycle Switch OFF
TransitionSymbol
No Part
Jump toMove
Conveyor
Jump to Waitfor Start
Jump toCheck for
Part
Step 2:Add FlowchartTransitions
-
8/11/2019 Programming Basics RLL PLUS
30/38
ProgrammingBasics
0--30RLLPLUS Programming Basics
DL305 User Manual, Rev. D
After you determine the events that cause a transition from step to step you shouldadd any actions that need to take place during the sequence. Again, dont try to useaddresses yet. Concentrate on using words to describe theactions taking place. Thefollowing flowchart adds the actions that take place during each part of the program.
Check Mode
Lock the Clamp
Wait for Start
Check for Part
Press the Part
Unlock the Clamp
Move Conveyor
Press Start Switch
Part in place
Clamp Limit Switch
Press Lower Limit Switch
Unclamp Limit Switch
Conveyor Index Limit Switch
Check 1-cycle Switch ON Check 1-cycle Switch OFF
No Part
Jump toMove
Conveyor
Jump to Waitfor Start
Jump toCheck for
Part
Clamp On
Press
Clamp Off
Conveyor On
ActionSymbol
Step 3:Add Actions
-
8/11/2019 Programming Basics RLL PLUS
31/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Some actions may only take place if certain conditions are met. Examine theprogram carefully to determine any conditions that should be added. The followingflowchart adds any conditions for the actions that take place during each part of theprogram.
Check Mode
Lock the Clamp
Wait for Start
Check for Part
Press the Part
Unlock the Clamp
Move Conveyor
Press Start Switch
Part in place
Clamp Limit Switch
Press Lower Limit Switch
Unclamp Limit Switch
Conveyor Index Limit Switch
Check 1-cycle Switch ON Check 1-cycle Switch OFF
No Part
Jump toMove
Conveyor
Jump to Waitfor Start
Jump toCheck for
Part
Clamp On
Press
Clamp Off
Conveyor On
ConditionSymbol
Press Up
Step 4:Add Conditions forActions
-
8/11/2019 Programming Basics RLL PLUS
32/38
ProgrammingBasics
0--32RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Many people are tempted to add alarm or monitoring operations earlier in theflowchart design process. It is almost always easier to add them last because thenyou know how they should affect the main part of the program. The followingflowchart adds an operation that monitors for the conditions that will stop the press.
Press Up
Check Mode
Lock the Clamp
Wait for Start
Check for Part
Press the Part
Unlock the Clamp
Move Conveyor
Press Start Switch
Part in place
Clamp Limit Switch
Press Lower Limit Switch
Unclamp Limit Switch
Conveyor Index Limit Switch
Check 1-cycle Switch ON Check 1-cycle Switch OFF
No Part
Jump toMove
Conveyor
Jump to Waitfor Start
Jump toCheck for
Part
Clamp On
Press On
Clamp Off
Conveyor On
Monitor for Stop
Stop Switch
Reset all Operations
Jump to Waitfor Start
Step 5:Add Alarm orMonitoringOperations
-
8/11/2019 Programming Basics RLL PLUS
33/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
You can number the stages any way you would like, but its usually best to followsome type of sequence that matches the flow of the program. This makes it mucheasier to understand. There are a few guidelines we have used to determine the bestnumbering sequence. You dont have to follow these guidelines, but they may help.
You can typically find these types of operations in any program.
S Sequential Operations a certain sequence of events, one after theother. This is usually the main part of the program. Its usually best tonumber these first. For example, you may want to always number thesestages from 0 -- 127 (octal).
S Independent Operations these operations usually only perform onetask, such as activating a motor or turning on a horn. For example, youmay want to number all independent operations starting from 130 -- 147(octal).
S Alarm and Monitoring Operations These operations usually monitorthe main parts of the program. Since you may want to reset parts of theprogram during an alarm condition, it is usually best to number theselast. This way you can use one Reset (RST) instruction to reset almostthe entire program. Use stages 150 -- 177 for alarming and monitoringstages.
These guidelines are especially helpful if you have many different programs. Byusing a standard numbering scheme, you always know where to look for the varioustypes of operations.
The example shows how we assigned numbers for the example press. Notice wevealso made a separate stage for the clamp. This was not an absolute requirementbecause there are several ways you could have done this. We just did it to show youan example of an independent operation.
Step 6:Determine StageNumbering
-
8/11/2019 Programming Basics RLL PLUS
34/38
ProgrammingBasics
0--34RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Press Up
Stage 6
Stage 2
Initial Stage 0
Stage 1
Stage 3
Stage 4
Stage 5
Press Start Switch
Part in place
Clamp Limit Switch
Press Lower Limit Switch
Unclamp Limit Switch
Conveyor Index Limit Switch
Check 1-cycle Switch ON Check 1-cycle Switch OFF
No Part
Jump toMove
Conveyor
Jump to Waitfor Start
Jump toCheck for
Part
Clamp On
Press On
Clamp Off
Conveyor On
Stage 150
Stop Switch
Reset all Operations
Jump to Waitfor Start
Wait for Start
Check for Part
Lock the Clamp
Press the Part
Unlock the Clamp
Move the Conveyor
Check Mode
Monitor for Stop
Stage 140Clamp
Clamp
-
8/11/2019 Programming Basics RLL PLUS
35/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
The final step before you enter the program is to assign the I/O addresses and thedestinations for any Jump, Set, or Reset instructions.
Press Up
Stage 6
Stage 2
Initial Stage 0
Stage 1
Stage 3
Stage 4
Stage 5
Press Start Switch
Part in place
Clamp Limit Switch
Press Lower Limit Switch
Unclamp Limit Switch
Conveyor Index Limit Switch
Check 1-cycle Switch ON Check 1-cycle Switch OFF
No Part
Jump toMove
Conveyor
Jump toWait for Start
Jump toCheck for
Part
ClampSET
Press OnOUT
Stage 150
Stop Switch
Jump toWait for Start
Wait for Start
Check for Part
Lock the Clamp
Press the Part
Unlock the Clamp
Move the Conveyor
Check Mode
Monitor for Stop
Stage 140Clamp
000
001
S140
021
ClampOUT020
002
004
003
005
ClampRSTS140
ConveyorOUT022006
010
Reset All OperationsRST
S0 -- S140
007 Open007 Closed
Step 7:Assign I/OAddresses
-
8/11/2019 Programming Basics RLL PLUS
36/38
ProgrammingBasics
0--36RLLPLUS Programming Basics
DL305 User Manual, Rev. D
The following diagram shows how the program would look when viewed as a ladderprogram.
ISGS000
Start S1JMP
SGS001
Present S2JMP
Part
001
000
S6JMP
PresentPart
001
SGS002
ClampSET
S3JMP
LockedPart
002
SGS003
Down021
S4JMP
LimitLower
004
Press
SGS004
ClampRST
S5JMP
Unlocked
Part
003
S140
SGS005
Conveyor022
S6JMP
MovedConveyor
006
Move
SGS006
Cycle S0JMP
One
007
S1JMP
CycleOne
007
Wait forStart
Check for a Part
Clamp the part
Press the part
Unclamp the part
Index the conveyor
One cycle or automatic?
LimitTop
005 S140
A
A
SGS140
SGS150
Stop S0 -- S140RST
010
Clamp
Check for Stop
ClampOUT
020
S150JMP
S000JMP
Step 8:Enter the Program
-
8/11/2019 Programming Basics RLL PLUS
37/38
10--RLLPLUS Programming Basics
DL305 User Manual, Rev. D
This diagram shows how a portion of the program would look when viewed as aStage Diagram in DirectSOFT.
ISGS0
SGS1
SGS150
SGS2
SGS6
SGS140
SGS3
J
J
J
J
J ISGS0
S
SGS140
R
J
Wait forStart Check for a Part Clamp the part
Press the part
Clamp
Check for Stop
-
8/11/2019 Programming Basics RLL PLUS
38/38