LostFile Word 187352488
LostFile Word 187352488
LostFile Word 187352488
TRAINING
SIEMENS
S7-300 PROGRAMMING
IN STATEMENT LIST
PAGE 1
CONTENTS: PAGE NO
1. STEP7 OVERVIEW 3
3. ADDRESSING OF MODULES 9
6. DATA TYPES 14
9. COMPARISON INSTRUCTIONS 27
22. GLOSSARY 86
PAGE 2
SIMATIC S7
PLC RANGE
2. Power Supply (PS) Converts the power system voltage (120/230VAC) into
24VDC for the S7-300 and load power supply for 24
VDC load circuits.
5. Function Modules (FMs) For time critical and memory intensive process signal
processing tasks eg. Closed loop control
10. RS 485 Repeater Interfaces the S7-300 over large distances to other S7-
300s or programming devices
PAGE 3
Overview of STEP 7
What is STEP 7?
STEP 7 is the standard software package used for configuring and programming
SIMATIC programmable logic controllers. It is part of the SIMATIC industry software.
Basic Tasks
When you create an automation solution with STEP 7, there are a series of basic tasks. The following
figure shows the tasks that need to be performed for most projects and assigns them to a basic
procedure.
Alternative Procedures
As shown in the figure above, you have two alternative procedures:
You can configure the hardware first and then program the blocks.
You can, however, program the blocks first without configuring the hardware. This is
recommended for service and maintenance work, for example, to integrate programmed
blocks into in an existing project.
Brief Description of the Individual Steps
PAGE 4
Installation and authorization
The first time you use STEP 7, install it and transfer the authorization from diskette to the hard
disk
Plan your controller
Before you work with STEP 7, plan your automation solution from dividing the process into
individual tasks to creating a configuration diagram Design the program structure
Turn the tasks described in the draft of your controller design into a program structure using
the blocks available in STEP 7
Start STEP 7
You start STEP 7 from the Windows 95/98/NT user interface
Create a project structure
A project is like a folder in which all data are stored in a hierarchical structure and are
available to you at any time. After you have created a project, all other tasks are executed in
this project Configure a station
When you configure the station you specify the programmable controller you want to use; for
example, SIMATIC 300, SIMATIC 400
Configure hardware
When you configure the hardware you specify in a configuration table which modules you
want to use for your automation solution and which addresses are to be used to access the
modules from the user program. The properties of the modules can also be assigned using
Configure networks and communication connections
The basis for communication is a pre-configured network. For this, you will need to create the
subnets required for your automation networks, set the subnet properties, and set the network
connection properties and any communication connections required for the networked
stations
Define symbols
You can define local or shared symbols, which have more descriptive names, in a symbol
table to use instead of absolute addresses in your user program
Create the program
Using one of the available programming languages create a program linked to a module or
independent of a module and store it as blocks, source files, or charts
S7 only: generate and evaluate reference data
You can make use of these reference data to make debugging and modifying your user
program easier
Configure messages
You create block-related messages, for example, with their texts and attributes. Using the
transfer program you transfer the message configuration data created to the operator
interface system database (for example, SIMATIC WinCC, SIMATIC ProTool)
Configure operator control and monitoring variables
You create operator control and monitoring variables once in STEP 7 and assign them the
required attributes. Using the transfer program you transfer the operator control and
monitoring variables created to the database of the operator interface system WinCC
Download programs to the programmable controller
S7 only: after all configuration, parameter assignment, and programming tasks are
completed, you can download your entire user program or individual blocks from it to the
programmable controller (programmable module for your hardware solution).
Test programs
S7 only: for testing you can either display the values of variables from your user program or a
CPU, assign values to the variables, and create a variable table for the variables that you
want to display or modify
Monitor operation, diagnose hardware
You determine the cause of a module fault by displaying online information about a module.
You determine the causes for errors in user program processing with the help of the
diagnostic buffer and the stack contents. You can also check whether a user program can run
on a particular CPU
Document the plant
After you have created a project/plant, it makes sense to produce clear documentation of the
project data to make further editing of the project and any service activities easier
PAGE 5
COMPARISON OF CPU'S
PAGE 6
THE DIFFERENT TYPES OF MODULES AVAILABLE ARE
2. FUNCTION MODULES
High Speed Counter Modules - Upto 100 KHz range
Positioning Modules - For position control, Stepper Motor Control, Cam Controllers
All function modules are enclosed and can be installed in any slot.
5. POWER SUPPLY MODULES - FOR 24 VDC LOAD CIRCUITS WITH DIFFERENT RATINGS.
PAGE 7
ADDRESSING OF MODULES
RACK 0
PS CPU
Slot Number 1 2 3 4 5 6 7 8 9 10 11
Digital Address 0 4 8 12 16 20 24 28
CPU IM AI / AO / DI / DO Modules
RACK 1
Slot Number 3 4 5 6 7 8 9 10 11
Digital Address 64
32 36 40 44 48 52 56 60
512
384 400 416 432 448 464 480 496
Analog Address
PAGE 8
Slot Addressing for Rack 2
RACK 2
Slot Number 3 4 5 6 7 8 9 10 11
Digital Address 64 68 72 76 80 84 88 92
CPU IM AI / AO / DI / DO Modules
RACK 3
Slot Number 3 4 5 6 7 8 9 10 11
Digital Address 64
96 100 104 108 112 116 120 124
512
640 656 672 688 704 720 736 752
Analog Address
PAGE 9
Rack 3
Slot Number IM 4 5 6 7 8 9 10 11
64
512
Rack 2
Slot Number IM 4 5 6 7 8 9 10 11
Connecting
64 cable 368
512
Rack 1
Slot Number IM 4 5 6 7 8 9 10 11
Connecting
64 cable 368
512
Rack 0
PS CPU
PAGE 10
Load Memory and Work Memory in the CPU
After completing the configuration, parameter assignment, and program creation and establishing the
online connection, you can download complete user programs or individual blocks to a programmable
controller. To test individual blocks, you must download at least one organization block (OB) and the
function blocks (FB) and functions (FC) called in the OB and the data blocks (DB) used. To download
the system data created when the hardware was configured, the networks configured, and the
connection table created to the programmable controller, you download the object “System Data".
You download user programs to a programmable controller using the SIMATIC Manager, for example,
during the end phase of the program testing or to run the finished user program.
Relationship - Load Memory and Work Memory
The complete user program is downloaded to the load memory; the parts relevant to program
execution are also loaded into the work memory.
PAGE 11
Blocks in the User Program
The STEP 7 programming software allows you to structure your user program, in other words to break
down the program into individual, self-contained program sections. This has the following advantages:
Extensive programs are easier to understand.
Individual program sections can be standardized.
Program organization is simplified.
It is easier to make modifications to the program.
Debugging is simplified since you can test separate sections.
Commissioning your system is made much easier.
The example of an industrial blending process illustrated the advantages of breaking down an
automation process into individual tasks. The program sections of a structured user program
correspond to these individual tasks and are known as the blocks of a program.
Block Types
There are several different types of blocks you can use within an S7 user program:
System function blocks (SFB) SFBs and SFCs are integrated in the S7 CPU and allow you
and system functions (SFC) access to some important system functions.
Function blocks (FB) FBs are blocks with a "memory" which you can program yourself.
Functions (FC) FCs contain program routines for frequently used functions.
Instance data blocks Instance DBs are associated with the block when an FB/SFB is
(instance DB) called. They are created automatically during compilation.
Data blocks (DB) DBs are data areas for storing user data. In addition to the data
that are assigned to a function block, shared data can also be
defined and used by any blocks.
OBs, FBs, SFBs, FCs, and SFCs contain sections of the program and are therefore also known as
logic blocks. The permitted number of blocks per block type and the permitted length of the blocks is
CPU-specific.
PAGE 12
DATA TYPES
Introduction to Data Types and Parameter Types
All the data in a user program must be identified by a data type. The following data types are
available:
Elementary data types provided by STEP 7
Complex data types that you yourself can create by combining elementary data types
Parameter types with which you define parameters to be transferred to FBs or FCs
General Information
Statement List, Ladder Logic, and Function Block Diagram instructions work with data objects of
specific sizes. Bit logic instructions work with bits, for example. Load and transfer instructions (STL)
and move instructions (LAD and FBD) work with bytes, words, and double words.
A bit is a binary digit "0" or "1." A byte is made up of eight bits, a word of 16 bits, and a double word of
32 bits.
Math instructions also work with bytes, words, or double words. In these byte, word, or double word
addresses you can code numbers of various formats such as integers and floating-point numbers.
When you use symbolic addressing, you define symbols and specify a data type for these symbols
(see table below). Different data types have different format options and number notations.
This chapter describes only some of the ways of writing numbers and constants. The following table lists the
formats of numbers and constants that will not be explained in detail.
Format Size in Bits Number Notation
date 16 D#
time 32 T#
Character 8 'A'
BOOL(Bit)
Boolean text TRUE/FALSE TRUE
L 2#0001_0000_0000_0000
Binary number 2. 0 to
2#1111_1111_1111_1111
WORD Hexadecimal number W#16#0 to W#16#FFFF L W#16#1000
16
(Word) L word16#1000
BCD C#0 to C#999 L C#998
Decimal number unsigned B#(0.0) to B#(255.255) L B#(10,20)
L byte#(10,20)
INT
16 Decimal number signed -32768 to 32767 L1
(Integer)
DINT L#-2147483648 to
32 Decimal number signed L L#1
(Integer, 32 bits) L#2147483647
REAL
IEEE Upper limit: 3.402823e+38 L 1.234567e+13
(Floating-point 32
Floating-point number Lower limit: 1.175 495e-38
number)
S5T#0H_0M_0S_10MS to L S5T#0H_1M_0S_0MS
S7 time in
S5TIME S5T#2H_46M_30S_0MS L
16 steps of
(SIMATIC time) and S5TIME#0H_1H_1M_0S_0
10 ms (default)
S5T#0H_0M_0S_0MS MS
-
L T#0D_1H_1M_0S_0MS
T#24D_20H_31M_23S_64
TIME IEC time in steps of 1 ms, L
32 8MS to
(IEC time) integer signed TIME#0D_1H_1M_0S_0MS
T#24D_20H_31M_23S_64
7MS
CHAR
8 ASCII characters 'A','B' etc. L 'E'
(Character)
Parameter Types
In addition to elementary and complex data types, you can also define parameter types for formal
parameters that are transferred between blocks. STEP 7 recognizes the following parameter types:
TIMER or COUNTER: this specifies a particular timer or particular counter that will be used
when the block is executed. If you supply a value to a formal parameter of the TIMER or
COUNTER parameter type, the corresponding actual parameter must be a timer or a counter,
in other words, you enter "T" or "C" followed by a positive integer.
BLOCK: specifies a particular block to be used as an input or output. The declaration of the
parameter determines the block type to be used (FB, FC, DB etc.). If you supply values to a
formal parameter of the BLOCK parameter type, specify a block address as the actual
parameter. Example: “FC101" (when using absolute addressing) or “Valve" (with symbolic
addressing).
BLOCK_FB
BLOCK_FC Indicates a block to be used by the program in the called logic block.
2 bytes
BLOCK_DB Format: FC101
BLOCK_SDB DB42
PAGE 14
PROGRAMMING IN STATEMENT LIST
Statement List (STL) is a textual programming language that can be used to create the code section
of logic blocks. Its syntax for statements is similar to assembler language and consists of instructions
followed by addresses on which the instructions act.
Of all the programming languages with which you can program S7 controllers, STL is the closest to
the machine code MC7 of the S7 CPU. This means that by using it to program S7 controllers, you can
optimize the run time and the use of memory.
The programming language STL has all the necessary elements for creating a complete user
program. It contains a comprehensive range of instructions. A total of over 130 different basic
instructions and a wide range of addresses are available. Functions and function blocks allow you to
structure your STL program clearly.
The STL programming package is an integral part of the STEP 7 Standard Software. This means that
following the installation of your STEP 7 software, all the editor functions, compiler functions and
test/debug functions for STL are available to you.
Using STL, you can create your own user program as follows:
_ With the Incremental Editor. The input of the local data structure is made easier with the help of
table editors.
_ With a source file in the Text Editor. Text input is made easier with the help of block templates.
There are three programming languages in the standard software, STL, FBD, and LAD. You can
switch from one language to the other almost without restriction and choose the most suitable
language for the particular block you are programming.
If you write programs in LAD or FBD, you can always switch over to the STL representation. If you
convert LAD programs into FBD programs and vice versa, program elements that cannot be
represented in the destination language are displayed in STL.
Address of an Instruction
The address of an instruction indicates a constant or the location where the instruction finds a value
(data object) on which to perform an operation. The address can have a symbolic name or an
absolute designation. The address can point to any of the following items :
_ A constant, the value of a timer or counter, or an ASCII character string to be loaded into
accumulator 1 (for example, L +27 See Table 2.1)
_ A bit in the status word of the programmable logic controller
_ A symbolic name (for example, A Motor.On, see Table 2-3)
_ A data block and a location within the data block area (for example, L DB4.DBD10, see Table 2-4)
_ A function (FC), function block (FB), integrated system function (SFC), or integrated system function
block (SFB) and the number of the function or block (see Table 2-5)
_ An address identifier and a location within the memory area that is indicated by the address
identifier (for example, A I 1.0)
PAGE 15
PAGE 16
PAGE 17
PAGE 18
PAGE 19
PAGE 20
PAGE 21
COMMANDS USED IN STATEMENT LIST
PAGE 22
PAGE 23
PAGE 24
PAGE 25
Comparison Instructions
PAGE 26
`
PAGE 27
Conversion Instructions
PAGE 28
BTD BCD to Double Integer (32-Bit)
Example:
L MD10 Load the BCD number into ACCU 1.
BTD Convert from BCD to integer; store result in ACCU 1.
T MD20 Transfer result (double integer number) to MD20.
PAGE 29
CAW Change Byte Sequence in ACCU 1-L (16-Bit)
Example:
L MW10 Load the value of MW10 into ACCU 1.
CAW Reverse the sequence of bytes in ACCU 1-L.
T MW20 Transfer the result to MW20.
PAGE 30
DTR Convert from double integer to floating point (32-bit IEEE FP); store result in
ACCU 1.
T MD20 Transfer result (BCD number) to MD20.
Contents of ACCU 1
before execution of INVD 0110 1111 1000 1100 0110 0011 1010 1110
Contents of ACCU 1
after execution of INVD 1001 0000 0111 0011 1001 1100 0101 0001
PAGE 31
ITB Integer (16-Bit) to BCD
Example:
L MW10 Load the integer number into ACCU 1-L.
ITB Convert from integer to BCD (16-bit); store result in ACCU 1-L.
T MW20 Transfer result (BCD number) to MW20.
ACCU 1-H ACCU 1-L
Bit: 31 16 : 15 0
Contents of ACCU 1 before execution of ITD: XXXX XXXX XXXX XXXX 1111 1111 1111 0110
Contents of ACCU 1 after execution of ITD: 1111 1111 1111 1111 1111 1111 1111 0110
(X = 0 or 1, bits are not used for conversion)
PAGE 32
Bit: 31 .0
Contents of ACCU 1 before execution of NEGD: 0101 1111 0110 0100 0101 1101 0011 1000
Contents of ACCU 1 after execution of NEGD: 1010 0000 1001 1011 1010 0010 1100 1000
L ID8 Load value into ACCU 1.
NEGD Generate twos complement (32-bit).
T MD10 Transfer result to MD10.
PAGE 33
RND Round
Example:
L MD10 Load the floating-point number into ACCU 1-L.
RND Convert the floating-point number (32-bit, IEEE-FP) into an integer (32-bit)
and
round off the result.
T MD20 Transfer result (double integer number) to MD20.
Value before conversion: Value after conversion:
MD10 = "100.5" => RND => MD20 = "+100"
MD10 = "-100.5" => RND => MD20 = "-100"
PAGE 34
RND+ Round to Upper Double Integer
Example:
L MD10 Load the floating-point number (32-bit, IEEE-FP) into ACCU 1-L.
RND+ Convert the floating-point number (32-bit, IEEE-FP) to an integer (32-bit) and
round
result.Store output in ACCU 1.
T MD20 Transfer result (double integer number) to MD20.
Value before conversion: Value after conversion:
MD10 = "100.5" => RND+ => MD20 = "+101"
MD10 = "-100.5" => RND+ => MD20 = "-100"
PAGE 35
TRUNC Truncate
Example:
L MD10 Load the floating-point number into ACCU 1-L.
TRUNC Convert the floating-point number (32-bit, IEEE-FP) to an integer (32-bit) and
round
result.Store the result in ACCU 1.
T MD20 Transfer result (double integer number) to MD20.
Value before conversion: Value after conversion:
MD10 = "100.5" => TRUNC => MD20 = "+100"
MD10 = "-100.5" => TRUNC => MD20 = "-100"
PAGE 36
Counter Instructions
PAGE 37
PAGE 38
PAGE 39
PAGE 40
PAGE 41
PAGE 42
CD Counter Down
Example:
L C#14 Counter preset value.
A I 0.1 Preset counter after detection of rising edge of I 0.1.
S C1 Load counter 1 preset if enabled.
A I 0.0 One count down per rising edge of I 0.0.
CD C1 Decrement counter C1 by 1 when RL0 transitions from 0 to 1 depending on
input
I 0.0.
AN C1 Zero detection using the C1 bit.
= Q 0.0 Q 0.0 = 1 if counter 1 value is zero.
CU Counter Up
Example:
A I 2.1 If there is a positive edge change at input I 2.1.
CU C3 Counter C3 is incremented by 1 when RL0 transitions from 0 to 1.
R Reset Counter
Example:
A I 2.3 Check signal state at input I 2.3.
R C3 Reset counter C3 to a value of 0 if RLO transitions from 0 to 1.
PAGE 43
Data Block Instructions
JM Jump if Minus
Example:
L IW8
L MW12
-I //Subtract contents of MW12 from contents of IW8.
JM NEG //Jump if result < 0 (that is, contents of ACCU 1 < 0).
AN M 4.0 //Program scan continues here if jump is not executed.
S M 4.0
JU NEXT
NEG: AN M 4.1 //Program scan resumes here after jump to jump label NEG.
PAGE 44
S M 4.1
NEXT: NOP 0 //Program scan resumes here after jump to jump label NEXT.
JP Jump if Plus
Example:
L IW8
L MW12
-I Subtract contents of MW12 from contents of IW8.
JP POS Jump if result >0 (that is, ACCU 1 > 0).
AN M 4.0 Program scan continues here if jump is not executed.
S M 4.0
JU NEXT
POS: AN M 4.1 Program scan resumes here after jump to jump label POS.
S M 4.1
NEXT: NOP 0 Program scan resumes here after jump to jump label NEXT.
JZ Jump if Zero
Example:
L MW10
SRW 1
JZ ZERO Jump to jump label ZERO if bit that has been shifted out = 0.
L MW2 Program scan continues here if jump is not executed.
INC 1
T MW2
JU NEXT
ZERO: L MW4 Program scan resumes here after jump to jump label ZERO.
INC 1
T MW4
NEXT: NOP 0 Program scan resumes here after jump to jump label NEXT.
LOOP Loop
Example for calculating the factor of 5:
L L#1 Load the integer constant (32 bit) into ACCU 1.
T MD20 Transfer the contents from ACCU 1 into MD20 (initialization).
L 5 Load number of loop cycles into ACCU 1-L.
NEXT: T MW10 Jump label = loop start / transfer ACCU 1-L to loop counter.
L MD20
* D Multiply current contents of MD20 by the current contents of MB10.
T MD20 Transfer the multiplication result to MD20.
L MW10 Load contents of loop counter into ACCU 1.
LOOP NEXT Decr. the contents of ACCU 1 and jump to the NEXT jump label if ACCU 1-L > 0.
L MW24 Program scan resumes here after loop is finished.
L 200
>I
PAGE 46
Load and Transfer Instructions
L Load
L <address> loads the addressed byte, word, or double word into ACCU 1 after the old contents of
ACCU 1 have been saved into ACCU 2, and ACCU 1 is reset to "0".
Example:
L IB10 Load input byte IB10 into ACCU 1-L-L.
L MB120 Load memory byte MB120 into ACCU 1-L-L.
L DBB12 Load data byte DBB12 into ACCU 1-L-L.
L DIW15 Load instance data word DIW15 into ACCU 1-L.
L LD252 Load local data double word LD252 ACCU 1.
T Transfer
T <address> transfers (copies) the contents of ACCU 1 to the destination address if the Master
Control Relay is switched on (MCR = 1). If MCR = 0, then the destination address is written with 0.
The number of bytes copied from ACCU 1 depends on the size expressed in the destination address.
ACCU 1 also saves the data after the transfer procedure. A transfer to the direct I/O area (memory
type PQ) also transfers the contents of ACCU 1 or "0" (if MCR=0) to the corresponding address of the
process image output table (memory type Q). The instruction is executed without regard to, and
without affecting, the status bits.
Example:
T QB10 Transfers contents of ACCU 1-L-L to output byte QB10.
T MW14 Transfers contents of ACCU 1-L to memory word MW14.
T DBD2 Transfers contents of ACCU 1 to data double word DBD2.
PAGE 47
Floating-Point Math Instructions; Basic
*R Multiply ACCU 1 and ACCU 2 as Floating Point Numbers (32-Bit IEEE-FP)
Example:
OPN DB10
L ID10 Load the value of ID10 into ACCU 1.
L MD14 Load the value of ACCU 1 into ACCU 2.Load the value of MD14 into
ACCU 1.
*R Multiply ACCU 2 and ACCU 1; store the result in ACCU 1.
T DBD25 The content of ACCU 1 (result) is transferred to DBD25 in DB10.
OPN DB10
L ID10 Load the value of ID10 into ACCU 1.
L MD14 Load the value of ACCU 1 into ACCU 2.Load the value of MD14 into
ACCU 1.
-R Subtract ACCU 1 from ACCU 2; store the result in ACCU 1.
T DBD25 The content of ACCU 1 (result) is transferred to DBD25 in DB10.
PAGE 48
Floating-Point Math Instructions: Extended
PAGE 49
Integer Math Instructions
+ Add Integer Constant (16, 32 Bit)
+ <integer constant> adds the integer constant to the contents of ACCU 1 and stores the result in
ACCU 1. The instruction is executed without regard to, and without affecting, the status word bits.
The contents of accumulator 2 remain unchanged for CPUs with two ACCUs.
The contents of accumulator 3 are copied into accumulator 2, and the contents of accumulator 4 are
copied into accumulator 3 for CPUs with four ACCUs. The contents of accumulator 4 remain
unchanged.
+ <16-bit integer constant>: Adds a 16-bit integer constant (in the range of -32768 to +32767) to the
contents of ACCU 1-L and stores the result in ACCU 1-L.
The contents of accumulator 2 remain unchanged for CPUs with two ACCUs.
The contents of accumulator 3 are copied into accumulator 2, and the contents of accumulator 4 are
copied into accumulator 3 for CPUs with four ACCUs. The contents of accumulator 4 remain
unchanged.
+ <32-bit integer constant>: Adds a 32-bit integer constant (in the range of -2,147,483,648 to
2,147,483,647) to the contents of ACCU 1 and stores the result in ACCU 1.
The contents of accumulator 2 remain unchanged for CPUs with two ACCUs.
The contents of accumulator 3 are copied into accumulator 2, and the contents of accumulator 4 are
copied into accumulator 3 for CPUs with four ACCUs. The contents of accumulator 4 remain
unchanged.
Example 1:
L IW10 Load the value of IW10 into ACCU 1-L.
L MW14 Load the contents of ACCU 1-L to ACCU 2-L. Load the value of MW14 into
ACCU 1-L.
+I Add ACCU 2-L and ACCU 1-L; store the result in ACCU 1-L.
+ 25 Add ACCU 1-L and 25; store the result in ACCU 1-L.
T DB1.DBW25 Transfer the contents of ACCU 1-L (result) to DBW25 of DB1.
Example 2:
L IW12
L IW14
+ 100 Add ACCU 1-L and 100; store the result in ACCU 1-L.
>I If ACCU 2 > ACCU 1, or IW12 > (IW14 + 100)
JC NEXT then conditional jump to jump label NEXT.
Example 3:
L MD20
L MD24
+D Add ACCU 1and ACCU 2; store the result in ACCU 1.
+ L#-200 Add ACCU 1 and -200; store the result in ACCU 1.
T MD28
PAGE 50
L MD14 Load the contents of ACCU 1 into ACCU 2.Load the value of MD14 into
ACCU 1.
-D Subtract ACCU 1 from ACCU 2; store the result in ACCU 1.
T DB1.DBD25 The contents of ACCU 1 (result) are transferred to DBD25 of DB1.
PAGE 51
/I Divide ACCU 2 by ACCU 1 as Integer (16-Bit)
Example:
PAGE 52
Program Control Instructions
BE Block End
BE (block end) terminates the program scan in the current block and causes a jump to the block that
called the current block. The program scan resumes with the first instruction that follows the block call
statement in the calling program.
Example:
A I 1.0 Update RLO.
BEC End block if RLO = 1.
L IW4 Continue here if BEC is not executed, RLO = 0.
T MW10
PAGE 53
Example 3: Calling FB99 with instance data block DB1
CALL FB99,DB1
Formal parameter Actual parameter
MAX_RPM := #RPM1_MAX
MIN_RPM := #RPM2
MAX_POWER := #POWER
MAX_TEMP := #TEMP
CC Conditional Call
CC <logic block identifier> (conditional block call) calls a logic block if RLO=1. CC is used to call logic
blocks of the FC or SFC type without parameters.
Example:
A I 2.0 Check signal state at input I 2.0.
CC FC6 Call function FC6 if I 2.0 is "1".
A M 3.0 Executed upon return from called function (I 2.0 = 1) or directly after A I 2.0
statement if I 2.0 = 0.
UC Unconditional Call
UC <logic block identifier> (unconditional block call) calls a logic block of the FC or SFC type. UC is
like the CALL instruction, except that you cannot transfer parameters with the called block.
Example 1:
UC FC6 Call function FC6 (without parameters).
Example 2:
UC SFC43 Call system function SFC43 (without parameters).
PAGE 54
Shift Instructions
ACCU 1-H ACCU 1-L
Bit: 31 16 15 0
ACCU 1 before execution of SLD 5: 0101 1111 0110 0100 0101 1101 0011 1011
ACCU 1 after execution of SLD 5: 1110 1100 1000 1011 1010 0111 0110 0000
Example 1:
L MD4 Load value into ACCU 1.
SLD 5 Shift bits in ACCU 1 five places to the left.
T MD8 Transfer result to MD8.
Examples:
ACCU 1-H ACCU 1-L
Bit: 31 16 15 0
ACCU 1 before execution of SLW 5: 0101 1111 0110 0100 0101 1101 0011 1011
ACCU 1 after execution of SLW 5: 0101 1111 0110 0100 1010 0111 0110 0000
Example 1:
L MW4 Load value into ACCU 1.
SLW 5 Shift the bits in ACCU 1 five places to the left.
T MW8 Transfer result to MW8.
Example 1:
L MD4 Load value into ACCU 1.
SRD 7 Shift bits in ACCU 1 seven places to the right.
T MD8 Transfer result to MD8.
PAGE 56
Timer Instructions
PAGE 57
SD On-Delay Timer
SD <timer> starts the addressed timer when the RLO transitions from "0" to "1". The programmed
time interval elapses as long as RLO = 1. The time is stopped if RLO transitions to "0" before the
programmed time interval has expired. This timer start instruction expects the time value and the time
base to be stored as a BCD number in ACCU 1-L.
Example:
A I 2.1
L S5T#10s Preset 10 seconds into ACCU 1.
SD T1 Start timer T1 as an on-delay timer.
PAGE 58
PAGE 59
SE Extended Pulse Timer
SE <timer> starts the addressed timer when the RLO transitions from "0" to "1". The programmed
time interval elapses, even if the RLO transitions to "0" in the meantime. The programmed time
interval is started again if RLO transitions from "0" to "1" before the programmed time has expired.
This timer start command expects the time value and the time base to be stored as a BCD number in
ACCU 1-L.
Example:
A I 2.1
L S5T#10s Preset 10 seconds into ACCU 1.
SE T1 Start timer T1 as an extended pulse timer.
A I 2.2
R T1 Reset timer T1.
A T1 Check signal state of timer T1.
= Q 4.0
PAGE 60
PAGE 61
SF Off-Delay Timer
SF <timer> starts the addressed timer when the RLO transitions from "1" to "0". The programmed
time elapses as long as RLO = 0. The time is stopped if RLO transitions to "1" before the programmed
time interval has expired. This timer start command expects the time value and the time base to be
stored as a BCD number in ACCU 1-L.
Example:
A I 2.1
L S5T#10s Preset 10 seconds into ACCU 1.
SF T1 Start timer T1 as an off-delay timer.
A I 2.2
R T1 Reset timer T1.
A T1 Check signal state of timer T1.
= Q 4.0
PAGE 62
PAGE 63
SP Pulse Timer
SP <timer> starts the addressed timer when the RLO transitions from "0" to "1". The programmed
time elapses as long as RLO = 1. The timer is stopped if RLO transitions to "0" before the
programmed time interval has expired. This timer start command expects the time value and the time
base to be stored as a BCD number in ACCU 1-L.
Example:
A I 2.1
L S5T#10s Preset 10 seconds into ACCU 1.
SP T1 Start timer T1 as a pulse timer.
A I 2.2
R T1 Reset timer T1.
A T1 Check signal state of timer T1.
= Q 4.0
PAGE 64
PAGE 65
SS Retentive On-Delay Timer
SS <timer> (start timer as a retentive ON timer) starts the addressed timer when the RLO transitions
from "0" to "1". The full programmed time interval elapses, even if the RLO transitions to "0" in the
meantime. The programmed time interval is re-triggered (started again) if RLO transitions from "0" to
"1" before the programmed time has expired. This timer start command expects the time value and
the time base to be stored as a BCD number in ACCU 1-L.
Example:
A I 2.1
L S5T#10s Preset 10 seconds into ACCU 1.
SS T1 Start timer T1 as a retentive on-delay timer.
A I 2.2
R T1 Reset timer T1.
A T1 Check signal state of timer T1.
= Q 4.0
PAGE 66
PAGE 67
PAGE 68
R Reset Timer
R <timer> stops the current timing function and clears the timer value and the time base of the
addressed timer word if the RLO transitions from 0 to 1.
Example:
A I 2.1
R T1 Check the signal state of input I 2.1 If RLO transitioned from 0 = 1, then reset timer
T1.
PAGE 69
Word Logic Instructions
AD AND Double Word (32-Bit)
AD (AND double word) combines the contents of ACCU 1 with ACCU 2 or a 32-bit constant bit by bit
according to the Boolean logic operation AND. A bit in the result double word is "1" only when the
corresponding bits of both double words combined in the logic operation are "1".
Examples:
Bit: 31 Bit:0
ACCU 1 before execution of AD: 0101 0000 1111 1100 1000 1001 0011 1011
ACCU 2 or 32-bit constant: 1111 0011 1000 0101 0111 0110 1011 0101
Result (ACCU 1) after execution of AD:0101 0000 1000 0100 0000 0000 0011 0001
Examples:
Bit: 31 Bit:0
ACCU 1 before execution of OD: 0101 0000 1111 1100 1000 0101 0011 1011
ACCU 2 or 32-bit constant: 1111 0011 1000 0101 0111 0110 1011 0101
Result (ACCU 1) after execution of OD:1111 0011 1111 1101 1111 0111 1011 1111
OW OR Word (16-Bit)
OW (OR word) combines the contents of ACCU 1-L with ACCU 2-L or a 16 bit-constant bit by bit
according to the Boolean logic operation OR. A bit in the result word is "1" when at least one of the
corresponding bits of both words combined in the logic operation is "1".
Examples:
Bit: 15 Bit:0
ACCU 1-L before execution of OW: 0101 0101 0011 1011
PAGE 70
ACCU 2-L or 16 bit constant: 1111 0110 1011 0101
Result (ACCU 1-L) after execution of OW: 1111 0111 1011 1111
Bit: 31 Bit:0
ACCU 1 before execution of XOD: 0101 0000 1111 1100 1000 0101 0011 1011
ACCU 2 or 32-bit constant: 1111 0011 1000 0101 0111 0110 1011 0101
Result (ACCU 1) after execution of OD:1010 0011 0111 1001 1111 0011 1000 1110
PAGE 71
Accumulator Instructions
PAGE 72
PROGRAMMING EXAMPLES
PAGE 73
PAGE 74
PAGE 75
PAGE 76
PAGE 77
PAGE 78
PAGE 79
PAGE 80
PAGE 81
PAGE 82
PAGE 83
PAGE 84
PAGE 85
PAGE 86
PAGE 87
PAGE 88
PAGE 89
PAGE 90
PAGE 91
PAGE 92
PAGE 93
PAGE 94
----------------------------------------------------------------------------------------------------------------
THANK YOU FOR ATTENDING OUR INDUSTRIAL
AUTOMATION TRAINING COURSE !
PAGE 95