Festo PLC Manual
Festo PLC Manual
Festo PLC Manual
Menubar
Menu
Search
Page
Toolbar
Menubar
Menu
Search
Page
Toolbar
Menubar
Menu
Search
Page
18352 MANUAL AWL E.HB-AWL-GB 1/97 R. Conde, Festo Corporation S. Baerwald, YC-ECI
All rights reserved, including translation rights. No part of this documentation may be reproduced by any means (printing, copying, microfilming or any other process) without the written consent of Festo KG.
Toolbar
Menubar
Menu
Search
Page
Toolbar
Menubar
Menu
Search
Page
1. Introduction
Target Audience This manual has been written for use by individuals who are familiar with the basic concepts of industrial controls. The purpose of this document is to familiarize the reader with programming Festo Programmable Controllers using the Statement List Language (STL).
Toolbar
Menubar
Menu
Search
Page
Toolbar
Menubar
Menu
Search
Page
1. Introduction
Manual Organization Content Organization This manual is divided into several major sections: Chapter 1 Introduction ............................................................................... 4 Provides a brief introduction into the organization and content of this document. FST Programming Environment .............................................. 7 Introduces the Festo FST family of programming software and defines some common terms that will be used in this manual. Using FST Software ................................................................ 11 Provides an overview of the process required to create, edit, load and run Statement List (STL) programs in the FST programming environment. Operands of Festo PLCs ....................................................... 15 Describes various addressable Operands (internal PLC elements) of Festo programmable controllers in summary format. The STL language operators are presented as well as the concept of Local and Global Operands. STL Program Structure .......................................................... 23 Addresses the various elements and instructions of the STL language as well as factors influencing program flow. STL Instruction Summary....................................................... 35 A brief introduction of each STL instruction is provided in alphabetical format. STL Instruction Reference ..................................................... 39 This section provides a detailed description of each STL command instruction including its purpose, the proper syntax and several examples of usage. Commands are listed in alphabetical order for quick access.
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Toolbar
Menubar
Menu
Search
Page
Toolbar
Menubar
Menu
Search
Page
1. Introduction
Content Organization (continued) Chapter 8 Accessing Digital Inputs and Outputs ................................... 75 Provides in depth information of how to address digital PLC Inputs and Outputs. Using Timers ........................................................................... 81 Describes how to use timers in STL. Also details the various system elements that encompass timing functions. Using Counters ....................................................................... 89 This chapter shows how to implement counters using the STL language. Using Registers....................................................................... 99 Explains the structure and uses of Registers using STL in Festo controllers. Flags and Flag Words........................................................... 103 Provides important information regarding the various uses and structure of Flags and Flag Words. Applying Specialized PLC functions.................................... 109 Includes basic information regarding application of Analog I/O, Networking, Field Bus and Positioning functions. Festo Controller Operands................................................... 117 A listing of the available operands for all current Festo programmable controllers in tabular format. Sample STL Programs.......................................................... 121 Several sample control tasks are presented, along with sample STL language solutions. Multiple Programs, Multiprocessing and Multitasking........ 137 Explains the meaning of these terms, how they are implemented and which controller models support these features. Understanding Binary numbers ........................................... 143 Offers a basic presentation of how to convert between binary and decimal numbers. ............................................................................................... 149
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Appendix A
Appendix B
Appendix C
Appendix D
Index
Toolbar
Menubar
Menu
Search
Page
Toolbar
Menubar
Contents
Search
Page
1. Introduction
Physical Organization Many sections of this manual are further divided to provide the following organizational structure: BRIEF, where appropriate, is located at the beginning of each section and describes the key points covered in the section. Experienced programmers and those who have studied the section can refer to the Brief to get, in condensed form, the information they need. Novice programmers can use the Brief as an introduction and guide to the important ideas and concepts that will be covered in the section. DETAILS is the heart of each section. It contains a thorough explanation of the topic, which may include theory, purpose and typical examples.
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
10
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
11
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS .................................................................................. 14 Preliminary steps ...................................................................... 13 Creating a program................................................................... 13 Program writing......................................................................... 14 Loading programs..................................................................... 14
12
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
13
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
14
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
15
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS .................................................................................. 17 Single vs Multibit Operands ................................................... 17 Single bit Operands .................................................................. 18 Multibit Operands...................................................................... 19 Local vs Global Operands ...................................................... 20 Global Operands ...................................................................... 20 Local Operands ........................................................................ 20 Operators................................................................................. 21
16
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
17
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Flag Counter Counter Timer Timer Program Program Processor Processor Error Status Auto Restart
F C C T T P P Y Y E ARU
Fn.n Cn Cn Tn Tn Pn Pn Yn Yn E ARU
e c e c e c e c e c c
NOTE: Operands which are marked by '*' may differ or not be available in all controller models.
18
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Operand Input Word Output Word Output Word Flag Word Flag Word Function Unit Function Unit Timer Word Timer Word Timer Preselect Timer Preselect Counter Word Counter Word Count. Preselect Count. Preselect Register Register Error Word Error Word
STL Form IW OW OW FW FW FU FU TW TW TP TP CW CW CP CP R R EW EW
Syntax IWn OWn OWn FWn FWn FUn FUn TWn TWn TPn TPn CWn CWn CPn CPn Rn Rn EW EW
Part c c e c e c e c e c e c e c e c e c e
Typical Example IF (IW3=V 255) IF (OW2=V80) LOAD V128 TO OW3 IF (FW3=V220) LOAD V21000 TO FW1 IF (FU32=V16) LOAD FU34 TO R60 IF (TW2 < V2000) LOAD V1345 TO TW6 IF (TP0 < V20) * THEN LOAD V500 TO TP4 IF (CW3 <> V50) THEN INC CW5 IF (CP3 = V555) LOAD V67 TO CP5 IF (R60 = V21113 ) LOAD (R53 + R45 ) TO R32 IF (EW AND V15) LOAD V0 TO EW
NOTE: Operands which are marked by '*' may differ or not be available in all controller models.
19
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
20
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Purpose NOT (negation) VALUE assignment for Multibit operands (decimal) VALUE assignment for Multibit operands (hexadecimal) VALUE assignment for Multibit operands (binary) Addition of Multibit operands and constants Subtraction of Multibit operands and constants Multiplication of Multibit operands and constants Division of Multibit operands and constants Multibit comparison...Less Than Multibit comparison...Greater Than Multibit comparison...Equal To Multibit comparison...Not Equal To Multibit comparison...Less Than or Equal To Multibit comparison...Greater Than or Equal To Opening/Closing parenthesis used to qualify or specify the Order of Precedence for Logic and Arithmetic operations.
21
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
22
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
23
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS .................................................................................. 25 STL Element Hierarchy........................................................... 26 Step Instruction......................................................................... 26 Sentences................................................................................. 26 Typical Sentences .................................................................... 27 Further Examples ..................................................................... 27 Comparison to Ladder Diagram................................................ 28 Step Instruction....................................................................... 29 Execution rules ....................................................................... 30 Influencing Program Flow ...................................................... 32 NOP Instruction ........................................................................ 32 JuMP Instruction ....................................................................... 33 OTHRW Instruction................................................................... 34
24
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
25
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
26
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
THEN
In the last sample sentence, the principle of compound conditions has been introduced. That is, all of the stated conditions in the current sentence must be true for the actions following the THEN keyword to be executed. Further Examples
IF THEN OR INC SET N I3.2 T6 CW1 T4 If Input 3.2 is Active or Timer 6 is NOT running then increment Counter 1 and start Timer 4 with preexisting parameters
This example shows the use of the OR structure within the conditional part of a sentence. That is, the sentence will evaluate as being true (and therefore Counter 1 would be incremented and Timer 4 started) if either or both of the stated conditions are true. The next sentence introduces the use of parentheses within the conditional part of a sentence to influence the manner in which conditions are evaluated.
IF AND OR AND ( ( I1.1 T4 I1.3 I1.2 If Input 1.1 is Active AND Timer 4 is running OR if Input 1.3 is Active and Input 1.2 is Active
) )
We have utilized the OR instruction to combine two compound conditions by means of the parenthesis operator.
27
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
You will notice that the previous example also introduced the OTHRW command. The STL language requires explicit instructions to alter the state of any operand (e.g. Output, Timer, Counter). The PSE instruction is placed at the end of a parallel program section to cause the program to be executed continuously by returning to the first Sentence of the current Step or the first Sentence of the program if no Steps are used. See chapter 7.
28
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
It is important to understand that the program will WAIT at this Step until the conditions are true at which time the actions will be performed and only then will the program proceed to the next Step. The optional Step label is only required if a Step will be the target of a JUMP instruction. It should be noted that when FST software loads STL programs into the programmable controller, it assigns relative Step numbers to each program Step. These assigned step numbers are also reproduced in all program listings and can be quite helpful in monitoring program execution for On-Line debugging purposes. Program Steps can, of course, include multiple sentences:
STEP IF THEN IF THEN I2.2 O4.4 I1.6 O2.5 O3.3 If Input 2.2 is Active Switch on Output 4.4 If Input 1.6 is Active Switch off Output 2.5 and Switch on Output 3.3
SET
RESET SET
In the previous example, we have introduced the concept of multiple Sentences within a Single Step. When the program reaches this Step, it will process the first sentence (in this case, turning on Output 4.4 if Input 2.2 is active) and then move to the second sentence regardless of whether the Conditions in the first sentence were true. When the last (in this case the second) sentence of a Step is processed, if the Conditional part is true, then the Executive part will be carried out and the program will proceed to the next Step. If the Conditional part of the last sentence is not true, then the program will return to the first sentence of the Current Step.
29
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Note:
It is important to understand when constructing Programs or Steps that contain multiple Sentences that will be processed in a parallel (scanning) manner; that every time the conditional part of a Sentence evaluates as true, the instructions programmed in the executive part will be performed. This must be considered in order to avoid uncontrolled multiple executions of instructions such as SET TIMER or INC/DEC counter. The STL language does not use 'edge triggering'...conditions are evaluated for truth each time they are processed without regard as to their prior status. This situation is easily handled by either using Steps, Flags or other means of control. See Appendix B for examples.
30
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
No
Yes Action
No
No
Yes
Yes
Go To Next STEP
31
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
SET
A typical use can be seen in the following example in which the author desired that when program execution reached Step 50 several conditions were to be checked and if they were true the appropriate actions were executed. However, regardless of whether any or all of the conditions were true, after being checked exactly one time the program would turn on Output 3.6 and proceed to the next Step...because we have forced the last sentence to be true via the NOP instruction.
STEP 50 IF THEN IF THEN IF THEN IF AND RESET
SET N
If Input 1.0 is Active then turn on Output 2.2 If Input 3.5 is NOT Active and Input 4.4 is Active then turn off Output 1.2 If Timer 3 is running then set Flag 0.0 in any case...we make certain that the LAST sentence will ALWAYS be true. turn on Output 3.6 , exit this Step and go to Next Step.
SET NOP
THEN
SET
O3.6
32
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
JuMP Instruction Another STL instruction which can be used to influence the flow of program execution is the JMP instruction. The JMP instruction adds the ability of program branching to the STL language. By modifying the previous example it is possible to test the conditions of each sentence and if true perform the programmed action and then JuMP to a designated program Step.
STEP 50 IF THEN
I1.0 O2.2 70
If Input 1.0 is Active turn on Output 2.2 and jump to Step label 70
IF THEN
If Input 3.5 is NOT Active and Input 4.4 is Active turn off Output 1.2 and jump to Step label 6
IF THEN IF THEN
SET
if Timer 3 is running then set Flag 0.0 Always true, so... turn on Output 3.6 and go to the next step.
SET
It can be seen that not only have we altered the program flow, but in addition have established priorities between the sentences. For example, sentences 2, 3 and 4 will only have the possibility to be processed if sentence 1 is false and therefore not executed; because if sentence 1 is executed, the program will Jump to Step 70 without ever processing any subsequent sentences in Step 50.
33
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
No
Action
No
No
No
Yes
Yes
Go To Next STEP
34
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
35
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
NOP
OR
36
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Instruction OTHRW
Purpose Provides the ability to continue program execution if the Conditional Part of a sentence is false. The PSE (Program Section End) instruction. The Reset instruction is used to change single bit operands to a logical '0' status. Rotates Left all bits contained in the Multibit Accumulator by one position. The most significant bit is moved to the least significant bit. Rotates Right all bits contained in the Multibit Accumulator by one position. The least significant bit is moved to the most significant bit. The Set instruction is used to change single bit operands to a logical '1' status. Performs a Single Bit Swap between a Single Bit Operand and the Single Bit Accumulator. Shifts Left all bits contained in the Multibit Accumulator by one position. The most significant bit is lost, and the least significant bit is filled with a zero (0). Shifts Right all bits contained in the Multibit Accumulator by one position. The least significant bit is lost, and the most significant bit is filled with a zero (0). Exchanges the high and low order bytes of the Multibit Accumulator. Used with the LOAD instruction to specify a destination operand. Keyword marking the beginning of the Executive part of a sentence. Used to pass parameters with some CFM/CMP instructions. Also used to specify timer clock rates for some PLC models.
ROR
SET SHIFT
SHL
SHR
37
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
38
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
39
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
40
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
AND
Purpose 1. To combine two or more single or multibit operands in the Conditional part of a Sentence using the logical AND operation. 2. To perform logical AND'ing of two multibit operands or values in either the Conditional or Executive parts of a sentence. Examples Single Bit
IF THEN AND SET I1.1 T6 O1.5 If Input 1.1 is Active and Timer 6 is running turn on Output 1.5
Multibit The following illustrates the logical bit-wise AND operation applied to two 8 bit operands: 0 1 0 0 1 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 1 0 0 operand 1 = 45 decimal AND operand 2 = 236 decimal result = 44 decimal
The AND function can be used with Multibit operands in both the Conditional as well as the Executive parts of a Sentence. When used in the Conditional part of a Sentence this function allows the result of a Logical AND function of two Multibit operands to be compared to a third Multibit operand or constant.
IF AND = THEN ... ( R6 R7 V34 the contents of Register 6 are AND'd to the contents of Register 7. Next the result is compared to the constant 34 decimal. If equality is found, any programmed actions will be performed.
41
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
The next example shows how to use the multibit performance of Festo controllers to Read an entire group (Word) of Inputs. Next the result is logically AND'ed with 15 decimal (00001111 binary). By comparing the result of this operation to see if it is greater than 0, we are able to test if any of Inputs 0.0 through 0.3 are active.
IF AND ( IW0 V15 ) the contents of Input Word 0 are AND'ed with the decimal constant 15, and the result is compared... as being greater than value 0 the sentence will be true
V0
The next example shows using the AND function with multibit operands in the Executive part of a sentence.
IF THEN ... LOAD if the conditions are true then transfer the contents of Register 38 to the Multibit Accumulator. logically AND'ing to Register 45 and placing the result in Register 17
R38
AND TO
R45 R17
42
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
BID
Purpose To convert the contents of the multibit accumulator from Binary to BCD format. This instruction is often used in conjunction with a device connected to the PLC's outputs (e.g. canned message displays, motor controls etc.) These devices often expect input commands in BCD format. Refer to the DEB instruction for conversion from BCD to Binary format. Examples The value to be converted must first be loaded into the multibit accumulator.
IF THEN LOAD BID AND TO I1.0 R26 Start Servo motor button Register 26 contains the new position information Convert to BCD format mask all bits except 0-3 and transfer the results to Output Word 2 (connected to servo controller)
V15 OW2
43
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
CFM
Purpose The CFM (Call Function Module) instruction is used to request execution of a standard system routine which is resident within the System memory of the controller. You should refer to the appropriate controller manual to see which CFM calls are available for your particular hardware configuration. These standard routines cannot be written by the user as they are integral sections of the controller's operating system. Some Function Modules may use Function Units (FU) to pass information to/from user programs and Function Modules. Examples Depending upon the specific controller model, as well as the particular CFM routine being called, it may be necessary to provide several parameters when programming a CFM. Example 1: FPC100 This system routine can be used to unconditionally clear or reset a variety of operands. The call to this CFM accepts a single numeric parameter. If we use a Value of 2, the Function Module will Reset ALL Flags to 0's.
IF THEN CFM WITH I1.2 0 V2 Reset button pressed Call Function Module 0 pass a value of 2 to parameter number 1, which here results in ALL FLAGS being placed in a RESET state.
44
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
V6 V0 V200
45
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
CMP
Purpose The CMP (Call Program Module) instruction is used to request execution of an external program routine. Program modules may be considered similar to subroutines. NOTE: It is NOT permissible to use the CMP instruction from WITHIN a Program Module. Program modules may be written in one of several languages including STL and Assembler. Festo is able to supply a number of optimized program modules for handling specialized tasks such as: Text I/O High Speed Counting 32 bit arithmetic functions If you have a task that you are unable to handle using standard language facilities, please contact your Festo office...we may have already solved your problem! Some Program Modules may use Function Units (FU) to pass information to/from user programs and Program Modules. Please refer to the CFM instruction for calling standard Festo Rom-resident routines. Examples Depending upon the specific controller model, as well as the particular Program module being called, it may be necessary to provide several parameters when using a CMP. Example: FPC100 This program module can be used to transmit text. The call to this particular CMP accepts several parameters depending upon the function desired.
IF THEN CMP WITH WITH I1.5 if tank high level sensor 7 Call Program Module 7 V0 specify text string output 'Tank #1 is Over-Full'
46
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
The previous example merely serves to provide a general understanding of the way in which program modules are called. The actual calling procedures vary greatly, so the user must always refer to the appropriate documentation. Simple Modules: In the situation where the user merely writes a subroutine as a program module, it is not necessary to pass any parameters. In such cases a simplified call may be made:
IF... THEN
CMP
47
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
CPL
Purpose This command complements the contents of the multibit accumulator using the two's complement method. In principle, the effect of using the CPL instruction is the same as multiplying a number by -1 when applied to signed integers. Examples The following illustrates applying the CPL instruction to a 16 bit number which has been loaded to the multibit accumulator:
0 1
0 1
0 1
1 0
0 1
0 1
1 0
0 1
0 1
1 0
1 0
0 1
0 1
1 0
1 0
1 1
The value to be operated on must first be loaded into the multibit accumulator. In the following example, the program will check to see if Register 32 contains a negative number, and if so will convert the number to a positive number and store it in Register 22.
IF ( < LOAD CPL TO R22 R32 V0 R32 test to see if Register 32 is less than 0....a negative value and if it is negative load it to the multibit accumulator apply the compliment instruction and copy the to Register 22.
THEN
48
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DEB
Purpose To convert the contents of the multibit accumulator from BCD to Binary format. It is common that various peripheral equipment may report information (values etc.) to a PLC via standard PLC Inputs. In order to minimize the number of Inputs required, the peripheral device may use BCD encoding. Since the DEB instruction operates on the contents of the multibit accumulator, the value to be converted must first be loaded into the Multibit accumulator. Examples For example, if we used two BCD thumbwheel switches to allow the entry for the number of cycles a machine should run, the following instructions might be used. We have connected the BCD switches to Inputs 0-7 of Input Word 1 and Input 0.3 is used to actually enter the current settings, which are then stored in Counter Word 2.
IF THEN LOAD ( I0.3 IW1 When Input 0.3 is activated, copy the COMPLETE Input Word to the Multibit Accumulator, and then use the AND function to MASK off Inputs 8-15. Whether or not Inputs 0.8-15 exist or not, this ensures that we only have the true value of the BCD switches lin the accumulator. Perform the actual BCD to Decimal conversion and then copy the result to Counter Word 2.
AND
V255
DEB TO CW2
49
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DEC
Purpose The DECrement instruction reduces the value of any multibit operand by 1. Unlike other arithmetic instructions, the DECrement operation may be carried out directly without the need to first load the operand to be DECremented to the multibit accumulator. While the DECrement instruction can be used with any multibit operand, it is most often used in conjunction with Counters. Chapter 10 contains specific, detailed information on how to work with counters. Examples In the following example we will assume that on a bottle filling line, Input 1.3 is activated each time a bottle passes by a counting station. The total number of bottles is to be stored in Register 9. However, sometimes a bottle is not completely filled and this is tested further on in the production process. If a partially filled bottle is sensed, the existing total count is to be reduced by 1.
IF THEN IF AND DEC N INC I1.3 R9 I2.2 I3.6 R9 Input 1.3 senses all bottles which we want to totalize so add 1 to the existing count When a bottle arrives at the level test station and it's not properly filled subtract 1 from the total
THEN
50
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
EXOR
Purpose To combine two or more single or multibit operands in the Conditional or Executive part of a Sentence using the logical EXOR (EXclusive OR) operation. Examples Single Bit In the following example, Output 1.3 will be switched on if either I1.1 or I1.2 is active, but not if both are active.
IF THEN EXOR SET I1.1 I1.2 O1.3 If either 1.1 or 1.2 is active (BUT NOT BOTH!) switch on Output 1.3
Multibit The following illustrates the logical bit-wise EXOR operation applied to two 8 bit operands: 0 1 1 0 1 1 1 1 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 1 operand 1 = 45 decimal EXOR with operand 2 =236 decimal result = 193 decimal
When used in the Conditional part of a Sentence, this function allows the result of a Logical EXOR function of two Multibit operands to be compared to a third Multibit operand or constant. In the following example, we will use the power of the EXOR function to control an 8 bottle filling station. The 8 filling positions are located on part of a bottle conveying system. As bottles pass by they must be checked. At any of the 8 positions it is possible that a bottle may or may not be present. Any unfilled bottles shall be filled and when all present bottles are filled the bottling line shall again continue moving, searching for the next group to fill.
51
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
bottles are not stopped & bottle exists at position 7 stop bottles from moving see which bottles are present and are NOT filled. Then turn on the outputs to fill bottles If ALL Outputs are Off
( =
) and the bottles were stopped for filling... let bottles move again goto Step 10
52
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
INC
Purpose The INCrement instruction increases the value of any multibit operand by 1. Unlike other arithmetic instructions, the INCrement operation may be carried out directly without the need to first load the operand to be INCremented to the multibit accumulator. While the INCrement instruction can be used with any multibit operand, it is most often used in conjunction with Counters. Chapter 10 contains specific, detailed information on how to work with counters. Examples In the following example we will assume that on a bottle filling line, Input 1.3 is activated each time a bottle passes by a counting station. The total number of bottles is to be stored in Register 9. However, sometimes a bottle is not completely filled and this is tested further on in the production process. If a partially filled bottle is sensed, the existing total count is to be reduced by 1.
IF THEN IF AND DEC N INC I1.3 R9 I2.2 I3.6 R9 Input 1.3 senses all bottles which we want to totalize so add 1 to the existing count When a bottle arrives at the level test station and it's not properly filled subtract 1 from the total
THEN
53
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
INV
Purpose This command complements (INVerts) the contents of the multibit accumulator using the one's complement method. When applied to signed integers, this is equivalent of multiplying a number by -1 and then adding -1. Examples The following illustrates applying the INV instruction to a 16 bit number which has been loaded into the multibit accumulator. 0 1 0 1 0 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 1 0
INV =
The INV instruction can be of use when it is desired to 'flip' (invert) each and every bit as contained in the multibit accumulator. In the following example, a mixing machine has 16 stations. The mixing cycle consists of alternating time periods of shaking and settling. During normal operation workers add or remove containers randomly. Only those stations that have containers in placed are to be activated. Sensors are provided to see which stations are to be activated.
STEP 10 IF THEN N LOAD T1 OW1 No Time cycle in progress Current status Outputs 0-15 for each station shakers is copied to the multibit accumulator now we 'flip' the status of each output...those that are On go Off etc. (but this is only done within the MBA!) now correct for any stations that were off, but were turned on and have no container. finally actually switch on the appropriate Outputs. Start the timer wait until process done time period done back to Step 10
INV
AND
IW1
OW1 T1
N JMP TO
T1 10
54
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
JMP TO
Purpose To provide a means to influence the flow of program execution based upon programmable criteria. Analogous to the BASIC language instruction GOTO. Please note that use of the JMP TO instruction can remove the requirement that the LAST sentence of a STEP be true for program execution to continue. The JMP TO instruction can also be used to prioritize the execution of sentences within a Step. Examples In the first example, the JuMP instruction is used within a parallel program to detect and then react to an ESTOP condition. Step 20 contains all of the sentences that are processed in a parallel manner. Note that ESTOP is a normally-closed button.
STEP 20 ...prior sentences in Step 20 IF THEN N LOAD TO TO JMP TO I1.1 V0 OW0 OW1 80 see is ESTOP was pressed if so, turn off ALL Outputs as a group in Output Word 0 and Output Word 1 then goto special routine
...remaining sentences in Step 20 STEP 80 IF AND THEN JMP TO ESTOP Routine wait here until the ESTOP signal is no longer sensed and the RESET button is pressed. continue at Step 20
I1.1 I2.1 20
The following example uses multiple jumps within a Step and illustrates a situation whereby a machine operator must select 1 of 3 possible choices.
55
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
STEP 40 IF AND AND JMP TO N N I1.1 I1.2 I1.3 100 I1.2 I1.1 I1.3 150 I1.3 I1.2 I1.1 200
THEN IF
Operator MUST select only 1 of 3 possible choices sequence 1 selected and not sequence 2 and not sequence 3 section for sequence 1 sequence 2 selected and not sequence 1 and not sequence 3 section for sequence 2 sequence 3 selected and not sequence 2 and not sequence 1 section for sequence 3
THEN IF
N N
THEN
N N
By carefully ordering multiple sentences within a Step, along with proper use of the JuMP instruction, it is easy to prioritize operational sequences. The next example assumes that Steps up through 50 contain instructions for machine processing, and that upon reaching STEP 60 the machine is to check Inputs 1.1, 1.2 and 1.3 and wait until the FIRST input appears and then process only (1) of these inputs with Input 1.1 having the highest priority and Input 1.3 having the lowest priority.
STEP 60 IF AND AND JMP TO N N N I1.1 I1.2 I1.3 60 I1.1 100 N AND JMP TO AND AND NOP N N I1.1 I1.2 150 I1.1 I1.2 I1.3 wait until at least one of the required input becomes true
JMP TO
it's the highest priority input step 100 make sure no higher priority request exists step 150 make sure no higher priority request exists ok to just proceed to the next program step
THEN
56
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
LOAD... TO
Purpose The LOAD instruction allows copying (loading) Single and Multibit operands to the Single Bit Accumulator and Multibit Accumulator (respectively) in preparation for: 1. performing logical and/or mathematical operations. 2. or as a required intermediate step for transferring information between operands. The ...TO part of the instruction allows specifying the destination operand. The LOAD...TO instruction is most often used with Multibit operands. Examples Single Bit Loads Single Bit Syntax
Source Optional Operation Destination
Note: SBO = any Single Bit Operand While the above examples are valid STL instructions, they are not typically used. They are, however, equivalent to:
IF THEN OTHRW SET RESET I1.0 O1.0 O1.0 If Input 1.0 is Active then switch on Output 1.0 else turn off Output 1.0
If Input 1.0 is Active and and Input 1.1 is NOT Active switch on Output 1.0 else turn off Output 1.0
57
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Note: MBO/V = any Multi Bit Operand or Value The use of the LOAD instruction with Multibit operands and values, when used in conjunction with the available mathematical or logical operations, provides very powerful processing capabilities. The following examples illustrate some of the diverse functions which can be accomplished using the LOAD instruction. Switching off ALL Outputs of a system We will assume our system contains 64 Outputs organized as 4 x16 bit words. Using the typical RESET instruction would require program logic such as:
IF THEN RESET RESET .... I1.0 O1.0 O1.1 eg.:. a Reset Button turn off 1 Output and another until we repeated this command for each of the 64 Outputs.
By using the LOAD instruction the same result can be accomplished by:
IF THEN LOAD TO TO TO TO I1.0 V0 OW1 OW2 OW3 OW4 eg.:. a Reset Button put zero in Multibit Accumulator turn off Outputs 1.0 - 1.15 turn off Outputs 2.0 - 2.15 turn off Outputs 3.0 - 3.15 turn off Outputs 4.0 - 4.15
Note that once a Value (in this case 0 ) has been loaded into the Multibit Accumulator, it can be copied (using TO) to multiple destinations without having to be reloaded.
58
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Note:
When a LOAD instruction is executed, the specified Multibit Operand or Value is loaded into the Multibit Accumulator (MBA). The MBA is 16 bits wide. If the Multibit Operand specified as the source (e.g. LOAD MBO) is only 8 bits wide (e.g. I/O module with only 8 discrete points) then the upper byte of the MBA will be filled with 0's. In the same way, if the MBA is transferred (via the TO instruction) to an 8 bit wide destination, the upper 8 bits will be lost.
Additional examples that include the LOAD instruction can be found throughout this chapter as part of the explanations and examples provided for many of the STL instructions including: SHL, SHR, ROR, ROL, SWAP, WITH, AND, OR, EXOR etc.
59
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
NOP
Purpose The NOP (No Operation) instruction, which at first may seem to be of little value, is quite often helpful when programming. The actual consequence of using the NOP instruction depends on whether it is used in the Conditional or Executive part of a sentence. Examples Conditional Part When used in the Conditional part of a sentence, the NOP instruction can be used to construct a sentence which will always be evaluated as true and any programmed instructions in the Executive part will be performed.
STEP 45 IF THEN NOP T6 O1.2 always true start timer 6 switch on Output 1.2
SET SET
Parallel Processing When a program step contains multiple sentences which are to be processed (scanned) continuously, the NOP instruction may be used to control program flow.
STEP 11 IF THEN IF THEN OTHRW IF THEN IF THEN IF THEN STEP 90 IF THEN AND JMP TO AND INC I1.4 T4 I3.0 O1.6 O1.6 T4 O1.6 CW3 I2.2 90 If Input 1.4 is active start Timer 4 Manual Start Input Start Motor else Stop Motor Timer 4 running motor is running increment cycle count Emergency Button Exit this scan ... always... continue this scan... special routine Emergency Button released Reset Button go back to Step 11, else wait
SET
SET RESET
11
I2.2 I3.3 11
60
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
61
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
OR
Purpose 1. To combine two or more single or multibit operands in the Conditional part of a Sentence using the logical OR operation. 2. To perform logical OR 'ing of two multibit operands (or values) in either the Conditional or Executive part of a sentence. Examples Single Bit
IF THEN OR SET I1.1 T6 O1.5 If Input 1.1 is Active or Timer 6 is running turn on Output 1.5
Multibit The following illustrates the logical bit-wise OR operation applied to two 8 bit operands: 0 1 1 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 1 0 1 operand 1 = 45 decimal OR operand 2 = 236 decimal result = 237 decimal
The OR function can be used with Multibit operands and values in both the Conditional as well as the Executive parts of a Sentence. When used in the Conditional part of a Sentence, this function allows the result of a logical OR function of two Multibit operands or values to be compared to a third Multibit operand or value.
IF OR = THEN ... ( R43 R7 V100 ) the contents of Register 43 are OR'd to the contents of Register 7. Next the result is equal to 100 if so, then perform any instructions provided.
62
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
The next example is a machine which consists of 16 parallel conveyors, each one of which transports component parts to an assembly area. Component parts are loaded by hand at one or more of 3 possible locations on each conveyor. Each conveyor includes 3 sensors that check if parts have been loaded. When all 16 conveyors have at least one component loaded, then each conveyor shall start running. As a part reaches the end position of each conveyor, that conveyor shall stop. Each conveyor contains a sensor to sense when a part is present at the end position.
STEP 50 IF OR = ( ( OW1 IW4 V0 IW1 IW2 IW3 = THEN LOAD TO V65535 V65535 OW1 ) ) all load station 1 sensors for conveyors 1,2,3 all load station 2 sensors for conveyors 1,2,3 all load station 3 sensors for conveyors 1,2,3 all 16 conveyors have at least 1 component loaded so turn-on all 16 conveyors which are controlled by Outputs 1.0 - 1.15 turn off each conveyor as a component reaches the end position when all conveyors are stopped then start again The criteria to start all conveyors are now stopped (outputs 1.0 - 1.15 ) AND all 16 end positions are clear
AND OR OR
LOAD TO ( = JMP TO
63
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
PSE
Purpose To mark the end of a program (Program Section End) and cause a program change. Will also result in a Virtual Processor Swap for controller models that support multi-tasking (see Appendix C). This instruction is not available in the FEC and IPC. Upon returning to the program which executed the PSE instruction, the program will continue processing: at the first sentence of the current Step or at the first sentence in the program when no Steps exist Examples If an STL program merely ends with a normal sentence, and no further instructions are given, the program will cease running. Typical programs or program sections are terminated using either the PSE instruction or the JUMP TO instruction.
Example 1 STEP 10 IF THEN SET STEP 20 IF THEN OTHRW
I1.1 O2.1
I3.1 O2.1
Cylinder is extended so retract cylinder goto first sentence goto first Sentence
When a program has been constructed without Step labels, and the program is to be processed continuously in a scanning manner; the program should end with a PSE instruction.
Example 3 ... ... ... IF THEN
NOP PSE
prior sentences " " always true program section end ....go to top sentence in program
64
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
RESET
Purpose The RESET instruction is used to change the status of Single Bit operands to a logical 0 (zero). RESETting an operand that is already reset has no effect. The actual effect of issuing a RESET instruction varies according to the operand addressed. The following table provides a summary of using the RESET instruction. Detailed information on using the RESET instruction can be found in chapters 8, 9, 10 and 12. Examples Operand
Output Flag
Syntax
RESET O1.6 RESET F2.12
Effect
Switches Output 1.6 off. Forces the status of Flag 12.2 to be '0'. The status of Counter changed to inactive. 6 is
Counter
RESET C6
Timer
RESET T4
The status of Timer 4 is changed to inactive. Program 2 is stopped Program 2 is suspended Clears the Error Status Bit
65
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
ROL
Purpose The ROtate Left instruction rotates the contents of the Multibit Accumulator to the Left by one position. The most significant bit (bit 15) is transferred to the least significant bit position. Also see the ROR, SHR and SHL instructions. It should be remembered that the LOAD...TO instruction is normally used first to prepare the Multibit Accumulator and again after the ROR instruction to copy the results to the desired MBO. Examples The following illustrates the effect of using the ROL instruction. 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1
LOAD MBO 1st ROL 2nd ROL TO MBO
IF THEN
T6 OW1
OW1
If Timer 6 is not running load all 16 bits of Output Word 1 to the MBA rotate left the first time rotate left a second time and copy the result back to the same place....could be an MBO!
This instruction may also find good use when applied to machinery that use various types of rotary tables or conveyors to track the status of production as the machinery indexes.
66
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
ROR
Purpose The ROtate Right instruction rotates the contents of the Multibit Accumulator to the Right by one position. The least significant bit (bit 0) is transferred to the most significant bit position. Also see the ROL, SHR and SHL instructions. It should be remembered that the LOAD...TO instruction is normally used first to prepare the Multibit Accumulator and again after the ROR instruction to copy the results to the desired MBO. Examples The following illustrates the effect of using the ROR instruction. 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 1 1 0 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 1 0 1 1 1 1 0 1 1
LOAD MBO 1st ROR 2nd ROR TO MBO
IF THEN
T6 OW1
OW1
If Timer 6 is not running all 16 bits of Output Word rotate right the first time rotate right a second time and copy the result back to the same place....could be an MBO!
This instruction may also find good use when applied to machinery that use various types of rotary tables or conveyors to track the status of production as the machinery indexes.
67
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
SET
Purpose The SET instruction is used to change the status of Single Bit operands to a logical 1 (one). The actual effect of issuing a SET instruction varies according to the operand addressed. The following table provides a summary of using the SET instruction. Detailed information on using the SET instruction can be found in chapters 8, 9, 10, and 12. Examples Operand
Output Flag Counter
Syntax
SET O1.6 SET F2.12 SET C6
Effect
Switches Output 1.6 ON. forces the status of Flag 12.2 to be '1'. 1. Counter Word 6 is loaded with a value of 0. 2. The status bit of Counter 6 (C6) is set to active (=1). 1. The contents of Timer Preselect 4 is copied to Timer Word 4. 2. The status bit of Timer 4 (T4) is set to active (=1). Program 2 is started from the beginning. Program 2 will be continued from where it was suspended by the instruction RESET PS2
Timer
SET T4
68
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
SHIFT
Purpose The SHIFT instruction executes a swap between the Single Bit Accumulator (SBA) and a Single Bit Operand (SBO). This instruction can be used to construct Shift Registers of varying lengths...longer or shorter than the 16 bit manipulations performed by the SHL and SHR instructions. To operate properly, the SBA must first be loaded and then any number of single bit SHIFT's can be programmed. Examples In the following example, each time Input 1.0 is activated, the status of Outputs 1.1 through 1.4 are to be updated: Output 1.4 shall take on the previous status of Output 1.3 Output 1.3 shall take on the previous status of Output 1.2 Output 1.2 shall take on the previous status of Output 1.1 Output 1.1 shall take on the status of Input 1.1
STEP 10 IF THEN I1.0 I1.1 F0.0 Input Activated a Flag is used here to avoid 'writing' to an Input, which would otherwise occur. SWAP F0.0 <-> O1.1 SWAP O1.1<-> O1.2 SWAP O1.2<-> O1.3 SWAP O1.3<-> O1.4
LOAD TO
N JMP TO
I1.0 10
See section 12 (Flags and Flag Words) for an alternative method of constructing Shift Registers.
69
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
SHL
Purpose The SHift Left instruction moves (shifts) the contents of the Multibit Accumulator to the Left by one position. The most significant bit (bit 15) is discarded and the least significant bit position is filled with a 0. Also see the ROL, ROR, SHR instructions. A typical use of the SHL instruction is to emulate a Shift Register. The SHL instruction may also be used to multiply any MBO or value by 2. The programmer must check for any possible overflow. It should be remembered that the LOAD...TO instruction is normally used first to prepare the Multibit Accumulator and again after the SHL instruction to copy the results to the desired MBO. Examples 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 0 0
LOAD MBO SHL TO MBO
Shift Register The following example demonstrates using SHL in combination with a MBO to emulate a shift register. While any multibit operand can be used, we have chosen to use a Flag Word, since Flag Words may be addressed on both a bit or word basis (see Chapter 12). We will assume that we are controlling a machine that assembles ribbon cartridges for computer printers. The process begins at station 1 where empty lower cartridge shells are placed on the assembly line; through station 10 where completed assemblies are off-loaded to a packing machine. At each station (1-10), after the respective assembly operation is completed, a quality check is made. Defective assemblies are removed immediately. In addition, when the machine is first started in the morning, and later shut down at night, only stations which contain valid components are to be processed.
70
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
THEN IF
F1.1 T1 I2.1 F1.1 F1.2 T1 I2.2 F1.2 F1.3 I1.3 T1 F1.3 T1 O1.1
THEN IF
N N
N N
SET
N LOAD SHL TO
STEP 60 IF THEN
RESET JMP TO
I2.0 O1.1 20
Multiplication The SHL instruction can also be used to multiply the contents of the MBA by 2.
IF THEN I1.0 R6 Parts sensor Register 6 multiply by 2 again, so actually x4 and store the result
R6
71
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
SHR
Purpose The SHift Right instruction moves (shifts) the contents of the Multibit Accumulator to the Right by one position. The least significant bit (bit 0) is discarded and the most significant bit position is filled with a 0. Also see the ROL, ROR, SHL instructions. The SHR instruction may also be used to divide any MBO or value by 2. The programmer must check for any possible overflow/underflow or if the dividend is an odd number, in which case the result will be incorrect as only integers (whole numbers) are supported. It should be remembered that the LOAD...TO instruction is normally used first to prepare the Multibit Accumulator and again after the SHR instruction to copy the results to the desired MBO. Examples Division 1 0 0 1 1 1 0 1 1 1 0 0 0 1 1 1 0 0 1 1 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 0 1 1 1 0 0
LOAD MBO SHL TO MBO
72
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
SWAP
Purposes Provides the means of exchanging (swapping) the high order byte (bits 8-15) and the low order byte (bits 0-7) of the Multibit accumulator. The Multibit Accumulator must be loaded with the appropriate MBO or value before executing the SWAP instruction. Examples 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1
LOAD MBO /V SWAP TO MBO
73
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
75
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS .................................................................................. 77 I/O Organization ...................................................................... 77 I/O Words ................................................................................. 77 Discrete I/O Stages................................................................... 78 Using Inputs in Programs....................................................... 78 Discrete Inputs.......................................................................... 78 Input Words .............................................................................. 79 Using Outputs in Programs.................................................... 80 Discrete Outputs ....................................................................... 80 Output Words ........................................................................... 80
76
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
It should be noted that every Input and Output within a system must have a unique address number. For example: It is not permissible for a system to have I/O's with duplicate addresses. However, it is generally acceptable for a system to include an Input Word with the same address number as an Output Word (e.g. IW1 and OW1). Please refer to the respective hardware manual for your specific controller model.
77
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Using Inputs in Programs Inputs are elements of the control system that are designed only to be read or queried. That is to say, they are connected to external devices such as sensors, switches, etc., which may or may not supply a signal to an individual input. Discrete Inputs By executing the appropriate STL instructions within the Conditional part of a sentence, the controller is able to determine the current status of a discrete Input.
IF IF N I1.1 I3.3 Test for a valid signal at Input 1.1 Test for a false signal at Input 3.3
Multiple Inputs as well as other conditions can be combined in various logical combinations. Examples can be found in chapter 7.
78
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
or by using the STL language's ability to evaluate complete Words, we can use the program sequence:
IF ( = IW2 V255 ) merely test if all 8 inputs are on...11111111 (binary) = 255
More complex tests, which would require long sequences if programmed bit by bit, are also easily accomplished using entire Input Words combined with other logical instructions. To test if one or more of Inputs 1.5, 1.6 1.7 are valid can be done by:
IF AND > ( IW1 V224 V31 ) first get the entire word = 11100000 binary if the result is greater than here we have
79
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
SETting an Output which is already SET or RESETting an Output which is already RESET will have no effect. As noted, Outputs may also be queried in the Conditional part...The following sentence checks if Input 2.4 is receiving a valid signal and if Output 2.2 is currently switched on:
IF THEN AND .... I2.4 O2.2 input 2.4 active and Output 2.2 is ON desired actions
Output Words Sometimes it may be desirable or necessary to test or alter the status of entire Output Words. In the same manner as Inputs can be manipulated on a group or Word basis, the same principles apply to Outputs. For example, the STL sentence:
THEN LOAD TO V0 OW2
will result in all of the Outputs associated with Output Word 2 being switched off.
80
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
9. Using Timers
9. Using Timers
81
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
9. Using Timers
Contents BRIEF ....................................................................................... 83
DETAILS .................................................................................. 83 General information .................................................................. 83 Using a timer ........................................................................... 83 Initializing a Timer Preselect .................................................. 84 Example: Initializing a Timer Preselect with a clock rate........... 84 Example: Initializing a Timer Preselect without a clock rate...... 84 Starting a Timer....................................................................... 85 Checking the Status of a Timer.............................................. 85 Stopping a Timer..................................................................... 85
Examples ................................................................................. 87 Avoiding unwanted restarting by use of the STL step structure.................................................................................... 87 Avoiding continuous restarting of Timers in Parallel processing ................................................................................ 87
82
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
9. Using Timers
BRIEF This chapter discusses how Timers are programmed using the STL language. In addition, an understanding regarding the internal functioning of STL Timers is presented. The reader is directed to Appendix A of this document which provides information regarding the number of timers available in each controller model. DETAILS General Information Each Timer as implemented in the STL language consists of several elements: Element/Operand Timer Status Bit Ref. Tn Function allows a program to test if a timer is active (running). This bit is changed to active when the timer is started (SET). When the programmed time period is complete or if the timer is stopped (RESET) the status bit becomes inactive. a 16 bit operand that contains the value that defines the time period for Timer n. a 16 bit operand to which the TP is transferred automatically when the Timer is started (SET). The contents are automatically decremented by the system at regular intervals.
Timer Preselect
TPn
Timer Word
TWn
Note: Controller models which incorporate back-up batteries maintain the contents of Timer Preselects during power-off periods. Using a Timer Several basic steps are required to use a timer in an STL program: a valid Timer Preselect must be established an instruction to start the Timer must be issued the status of the Timer (active/stopped) can be tested
83
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
9. Using Timers
Initializing a Timer Preselect
Note:
Depending upon which controller model is being used, it may or may not be required to specify a clock rate as well as a time value. Please refer to the hardware manual for the controller model you are programming.
Before any Timer can be used, the respective Timer Preselect must first be initialized with a value corresponding to the desired time period. This initialization only needs to be performed again if the time value needs to be changed. It is not necessary to reload the Timer Preselect each time the Timer is started. Timer Preselects may be loaded with either a value or with the contents of any MBO (e.g. Register, Input Word, Flag Word etc.) Example: Initializing a Timer Preselect with a clock rate
STEP 1 IF LOAD TO WITH we do this first ! unconditionally value 10 to Timer Preselect 4 clock rate=seconds ...Timer 4 will now be a 10 second timer
The available clock rates are: HSC hundredths of seconds TSC tenths of seconds SEC seconds MIN minutes Example: Initializing a Timer Preselect without a clock rate
STEP 1 IF LOAD we do this first ! unconditionally value 100....the unspecified clock rate will be in 1/100th of a second increments. to Timer Preselect 0 = 1 sec.
NOP V100
TO
TP0
The preceding example has initialized Timer 0 to have a duration of 1 second ( 100 x 1/100th second). The allowable range is 0-65535 which provides timer periods from 0.01s to 655.35 s (approx. 10 minutes).
84
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
9. Using Timers
Starting a Timer Starting a timer only requires issuing a SET instruction and specifying which timer is to be started:
IF THEN SET I1.0 T6 any condition to start so start timer 6
Whenever the SET Tn instruction is executed, the following occurs: 1. The value stored in TPn (Timer Preselect n) is copied to TWn (Timer Word n). 2. Tn (Timer Status n) becomes '1' (active/running). 3. The controller automatically decrements the value stored in TWn at regular intervals. 4. When the value stored in TWn reaches 0 (zero), Tn (Timer Status) becomes '0' (inactive/stopped).
Note:
If an instruction to SET a Timer is executed, AND the timer specified is ALREADY active, the timer will be RESTARTED and a NEW timing period will be begin. Checking the Status of a Timer In order for timers to be useful in controlling processes, it is necessary to know when a programmed time is complete. The STL language provides the means to check whether a timer is active in the same manner as checking if an Input is active.
IF T5 test if Timer 5 is active (running) test if Timer 3 is not active (stopped)
IF
T3
Stopping a Timer Stopping a timer only requires issuing a RESET instruction and specifying which timer is to be stopped:
IF THEN RESET I2.0 T5 Input to stop the timer Stop Timer 5
When the RESET Tn instruction is issued the Timer Status Bit (Tn) becomes 0 (inactive). If the timer was already inactive, there is no effect.
85
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
9. Using Timers
Figure 9-1 illustrates the relationship between the Timer Status Bit (Tn), the SET Tn, and RESET Tn instructions and the normal timing period. The solid line represents the a normal timing sequence in which the status of the timer becomes active when the SET Tn instruction is executed and the status returns to inactive when the programmed time period is complete. The broken line indicates that issuing a RESET Tn instruction will immediately return the timer status to inactive.
Timer active = 1 Programmed time
Timer inactive = 0
SET Tn
RESET Tn
Caution:
It is important to understand when constructing Programs or Steps that contain multiple Sentences that will be processed in a parallel (scanning) manner; that every time the conditional part of a Sentence evaluates as true, the instructions programmed in the executive part will be performed. This must be considered in order to avoid uncontrolled multiple executions of most instructions including SET TIMER or INC/DEC Counter Word, SHL, etc. The STL language does not use 'edge triggering'...conditions are evaluated for truth each time they are processed without regard as to their prior status. This situation is easily handled by either using Steps, Flags or other means of control. The following examples show two possible ways in which this effect can be minimized.
86
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
9. Using Timers
Examples Avoiding unwanted restarting by use of the STL Step structure The next example shows a program section in which it is desired to turn on a motor for 3 seconds each time a button is pressed if the motor is not already running and at least 9 seconds time has passed since the motor was last run. In this program the potential situation of timers being continually re-started is eliminated by combining the STL Step keyword with the N Timer instruction.
Step 1 IF THEN
initialize on power up 900 * .01sec unit of time Timer 0 is 2 sec pause time 300 * .01sec unit of time Timer 2 is motor time run the pause timer Timer 0 has finished Timer 2 is not running Motor not running Button pressed Start Timer Start motor motor time done stop the motor start the pause timer start again
Avoiding continuous restarting of Timers in Parallel processing It is important that the STL programmer understand that a Timer status bit (e.g. T2) can be tested using the instructions:
IF T2 This test is true if Timer 2 is currently active and timing This test is true if Timer 2 is not currently active
IF
T2
It is vital to understand that neither of these instructions allow testing whether Timer 2 has been started and is complete. Therefore, when STL programs are constructed in a manner allowing program sentences to be processed multiple times, measures must be taken to avoid unexpected results.
87
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
9. Using Timers
The following example presents a program section in which a pushbutton is used to extend a cylinder for a preset timer period. The program logic used will avoid the following problems which might otherwise arise: Holding the pushbutton or pressing and releasing the button multiple times within the defined time period will not alter the programmed time.
STEP 1 THEN initialization first time only LOAD TO RESET LOAD TO V0 OW0 F3.0 V100 TP0 all outputs off clear Flag 3.0 initialize timer Make timer T0 1 second main scanning section Button 1 is pressed and Timer 0 is not running form edge detection start Timer 0 extend cylinder 1 memorize rising edge of P.B. Timer 0 is not running and cylinder is extended then retract the cylinder Timer 0 is not active and we previously had a rising edge and the pushbutton is released...falling edge found! so get ready for next edge just keep scanning the currrent step.
THEN
I1.0 T0 F3.0 T0 O1.0 F3.0 T0 O1.0 O1.0 T0 F3.0 I1.0 F3.0 NOP 2
JMP TO
88
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
89
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS .................................................................................. 91 Standard Counters.................................................................. 91 Using Standard Counters ....................................................... 92 Initializing a Counter Preselect ................................................. 92 Example: Initializing Counter Preselects with an absolute value................................................................. 92 Example: Initializing Counter Preselects with a MBO...... 92 Starting a Counter .................................................................... 93 Checking the Status of a Counter............................................. 93 Counting Events ....................................................................... 93 Stopping a Counter................................................................... 93
Examples ................................................................................. 94 Standard Counter.................................................................... 94 UP/DOWN Counters ................................................................ 97 Example: Using a register as a counter .................................... 97
90
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Counter Preselect
CPn
Counter Word
CWn a 16 bit operand which contains the current number of counts recorded by means of the DECrement or INCrement instructions. When using standard counters and the SET Cn instruction is executed, the Counter Word is automatically changed to 0 (zero).
Note: Controller models which incorporate back-up batteries maintain the contents of Counter Preselects, Words and Status Bits during power-off periods.
91
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
LOAD
TO
CP4
LOAD TO
By means of the DEB instruction, we could also use external BCD switches to establish the count. See the DEB instruction in the STL Instruction Reference Chapter 7. 92
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Whenever the Set Cn instruction is executed, the following occurs: 1. The respective Counter Word (CWn) is loaded with a 0 (zero). 2. Cn (Counter Status n) becomes a '1' (active).
Note:
If an instruction to SET a Counter is executed, AND the Counter specified is ALREADY active, the Counter will be RESTARTED and the current count (in CWn) will be returned to 0 (zero). Checking the Status of a Counter In order to utilize counters in a meaningful way, it is necessary to be able to determine when the preselected count has been reached. Counting Events Once the counter has been activated (SET), the current count is maintained in the respective Counter Word, which can be updated using either the INC CWn or DEC CWn instructions. Stopping a Counter A counter can be stopped (deactivated) at any time by issuing the RESET Cn instruction. When the RESET Cn instruction is executed the Counter Status Bit (Cn) becomes 0 (zero). The contents of the Counter Word remain unchanged.
Caution:
In Programs or Steps that contain multiple Sentences that will be processed in a parallel (scanning) manner; every time the conditional part of a Sentence evaluates as true, the instructions programmed in the executive part will be performed. This must be considered in order to avoid uncontrolled multiple executions of instructions including SET TIMER or INC/DEC Counter Word, SHL, etc. The STL language does not use 'edge triggering'...conditions are evaluated for truth each time they are processed without regard as to their prior status.
93
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
94
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
STEP 1 THEN
C0 C1 O1.0 O1.1 V25 CP0 V2 CP2 V100 TP0 I1.0 C0 O1.0 I1.1 CW0 N C0 O1.0 C2 50 I1.1 10 O1.1 T2 CW2 N T2 O1.1
Power Up bottle counter press counter switch off conveyor switch off cork press how many to count counter 0 preselect how many presses counter 2 preselect 100 x .01s = 1 second Timer 0 Preselect Wait for start button Start Button activate counter start conveyor Start counting bottles a bottle was sensed increment bottle counter 25 bottles yet ? we're all done, so... stop conveyor activate press counter exit counting loop else wait for last bottle sensed to move away from sensor. and continue counting 25 bottles were counted Press corks Start Pressing Timer count this pressing Wait for 1 second timer time is done stop pressing done ? pressed corks 2 times back to Step 5 else press again
SET SET
INC
RESET
N JMP TO JMP TO
C2 5 50
95
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
STEP 2 IF
THEN
N N
I1.1 C0 F3.0 O1.0 O1.0 F3.0 I1.2 F3.0 CW0 F3.0 O1.0
IF THEN
C0 1
96
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
I1.0 V100 R50 O1.1 I1.1 I2.3 R50 30 I1.1 I2.3 NOP
N JMP TO
97
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
98
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
99
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS ................................................................................ 101 Examples ............................................................................... 101 Using Registers in the Conditional Part of a Sentence ........... 101 Using Registers in the Executive Part of a Sentence ............. 101
100
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
If the controller model you are using includes a backup battery, then the contents of the Registers will be maintained during power-off periods. Registers which have never been initialized will contain random values. Registers are most often used in conjunction with the LOAD TO and multibit logic operations. Registers are not addressable on a bit by bit basis. If bit access is required, Flag Words may be more suitable (see chapter 12). Registers may also be used to simplify controlling multiple sequential processes within a single scanned program section (see Appendix B for examples). Examples Using Registers in the Conditional Part of a Sentence
IF AND AND THEN... ( = ( < R51 V111 T7 R3 R8 if the contents of Register 51 equals 111 and Timer 7 is running and Register is smaller than Register 8 do whatever is programmed..
LOAD + TO
101
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
102
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
103
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS ................................................................................ 105 Similarities to other Multibit Operands .................................... 105 Differences compared to other Multibit Operands .................. 105 Examples ............................................................................... 106 Conditional Part Examples ..................................................... 106 Executive Part Examples........................................................ 107 Shift Registers....................................................................... 107
104
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
If the controller model you are using includes Flash or ZPRAM memory or RAM memory and a backup battery, then the contents of Flags will be maintained during power-off periods. Flags which have never been initialized will contain random values. Flag Words do differ from other Multibit Operands in several important ways: Differences compared to other Multibit Operands 1. A major difference between Flags and other Multibit Operands such as Registers, Counter Words, etc., is that each 16 bit Flag Word is also addressable on a per-bit basis. For example, the FPC100 contains 16 Flag Words, addressed as FW0 through FW15. It is also possible to address individual bits (Flags) of each Flag Word by using the syntax: F(Flag Word number).Bit number where Bit Number ranges from 0 to 15. For example, F7.14 references Bit 14 of Flag 7. This addressing scheme is quite similar to that used when accessing standard digital I/O points as previously described. While Flag Words may be used with any STL instructions suitable for Multibit Operands, individual Flags are only accessible using STL instructions designed for Single Bit Operands (see chapter 4). Single bit Flags are most often used as a convenient means to memorize events. In this respect they are similar to "internal coils or relays" often found in Ladder Diagram. 105
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
In such multiple CPU systems, each Flag Word is referenced as: CPU number.Flag Word number For example, FW2.14 references Flag Word 14 in CPU 2. In the same manner it is also possible to address Single Bit Flags in other CPU's by extending the addressing syntax: CPU number.F(Flag Word number).Bit number For example, F0.11.9 refers to Flag Bit 9 in Flag Word 11 located in CPU 0. Examples Individual Flags (as well as Flag Words) can be programmed in both the Conditional and Executive parts of a Sentence. In the conditional part, Flags can be interrogated as to their status (0=RESET, 1=SET); while Flags Words can be compared to values or other MBO's. Conditional Part Examples
IF F1.1 IF Bit 1 of Flag Word 1 is SET IF Bit 1 of Flag Word 2 is SET and Bit 0 of Flag Word 4 is not SET.
IF AND N
F2.1 F4.0
Just as with all other Single and Multibit Operands, Flags may be combined with other operands.
IF AND OR ( (( = N I3.0 F0.0 FW3 V500 T7 ) If Input 3.0 is valid and Flag 0.0 is SET or the value of all 16 bits of Flag Word 3 is equal to 500 and Timer 7 is not active
AND
) )
106
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
SET
SET RESET
In the Executive Part of Sentences, Flag Words may be used as the source or destination of any Multibit instruction. Shift Registers The fact that Flags are addressable both on a Word basis as well as on a Bit basis provides a convenient method for constructing shift registers. As an example, we may need to program a machining line in which raw castings are loaded at station 0 and subsequently various operations are to be performed at the following 15 stations. The complete machine indexes every 2 seconds and during that time a new raw casting may or may not be loaded at station 1...which can be checked by means of a sensor. Stations 1-15 do not include sensors, but we only want each station to operate if a part is in place. This presents an ideal situation in which a shift register can be used. We will use Flag Word 6 to keep track of which stations contain materials to be machined. The Shift Left (SHL) instruction will be used to actually move the individual bits within the Flag Word. The following I/O's are also used: Input 1.0 Start Button Input 1.1 Part Sensor at Station 0 Input 2.2 Transfer Line is indexed Output 2.0Indexes machining line Outputs 1.0 - 1.15 control the machining operation at stations 0 - 15 respectively
107
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Start Up Start Button Line is indexed 2 seconds to Timer 0 Preselect assume new production run no parts at any station wait until some parts ready part was found at station 0 memorize it any parts to process ? some exist ! turn on motors at stations with parts start process timer machining time done ? timer done turn off all station motors start indexing line wait until index is started started to index get all stations status move bits to match parts and store it is index complete ? new index point Stop index motor back to Step 15 for more
STEP 20 IF THEN
N LOAD SET
T0 V0 O2.0
STEP 25 IF THEN
N LOAD TO
STEP 30 IF THEN
RESET JMP TO
I2.2 O2.0 15
108
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
109
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS ................................................................................ 111 Analog I/O .............................................................................. 111 Common Analog Signals ........................................................ 111 Common Analog Functions .................................................... 112 Networking ............................................................................ 113 Network functions ................................................................... 113 Position Controlling .............................................................. 114 Field Bus................................................................................ 115 An Introduction to Field Bus.................................................... 115
110
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
111
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
112
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
113
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
114
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
m = s =
115
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
116
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Appendix A - Operands
Appendix A - Operands
117
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Appendix A - Operands
Contents BRIEF ..................................................................................... 119
118
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Appendix A - Operands
BRIEF This section provides an overview of the available range of Operands in each controller model. The reader should be aware that the information provided refers to the operands that are available when programming in the STL language. The number of operands may vary depending upon the programming language used. This listing should only be used as a guide. You should refer to the appropriate hardware and FST manual for any possible changes. DETAILS The following table includes those operands most often used when programming in STL. For models which allow multiple CPU's the quantities shown are per CPU. Controller Model FPC405 FEC
64 64 1024/ 64 x 16 bit 256 256 160.000/ 10.000 x 16 bit 256 yes 64
Operands
Counters Timers Flags/ Flag Words
FPC100
16 32 256/ 16 x 16 bit
IPC
256 256 160.000/ 10.000 x 16 bit 256 yes 64
64 yes 8
128 yes 64
119
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Appendix A - Operands
120
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
121
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS ................................................................................ 123 Examples................................................................................ 123 Sample 1. Completely Sequential........................................... 123 Sample 2. Mostly Sequential with Random events ................. 125 Sample 3. Completely Random events................................... 128 Sample 4. Multiple sequences & Random events................... 129
122
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
STEP 1 IF THEN
power up initialization always do this unconditionally switch off all Outputs Prepare Timer 0 as a 3 second timer units = 0.01 seconds Prepare Counter 2
be certain all positions ok Start Button is pressed Cylinder A is retracted Cylinder B is retracted Cylinder C is retracted begin extending cylinder A Cylinder A fully extended ? now it's fully extended start the 3 second timer wait 3 seconds timer is complete begin retracting cylinder A Cylinder A fully retracted ? Cylinder A is retracted setup counter 2 - 4 counts begin extending cylinder B Cylinder B fully extended ? now it's fully extended count this cycle begin retracting cylinder B is this the 4th extension ? Cylinder B retracted and 4 strokes not done begin extending cylinder B continue cycles Cylinder B retracted and 4 strokes are done begin extending cylinder B
SET
I1.2 T0
N RESET
T0 O1.0
SET SET
I1.1 C2 O1.1
STEP 20 IF THEN
INC RESET
124
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
SET
I1.4 O1.2
Cylinder B fully extended ? Cylinder B fully extended 5 x begin extending cylinder C Cylinder C fully extended ? Cylinder C fully extended Begin extending cylinder A All cylinders extended ? cylinder A fully extended too retract Cyl. A retract Cyl. B retract Cyl. C go back to Step 5
SET
I1.6 O1.0
Sample 2: Mostly Sequential with Random events While some simple machinery may be completely sequential in operation, there may be one or more exceptions which change the classification of the task so that it is no longer totally sequential. If the majority of the control task is sequential and the controller model allows Multitasking (see Appendix A), a possible solution may be to divide the sequential and random event processing into separate programs (see Appendix C). However it is also possible to handle such situations with a single STL program. If the random event(s) to be monitored are few and the balance of the program is relatively simple, then it may be possible to handle the requirements by adding a program Sentence in every Step. Other possible solutions include the use of interrupt processing (only supported on some controller models) or by constructing the entire sequence as a parallel (scanning) program section. This method will be demonstrated in samples 3 and 4. Sample 2 will illustrate inserting a program Sentence in every existing Step of the program presented in Sample 1 as a means of detecting and responding to a simple "pause" push button; which when pressed, results in the program being suspended until it is released.
125
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
STEP 1 IF THEN
power up initialization always do this unconditionally switch off all Outputs Prepare Timer 0 as a 3 second timer units = 0.01 seconds Prepare Counter 2
THEN STEP 10 IF THEN IF THEN STEP 12 IF THEN IF THEN STEP 15 IF THEN IF THEN
be certain all positions ok Start Button is pressed Cylinder A is retracted Cylinder B is retracted Cylinder C is retracted pause button not active begin extending cylinder A Cylinder A fully extended ? pause button if so stay here now it's fully extended start the 3 second timer wait 3 seconds pause button if so stay here timer is complete begin retracting cylinder A Cylinder A fully retracted ? pause button if so stay here Cylinder A is retracted setup counter 2 - 4 counts begin extending cylinder B Cylinder B fully extended ? pause button if so stay here now it's fully extended count this cycle begin retracting cylinder B
JMP TO
I1.7 10 I1.2 T0
SET
JMP TO N RESET
I1.7 12 T0 O1.0
JMP TO
SET SET
JMP TO
INC RESET
126
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
JMP TO
is this the 4th extension ? pause button stay here Cylinder B retracted and 4 strokes not done begin extending cylinder B continue cycles Cylinder B retracted and 4 strokes are done begin extending cylinder B Cylinder B fully extended ? pause button if so stay here Cylinder B fully extended 5 x begin extending cylinder C Cylinder C fully extended ? pause button
IF THEN STEP 30 IF THEN IF THEN STEP 35 IF THEN IF THEN STEP 40 IF THEN IF THEN AND SET N
JMP TO
SET
JMP TO
SET
Cylinder C fully extended Begin extending cylinder A All cylinders extended ? pause button if so stay here cylinder A fully extended too retract Cyl. A retract Cyl. B retract Cyl. C go back to Step 5
JMP TO
In summary, it is possible to handle limited amounts of parallel conditions within an otherwise strictly sequential process using the Step instruction.
127
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
LOAD TO
NOP V0 OW1
STEP 20 IF THEN IF THEN OTHRW IF THEN IF THEN OTHRW IF THEN OTHRW IF THEN
SET
I1.0 O1.0 I1.1 I2.0 O1.3 O1.3 I1.2 O1.3 O1.0 I1.3 O1.1 O1.1 I1.4 I1.5 O1.4 O1.4 NOP 20
AND RESET
Mold Open Push button Injection not active Open Mold Rotate Screw mechanism Screw Rotate Solenoid Halt Screw mechanism Mold fully Open Sensor Mold Ejector Push Button Mold Ejector Solenoid Halt Ejection process always do keep processing
SET RESET
JMP TO
128
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
129
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
STEP 10 THEN
initialization LOAD TO TO TO TO TO TO TO TO TO TO TO LOAD TO LOAD TO LOAD TO V0 OW0 OW1 OW2 OW3 OW4 FW0 R0 R1 R2 R3 R4 V25 TP2 V250 TP3 V300 TP4 turn off all outputs
initialize "shift register" Table Index Control Register Station 1 Control Register Station 2 Control Register Station 3 Control Register Station 4 Control Register Timer 2 as 1/4 second Timer 3 as 2.5 seconds Timer 4 as 3 seconds all stations home ? E_Stop Active Special Routine table is indexed Station 2 Left insert Cyl. Ret. Station 2 Right insert Cyl. Ret. Station 2 Left spool in place Station 2 Right spool in place Station 3 pinch ribbon gripper open Station 3 Ribbon Advance Cyl. is retracted Station 3 Right side ribbon attach cylinder retracted Station 4 insertion cyl. retr'd. no prior top half in place Station 4 Eject. Cyl. Home Run Switch to Run position E.Stop not Active Cartridge at Station 1 or parts at some stations entire 16 bit word mask all but bits 0,1,2,3 then an active part exists Ok to proceed, else wait
STEP 20 IF THEN IF
N JMP TO
I0.0 99 I0.2 I2.1 I2.3 I2.5 I2.6 I3.1 I3.4 I3.6 I4.1 I4.3 I4.4 I0.1 I0.0 I1.1 FW0 V15 V0 NOP
N N
( ( >
))
130
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
( = ( = ( = ( =
) ) ) )
STATION 1 first station 1 control register just starting station 2 control register indicates it's done station 3 control register indicates it's done station 4 control register indicates it's done all other stations are done, so correct time to see if a part was loaded into Station 1 Station 1 control register ready to read sensor part in place sensor place a '1' in 'shift register' when we are here, ALL stations are done
IF AND SET
( =
THEN IF THEN
( = LOAD TO
IF AND OR LOAD TO
( = ( N N
R2 V0 I2.0 F0.1 V255 R2 R2 V0 O2.0 O2.1 V20 R2 R2 V20 I2.2 I2.4 I2.5 I2.6 O2.2 T2 V30 R2
STATION 2 section Station 2 control register ) Station 2 not activated or no parts in Station 2 so mark Station 2 as done
THEN
( =
Station 2 control register just starting extend Left Side Spool Cyl. extend Right Side Spool Cyl. advance control sequence Station 2 control register
( =
) Left side fully extended Right side fully extended Left Spool in fixture Right Spool in fixture Switch on holding vacuum Start Timer Update Station 2 control Reg.
THEN
131
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
( = N
THEN
Station 2 control register ) 1/4 sec. dwell time complete retract Left Side Spool Cyl. retract Right Side Spool Cyl. Update Station 2 control Reg. Station 2 control register ) Left Side Spool Cyl. is home Right Side Spool Cyl. is home Switch vacuum off Mark station 2 as complete STATION 3 section Station 3 control register ) Station 3 not activated or no parts in Station 3 so mark Station 3 as done
( =
IF AND OR LOAD TO
( = ( N N
R3 V0 I3.0 F0.2 V255 R3 R3 V0 O3.1 V10 R3 R3 V10 I3.2 O3.2 V30 R3 R3 V30 I3.3 O3.2 O3.1 V40 R3
THEN
( =
Station 3 control register ) ribbon gripper close solenoid Update Station 3 control Reg. Station 3 control register ) gripper fully closed insert ribbon in left spool Update Station 3 control Reg. Station 3 control register ) Ribbon is inserted into spool retract insertion cylinder release ribbon gripper Update Station 3 control Reg.
( =
THEN
( =
THEN
132
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
( =
R3 V40 I3.4 O3.3 T3 V50 R3 R3 V50 T3 O3.3 O3.4 V60 R3 R3 V60 I3.5 O3.4 V70 R3 R3 V70 I3.6 V255 R3
Station 3 control register ) insertion cylinder is home start ribbon winding motor start winding timer Update Station 3 control Reg. Station 3 control register ) winding time is complete halt winding motor Rt. Side Ribbon Insertion Cyl. Update Station 3 control Reg. Station 3 control register ) Right Spool insertion sensor Retract Rt. Side Insertion Cyl. Update Station 3 control Reg. Station 3 control register ) Rt. Side Insertion Cyl.= home mark Station 3 as complete STATION 4 section Station 4 control register ) Station 4 not activated or no parts in Station 4 so mark Station 4 as done
( = N
THEN
( =
THEN
IF AND LOAD TO
( =
THEN
IF AND OR LOAD TO
( = ( N N
THEN
( =
Station 4 control register ) Lower upper cartridge Update Station 4 control Reg.
133
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
( =
THEN
R4 V10 I4.2 I4.3 O4.2 T4 V20 R4 R4 V20 T3 O4.2 O4.1 V30 R4 R4 V30 I4.1 O4.3 V40 R4 R4 V40 I4.5 O4.3 V50 R4 V50 I4.4 F0.3 V255 R4 R1 V255 V10 R0
Station 4 control register ) Cartridge cylinder extended Cartridge fully in fixture Start Ultrasonic bonding Start welding timer Update Station 4 control Reg. Station 4 control register ) welding Timer complete halt welding unclamp up cartridge Cyl. Update Station 4 control Reg. Station 4 control register ) Upper shell Cyl. is home Extend Ejection Cylinder Update Station 4 control Reg. Station 4 control register ) Ejection Cylinder extended Retract Ejection Cylinder Update Station 4 control Reg. Station 4 control register ) Ejection Cylinder is home Empty Position in Shift Reg. mark station 4 as complete Stations 1-4 done ) Index Control Register
( = N
THEN
( =
THEN
( =
THEN
( =
THEN
IF THEN LOAD TO
( =
( = (( >
TABLE INDEX section Index Control Register ) ) ) complete 16 bit unit mask all except bits 0,1,2,3 at least 1 station occupied Update Index Control Reg.
134
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
( =
Index Control Register no index required Continue Process Index Control Register an index is needed Begin table index Update Index Control Reg. Index Control Register
( =
( = N
) indexing underway Update Index Control Reg. Load Shift Register to MBA Shift bits left to match actual parts Index Sequence complete Index Control Register ) New index found halt indexing clear control registers
THEN
( =
THEN
Resume processing E_Stop Active Special Routine Continue scanning unconditionally continue to process Step 30 ESTOP ROUTINE wait E_Stop until is released & handle like power-up
IF THEN
N JMP TO
JMP TO
NOP 30
JMP TO
I0.0 10
135
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
136
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
137
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS ................................................................................ 139 General Concepts ................................................................. 139 Multitasking............................................................................. 139 Assigning Programs ............................................................. 140 FEC ........................................................................................ 140 FPC100B/AF .......................................................................... 140 FPC405 .................................................................................. 140 IPC.......................................................................................... 140 Using Multitasking................................................................. 141
138
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
139
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
140
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Examples A typical machine might have the following requirements: 1. Manual operation 2. Automatic cycle During operation, in addition to some sequential tasks, there is also the need to continuously monitor functions such as Emergency Stop, Stop, Watch Dog Timer, and home position etc. These tasks might be solved by dividing the overall control requirements into easily manageable parts: Program 0: Performs any required power-up initialization and acts as a dispatcher program to start and stop other programs depending on the desired operation. This program also provides the continuous monitoring functions (e.g. Emergency Stop). Program 1: This program provides the logic required for manual operation. In addition, by means of Flags (see chapter 12), this program is able to check the physical status of the machine as determined by program 3. Program 2: This program provides the logic required for automatic operation. In addition, by means of Flags (see chapter 12), this program is able to check the physical status of the machine as determined by program 3. Program 3: This program constantly monitors the physical status of various machine parts, and based upon their positions Sets or Resets Flags which can then be read by other programs. This often eliminates duplicate program logic. In this example, the following programs would be active depending upon the mode of operation: Manual Mode Program 0 Program 1 Program 3 Automatic Mode Program 0 Program 2 Program 3
Multiprocessing Multiprocessing is possible in systems which employ multiple CPU's. When multiple CPU's are used, true concurrent processing of multiple programs is possible in addition to the 141
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
142
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
143
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
144
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
DETAILS ................................................................................ 145 Decimal Numbers ................................................................... 145 Binary Numbers ...................................................................... 145
145
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
and we were informed to enter only (1) one digit per box, we would all quickly realize that the maximum age that could be entered would be 99. In total, we would be able to make 100 different entries, ranging from 0 to 99. This is possible as each box is able to accept any one of 10 possible entries (0-9). Binary Numbers In the world of digital computers, binary format is very common due to technical reasons. If the previous question were rewritten to read "Enter your age in binary years:" and the same two boxes were provided:
then the maximum age that could be entered would be 3 decimal or "11" binary. Therefore, a total of only 4 different entries (0-3 decimal) would be possible because only a '0' or '1' could be entered in each box.
146
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
0 0 1 1
0 1 0 1
Just as in the decimal format, it can be seen that each box, or column has a certain weighted value. In decimal numbers we refer to these columns as: the "one's column" the "ten's column" the "hundred's column" The equivalent descriptions when working with binary numbers would be: the "one's column" the "two's column" the "four's column" etc. To convert a value between binary and decimal formats it is necessary to know the weighted value of each column or position. Assuming that we are working with unsigned integers the following values can be stored: 8 bit MBO 16 bit MBO range 0 - 255 decimal range 0 - 65535
147
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
148
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
149
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Index
Index
150
Toolbar
Menubar
Contents
Search
Page
Toolbar
Menubar
Contents
Search
Page
Index
A
Analog 111-112 AND 27, 37, 41-42 Comparison to 28 Language Elements of 26 Structure 25 LOAD 37, 58-60
R
Random events 125, 128 Registers 101, 129 RESET 38, 66, 85 ROL 38, 67 ROR 38, 68
B
BID 37, 43 Binary 37, 43, 145
M
MBA 17 MBO 17 Motors 114 Multibit Operands 17 Listing of 19 Multiprocessing 142 Multitasking 115, 139, 140, 141
S
Sample programs 123136 SBA 17 SBO 17 Scanning 30, 61 Sentences 26-31 Sequential task 123 SET 38, 69 SHIFT 38, 70 Shift Register 107 SHL 38, 71-72 SHR 38, 73 Single Bit Operands 18 Listing of 18 STEP instruction 26, 27, 29 Conditional Part 26 Execution rules 30-31 Executive Part 26 Label 26, 29 SWAP 38, 74
C
CCU 10 CFM 37, 44-45 CMP 37, 46-47 Control registers 129 Counters Initializing 92 Preselect 91 Standard 91 Starting 93 Status 91, 93 Stopping 93 Updating 93 UP/DOWN 97 Word 91-92 CPL 37, 48 CPU 10
N
Network 77, 111, 113 NOP 32, 37, 61-62 NOT 21, 27
O
On-line Mode 14 Operands 17 Absolute 17 Global 20 Listing by model 119 Local 20 Multibit 19 Single Bit 18 Symbolic 17 Operators 21 OR 27, 37, 63-64 OTHRW 34, 38 Outputs 80
D
DEB 37, 49 DEC 37, 50 Decimal 49, 145
T
THEN 26, 38 Timers 83, 87 Clock rate 84 Preselect 83, 84 Resetting 85-86 Starting 85 Status 83, 85 Stopping 85 Word 83 TO 38
E
Edge triggering 30 EXOR 37, 51-52
F
Field Bus 77, 115 Flags 105-107 FST 9
P
Parallel processing 30,61 Positioning 114 Program 10 Creating 13 Execution 26-29 Loading 14 Samples 123-136 Starting 140 Structure 25-34, 123 Types 123 Version 13 Writing 14 Project 10 PSE 38, 65
I
IF 26-27, 37 INC 37, 53 Inputs 78-79 Installation 13 I/O 77-78 INV 37, 54
J
JMP 33, 37, 55-57
L
Ladder Diagram
151
Toolbar
Menubar
Contents
Search
Page