Brief details of this edition and previous editions are listed below.
The status of each edition is shown by the code in the ”Remarks” column.
Status code in
”Remarks”
column
:
A . . . New documentation
B . . . Unrevised reprint with new Order No.
C . . . Revised edition with new status. If factual changes have been made on a page since
the last edition, this is indicated by a new edition coding in the header on that page.
EditionOrder No.Remarks
01.906ZB5 410-0CM02-0BA0A
10.906ZB5 410-0CM02-0BA1C
01.916ZB5 410-0CM02-0AA2C
11.916ZB5 410-0CM02-0AA3C
05.936ZB5 410-0CM02-0AN3Supplement
Other functions not described in this documentation might be
executable in the control. This does not, however, represent an
obligation to supply such functions with a new control or when
servicing.
This publication was produced on the Siemens 5800 Office
System.
Subject to change without prior notice.
The reproduction, transmission or use of this document or its
contents is not permitted without express written authority.
Offenders will be liable for damages. All rights, including rights
created by patent grant or registration of a utility model or
design, are reserved.
This manual is intended for the manufacturers of machine tools using SINUMERIK 805.
The Guide describes the program structure and the operation set of the PLC, and explains
how basic PLC software and user programs, which comprise data blocks, function blocks,
program blocks and organization blocks, are constructed.
The SINUMERIK documentation is organized in three levels:
•User documentation
•Manufacturer documentation and
•Service documentation
The Manufacturer Documentation for SINUMERIK 805 is divided into the following:
•Instruction Manual
•Description of interfaces
Part 1: Signals
Part 2: Cables and hardware
•PLC Programming
Additional SINUMERIK publications are also available for all SINUMERIK controls (e. g.
publications on the Universal Interface, Measuring Cycles, CL 800 Cycles language).
Please contact your Siemens regional office for further details.
The PLC is a powerful interface controller. It has no inherent hardware, and is used as
”software PLC” in the SINUMERIK 805.
The PLC is responsible for control of machine-related functional sequences such as
•Controlling auxiliary axes
•Controlling tool-changers
•Gathering the signals generated by the machine's monitoring devices.
Special features:
On the SINUMERIK 805, all NC and PLC jobs are executed by a common processor
(Intel 80 186). A specially developed coprocessor (COP) is responsible for high-speed execution of binary operations and byte and word commands of the STEP 5 user program (e. g.
A I 3.0, L FW3, etc.).
The single-processor structure calls for strict priority scheduling of NC and PLC jobs. NC functions such as position control and block preparation, but also the PLC ”Interrupt processing”
function (OB 2), have highest priority, while scanning of the cyclic program (OB 1) is of lesser
importance.
The amount of processor time available to the PLC has been restricted to a maximum of 20%
in order to ensure that the NC can fulfill its primary objectives (positioning accuracy, short
block change times) even in extreme situations, e. g. where an exceptionally long STEP 5
program or frequent interrupt servicing is involved. It is also possible to influence the manner
in which the cyclic user program scanned via machine data (see Section 1.3.4).
The operations available in STEP 5 enable the user to program functions ranging from simple
binary logic to complex digital functions and basic arithmetic operations.
Depending on the programmer (PG) used a STEP 5 program may be written in the form of a
control system flowchart (CSF), ladder diagram (LAD) or statement list (STL) , thus enabling
the programming method to be adapted to the application. The machine code (MC5) generated
by the programmers is identical for all three. Depending on the programmer (PG) used, the
user program can be translated from one method of representation to another by conforming
to certain programming conventions (see Section10).
Ladder diagramStatement listControl system
Programming withProgramming withProgramming
symbols similar tousing mnemonicswith graphic
those used in sche-designatingsymbols
matic circuit dia-functions
grams
Complies withComplies withComplies with
DIN 19239 DIN 19239 IEC 117 - 15
(draft)(draft)DIN 40700
LADSTL
AI
( )
AN I
AI
ON I
OI
=Q
flowchart
DIN 40719
DIN 19239
(draft)
CSF
Methods of representing the STEP 5 programming language
The PLC software comprises the operating system, the basic software and the user program.
The operating system contains all statements and declarations for internal system functions.
The basic software has a flexible interface to the operating basic functions (e. g. generation of
data blocks, NC-PLC interface initialization, signal interchange with the peripherals). The basic
software also contains pretested function blocks written in STEP 5 and assembled to form
function macros.
The operating system and the basic software are integral components of the PLC; they are
supplied on EPROMs together with the NC system program, and may not be modified in any
way.
The user program is the total of all statements and declarations/data programmed by the user.
The PLC structure makes structured programming essential, i. e. the program must be divided
into individual, self-contained sections called blocks. This method offers the following
advantages:
•Easy, lucid programming, even of large programs
•Easy standardization of program sections
•Simple program organization
•Fast, easy modification
•Simple program testing
•Easy start-up
A number of block types, each of which is used for different tasks, is available for structuring
the user program:
•Organization blocks (OBs)
The OBs serve as interface between operating system and user program.
•Program blocks (PBs)
The PBs are used to break the user program down into technologically oriented sections.
•Function blocks (FBs)
The FBs are used to program frequently recurring complex functions (such as individual
controls, reporting, arithmetic and PID control functions).
•Sequence blocks (SBs)
SBs are special forms of program blocks used primarily for processing sequencers.
•Data blocks (DBs)
DBs are used for storing data or texts, and differ in both function and structure from all
other block types.
With the exception of the organization blocks, the maximum number of programmable blocks
of each type is 255. The number of organization blocks may not exceed 64; of these, only OB
20, PB 1 and OB 2 are serviced by the operating system (cf. Section 5).
The programmer stores all programmed blocks in arbitrary order in program memory
(Fig. 1.2).
Siemens AG 1990 All Rights Reserved 6ZB5 410-0CM021-3
The manner in which the program is organized determines whether and in what order the
program, function and sequence blocks are executed. The order in which these blocks are
involved is stipulated by programming the relevant calls (conditional or unconditional) in
organization blocks (see Section 5.4, ”Cyclic program”).
Like the other blocks, the organization blocks are stored in user memory.
PB1
PB2
•
•
FB1
•
•
DB1
•
SB10
•
FX1
•
•
OB1
Storing the blocks in arbitrary order in program
memory
OB
PB
Different organization blocks are provided for
various methods of program execution (cf.
Section 5.2).
Organization, program, function and
sequence blocks can invoke other program,
function and sequence blocks. The user
program cannot call organization blocks. The
maximum permissible nesting depth for
organization blocks is 12, not including an
accompanying data block, if any.
FBFB
FBFBPBPB
PB
PB
1
Typical program organization in STEP 5 (nesting depth 8) (max. nesting depth 12)
2
34
DBFB
DB
5678
DB
OBOrganization block
PBProgram block
FBFunction block
DB Data block
One-shot scan in the controller's restart routine following ”Power up” or ”Hardware reset”.
The statements to be executed must be programmed in OB 20.
•Cyclic scanning
For cyclic scanning 0B1 is available. This block is passed at intervals of 48 ms (up to
SW4.1: 60 ms) and calls the programmed blocks.
•Interrupt scan
Event-driven, one-shot execution of the statements in OB 2, e. g. in response to an
interrupt. Prerequisites for event-driven execution are as follows:
• Normal termination of the controller's restart routine
• Interrupt enable via PLC-MD 2002, bit 0=”0”.
• A change in the interrupt input byte specified per PLC-MD 0.
Cyclic scanning can be interrupted by the high-priority NC functions' interrupt service routine
or delayed pending termination of OB 2 following execution of each STEP 5 command.
Execution of a PLC cycle; cyclic program scanning
Before OB 1 is called and started, the basic program loads the momentary state of all
peripheral inputs into working memory. All input scans in the cycle which follows refer to this
loaded status image. It is also known as ”Process Input Image” or PII for short.
OB 1 is now called. This executes the blocks that have been called one after the other. This
process can be interrupted by one or several interrupt scans (OB 2).
When OB 1 has been worked through completely, the system program transferss the statuses
of the outputs (resulting from program execution) from the working memory to the peripheral
outputs (MDP submodules, for example).
As mentioned in Section 1.1, execution of the STEP 5 program should not take up more then
15 % of the total available CPU time, nor should the interrupt service routine in OB 2 take up
more time than necessary because of its high priority, as this would delay execution of
important NC functions.
For this purpose, the execution times of both the cyclic user program and the interrupt service
routine are monitored at the hardware level. The permissible runtimes can be set in PLC MD 1
and 3, whereby confirmation of the defaults ensures that the ”integrated PLC” will not take up
more than the admissible amount of CPU time. When these values are exceeded, the PLC
goes to the state specified in bit 0 or 1 of PLC MD 2003; when the defaults are used, the
”integrated PLC” always enters the Stop mode.
When the user programs exceed the permissible execution times only slightly, program
scanning can be upheld by modifying these machine data bits, but this may adversely affect
the NC functions.
There are two ways of ensuring the executability of large cyclic user programs without placing
an excessive load on the CPU:
•Fragmenting cyclic execution through autonomous interrupts
•Allowing cyclic execution to be interrupted by higher-priority program blocks only
The mode is set in PLC MD 2003, bit 6. The percentage in PLC MD thus assumes the
following meaning as regards the scan time:
•No fragmenting (bit 6 of MD 2003 = 0 ˆ= default):
15% of the cyclic program's timing grid (48 ms) results in a permissible runtime of 7.2 ms.
•Fragmenting (bit 6 of MD 2003 = 1)
15% of 1/3 of the cyclic program's timing grid (48 ms) results in a runtime of 2.4 ms. The
cyclic program then interrupts itself autonomously, and resumes execution in the next
third.
Grafic overview of the two methods for cyclic program scanning
Note: OB 1 (cyclical user program) can only be called up in the 48 ms grid (up to SW 4.1:
The timing grid,of cyclic program scanning is 12 x the scanning time of the position control
(12 x 4 ms = 48 ms; up to SW 4.1: 12 x 5 = 60 ms).
The admissible execution time of the cyclic program for both variants can also be increased by
augmenting PLC MD 1 (CPU load in %).
The admissible runtime for the interrupt service routine (PLC MD 3), regardless of the cyclic
execution mode, may not exceed 2000 us in an interval of 4 * scanning time (4 x 4 ms =
16 ms; up to SW 4.1: 4 x 5 = 20 ms).
The entire runtime may either be used for one-shot execution of the statements in OB 2 or, in
an extreme situation, for 4-shot execution of OB 2, as the interrupt input byte is scanned for an
edge change on the basis of the scanning time. If the default runtime for OB 2 proves
µ
insufficient, PLC-MD 3 must either be incremented (to max. 2500
s) or the PLC set to the
Stop mode when OB 2 exceeds the allotted time by modifying bit 1 in PLC MD 2003. The
example on the next page emphasizes the difference between the two variants for a cyclic
user program with a runtime time of 25 ms.
No fragmentation:
The cyclic user program may be interrupted by higher-priority NC and PLC program blocks
only ( e. g. position control, interpolation, monitoring functions, programming and test
functions, interrupt service routine (OB 2)). It is otherwise continued until it has terminated and
all signals it generated habe been forwarded to their destinations (NC, I/Os). Only then can the
low-priority functions execute.
Depending on the size of the STEP 5 program in OB 1, the remaining interval may be quite
shorte, as the operating system recalls the cyclic program when 48 ms (up to SW 4.1: 60 ms)
have passed. The consequence is that too little time is available for the low-priority functions, a
fact which becomes immediately apparent in a sluggish ”operator interface”. Display
construction is extremely slow, as is the controller's reaction to keyboard entries. In extreme
situations, the low-priority functions are allatted almost no time at all to execute.
In the example, (runtime of cyclic user program = 25 ms, SW 4.2 installed) the CPU load
caused by the STEP 5 program alone would escalate to value x, where
x =
25 ms
48 ms
.
100 % =
52 % , assuming that cyclic execution
is terminated within 48 ms. In the example, no regard was paid to the 5% basic load resulting
from data transfers prior to and following the OB 1 call.
It is obvious that a CPU load of almost 57% for the controller alone is not acceptable.
When this variant is used, the cyclic program interrupts itself autonomously. If the default is
used (values for SW 4.2), the CPU load, referred to the cyclic program timing grid, would be:
x =
2.4 ms . 3
48 ms
.
100 %=15 %
The basic load for the cyclic program, about 5%, must be added to this, so that the cyclic
program load on the CPU would always be 20 %. It is less than 20% when cyclic execution
is not terminated within one timing period. Extremely long cyclic user programs may cause the
cycle time monitor to response (default: 300 ms).
Note:
By selecting the diagnostics function (PLC MD 2003, bit 7 = 1), the user can obtain a general
view of the anticipated run time for STEP 5 programs as well as the required cycle time. On
the basis of these data, he can optimize the configuration of his MD as regards his job
requests and the purpose for which the controller is to be used (cf. section 8 ”Error Analysis”).
Siemens AG 1990 All Rights Reserved 6ZB5 410-0CM021–9
The information presented in this Section applies to the programming of organization (OBs),
program (PBs) and sequence blocks (SBs). These three block types are all programmed in
the same way. Section 3 gives information on programming data blocks and Section 4 information on programming function blocks. Program, organization and sequence blocks can be
programmed in all three STEP 5 modes of representation using the basic operations.
The following description deals with program blocks by way of example.
The first step in programming a program block (PB) is the specification of a program block
number between 0 and 255 (example: PB 25). This is followed by the actual control program,
which is terminated with a ”BE” statement.
An S5 block comprises two parts:
• Block header
•S5 operations (block body)
The block header, which the programmer generates automatically, takes up five words in
program memory.
A program block should always be a self-contained program.
Logical links to other blocks serve no practical purpose.
Block calls are used to release the blocks for execution. These block calls can be programmed
only in organization, sequence, program or function blocks.
(Only organization blocks may not be invoked by the user program).
A block call is comparable to a ”subroutine branch”, and may be both conditional and
unconditional.
A ”BE” statement is used to return to the block that contained the block call. No further logic
operations can be carried out on the RLO following a block call or a ”BE”. The RLO (result of
the logic operation) is passed to the ”new block”, and can be evaluated there.
Unconditional call: for example JU PB5
The program block is executed without regard to the RLO.
Conditional call: for example JC PB6
The program block is executed in dependence on the RLO.
AI 1.0AI 2.0
JU PB5
OI 5.3
AI 1.5
JC PB 6
AI3.2
BEBE
Block calls for enabling execution of a program block
The data required by the user program is stored in data blocks (DBs). No STEP 5 operations
are programmed in these blocks.
Data may be:
•Arbitrary bit patterns, e. g. for plant status indications
•Numbers (hexadecimal, binary, decimal), e. g. for times and results of arithmetic
operations
•Alphanumeric characters, e. g. for message texts
Generation of a data block on the programmer begins by specifying a data block number
between 1 and 255. Each data block (example: DB99) may comprises as many as 256 data
words (of 16 bits each). The data must be entered by word, beginning with data word 0.
One word is reserved in program memory for each data word. The programmer also generates
a block header for each data block; the header takes up five words in program memory.
The operating system generates data blocks DB1 (diagnostics DB), DB36 (read/write job
status for NC data) and DB37 (initialize the two V.24 (RS232C) interfaces) in the controller's
restart routine. The programmer (PG) prevents deletion of these blocks (message 70: DB in
EPROM).
For test purposes, however, the user can invoke the ”Force Variable” programmer function if
he wants to view or modify data words.
Data blocks can be called unconditionally only. Once called, a data block remains in force until
the next is invoked.
User data blocks must not conflict with those required by the system.
A data block call can be programmed in an organization, program, function or sequence block.
The ”A DB xxx” command calls a data block, e.g. (DB10, i.e. call from DB 10).
Example 1
Transferring the contents of data word 1, data block 10 to data word 1, data block 20.
:C DB10
:LDW1
:C DB20
:T DW1
DW255
Calling a data block
DW0
DW1
DW0
DW1
DB 10
DB 20
Example 2
When a program block in which a data block has already been addressed calls another
program block that addresses another data block, the latter is valid only in the program block
that was called. The original data block is again valid following return to the calling block.
Function blocks are used to implement frequently recurring or extremely complex functions.
Functions blocks (FBs) are as much a part of the user program as, for example, program
blocks. There are three basic differences between function blocks and organization, program
or sequence blocks:
•Function block can be initialized, i. e. a function block's formal parameters can be
replaced by the actual operands with which the function block is called.
•In contrast to organization, program and sequence blocks, an extended operation set
comprising the STEP 5 supplementary operations (see also Section 9.4) can be used to
program function blocks, and only function blocks.
•The program in a function block can be generated and logged in statement list form
only.
The function blocks in a user program represent complex, self-contained functions. A function
block programmed in the STEP 5 language can be programmed by the user himself, or may
be purchased from Siemens as a software product. In addition, a number of pretested,
technology-specific function blocks can be assembled to form function macros and linked into
the basic program. The user can call these macros as he would a function block, but he
cannot modify them. These blocks are written in assembly language and are also referred to
as ”resident” or integral function blocks” (cf. Section 6.1).
Siemens AG 1990 All Rights Reserved 6ZB5 410-0CM024-1
A function block comprises a block header, name and parameter declaration, and the block
body.
Block header
Name and parameter
declarations
Block body with STEP 5
program or assembly
language statements
Structure of a function block
4.2.1Block header
The block header contains all information which the programmer needs in order to display the
function block in graphic form and check the operands when the function block is initialized.
The user must enter the header (using the programmer) before programming the function
block.
4.2.2Block body
The block body contains the actual program, i. e. describes the function to be executed in the
STEP 5 language. Only the block body is processed when the function block is called.
The programmer echoes the block name and parameter declaration when integral assemblylanguage function blocks are called.
When the ”first executable statement” in the block body is the ”ASM” STEP 5 command
(switch to assembly code), the processor executes the subsequent assembly language
statements immediately.
Function blocks (FBs) are present only once in memory. They can be called once or more
than once by a block, and different parameters can be used for each call.
Function blocks are programmed or called by specifying a block number (FB 0 to 255).
A function block call can be programmed in an organization, sequence or program block or in
another function block. A call comprises the call statement and the parameter list.
4.3.1Call statement
Unconditional call: e.g. JU FB 30
The function block is executed without regard to the RLO.
Conditional call: e.g. JC FB 35
The function block is executed only when the RLO is in signal state ”1”.
4.3.2Parameter list
The parameter list immediately follows the call statement, and defines all input variables,
output variables and data. The parameter list may contain no more than 40 variables.
The variables from the parameter list replace the formal parameters when the function block is
executed. The programmer (PG) monitors the order in which the variables are entered in the
parameter list.
The programmer automatically generates, but does not display, the jump statement that follows
the FB call.
The FB call reserves two words in program memory, and each parameter one additional word.
The identifiers for the function block's inputs and outputs and the name of the function block
are displayed on the programmer when the user programs the function block.
This information is in the function block itself. It is therefore necessary that all required function
blocks either be resident as function macro in the PLC's basic software, be transferred to the
program diskette, or be entered directly into the programmable controller's program memory
before function block programming can begin (for details, refer to the Operating Instructions).
Siemens AG 1990 All Rights Reserved 6ZB5 410-0CM024-3