The text of a manual · part 15 of 50
Festo Software Tools: Statement list and Ladder diagram for SF 3, FST 200 Manual, pages 141 to 150
Pages 141 to 150 of 496
The original document is the PDF (3.1 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Filed in the catalog under the Festo FPC-202
Page 141
FST 200-STL
4. Programming in the statement list
Example: STEP Label 1 IF ... THEN LOAD TO ... ""Alternative STEP Label 2 IF ... THEN SET WITH
V520 TP7
T7 5.2s
The LOAD instruction loads the value of the constants into the timer preselect. You may use any multi-bit operand instead of the constants entered. This means that you can just as easily load an input word into the timer preselect. Start timer Once a timer has been initialized, it need only be activated in a program. A single instruction is sufficient for this. STEP Label IF ... THEN SET
T7
This instruction first loads the timer preselect (TP7) into the timer word. Then timer T7 is started. Once the timer is running, the timer word is counted down (decremented) until it has the value zero.
9610a
4-45
Page 142
FST 200-STL
4. Programming in the statement list
Stop timer You can stop a running timer by means of the program at any value of the timer word. Example: STEP Label IF AND AND THEN RESET STEP ... ...
I1.0 I1.7 T7 T7
Timer T7 will be stopped if conditions I1.0 and I1.7 are met within the period specified in timer default TP7. The IF statement implements a monitoring time, as this also queries the timer status. Query timer You may query two values of timers in an STL program. These are: • Timer status • Value of the timer word. Further actions in the program can be controlled depending on the result.
4-46
9610a
Page 143
FST 200-STL
4. Programming in the statement list
Example: STEP 1 IF N THEN SET ... STEP 2 IF THEN SET OTHRW RESET ... STEP 3 IF = THEN LOAD TO SET
T7 O1.7
T5 O1.0 O1.0
TW7 V100 IW0 CP15 C15
Step 1 queries whether timer no. 7 has run down. If yes, output 1.7 is set. In Step 2, output 1.0 is set all the time timer no. 5 is running. In Step 3, counter C15 is initialized as an upwards counter and started if the value of the timer word is equal to 100.
You may associate the timer word with any multi-bit operand in an STL program. Details of the syntax of possible logic operations are described below.
9610a
4-47
Page 144
FST 200-STL
4. Programming in the statement list
Features of the pulse timer Using a pulse timer, you can affect processes by states within the program or by an input pulse for a predefined period. The timer is started (Tnn=1) by this pulse, or rather by its positive edge. The timer default (initial value) is loaded into the timer word and the timer begins to run down. The timer word is now decremented until • It has the value 0. The timer is then run down (Tnn=0) • Another positive edge (pulse) occurs in the conditional statement causing the timer to be started again from the beginning (restart) • The timer status is reset (halting the timer). 4.4.2 Programming counters Counters are used to count events or numbers of items. You may program two types of counter in an STL program. These are: • Upwards counters • Downward counters With the upwards counter, the program counts up (increments) from the current counter reading; with the downward counter it counts down (decrements).
4-48
9610a
Page 145
FST 200-STL
4. Programming in the statement list
A counter is a one-bit operand. It may be set, reset and queried. Each counter has: • A counter status (Cnn) • A counter preselection (CPnn) • A counter word (CWnn).
nn is the counter number. 32 counters are available (0-31). Counter status The counter status indicates whether the counter is active or inactive. The values for this are: Cnn=0 Cnn=1
Counter is inactive (stopped or run down) Counter is active (it is counting events)
The counter status is a one-bit operand. It may be set, reset or queried. The counter status is remanent. Counter default The counter default contains the final value for the upwards counter or the initial value for the downwards counter. You may enter any number you wish here. Appendix A.1.2 lists the values which are valid here. The counter default is remanent. Counter word The counter default is loaded into the counter word when a counter is started. The value of this counter word is then reduced or increased, depending on the counter type. The counter word is remanent.
9610a
4-49
Page 146
FST 200-STL
4. Programming in the statement list
To use a counter, you must 1. Initialize it 2. Increment or decrement it Then you will be able to query the counter status and initiate actions depending on its value. A currently active counter may be stopped by the program at any value of the counter word. Initialize counter The content of the counter default is specified in the initialization of a counter. This value represents the final value for the upwards counter or the initial value for the downwards counter (see diagram).
Counter default 12345
Upwards counter
Downwards counter
Final value: 12345
Initial value: 12345
Initial value: 0
Final value:
0
Initialization is different for the two types of counter. The SET Cnn command is not necessary on the downwards counter, as this counter type is set with the assignment LOAD Vnnnnn TO CWnn.
4-50
9610a
Page 147
FST 200-STL
4. Programming in the statement list
Initialize upwards counter STEP Label IF ... THEN LOAD TO SET ...
V100 CP15 C15
The LOAD instruction loads the value of the constants into the counter default CP15. This value represents the final value up to which you wish to count. The instruction SET C15 sets the counter word to zero. This is the initial value for the upwards counter. You may now increment and query this counter in an STL program. Initialize downwards counter STEP Label IF ... THEN LOAD TO ...
V100 CW15
Since the comparison here is not with the counter default but with zero, the counter word is the initial value. You are thus loading the constant directly into the counter word. It is not necessary to specify the counter default. The SET instruction is omitted. You may use any multi-bit operand instead of the constants entered. The same rules apply as for the timer. Count commands In principle, you may count all settable multi-bit operands. The two instructions below are available for this purpose.
9610a
4-51
Page 148
FST 200-STL
4. Programming in the statement list
• INC (count upwards = increment) • DEC (count backwards = decrement). You also use these instructions if you wish to increment or decrement the counter values. There is no difference here if you specify the counter word or the counter itself. The following cases are, therefore, possible and valid: Increment ... ... THEN INC CW0 THEN INC C0 ...
Decrement ... ... THEN DEC CW0 THEN DEC C0 ...
Stop counter You can reset an active counter by means of the program to any value of the timer word. It does not matter whether this is an upwards counter or a downwards counter. Example: STEP Label IF ... THEN RESET ...
C15
The counter entered is considered to have run down immediately after the RESET C15 instruction. You will have to initialize it again completely for a restart. 4-52
9610a
Page 149
FST 200-STL
4. Programming in the statement list
Query counter You may query two values of counters in an STL program. These are: • Counter status • Value of the counter word You can then control further actions in the program according to their value. Example: STEP 1 IF THEN ... STEP 2 IF THEN OTHRW ... STEP 3 IF
N SET
C15 O1.7
SET RESET
C3 O1.0 O1.0
THEN LOAD TO SET ...
CW15 = V25 V100 TP7 T7
In step 1, output O1.7 is set permanently as soon as counter no. 15 has run down. In step 2, output O1.0 is set as long as counter no. 3 is active. In Step 3, timer T7 is initialized and started if the value of the counter word is equal to 25. You may associate the counter word with any multi-bit operand in an STL program. Details of the syntax of possible logical operations are listed in appendix A.3.
9610a
4-53
Page 150
FST 200-STL
4.5
4. Programming in the statement list
Software modules In addition to the user programs, you can also use software modules. Two different types of software modules are supported, • Function modules (CFM) • Program modules (CMP). You may call a software module in the execution statements of a statement list.
4.5.1 Function modules (CFMnn) The controller operating system provides function modules for you to handle special tasks. These are machine programs prepared by Festo which you may use, but not modify. They need only be provided with the appropriate parameters when they are called. A total of 256 such function modules are possible. They are numbered from 0 to 255. Calling a function module A function module is always called within the execution statement of a program or program module. Here you should place the cursor on the program line after which you wish to insert a function module. Now select the Module box function from the Extended commands. A window appears at the right side of the screen (see Fig. 4.13).
4-54
9610a