Programming with statement list - PowerPoint PPT Presentation

1 / 56
About This Presentation
Title:

Programming with statement list

Description:

Title: Training & Consulting Resources Author: David Hoey Last modified by: David Hoey Created Date: 8/12/2003 1:47:05 PM Document presentation format – PowerPoint PPT presentation

Number of Views:166
Avg rating:3.0/5.0
Slides: 57
Provided by: DavidH225
Category:

less

Transcript and Presenter's Notes

Title: Programming with statement list


1
Programming with statement list
2
Operands
3
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.

4
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

5
Absolute and symbolic operand
  • Examples of symbolic operands are
  • S1
  • Timer
  • Solenoid
  • Y1

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

7
Single bit operand
Operand STL Form Syntax Typical example
Input I In.n IF I 2.0
Output O On.n IF I 2.0 SET O2.3
Flag F Fn.n IF F 7.16 RESET F9.3
Counter C Cn IF C3 SET C5
8
Multi-bit operand
Operand STL Form Syntax Typical example
Input word IW Iwn IF (IW3V 255)
Output word OW Own IF (OW2V80) LOAD V128 TO OW3
Flag word FW FWn IF (FW3V220) LOAD V21000 TO FW1
Function Unit FU FUn IF (FU32V16) LOAD FU34 to R60
9
Multi-bit operand
Operand STL Form Syntax Typical example
Timer Word TW TWn IF (TW2ltV 2000) LOAD V1345 TO TW6
Timer Preselect TP TPn IF (TP0ltV20) THEN LOAD V500 TO TP4
Counter Word CW CWn IF (CW3ltgtV50) THEN INC CW5
Counter Preselect CP CPn IF (CP3V555) LOAD V67 to CP5
Register R RN IF (R60V21113) LOAD (R53 R45) TO R32
Error Word EW EW IF (EW AND V15) LOAD V0 TO EW
10
STL program structure
11
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.

12
STL program structure element hierarchy
  • Program
  • Step
  • Sentence
  • Conditional part
  • Executive part

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

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

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

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

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

18
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

19
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

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

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

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

23
STL program structure programming
  • Single sentence within a step

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

25
STL program structure programming
  • Multiple sentence within a step

26
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

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

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

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

30
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 True THEN SET O1.0 so
Output 1.0 will always be turned on when the
program reaches here
31
STL program structure NOP instruction
  • Example of an NOP instruction

32
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 th
en 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
33
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.

34
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.
35
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.

36
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 the
n set flag 0.0 IF NOP Always true, so
... THEN SET O3.6 Turn on output 3.6, exit and go
to next step
37
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.

38
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
39
STL program structure OTHRW instruction
  • STEP execution with OTHRW (Otherwise) instruction

40
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

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

43
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 twos 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 ones compliment of the contents of the multibit accumulator.
44
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.
45
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.
46
Multitasking
47
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.

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

49
Multitasking
P0 Main control program P0 is activated
automatically when power on
P1
CMP 0
CFM 0
P2
CMP 49
CFM 49
P63
CMP 99
CFM 99
Program ( Multi-Tasking )
Module Program ( Subroutine )
Function modules ( Predefined by Festo )
50
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.

51
Multitasking
52
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

53
Multitasking call module program
54
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 X
  • THEN CFM x module number x
  • With p1 1st parameter
  • With p2 2nd parameter
  • With p3 3rd parameter
  • With p4 4th parameter

55
Multitasking call function module
56
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.
Write a Comment
User Comments (0)
About PowerShow.com