20.12.03 no. 1 / 56© festo didactic – training & consultingplc programming programming with...

56
20.12.03 No. 1 esto Didactic – Training & Consulting PLC programming Programming with statement list

Upload: adam-greer

Post on 01-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 1 / 56 © Festo Didactic – Training & Consulting PLC programming

Programming with statement list

Page 2: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 2 / 56 © Festo Didactic – Training & Consulting PLC programming

Operands

Page 3: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 3 / 56 © Festo Didactic – Training & Consulting PLC programming

Operands

• System identifiers are referred to as operands.

• Operands are elements within the controller that can be interrogated or manipulated using program instructions and operators.

Page 4: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 4 / 56 © Festo Didactic – Training & Consulting PLC programming

Absolute and symbolic operand

The software allows programs to be written using both absolute and symbolic operand.

• Examples of absolute operands are :

• I0.1

• T1

• O0.4

Page 5: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 5 / 56 © Festo Didactic – Training & Consulting PLC programming

Absolute and symbolic operand

Examples of symbolic operands are :• S1• Timer• Solenoid• Y1

Page 6: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 6 / 56 © Festo Didactic – Training & Consulting PLC programming

Single bit vs multi-bit operand

• Single bit operands (SBO) can be evaluated as true/false in the conditional part of the program sentence and can be set/reset in the execution part of the program sentence.

• Multi bit operands (MBO) can be tested for value or compared to other multi bit operands in the conditional part of the sentence.

• In the executive part of the program sentence, they can be loaded with a value, decremented or incremented, or manipulated via a rich set of arithmetic and logic operators.

Page 7: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 7 / 56 © Festo Didactic – Training & Consulting PLC programming

Single bit operand

Operand STL Form

Syntax Typical example

Input I In.n IF I 2.0

Output O On.n IF I 2.0SET O2.3

Flag F Fn.n IF F 7.16RESET F9.3

Counter C Cn IF C3SET C5

Page 8: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 8 / 56 © Festo Didactic – Training & Consulting PLC programming

Multi-bit operand

Operand STL Form

Syntax Typical example

Input word IW Iwn IF (IW3=V 255)

Output word OW Own IF (OW2=V80)LOAD V128 TO OW3

Flag word FW FWn IF (FW3=V220)LOAD V21000 TO

FW1

Function Unit FU FUn IF (FU32=V16)LOAD FU34 to R60

Page 9: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 9 / 56 © Festo Didactic – Training & Consulting PLC programming

Multi-bit operand

Operand STL Form

Syntax Typical example

Timer Word TW TWn IF (TW2<V 2000)LOAD V1345 TO TW6

Timer Preselect TP TPn IF (TP0<V20)THEN LOAD V500 TO

TP4

Counter Word CW CWn IF (CW3<>V50)THEN INC CW5

Counter Preselect

CP CPn IF (CP3=V555) LOAD V67 to CP5

Register R RN IF (R60=V21113)LOAD (R53 + R45)

TO R32

Error Word EW EW IF (EW AND V15)LOAD V0 TO EW

Page 10: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 10 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure

Page 11: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 11 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure

• The STL language allows the programmer to solve control tasks using simple english statements to describe the desired operation of the controller.

• The modular nature of the language allows the programmer to solve complex tasks in an efficient and self-documenting manner.

Page 12: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 12 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – element hierarchy

ProgramStepSentenceConditional partExecutive part

Page 13: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 13 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – step inspection

• Although the use of the keyword STEP is optional, most STL programs will use the STEP instruction.

• The step instruction is used to mark the beginning of a logical block of program code.

Page 14: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 14 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – step inspection

• Each STL program may contain up to 255 discrete STEPS.

• Each step may contain one or more sentences.

• Each step may be assigned an optional label or name.

Page 15: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 15 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – step inspection

• A step label is only required if the respective step will later be assigned

as the destination of a jump instruction.

Page 16: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 16 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – sentences

• The sentence forms the most basic level of program organisation.• Each sentence consists of a conditional part and an executive part.

Page 17: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 17 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – conditional part

• The conditional part serves to list one or more conditions which are to be evaluated at run time as being either true or false.

• This part usually begins with the if keyword and continues with one or more statements that describe the conditions to be evaluated.

Page 18: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 18 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – conditional part

• If the program conditions are evaluated as true, then any instructions programmed in the executive part of the sentence will be performed.

• Examples are:

• If I0.1

• If I0.2 and I1.3

Page 19: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 19 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – executive part

• It is the section of the sentence where the output is activated if the conditional part is evaluated as true.

• Examples are :• THEN SET Y1• THEN RESET Y2• THEN JMP TO 10

Page 20: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 20 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – step instruction

• Programs that do not use the STEP instruction can be processed in a parallel (scanning) fashion.

• Although this type of program execution may be well suited for solving certain types of control tasks, the STL language provides the step instruction which allows programs to be divided into discrete sections (steps) which will be executed independently.

Page 21: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 21 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – step instruction

In its simplest form, a STEP includes at least one sentence.

STEP (label) IF I1.0 If Input 1.0 is active THEN SET O2.4 then turn on output 2.4

and proceed to the next step.

Page 22: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 22 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – step instruction

• 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.

• Only then will the program proceed to the next step.

Page 23: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 23 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – programming

Single sentence within a step

STEP Start - Label for STEP can be up to 8 alphanumericIF I0.0 - Conditional partTHEN SET O0.0 - Execution part

STEP StopIF I0.1THEN RESET O0.0

Page 24: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 24 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – programming

• Single sentence within a step

• The program will execute the first step, STEP start.

• If the condition i0.0 is true, then it will execute the execution part (set O0.0) and proceed to next step, STEP stop

• If the condition is false, it will WAIT at STEP start.

Page 25: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 25 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – programming

Multiple sentence within a step

STEP StartIF I0.0 - First SentenceTHEN SET O0.0

IF I0.1 - Second SentenceTHEN SET O0.1

IF I0.2 - Third SentenceTHEN SET O0.2

STEP StopIF I0.1THEN RESET O0.0

RESET O0.1RESET O0.2

Page 26: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 26 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – programming

• Multiple sentence within a step

• Sequence of execution

• If the conditional part of the first sentence is true, then it will execute the execution part and proceed to second sentence WITHOUT any exception

Page 27: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 27 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – programming

• If the conditional part of the second sentence is true, then it will execute the execution part and proceed to third sentence WITHOUT any exception. No waiting at second sentence.

• If the conditional part of the third sentence is true, then it will execute the execution part and proceed to next step. If not true, it will proceed to first sentence, second sentence and it will loop within the step.

• Generally, only when the last sentence within the step is true, it will proceed to next step.

Page 28: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 28 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – programming

• If the conditions of a sentence are met, then the programmed actions are executed.

• If the conditions of the last (or only) sentence within a step are met, then the programmed actions are executed and the program proceeds to the next step.

• If the conditions of a sentence are not met, then the program will move to the next step in the current step.

• If the conditions of the last (or only) sentence within a step are not met, then the program will return to the first sentence of the current step.

Page 29: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 29 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – influencing program flow

In addition to the control structures inherent within the step instruction, several additional STL instructions are available which can be used to influence the execution criteria of program steps and sentences.

Page 30: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 30 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – NOP instruction

• The NOP instruction may be used in either the conditional or executive part of a sentence.

• When used in the conditional part, the NOP instruction is always evaluated as true.

• The NOP instruction can be used to cause unconditional execution of a sentence.IF NOP This is always TrueTHEN SET O1.0 so Output 1.0 will always be turned

on when the program reaches here

Page 31: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 31 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – NOP instruction

Example of an NOP instruction

Page 32: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 32 / 56 © Festo Didactic – Training & Consulting PLC programming

STEP 50

IF I10.0 If input 1.0 is active

THEN SET O2.2 then turn on output 2.2

IF N I3.5 If input 3.5 is not active

AND I4.4 and input 4.4 is active

THEN RESET O1.2 then turn off output 1.2

IF T3 If timer 3 is running

THEN SET F0.0 then set flag 0.0

IF NOP In any case, we make sure that the

last sentence will always be true

THEN SET O3.6 Turn on output 3.6, exit and go to

next step

Page 33: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 33 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – NOP instruction

• In step 50, several conditions were to be checked.

• 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.

• We have forced the last sentence to be true via the nop instruction.

Page 34: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 34 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – NOP instruction

• The NOP instruction may also be used in the executive part. Here the NOP is equivalent to “do nothing”.

• It is often used when the program is to wait for certain conditions and then proceed to the next step.

IF I3.2 If Input 3.2 is Active

THEN NOP Do nothing and go to the next step.

Page 35: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 35 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – jump instruction

• The JMP instruction adds the ability of program branching to the STL language.

• As an example, we will modify the previous example used for NOP instruction.

• It would now be possible to test the conditions of each sentence and if true perform the programmed action and then jump to a designated program step.

Page 36: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 36 / 56 © Festo Didactic – Training & Consulting PLC programming

STEP 50

IF I10.0 If input 1.0 is active

THEN SET O2.2 then turn on output 2.2

JMP TO 70 and jump to step label 70

IF N I3.5 If input 3.5 is not active

AND I4.4 and input 4.4 is active

THEN RESET O1.2 then turn off output 1.2

JMP To 6 and jump to step label 70

IF T3 If timer 3 is running

THEN SET F0.0 then set flag 0.0

IF NOP Always true, so ...

THEN SET O3.6 Turn on output 3.6, exit and go to next step

Page 37: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 37 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – jump instruction

• It can be seen that not only have we altered the program flow, but in addition have established priorities between the sentences.

• Sentences 2,3 and 4 will only have the possibility to be processed if sentence 1 is false and therefore not executed.

• If sentence 1 is executed, the program will jump to step 70 without ever processing any subsequent sentences in step 50.

Page 38: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 38 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – OTHRW instruction

• The OTHRW instruction is executed when the last encountered IF clause is evaluated as not true.

IF I2.0 If Input 2.0 is active

THEN SET O3.3 Turn on output 3.3

OTHRW RESET O4.5 Otherwise turn on output 4.5

Page 39: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 39 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – OTHRW instruction

STEP execution with OTHRW (Otherwise) instruction

STEP Start - Label for STEP can be up to 8 alphanumericIF I0.0 - Conditional partTHEN SET O0.0 - Execution partOTHRW RESET O0.0 - Execution part

STEP StopIF I0.1THEN RESET O0.0

Page 40: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 40 / 56 © Festo Didactic – Training & Consulting PLC programming

STL program structure – OTHRW instruction

• The program will execute the first step, STEP start.

• If the condition i0.0 is true, then it will execute the execution part (set O0.0) and proceed to next step, STEP stop. Otherwise (if not true), it will execute the RESET O0.0 and proceed to next step, STEP stop

• In this case, there is no waiting at STEP start, either it executes SET O0.0 or RESET O0.0 and proceed to next step

Page 41: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 41 / 56 © Festo Didactic – Training & Consulting PLC programming

STL instruction summary

Page 42: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 42 / 56 © Festo Didactic – Training & Consulting PLC programming

STL instruction summary

The STL language provides the following instructions which allow both simple and complex tasks to be solved quickly and easily.

Page 43: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 43 / 56 © Festo Didactic – Training & Consulting PLC programming

STL instruction summary

AND Performs a logical AND operation on single or Multibit operands and constants.

BID Converts the contents of the Multibit Accumulator from Binary to BCD format.

CFM n Begin Execution of a Function Module.

CMP n Begin Execution of a Program Module.

CPL Produces the two’s compliment of the contents of the multibit accumulator.

DEC Decrements a Multibit Operand / Accumulator.

DEB Converts the contents of the Multibit Accumulator from BCD to Binary format.

EXOR Performs a logical EXOR operation on single or multi operands and constants.

IF Keyword marking the beginning of the Conditional part of a sentence.

INC Increments a Multibit Operand / Accumulator.

INV Produces the one’s compliment of the contents of the multibit accumulator.

Page 44: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 44 / 56 © Festo Didactic – Training & Consulting PLC programming

STL instruction summary

JMP TO(Step Label)

Causes the program to continue execution at the specified Step.

LOAD Allows loading specified operands (single or multibit) and constants to either the single or multibit accumulator.

NOP A Special instruction which is Always True in the Conditional Part of a sentence. In the Executive Part it is equivalent to “Do nothing”.

OR Performs a logical OR operation on single or multibit operands and constants.

OTHRW Provides the ability to continue program execution if the Conditional Part of a sentence is False.

RESET The Reset instruction is used to change single bit operands to logical “0” status.

ROL Rotates Left all bits contained in the Multibit Accumulator by one position. The most significant bit is moved to the least significant bit.

ROR Rotates Right all bits contained in the Multibit Accumulator by one position. The most significant bit is moved to the most significant bit.

Page 45: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 45 / 56 © Festo Didactic – Training & Consulting PLC programming

STL instruction summary

SET The Set instruction is used to change single bit operands to a logical “1” status.

SHIFT Performs a Single Bit Swap between a Single Bit Operand and the Single Bit Accumulator.

SHL 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).

SHR Shifts Right 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).

SWAP Exchanges the high and low order bytes of the Multibit Accumulator.

TO Used with the LOAD instruction to specify a destination operand.

THEN Keyword marking the beginning of the Executive Part of a sentence.

WITH Used to pass parameters with some CFM/CMP instructions. Also used to specify timer clock rates for some PLC models.

Page 46: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 46 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking

Page 47: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 47 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking

• Multitasking is the term used for the “simultaneous” execution of a number of different tasks (problems, programs)

• Organising the program sections using modular programming techniques.• The PLC program can consist of several parts each of which is a program in its

own right. These programs have various functions.

Page 48: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 48 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking

• The advantages of this method of working include clearer program structures and shorter cycle times.

• With multitasking it is easy to program several different operating modes and to be able to call them up at any time and to run parallel with the main program.

Page 49: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 49 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking

P1

P2

P63

CMP 0

CMP 49

CMP 99

CFM 0

CFM 49

CFM 99

Program( Multi-Tasking )

Module Program ( Subroutine )

Function modules( Predefined by

Festo )

P0Main control programP0 is activated automatically when power on

Page 50: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 50 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking

• Multitasking – modules can be activated by the main program / other programs to run concurrently.

• P1 to p63 can be activated to run parallel with P0. Hence, a multi-tasking of 64 programs can be achieved.

Page 51: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 51 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking

STEP 10Then Set O0.0

STEP 20If I0.0Then SET P1

STEP 30Then Reset O0.0

STEP 10Then Set O0.0

STEP 20If I0.0Then SET P1

STEP 30Then Reset O0.0

STEP StartIf I0.1Then Set O0.2

STEP EndThen NOP

STEP StartIf I0.1Then Set O0.2

STEP EndThen NOP

P0

P1

Page 52: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 52 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking – call module program

• Sub routine – modules can only be activated by the main program to run as sub-routines. (CMP – call module program)

• Command – CMP X THEN CMP x module number x

With p1 1st parameter With p2 2nd parameter With p3 3rd parameter With p4 4th parameter

Page 53: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 53 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking – call module program

STEP 10Then Set O0.0

STEP 20If I0.0Then CMP0

STEP 30Then Reset O0.0

STEP 10Then Set O0.0

STEP 20If I0.0Then CMP0

STEP 30Then Reset O0.0

STEP StartIf I0.1Then Set O0.2

STEP EndThen NOP

STEP StartIf I0.1Then Set O0.2

STEP EndThen NOP

P0

B0

Page 54: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 54 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking – call function module

• Sub routine – modules can only be activated by the main program to run as sub-routines. (CFM – call function module)

• Command – CFM XTHEN CFM x module number x

With p1 1st parameter With p2 2nd parameter With p3 3rd parameter With p4 4th parameter

Page 55: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 55 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking – call function module

STEP 10Then Set O0.0

STEP 20If I0.0Then CFM 8 With v2 With v6 Load FU32 To R0

STEP 10Then Set O0.0

STEP 20If I0.0Then CFM 8 With v2 With v6 Load FU32 To R0

Function Add(Internal Module)v2 + v6 = v8

Function Add(Internal Module)v2 + v6 = v8

P0

F8

Page 56: 20.12.03 No. 1 / 56© Festo Didactic – Training & ConsultingPLC programming Programming with statement list

20.12.03 No. 56 / 56 © Festo Didactic – Training & Consulting PLC programming

Multitasking - summary

When you are doing multitasking:

• The sub-program will be activated and will run together with the main program, which will still carry on running.

• The programs are running parallel.

• When using the CMP (call module program) or CFM (call function module) command, you are activating a sub-routine.

• In this case, the main program will stop and stay at that step and the sub-program will be activated.

• Only when the sub-program is completed it will jump back to the main program at the point where it left.