Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
49 views149 pages

C Hoch

This document provides guidance on using a block generator for creating function blocks in PL/M or C programming languages to be used in a PLC 135 WB controller. It describes the software and hardware requirements, installation process, operation of the block generator user interface through various menus, definitions of the block interfaces and parameters, and examples of programming blocks in PL/M and C. The intended audience is manufacturers or engineers programming PLC controllers.

Uploaded by

arash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views149 pages

C Hoch

This document provides guidance on using a block generator for creating function blocks in PL/M or C programming languages to be used in a PLC 135 WB controller. It describes the software and hardware requirements, installation process, operation of the block generator user interface through various menus, definitions of the block interfaces and parameters, and examples of programming blocks in PL/M and C. The intended audience is manufacturers or engineers programming PLC controllers.

Uploaded by

arash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 149

SINUMERIK 840/840C

SINUMERIK 880/880 GA2


PLC 135 WB, S5-HLL,
High-Level Language Programming
Planning Guide 11.92 Edition

Manufacturer Documentation
SINUMERIK 840/840C
SINUMERIK 880/880 GA2
PLC 135 WB, S5-HLL,
High-Level Language Programming

Planning Guide

Manufacturer Documentation

Valid for:

Control Software Version


SINUMERIK 840T/M 01 or higher
SINUMERIK 840C 01
SINUMERIK 880T/M 04 or higher
SINUMERIK 880 GA2 01

11.92 Edition
SINUMERIK® documentation

Printing history

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 the page since the last edition, this is
indicated by a new edition coding in the header on that page.

Edition Order No. Remarks


02.90 6ZB5 410-0CQ02-0BA0 A
11.91 6ZB5 410-0CQ02-0AA1 C
11.92 6FC5 197-0AC00-0BP0 C

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.

© Siemens AG 1990, 1991, 1992, All Rights Reserved


SINUMERIK 840/880C
SINUMERIK 880/880 GA2

Part 1: S5-HLL Block Generator

Planning Guide

Manufacturer Documentation
Introduction 1

Requirements for the Operation of the Block Generator 2

Installation 3

Operation 4

Interfaces of the HLL Block 5

Format of the Module Header 6

Programming with PL/M 7

Programming with C 8

Programming Examples 9

Information for the Use of the Block Generator 10

Error Messages and Warnings 11


Contents

Page

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–1

1.1 PLC Programming with High-Level Languages . . . . . . . . . . . . . . . . . . 1–1


1.2 PL/M and C Function Blocks for the PLC 135 WB . . . . . . . . . . . . . . . . 1–1
1.3 Testing the HLL Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–2
1.4 Definition of Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1–2
1.5 Modifications since the Preceding Version . . . . . . . . . . . . . . . . . . . . . 1–3

2 Requirements for the Operation of the Block Generator ......... 2–1

2.1 Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–1


2.2 Software Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2–1

3 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–1

3.1 Required Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–1


3.2 Installation Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–1
3.3 Integration of the Program Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–3
3.4 Installation Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–4
3.5 Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3–6

4 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–1

4.1 General Operating Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–1


4.1.1 Menu Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–1
4.1.2 Default Settings in Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–2
4.1.3 Use of Upper and Lower Case Letters for Input . . . . . . . . . . . . . . . . . . 4–2
4.2 Block Generation Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–2
4.3 Calling the Block Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–4
4.4 Parameters for HLL Block (Menu 1) . . . . . . . . . . . . . . . . . . . . . . . . . . 4–4
4.4.1 Define Key Data of HLL Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–5
4.4.2 Function Keys and Special Keys in Menu 1 . . . . . . . . . . . . . . . . . . . . . 4–7
4.5 Define Directories (Menu 1.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–8
4.5.1 Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–9
4.5.2 Function Keys and Special Keys in Menu 1.1 . . . . . . . . . . . . . . . . . . . 4–9
4.6 Select Processing Steps (Menu 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–10
4.6.1 Description of the Processing Steps . . . . . . . . . . . . . . . . . . . . . . . . . . 4–11
4.6.1.1 Define Block Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–11
4.6.1.2 Change Block Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–11
4.6.1.3 Create Block Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–11
4.6.1.4 Generate Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–11
4.6.1.5 Prepare Block for Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–11
4.6.1.6 Check Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–12
4.6.2 Function Keys in Menu 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–13
4.7 Define/Change Call Parameters (Menu 5) . . . . . . . . . . . . . . . . . . . . . . 4–14
4.7.1 Block without Call Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–14
4.7.2 Block with Call Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–15
4.7.2.1 Add Call Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–15
4.7.2.2 Change Call Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–16
4.7.3 Exit Menu 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–17
4.7.4 Function Keys and Special Keys in Menu 5 . . . . . . . . . . . . . . . . . . . . . 4–17
4.8 Define/Change System Interface (Menu 6) . . . . . . . . . . . . . . . . . . . . . 4–19
4.8.1 Function Keys and Special Keys in Menu 6 . . . . . . . . . . . . . . . . . . . . . 4–20
4.9 Edit HLL Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4–21
4.10 Compile and Link HLL Block (Menu 3) . . . . . . . . . . . . . . . . . . . . . . . . 4–21
4.10.1 Function Keys and Special Keys for Menu 3 . . . . . . . . . . . . . . . . . . . . 4–22
4.11 Generate S5-DOS Block File (Menu 4) . . . . . . . . . . . . . . . . . . . . . . . . 4–23
4.11.1 Define S5-DOS Block File Name and Block List . . . . . . . . . . . . . . . . . . 4–23
4.11.2 Function Keys and Special Keys in Menu 4 . . . . . . . . . . . . . . . . . . . . . 4–24

5 Interfaces of the HLL Block .............................. 5–1

5.1 Type and Scope of the Block Interfaces . . . . . . . . . . . . . . . . . . . . . . . 5–1


5.2 STEP 5-Specific Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–1
5.3 Call Parameters of HLL Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–3
5.3.1 Types of Call Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–3
5.3.2 Data Format Conversion for Call Parameters . . . . . . . . . . . . . . . . . . . . 5–4
5.4 PLC System Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–4
5.4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–5
5.4.2 HLL_ADB(), Open Data Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–5
5.4.3 HLL_S5(), Call STEP 5 Program Blocks ...................... 5–6
5.4.4 HLL_MACRO(), Call Function Macro . . . . . . . . . . . . . . . . . . . . . . . . . 5–6
5.4.4.1 Available Function Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–7
5.4.4.2 Passing Parameters to Function Macros . . . . . . . . . . . . . . . . . . . . . . . 5–8
5.4.5 HLL_HLL(), HLL Block Calls HLL Block . . . . . . . . . . . . . . . . . . . . . . . 5–8
5.4.6 HLL_LIM(), HLL_SIM(), Disable and Enable OBs ................ 5–9
5.4.7 HLL_STOP(), Initiate System Stop .......................... 5–11
5.5 PLC System Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–11
5.5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–11
5.5.2 I/Q/F/C/T Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–12
5.5.2.1 Process Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–13
5.5.2.2 Flag Area and Extended Flag Area . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–13
5.5.2.3 Timers and Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–14
5.5.3 Interpreter Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–15
5.5.3.1 Status Bits on PLC Systems with COP/ACOP . . . . . . . . . . . . . . . . . . . 5–16
5.5.3.2 Active OB No. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–17
5.5.4 Processing of Data Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–17
5.5.4.1 Global Declaration of Data Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–18
5.5.4.2 Opening Data Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–18
5.5.4.3 Length of the Active Data Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–18
5.5.4.4 Processing of Data Blocks with Pointers . . . . . . . . . . . . . . . . . . . . . . . 5–19
5.5.5 Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–19
5.5.6 Block and I/O Address Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5–21
5.5.6.1 Block Address Lists on PLC Systems with COP/ACOP . . . . . . . . . . . . . 5–21
5.5.6.2 I/O Address Lists on PLC Systems with COP/ACOP . . . . . . . . . . . . . . 5–22
6 Format of the Module Header ............................ 6–1

6.1 Task of the Module Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6–1


6.2 Call Parameter Definitions in the Module Header . . . . . . . . . . . . . . . . . 6–1
6.3 Evaluation of the Module Header by the Block Generator . . . . . . . . . . . 6–4
6.3.1 Operating Situations in which the Module Header is Evaluated . . . . . . . 6–4
6.3.2 Criteria for Cancellation of Evaluation of the Module Header . . . . . . . . . 6–4

7 Programming with PL/M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7–1

7.1 Language-Specific Features of PL/M . . . . . . . . . . . . . . . . . . . . . . . . . 7–1


7.2 Format of the PL/M Module Body . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7–1
7.2.1 Module Body of a PL/M Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7–3
7.2.1.1 Module Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7–3
7.2.1.2 Compiler Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7–4
7.2.1.3 Module Block and Literally Declarations . . . . . . . . . . . . . . . . . . . . . . . 7–4
7.2.1.4 External Declarations of System Data and Functions . . . . . . . . . . . . . . 7–4
7.2.1.5 Procedure Declaration of Main Program, Call Parameters . . . . . . . . . . . 7–6
7.2.1.6 Local Data and Statement Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7–7
7.3 Parameter Check for HLL Calls in PL/M . . . . . . . . . . . . . . . . . . . . . . . 7–7
7.3.1 Parameter Data Types Recognized in the Parameter Check . . . . . . . . . 7–7
7.3.2 Cross-Reference List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7–8
7.4 Brief Examples for PL/M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7–8
7.5 Rules for Upper and Lower Case Notation . . . . . . . . . . . . . . . . . . . . . 7–10
7.6 Reserved Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7–10

8 Programming with C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–1

8.1 Language-Specific Features of C . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–1


8.2 Format of the C Module Body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–1
8.2.1 Module Body of a C Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–2
8.2.1.1 Module Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–3
8.2.1.2 Definition of Types of Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–3
8.2.1.3 External Declarations of System Data and Functions . . . . . . . . . . . . . . 8–3
8.2.1.4 Procedure Declaration of Main Program, Call Parameters . . . . . . . . . . . 8–5
8.2.1.5 Local Data and Statement Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–6
8.3 Brief Examples for C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–6
8.4 Processing of Data Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–9
8.5 Use of C Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–11
8.6 Rules for Upper and Lower Case Notation . . . . . . . . . . . . . . . . . . . . . 8–12
8.7 Reserved Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8–13

9 Example Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–1

9.1 Examples in PL/M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–1


9.1.1 FB 1, Access to Data Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–1
9.1.2 FB 2, Access to Process Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–6
9.1.3 FB 4, Processing of Counters and Timers . . . . . . . . . . . . . . . . . . . . . . 9–9
9.1.4 FB 6, Search in Data Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–12
9.1.5 FB 8, Call Other HLL Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–15
9.1.6 FB 10, FB 15, Use of Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–18
9.1.7 FB 20, I/O Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–22
9.2 Examples in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–26
9.2.1 FX 1, Access to Data Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–26
9.2.2 FX 2, Access to Process Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–30
9.2.3 FX 4, Processing of Counters and Timers . . . . . . . . . . . . . . . . . . . . . . 9–33
9.2.4 FX 6, Search in Data Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–36
9.2.5 FX 8, Call Other HLL Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–40
9.2.6 FX 10, FX 15, Use of Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–43
9.2.7 FX 20, I/O Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9–47

10 Information for the Use of the Block Generator ............... 10–1

10.1 Information for the Use of HLL Programs


on the Programmable Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10–1
10.2 Restrictions for the Use of the Block Generator . . . . . . . . . . . . . . . . . . 10–2
10.3 Restrictions for Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10–2
10.3.1 General Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10–2
10.3.2 Further Restrictions for C Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10–3

11 Error Messages and Warnings ............................ 11–1

11.1 Error Messages from the HLL Block . . . . . . . . . . . . . . . . . . . . . . . . . . 11–1


11.2 Error Messages of Block Generator . . . . . . . . . . . . . . . . . . . . . . . . . . 11–2
11.3 Warnings of Block Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11–2
11.92 1 Introduction
1.1 PLC Programming with High-Level Languages

1 Introduction

1.1 PLC Programming with High-Level Languages

The PLC 135 WB is programmed with the control language STEP 5. This language is tailored
to the needs of a programmable logic controller, i.e. to high-speed bit processing.
The tasks performed by the PLC as an interface between numerical controls (NC) and
machine tools have increased enormously over the years. The PLC has taken on a key role in
the powerful combination of NC and machine.
PLC programs have become so complex that high-level programming languages have
emerged as powerful tools for programming the PLC. Program branches, conditions and the
processing of large data blocks can be programmed faster and more compactly in high-level
languages than in STEP 5. Structogram generators are also available for high-level languages
for the graphical description of program structures and the automatic generation of high-level
language source code (e.g. XTOOLS).
When programming the PLC, the high-level language compiler must generate code and
runtime-optimized machine programs, because the program memory has to be utilized as
effectively as possible and the programs are components of a real-time system.
The availability of software development tools for many high-level languages even makes it
possible to create and test programs on standard PCs.

1.2 PL/M and C Function Blocks for the PLC 135 WB


The S5-HLL block generator supports the formulation of function blocks for the PLC 135 WB
in the high-level languages PL/M and C. Compilers for these languages, which are produced
by the intel Corporation especially for the processors used in PLCs, enable PLC programmers
to utilize the full potential of the languages STEP 5, PL/M and C, with the aid of the S5-HLL
block generator.
The S5-HLL block generator performs the following main tasks:
• Menu-driven definition of the key data for the block and block interfaces
• Automatic generation of the module body for the block
• Integrated program editors for the creation of the block program
• Generation of the function block from the source code
• Generation of S5 block files with multiple function blocks
• Management of the high-level language program blocks from interface definition to S5
block file

The following are obtainable for the block generator:


• The HLL data generator, which enables testing of HLL function blocks on the PC in
combination with a standard high-level language debugger; the system environment is
simulated
• The HLL on-line debugger for testing the programs on the target hardware

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 1–1


SINUMERIK 840/880 Part 1 (PJ)
1 Introduction 11.91
1.3 Testing the HLL Function Blocks

1.3 Testing the HLL Function Blocks


The high-level blocks generated with the S5-HLL block generator can be tested both on-line
and off-line.

Off-line test
In combination with a standard high-level language debugger, the HLL data generator enables
the HLL blocks to be tested on the same PC on which they are programmed. The PLC is
simulated with the aid of the data generator. The PLC system data can be displayed and
modified.

On-line test
The HLL on-line debugger enables the HLL blocks to be tested on the PLC. You can use a
programming device to test the operation of your HLL function blocks directly in the application
environment.

1.4 Definition of Terminology

In order to prevent misunderstandings and to make the documentation as concise as possible


by avoiding unnecessary repetition, terms which occur frequently are defined below. You can
also refer to the section entitled "Terms and Abbreviations" at the end of this documentation
(Appendix).

HLL
Abbreviation for high-level language. HLL is used as a synonym for the languages PL/M and/or
C, particularly in cases where it is irrelevant whether the language is PL/M or C.

PLC
In this documentation, the term PLC always refers to the PLC 135 WB. A distinction is made
between the PLC 135 WB version with the COP coprocessor and the version with the ACOP
coprocessor.

PLC system data


The term PLC system data refers to all PLC data which can be accessed by an HLL program
block (e.g. process image, I/Os, etc.).

PL/M
The term PL/M always refers to PL/M-86 of the intel Corporation.

C
C always refers to iC86 of the intel Corporation.

1–2 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 1 Introduction
1.5 Modifications since the Preceding Version

1.5 Modifications since the Preceding Version


The present version 2.2 of the block generator incorporates the following main modifications
compared with the preceding version:
• The modification of the block interface, i.e. the call parameters and the use of PLC system
data, can now be performed with the block generator. In this case, the declarations of the
old block interface are deleted; please refer to the section on "Block Interfaces" and the
section on "Format of the Module Header".
• Logical drives are no longer supported. The corresponding menu has been omitted.
• The version with ACOP is also supported on the PLC 135 WB. The data to be entered in
the block have been extended with this item.
• The library number and the block name can also be changed with Version 2.1 of the block
generator. It was previously only possible to enter this data.
• The system interface to the PLC has been extended.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 1–3


SINUMERIK 840/880 Part 1 (PJ)
11.92 2 Requirements for the Operation of the Block Generator
2.1 Hardware Requirements

2 Requirements for the Operation of the Block


Generator

2.1 Hardware Requirements

A PC 16-20, PG 750 or any other IBM-compatible PC with the following configuration is


required for the operation of the S5-HLL block generator:
• A hard disk with at least 1 MB free capacity
• At least 640 KB main memory
• A Hercules graphics card or a color graphics card (CGA, EGA or VGA) or compatible
graphics card

The target hardware for the generated function blocks is the PLC 135 WB. The block
generator distinguishes between versions of the PLC 135 WB with COP or with ACOP.

2.2 Software Requirements

The block generator runs under MS-DOS. The following software components are required:
• S5-HLL block generator for SINUMERIK (Siemens, Version 2.2)
• ASM86 for DOS (intel, Version 2.1)
• PL/M-86 for DOS (intel, Version 2.7)
• iC-86 for DOS (intel, Version 4.1)
• LINK86 for DOS (intel, Version 2.7)
• LOC86 for DOS (intel, Version 2.5)
• OH86 for DOS (intel, Version 1.1)
• SuperCopy (Comfood Software GmbH)
• Program editor (e.g. Aedit, Word, etc.)

Compatible versions can also be used.


If required, a structogram editor such as XTOOLS can be used for the development of HLL
blocks for the application software.
The function blocks generated with the block generator are intended for use on the PLC 135
WB and require a system environment with the PLC operating system and a STEP 5 standard
program which calls the HLL function blocks.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 2–1


SINUMERIK 840/880 Part 1 (PJ)
11.91 3 Installation
3.1 Required Programs

3 Installation

This chapter describes the installation of the S5-HLL block generator on your MS-DOS
computer.

3.1 Required Programs


The installation program INSTALL.EXE and the files of the block generator are stored on the
program diskette containing the S5-HLL block generator.
In addition to the files on the block generator program diskette, you will also require the
following programs for the installation of the block generator:
• PLM86 (PL/M compiler)
• iC86 (C compiler)
• ASM86 (Assembler)
• LINK86 (Linker)
• LOC86 (Locator)
• OH86 (Hex converter)
• SuperCopy
• Program editor (e.g. Aedit, Word, etc.)

The producers of these programs and permissible versions are listed in the section entitled
"Requirements for the Operation of the Block Generator".

3.2 Installation Program

On the supplied diskette, you will find the installation program INSTALL.EXE, which is used to
install the S5-HLL block generator on your hard disk. Insert the diskette in a diskette drive on
your computer and change to this drive. To start the program, enter the following command in
the command line:

INSTALL

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 3–1


SINUMERIK 840/880 Part 1 (PJ)
aaaaaaaaaaaa aa a
aa
aa
aa
aa
a
aaaaaa a
aaa
aa
a a
aa
aa
aa
aa aaaaaaaaaa

3–2
aaaaaaaaaaaaaaaaaaaaaaaa aa
aaa
aaa
aa
a a
aa
aaa
aaa
aaaa
aaa
a
aaaaaaaaaa
aaaa aaaaaaaa aaaaaaaaaa




aaaaaaaaaaaa aaaa aaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaa

Paths
aaaaaaaaaaaa a
aa
aa
aa
a aaaa
aaaaa
aa
aa
aa aaaaaaaaaa
aaaa aa
a aaaaaaaaaa
3 Installation

aaaaaaaaaaaaaaaaaa a
aa
aa
aa
a
aa
a
a
aa
a
aa
aaa
a aaaaaaaaaa
aaaa aaaaa

Installation Menu
aaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaa
aaaa aaaaaaaa aaaaaaaaaa

Object Files
Source Data
aaaaaaaaaaaaaaaaaa aaa aaaaaaaa

System Data
aa
a aaaaaaaa aaaaaaaaaa

Program Lists
aaaaaaaaaaaaaaaaaa aa
aaaa aaaaaaaa

Copy
Copy
aaaaaaaaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaa
3.2 Installation Program

Block Generator
aaaaaaaaaaaaaaa a
aa
aa
aa
a aaaa
aa
aa
aa
aa
a
aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa a
aa
aa
aa
aa aaaaaaaaaa
aaaaaaaaaaaaaaaaaa aa
a aa
aaa
a aa
aaaaa
aaa
a
aaaaaaaaaa
a
aa
aa
aa
a a
aa
aa
aa
aa
a
aaaaaaaaaa

:
:
:
:
aaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaa
aaaaaaaaaaaaaaa a
aa
aa
aa
a aaaa
aa
aa
aa
aa aaaaaaaaaa
aaaaaaaaaaaaaaaaaa a
aa
aa
aa
a aa
aaaaa
aaa
a
aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a
aaaaaaaaaa
aaaa aaaaa aaaaaaaaaa

Definition of the Directories for Installation


aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
aaaaaaaaaaaa aaa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
aaaaaa aa
a
a
aa
aaa
a a
aa
aa
aa
aa
a aaaaaaaaaa

structure to be used for the installation.


aaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
a aaaa
aaaaa
aa
aa
aa
a aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa

> C:\PLM
aaaaaaaaaaaa aa
aaa
aa
a aaaa
aa
a aaaaaaaaaa
aaaa aa
aaa
aaa
SINUMERIK S5-HLL Installation Program

aaaaaaaaaaaa aaaa aaaaa aaaaaaaaaa

SINUMERIK S5-HLL Installation Program


aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
Welcome to

aaaa aaaaa

> C:\PLM\LIST
aaaaaaaaaaaa aaaa aaaaa aaaaaaaaaa
aaaaaa a
aa
aa
aa
a aaaa
aa
a aaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
a aaaaa
a
aaaa
aa
a
aa
aaa
a aaaaaaaaaa

> C:\PLM\OBJECT
for the block generator

aaaa aaaaa

> C:\PLM\SOURCE
the installation program

aaaaaaaaaaaa aaaa aaaaa aaaaaaaaaa


Press function key F8 to exit the installation.

aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
aaa aaaaa
Then start the installation with function key F2.

aaaaaaaaaaaa aaaa
a aaaaa aaaaaaaaaa
aaaaaaaaaaaa a
a
aa
aaa
a a
aa
aa
aa
aa
a aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
aaaaaa aa
aaa
aa
a aaaa
aa
a aaaaaaaaaa
aaaa aa
aaa
aa
aa
aa
aaa

<
<
<
<
aaaaaaaaaaaaaaaaaaaaaaaaaaa aaaa aaaaaaaa aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
aaaa aaaaa
Block Generator

Block Generator
aaaaaaaaaaaa aaaa aaaaa aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a aaaa
aa
a aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a
aa
a
a
aa
a
aa
aaa
a aaaaaaaaaa
aaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
aaaa aaaaaaaa

© Siemens AG 1990 All Rights Reserved


aaaaaaaaaaaaaaaaaaaaaaaa aaaa aaaaaaaa aaaaaaaaaa
aaa aaaaaaaa
When you press the Return key, the following menu appears on the screen:

aaaaaaaaaaaaaaa aaaa
a aaaaa aaaaaaaaaa
aaaaaaaaaaaa a
a
aa
aaa
a a
aa
aa
aa
aa
a aaaaaaaaaa
Menu 1

Menu 1
aaaa aaaaa
To start, define your individual path environment with function key F1.

aaaaaaaaaaaa aaaa aaaaa aaaaaaaaaa


aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
aaaaaaaaaaaa aa
aaa
aa
a aaaa
aa
a aaaaaaaaaa
aaaaaaaaaaaa a
a
aa
aaa
a
aa
a
a
aa
a
aa
aaa
a aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
When you press function key F1, a menu appears in which you can define the directory

aaaaaaaaaaaaaaaaaaaaaaaa aaaa aaaaaaa


aaaaaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
a aa
aaa
aa
aa
aaaa
aaa
a
aaaaaaaaaa
aaaa aaaaaaaa aaaaaaaaaa

End
End

aaaaaaaaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
a aaaaaaaaaa
aaaaaaaaaaaa a
aa
aa
aa
a a
aa
aa
aa
aa
a aaaaaaaaaa
Version 1.1

aaa aaaaa
Version 1.1

aaaaaaaaaaaa aa
a aaaaa aaaaaaaaaa

SINUMERIK 840/880 Part 1 (PJ)


aa
aaaa aaaaa
11.92

6FC5197-0AC00-0BP0
aaaaaaaaaaaa aaaa
aaaaaa aaaaa
a
11.92 3 Installation
3.2 Installation Program

The software suggests default directories for the standard installation of the block generator.
The following files are stored or are expected to be found in the following separate directories:
Block generator:
System Data All data relating to the block generator are stored here.
Source Data The C or PL/M source files are stored here.
Object Files The compiled, linked and located HLL blocks are stored here.
Program Lists The program lists and MAP files of the HLL blocks are stored here.

The conventional editing keys are available for changing the default directories: Ins, Del, BS,
Home, Ret and the cursor control keys. If you change the name of a directory, you can restore
the old name by pressing the Escape key as long as the cursor is positioned in the field.
When you have defined all the directories, start the installation by pressing F2.
The installation then proceeds as follows:
• The defined directories are created.
• The batch file INST.BAT is started. This file copies the files from the supplied diskette into
the directories which you have defined on the hard disk.

When all the files have been copied, you can exit the installation program by pressing function
key F8.

Note:
When installing the HLL data generator, the directories which you define for the block
generator must be the same as entered here.

3.3 Integration of the Program Editor

A program editor call is integrated in the block generator. You can thus edit HLL programs
directly by calling the program editor from the block generator. You can choose your own
program editor; the AEDIT editor (intel) is the default setting.
The program editor is called by the block generator via the batch file EDIT_HLL.BAT. You can
integrate the desired program editor (or, to be more precise, you can integrate the call) by
editing the EDIT_HLL.BAT file. In the most straightforward case (where the editor is stored
within the search path of the operating system) you will only need to change the name of the
default editor (AEDIT).

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 3–3


SINUMERIK 840/880 Part 1 (PJ)
3 Installation 11.92
3.3 Integration of the Program Editor

Suggestion for EDIT_HLL.BAT:


aedit %3%4%5,%6%7%8

Meaning of parameters %1 ... %8:


%1 Current drive
%2 Current path
%3 Drive where the source file to be edited is stored
%4 Path of the source file to be edited
%5 Name and extension of the source file to be edited
%6 Drive where the list file to be edited is stored
%7 Path of the list file to be edited
%8 Name and extension of the list file to be edited

Parameters %1 to %8 for the batch file are passed by the block generator.

Note:
Following processing of the batch file by the operating system, the same current directory and
drive must be set as when the block generator was called. If the current directory is changed
in EDIT_HLL.BAT, it must be reset at the end of EDIT_HLL.BAT using parameters %1 and
%2.
Example for EDIT_HLL.BAT with directory change:
c:
cd \editor
editor %3%4%5
%1
cd %2

The block generator expects to find the file EDIT_HLL.BAT in the current directory (the
directory that was set when the block generator was called). This allows any user to use a
program editor of his choice without having to modify the installation of the block generator.

3.4 Installation Procedure

This section summarizes all the steps for installing the block generator with the aid of the
installation program.

Installation steps:
• Start the computer
• Insert the program diskette containing the S5-HLL block generator in drive A: of your
computer.
• Make drive A: the current drive by entering A: and pressing the Return key.
• If a README file is stored on the program diskette, please read this file and follow the
instructions provided.
• Start the installation program by entering INSTALL and pressing the Return key.
• Enter the desired directory names in the menu of the installation program.

3–4 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 3 Installation
3.4 Installation Procedure

• Start the file transfer for the block generator by pressing function key F2. When the
required directories have been set up and the files have been copied from the program
diskette, you can exit the installation program by pressing function key F8.
• Press function key F1 to call up the menu for entering the directories. Enter the desired
directory names.
• Install the programs
PLM86
iC86
ASM86
LINK86
LOC86
OH86
in the directory which you have defined in the installation menu as the system directory for
the block generator. Please follow the installation instructions provided by the
manufacturers of these programs.
• Install the SUPERCOPY program in accordance with the instructions of the manufacturer.
• Define the program editor:
In the file HLL_EDIT.BAT, specify the program editor which you want to use to edit HLL
programs from the block generator (see the section entitled "Integration of the Program
Editor"). If the program editor is not yet ready for operation, please install it now on your
computer.
• Check the FILES command:
The block generator opens up to 10 files simultaneously. Check whether the value in the
FILES command in the CONFIG.SYS file on your computer is sufficiently high and
increase the number if necessary.
• Specify the screen type:
If the computer on which you install the block generator has a plasma screen, you must
include the following entry in the AUTOEXEC.BAT file of your computer (please remember
to enter the command in upper case letters):
SET SWSCREEN=MONO
When you have done this, restart your computer to invoke the command. In the event of
an operating system error message (such as "Insufficient environment memory"), please
consult your DOS manual.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 3–5


SINUMERIK 840/880 Part 1 (PJ)
3 Installation 11.92
3.5 Files and Directories

3.5 Files and Directories


The block generator distinguishes between the following directories:
• Directory with system programs
• " " system data
• " " source programs
• " " object files
• " " lists
• S5-DOS directory
• Current directory

The paths to these directories are defined during the installation and can be displayed and
modified in Menu 1.1 "Define Directories" of the block generator (see the section entitled
"Operation"). The directory with the system programs and the S5-DOS directory are not yet
required at the time of installation. Please enter these directories in Menu 1.1. The current
directory is the directory which is active when you call the block generator.
The following list shows which files of the block generator are stored or are expected to be
found in the individual directories.

• Directory with system programs:


The following programs must be stored here:
– PLM86
– iC86
– ASM86
– LINK86
– LOC86
– OH86

Note:
If no path for the system programs is specified in Menu 1.1 "Define Directories", the DOS
search path is used when the listed system programs are called.

• Directory with system data:


This directory must contain the files with the texts for the system data and with the located
system data.
– SYSDATxn.DBF
– DAT_COMn.LOC
with x=P for the PL/M language
x=C for the C language
and n=1 for the PLC system with COP
n=2 for the PLC system with ACOP

• Directory with source programs:


– File with assembler code for the block header (*.ASM)
– File with assembler code for the block end (*.ASM)
– Source files for the HLL blocks (*.PLM or *.C)

3–6 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 3 Installation
3.5 Files and Directories

• Directory with the object files:


– File with the object code for the block header (*.OBJ)
– File with the object code for the block end (*.OBJ)
– Object files for the HLL blocks (*.OBJ)
– All files which are to be linked to the block (e.g. *.OBJ, *.LNK, *.LOC, *.LIB)
– Files with the linked blocks (*.LNK)
– Files with the located blocks (*.LOC)
– Files with the intel hex code for the blocks (*.H86)
– Files with the prepared binary code for the blocks (*.BIN)

• List directory:
– Compiler lists for the HLL source blocks (*.LST)
– Assembler lists for the block headers and block ends (*.LST)
– Error list of the assembler (*.ERR)
– List file for diagnostics data and error messages (S5HLL.ERR)
– Cross-reference lists (*.CRF)
– Map files for the linker (*.MP1)
– Map files for the locator (*.MP2)

• S5-DOS directory:
– S5-DOS block file
– Copies of the link and list files for the HLL blocks entered in the block file (insofar as
link and list files exist for the blocks)

• Current directory:
– Batch file for calling the program editor EDIT_HLL.BAT
– Include files of HLL blocks (if no path is specified in the include statement)
– Temporary files for the block generator
– Parameter file S5.PAR with the data of the last block generator call made from this
directory

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 3–7


SINUMERIK 840/880 Part 1 (PJ)
11.91 4 Operation
4.1 General Operating Information

4 Operation

4.1 General Operating Information

The operation of the block generator is performed mainly using the function keys. Certain
other special keys are also used in some of the menus. Particular reference should therefore
be made to the meaning of the special keys in the individual menus.
The active input field is always displayed in inverse format and/or highlighted in color.
Some functions in the block generator do not require a menu. If errors occur with these
functions, the error messages appear, where possible, in the menu last displayed.

4.1.1 Menu Tree

Call block generator


a
a
a
a
a
a
aa
a
a
aaaaa
a

a
a
a
aa
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
aa
a

a
a
a
a
aa
a
a
a
a
a
a
Menu 1 Menu 1.1
a
a
a
a
a
a
a
aa
a

a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a

a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aaaa
a

Menu 2
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

Menu 3 Menu 4 Menu 5 Editor


a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
aa

Menu 6
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a

Next menu depends on input in Menu 2

Menu Tree of the Block Generator

Notes:
• If several processing steps are selected simultaneously in Menu 2, the block generator
determines the sequence of the menus and the other processing steps automatically. The
sequence of the processing steps is based on the requirements of the block generation.
• If the predefined directory structure does not match the real directory structure, Menu 1.1
"Define Directories" appears with an error message when the block generator is called.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–1


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.92
4.1.2 Default Settings in Menus

4.1.2 Default Settings in Menus


Where possible, appropriate default values are entered in the menus. These defaults are
based, for example, on:
• the last entries in that menu
• the current values for the selected block, or
• the processing steps which must be performed on the basis of your entries.

4.1.3 Use of Upper and Lower Case Letters for Input

You can use upper or lower case letters for input. The block generator converts the entries in
the menu fields to upper case.
When you use a progarm editor to edit the source files of the block programs, the input
notation (upper or lower case) is retained.

4.2 Block Generation Sequence


The following flow chart illustrates the generation sequence of an HLL block. The framed steps
in the block generation flow chart must be performed by the user; the unframed steps are
performed by the block generator.
The block generation steps can be performed individually, and the order of the individual steps
can be changed. The selection of the processing steps and their meaning are described in the
following sections on the operation of the block generator.

4–2 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
2)
1)
11.92

_______
a
aa
aa
aa
aa
aa
aa
aa
aa
a aa aa
a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa
aa
aa
a
a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa
aa
aa
a

SINUMERIK 840/880 Part 1 (PJ)


aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aa
aa
a
aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa
aaaaaa
aaaaaaaaaaaaaaaaaaa aa
aa
a
aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a aa aaaaaaaaaaaaaaaaaaa aa
aa
a

Block Generation Sequence (Principle)


aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a
aa
a
a
aaaaaaaaaaaaaaaaaaa
a aaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aaa
a
aaaaaaaaa aa aaaaaaaaaaaa aa

© Siemens AG 1990 All Rights Reserved


aaaaaaaaaaaaaaaaaa aaaaaaaaa aa aaaaaaaaaaaaaaaaaaa aaa
aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa
aaaaaa aaaaaaaaaaaaaaaaaaa aa
aa
a
aaaaaaaaaaaaaaaaaa aa
aaaaaaaa
aa
a aa aaaaaaaaaaaaaaaaaaa a
aa
a
aaaaaaaaaaaaaaaaaa a
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
aaa
a
aa
a
a
aaaaaaaaaaaaaaaaaaa
a aaaaaaaaaaaaaaaaaaa aa
aaa
a
aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aa
aa
a
or
or

aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aa
aa
a

call)
aaaaaaaa aa aaaaaaaaaaaa aa

(see section entitled "Format of Module Header")


aaaaaaaaaaaaaaaaaa aa aa
a aa aaaaaaaaaaaaaaaaaaa aa
aaaaaaaaaaaaaaaaaa a
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
aaa
a a
aa
a
aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa a
aa
aa
a
aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aa
aa
a
aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa
aaaaaa aaaaaaaaaaaaaaaaaaa aa
aa
a
aaaaaaaaa aa a
Select existing block

aaaaaaaaaaaaaaaaaa aaaaaaaaa aaaaaaaaaaaaaaaaaaa aa


a

Transfer HLL blocks


Define block key data

Check parameters 2)
Define block interface

(integrated editor call)


(integrated editor call)

aaaaaaaaa aa
aaaaaaaaaaaaaaaaaaaa aaa
Change block interface

in HLL source program

aaaaaaaaaaaaaaaaaa aaaaaaaaa aa aaaaaaaaaaaaaaaaaaa aaa

Edit HLL source program


Edit HLL source program

aaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
a
aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aa
aa
a

Generate S5-DOS block file


aaaaaaaaa aa aaaaaaaaaaaa aa

Only possible when calling other PL/M blocks from PL/M blocks
Compile HLL source program
aaaaaaaaaaaaaaaaaa aaaaaaaaa aa aaaaaa aaaaaaaaaaaaaaaaaaa aaa

6FC5197-0AC00-0BP0
Correct hex code and convert
aaaaaaaa aa a

Correct errors (integrated editor


Include any modified input/output

aaaaaaaaaaaaaaaaaa aa
a aaaaaaaaaaaaaaaaaaa aa
a
or change declarations and module header

aaaaaaaaa aa
a
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
aaa
a
aa
a
a
aaaaaaaaaaaaaaaaaaa
a
aa
aaaaaaaaaaaaaaaaaaa
aaa

link block, locate, generate hex code


parameters in HLL source program 1)

a
aa
aa
aa
aa
aa
aa
aa
aa aaaaaaaaaaaaaa aaaaaaaaaaaa a
aaaaaaaaa
a

Only relevant for HLL blocks generated with Version 1 of the block generator
Generate module body for the HLL source program

Generate ASM block header and block end, assemble,


4 Operation

4–3
4.2 Block Generation Sequence
a
aa
aa
aa
aa
a aa
a
aa
aa
aa
aa
a a
aaa
aa
aa
a

4–4
4.4
4.3
aaaaa aaaaa aa
aa
aa
aa
a
aaaaa a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
a

Note:
aaaaa aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
aaaaa aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
a S5_DOS
aaaa aaaaa
4 Operation

aaaaa aa
aa
aaaa
aaa aaaaa
a aaaaa

reactivated.
aaaaa aaaaaa aaaaa
aaaa aa
aa
aa
aa
a a
aa
aa
aa
aa
a
aaaaaaa aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
aaaaaaa a
aa
aa
aa
aa
a aaaa
aa
a
aaaaaaa a
aa
aa
aa
aa
aa
a
aa
a
a
aa
a
aa
aaa
a
aaaaaaa aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
aaaaa aaaaa

Continue Defpath
aaaaaaa aaaaaa aaaaa

SINUMERIK S5-HLL
aaaaa a
aaaa
aa
a aaaa
aa
a
a
a
aa
a
aa
aaa
a
aa
a
a
aa
a
aa
aaa
a
4.3 Calling the Block Generator

a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a

Block Name

PLC System
aaaaa aaaaaa aaaaa

Menu 1, Parameters for HLL Block

"Defpath" and of Menu 1.1).


aaaa aaaa aaaaa

Block Number
and pressing the Return key.

aaaa
aa
a a
aa
aa
aa
aa
a

Library Number
aa
aaa
aaa aaaaa
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
aaaaa aaaaa

Block Type (FB, FX)

Language (PL/M, C)
a
aa
aa
aa
aa
a aaaa
aa
a
a
aa
aa
aa
aa
a
aa
a
a
aa
a
aa
aaa
a
aaaaa a
aaa
aa
aa
aa
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
The block generator is started by entering

aaaa
aa
a aaaa
aa
a

:
:
:
:
:
:
aa
aaa
aaa aa
aaa
aaa
aaaaa aaaaa
Calling the Block Generator

a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
aa
aaaa
aa
a a
aa
aa
aa
aa
a
aaaaa a
aa
aa
a
aa
aaa
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
aaaaa aaaaa
Block Generator

>X<
aaaaa aaaaa
Parameters for HLL Block (Menu 1)

a
aa
aa
aa
aa
a aaaa
aa
a

>004<
a
aa
aa
aa
aa
a
aa
a
a
aa
a
aa
aaa
a

>PL/M<
aaaaa aaaaa

>09135<
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa a
aa
aa
aa
aa
aaaaaaa aa
aa
aaaa
aaa
a aa
aaaaa
aaa
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
a

>TOOLVERW<
aaaaa aaaaa
appears on the screen. (The data in the input fields are examples.)

a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
aa
aaaa
aa
a a
aa
aa
aa
aa
a
a
a
aa
a
aa
aaa
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
Menu 1

aaaaa aaaaa

© Siemens AG 1990 All Rights Reserved


aaaaa aaaaaa aaaaa
aaaa aa
aa
aa
aa
a aaaa
aa
a
aaaaa aa
aaa
aaa

>PLC 135WB with ACOP<


a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa a
aa
aa
aa
aa
aa
aaaaa
aaa
a aa
aaaaa
aaa
a
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a

the desired directory structure has been defined (see the description of function key F2
aaaaa aaaaaa aaaaa
aaaa aaaaa
block generator), the data of the last block to be processed from the current directory are

aaaaa aa
aa
aaaa
aaa aaaaa
a aaaaa

The block generator checks your parameters to see if the block already exists. This check
aaaaaaaaaaa aaaaa

Back
If an S5.PAR file already exists in the current directory (it is generated automatically by the

aaaa aaaaa

includes the directories which appear in Submenu 1.1. You should therefore make sure that
aaaaa
aa
aaaaa aaaaa

In this menu, you enter the basic parameters for the function block which is to be processed.
When the block generator is called, the following menu (Menu 1 "Parameters for HLL Block")

a
aa
aa
aa
aa
a a
aa
aa
aa
aa
a
aaaaa aaaa
Version 2.2

6FC5197-0AC00-0BP0
aaaaa aa
a

SINUMERIK 840/880 Part 1 (PJ)


aaaaa aa
aaa
aaa
11.92

aaaa
aaaaa
a
11.91 4 Operation
4.4.1 Define Key Data of HLL Block

4.4.1 Define Key Data of HLL Block


This section describes the meaning of the input fields in Menu 1 "Parameters for HLL Block".

Unique definition of block identification


Within the selected directory structure, an HLL block is identified by block type, block number
and programming language. If a block matching the parameters entered for the block type,
block number and programming language does not yet exist, a new block is subsequently
created. This is indicated by the following message in the lower region of Menu 1:
Note: New block will be created

When you move the cursor away from one of the input fields for the block type, block number
or programming language, the block generator checks whether a block for the current data
already exists in the defined directory structure. If the block generator finds a matching HLL
block, the remaining input fields of Menu 1 are filled with the data of this block.

Block type (FB, FX)


Input: Meaning, effect:
Space bar Switch block type
B Select block type FB
X Select block type FX
When you enter "B" or "X", the appropriate block type is set and the cursor jumps to the next
field in the menu.

Block number
Input: Meaning, effect:
0...255 Here you enter the number of the function block you want to process.
(decimal number)

Language (PL/M, C)
Input: Meaning, effect:
Space bar You enter the programming language in which the block is to be, or has
been, created. Press the space bar to change the programming
language in the display.

Block name
Input: Meaning, effect:
Alphanumeric, Here you can define a name for the block. The definition of a block
max. 8 characters name is optional and is not required for operation of the block
generator.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–5


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.92
4.4.1 Define Key Data of HLL Block

Library number
Input: Meaning, effect:
Decimal number Here you can define the number of a block library. The definition of a
library number is optional and is not required for operation of the block
generator.

PLC system
Input: Meaning, effect:
Space bar Here you can define the PLC system on which the block is to be used.
Use the Space bar to toggle the display between the PLC 135 WB with
COP and the PLC 135 WB with ACOP.

File names
This parameter defines the file name under which the block generator stores the source file for
a block. File names have the following structure:

xFyxxx.xxx

File name extension


PLM for PL/M function block
C for C function block

Block number
Value range: 000...255
Parameter with leading zeroes

Block type "FB" or "FX"

Language identifier
P for PL/M
C for C

Notes:
• When you call the block generator, the data of the last block to be processed are generally
reactivated (see note in the section entitled "Calling the Block Generator"). If there are no
parameters for previous blocks, the following fixed values appear as the defaults in
Menu 1:
– Block: FB 000
– Block Name and Library Number: unassigned
– Language: PL/M
– PLC System: PLC 135 WB with ACOP

• If the last directories to be used no longer exist, Menu 1.1 appears (see the section
"Define Directories (Menu 1.1)").
• The input fields for block type, block number, language and PLC system must be filled in.

4–6 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 4 Operation
4.4.1 Define Key Data of HLL Block

• The meaning of the PLC system for block generation is described in the section entitled
"Upwards Compatibility".
• A new block is not created until you reach the "Define Block Interface" processing step.
This processing step is therefore always selected for new blocks in Menu 2 "Select
Processing Steps".
Modifications to the library number or block name for existing blocks:
Modifications to the library number or block name only take effect when you reach the
"Change Block Interface" processing step. If you do not run this processing step following
a change to the block name or library number, the changes are cancelled.
When you change to Menu 2 "Select Processing Steps", the "Change Block Interface"
step is therefore always selected following a change to the library number or block name.
• The file names are assigned by the block generator and cannot be changed.

Examples:
• PL/M function block FB 16
File name: PFB016.PLM
• C function block FX 8
File name: CFX008.C

4.4.2 Function Keys and Special Keys in Menu 1


F1 Continue
The entries in Menu 1, for selecting and defining the block to be processed, are accepted.
They are used for further processing of the block. Menu 2 appears for the selection of the
processing steps.

F2 Defpath
Menu 1.1 appears for defining the directories.

F8 Back
Exits the block generator. The last block to be processed and the directory structure which
was used are stored in the current directory. These parameters are used as defaults the next
time the block generator is called up (from the current directory).
If you exit the block generator without having activated F1 "Continue" from Menu 2 "Select
Processing Steps", F8 "Back" in Menu 1 acts as a Cancel function. Because the block has
not been processed in this case, no data are saved.

Space bar
Use the Space bar to toggle between the valid values in the input fields for block type,
language and PLC system.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–7


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.92
4.5 Define Directories (Menu 1.1)

4.5 Define Directories (Menu 1.1)


The directories used by the block generator when processing the block are defined during
installation. The directories are displayed and can be modified in Menu 1.1. The files which the
block generators stores or expects to find in the individual directories are described in the
section entitled "Files and Directories".
When you select Menu 1.1, the current directory structure is displayed. (The paths in the input
fields of the illustrated menu are examples).
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaa
SINUMERIK S5-HLL Block Generator Menu 1.1 Version 2.2

System Programs : >C:\SYSTEM\ <


System Data : >C:\S5HLL\SYSDAT\ <
Source Files : >D:\PROJEKT\MASCHINE\PLC1\SOURCE\ <
Object Files : >D:\PROJEKT\MASCHINE\PLC1\OBJ\ <
Program Lists : >D:\LISTEN\TEMP\ <
S5-DOS Directory : >H: <
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
aaaaa
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
aaaaa
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
aa
a
a
a
a
a
a
a
Continue
a
a
a
a
a
a
a
aa
a
a
a

a
a

aa

a
a

a
a
a
aa
a
aa
Back
a
a
a
a
a
a
a
a
aa
a
a
a

a
a

aa

a
a

a
a
a
aa
a
aa
a
a
a
a
a
a
a
a
aa
a
a
a

a
a

aa

a
a

a
a
a
aa
a
aa
a
a
a
a
a
a
a
a
a
a
a
a

a
a

a
a

a
a
a
a
a
a
Menu 1.1 Defining the Directories

Notes:
• When the block generator is called, it searches in the current directory for information on
the last directory structure to be used. These settings are reactivated when the block
generator is called.
• If the block generator does not find any information on the default directory structure, the
current directory is used for all paths. In this case, the fields in Menu 1.1 are empty.
• If the defaults for the last directory structure to be used do not match the real directory
structure, Menu 1.1 appears immediately after the block generator is called. In this case,
you must change the settings in the menu.
If you do not change the incorrect paths (and activate F8 "Back" instead), the block
generator uses the current directory for all paths. The default settings are deleted.
The above situation can arise when directories are deleted.

4–8 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 4 Operation
4.5.1 Paths

4.5.1 Paths
The length of the path for the directories is limited to 30 characters (including the drive
parameter).
Paths must be terminated with a Backslash (\); if the Backslash is omitted, it is automatically
inserted by the block generator. If you only enter a drive, you do not need the Backslash; your
entry is accepted unmodified by the block generator.

4.5.2 Function Keys and Special Keys in Menu 1.1

F1 Continue
The block generator initially checks whether the directories defined in Menu 1.1 exist. If not all
of the defined directories exist, the block generator outputs an error message. If this happens,
you should correct the path. If the defined directories exist, the directory structure set in Menu
1.1 is activated immediately.
When the path check is complete, you exit Menu 1.1 and Menu 1 "Parameters for HLL Block"
appears.

F8 Back
Menu 1 "Parameters for HLL Block" reappears. Any changes which you have made in Menu
1.1 are cancelled. The parameters which were active before you selected Menu 1.1 remain
valid; no checks are performed (exception: see notes above).

, , Ret, PgUp, PgDn, Home, End


When the block generator is called, it searches in the current directory for information on the
last directory structure to be used. These settings are reactivated when the block generator is
called.

, , BS, Del, Ins


These key functions are available for editing text in the input fields.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–9


SINUMERIK 840/880 Part 1 (PJ)
a
aa
aa
aa
aa
a
aaaaa
aa
aa
aa
aa
a
aaaaaaaaaa
4.6
a
aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaa

4–10
aaaaaaaaa aaaaaaaaaa

versa.
a
aa
aa
aa
aa
aa
aa
aa
aa
a aaaaaaaaaa
a
aa
aa
aa
aa
aa
aa
aa
aa
a aaaaaaaaaa
aaaaaaaa
4 Operation

aa
aaa
aa
aa
aa
aaaa
aaa
a
aaaaaaaaaa

Continue
aaaaa
aaaaaa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaa
aaaaa
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa

Please Select:
a
aa
aa
aa
aa
a
aaaaaaaaaa

Check Block
aaaaa aaaaaaaaaa

SINUMERIK S5-HLL
aa
aaaa
aa
a aaaaaaaaaa
aaa
aaa

Generate Block
a
aa
aa
aa
aa
a
aaaaaaaaaa

PL/M Function Block:

Menu 2, Select Processing Steps


a
aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaa
aaaaa
aa
aa
aa
aa aaaaaaaaaa
aa
a aaaaaaaaaa
4.6 Select Processing Steps (Menu 2)

aa
aaa
aaa

Define Block Interface

Create Block Program


a
aa
aa
aa
aa
a
aaaaaaaaaa

Change Block Interface


a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa

Prepare Block for Transfer


a
aa
aa
aa
aa
a
aaaaaaaaaa
aaaaa
aa
aa
aa
aa
a
aaaaaaaaaa
aaaaa
aa
aa
aa
aa
a
aaaaaaaaaa
processing steps in an appropriate order.

a
aa
aa
aa
aa aaaaaaaaaa
aa
aaaaa
aaa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
>PFX004<

a
aa
aa
aa
aa aaaaaaaaaa
aaaaaa
aaaaa
aaa
a
aaaaaaaaaa
aaaaa
aa
aa
aa
aa
a
aaaaaaaaaa
aaaaa aaaaaaaaaa
Select Processing Steps (Menu 2)

aaaaa
Block Generator

a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa aaaaaaaaaa
aa
a aaaaaaaaaa
> <
> <
> <
> <

aa
aaa
aa
aa
aa
aa
aaa
>X<
>X<

aaaaa
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa aaaaaaaaaa
aa
aaaaa
aaa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
aaaaa aaaaaaaaaa
Menu 2

aaaaaaaaa

© Siemens AG 1990 All Rights Reserved


aaaaa
aaaaaa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa aaaaaaaaaa
aa
a aaaaaaaaaa
Name: >TOOLVERW<

aa
aaa
aaa
a
aa
aa
aa
aa
a
aaaaaaaaaa
aaaaa
aa
aa
aa
aa
a
aaaaaaaaaa
a
aa
aa
aa
aa
aa
aa
aa
aa aaaaaaaaaa
In Menu 2, you can enter the processing steps for the block selected in Menu 1. You can

aa
aaa
aa
aa
aa
aaaa
aaa
a
aaaaaaaaaa
define several processing steps simultaneously. The block generator executes the defined

aaaaaaaaa aaaaaaaaaa
Back

a
aa
aa
aa
aa
aa
aa
aa
aa
a aaaaaaaaaa
The processing steps are selected with an "X" or the Space bar. The Space bar has a toggle

a
aa
aa
aa
aa
a aaaaaaaaaa
function which you can use to deselect processing steps which are already selected, and vice-

aaaaa
Version 2.2

6FC5197-0AC00-0BP0
aaaaa aaaaaaaaaa

SINUMERIK 840/880 Part 1 (PJ)


aaaaa aaaaa
11.92

aaaa
aaaaa
a
11.92 4 Operation
4.6.1 Description of the Processing Steps

4.6.1 Description of the Processing Steps


4.6.1.1 Define Block Interface

This function defines the call parameters and the system interface for the new block. The
function runs in Menus 5 and 6. The block generator subsequently generates the module body
for the HLL block.

Caution:
In this processing step, the block generator creates a new block.
If this processing step is selected for an existing block,
the existing block is deleted. You are prompted
to overwrite the block or cancel the operation.

4.6.1.2 Change Block Interface

You can use this function to modify the block interface for existing blocks. Menus 5 and 6 are
also used for this function. In contrast to the "Define Block Interface" processing step, the
source file of the HLL block is not created, it is only modified.
Changes to the block name or library number which you have entered in Menu 1 are activated
during this processing step.

4.6.1.3 Create Block Program

You can edit the block with the installed editor (see the section entitled "Installation") by
calling it from the block generator.

4.6.1.4 Generate Block

In Menu 3 "Compile and Link HLL Block", you can define additional link modules with which
the block is to be linked.
The block generator creates the assembler header for the function block and compiles the HLL
source file. Following error-free compilation of the block, the block is linked and located. The
hex code for the HLL block is subsequently generated from the resulting file.

4.6.1.5 Prepare Block for Transfer

In Menu 4 "Generate S5-DOS Block File" you can define which function blocks are to be
stored together in a block file. The block generator then creates the S5-DOS block file which is
used to transfer the blocks to the PLC (or initially to the programming device).

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–11


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.92
4.6.1 Description of the Processing Steps

4.6.1.6 Check Block


The block generator checks the parameters of the HLL block calls in the current function
block. This parameter check can only be performed on blocks which have been created in the
PL/M language and compiled without errors. If the HLL block still contains errors, particularly
violations of the block structure, the results of the parameter check will be purely arbitrary.
For the parameter check, the block generator must be able to access the source files of all the
HLL blocks called in the PL/M block and all the Include files used. If the block generator
cannot find these files, it cancels the parameter check and outputs an error message.
During the parameter check, the block generator produces a cross-reference list of all HLL
blocks called by the block being checked. This cross-reference list is stored in the list
directory defined in Menu 1.1 "Define Directories". The file name differs from the source file
only with respect to the file name extension. File names for cross-reference lists always have
the extension ".CRF".

***********************************************************
* *
* SINUMERIK Block Generator S5-PL/M Version 2.2 Date 10.08.91 *
* Directory of all blocks called from: FB 8 Page: 1 *
* *
***********************************************************

Block Called in File


Type Number Name name Line Parameters

FB 2 I/Q/F PFB008.PLM 99 NR : D KF
NR1 : I BY

4–12 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 4 Operation
4.6.2 Function Keys in Menu 2

4.6.2 Function Keys in Menu 2


F1 Continue
The block generator executes the processing steps selected in Menu 2 in a logical sequence.
Further menus and/or messages are displayed on the screen.
When all selected steps have been executed, Menu 1 reappears on the screen.

F8 Back
Menu 1 is displayed again. The selected processing steps are not executed, however the
selections that you made in Menu 2 are retained.

, , , , Ret, PgUp, PgDn, Home, End


You can use these keys to select the desired input field. The page keys and the Home and
End keys move the cursor to the first or last input field. You cannot exit an input field that
contains illegal characters ("X" or the space character are legal).

Space bar
The Space bar can be used to set or cancel selections in the input fields. The Space bar acts
as a toggle function.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–13


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.92
4.7 Define/Change Call Parameters (Menu 5)

4.7 Define/Change Call Parameters (Menu 5)


In Menu 5, you define the call parameters for the block. The function block is displayed as a
graphical symbol in Menu 5; the inputs and outputs of the function block correspond to the call
parameters.
Call parameters can be redefined in Menu 5, and parameters which are displayed can be
modified or deleted.

4.7.1 Block without Call Parameters

A new function block will initially have no call parameters. In Menu 5, a block without
parameters is represented by an empty box. The block generator asks you whether call
parameters are to be assigned to the block. In this case, Menu 5 will have the following
appearance:
aaaaaaaaaa
aaaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaa
aaaaaaaaaa
aaaaaa
aaaaaa
aaa
aaaaaaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaa
aaaaaaaaaa
aaaaaa
aaaaaa
aaa
aaaaaaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaa
aaaaaaaaaa
aaaaaa
aaaaaa
aaa
aaaaaaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaa
aaaaaaaaaa
aaaaaa
aaaaaa
aaa
aaaaaaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaa
aaaaaaaaaa
SINUMERIK S5-HLL Block Generator Menu 5 Version 2.2
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
PL/M Block: FX 004
Block Name: TOOLVERW
Library Number: 9135

Assign parameters to this block?


a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
aaaa
a
a
a
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
a Yes No
a
a
a
a
a
a

a
a
a
a

a
a

aa

a
a

a
a
a
a
a
a
a
a

a
a
a
a

a
a

aa

a
a

a
a
a
a
a
a
a
a

a
a
a
a

a
a

a
a

a
a

Menu 5, Define/Change Call Parameters

Use function keys F1 and F2 to define whether or not call parameters are to be assigned to
the block.
If you enter "No" with function key F2, Menu 6 "Define/Change System Interface" appears
and no call parameters are assigned to the function block.
If you press function key F1 for "Yes", you are prompted to enter a parameter name.

Note:
If you change the interface on existing blocks which do not have call parameters, the block
generator responds in the same way as with a new block.

4–14 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 4 Operation
4.7.2 Block with Call Parameters

4.7.2 Block with Call Parameters


In Menu 5, the call parameters are represented by terminals on a block symbol (similar to a
STEP 5 function chart). Each of these symbolic terminals is labelled with the parameter name,
the parameter type and its data type. Inputs, constants, timers and counters which are used as
call parameters are displayed on the left of the block symbol and outputs are displayed on the
right.

INDX I Byte Q DWord STAT


SRC I Word Q Bit OK
INP1 I Bit
INP I Bit
ACTC C
ACTT T

Example: HLL Block with Parameters in Menu 5

4.7.2.1 Add Call Parameters

Enter parameter name


When the input field at the bottom left of the block symbol is displayed in inverse format, you
can add a new parameter to the existing ones. Select the input field with the End key. The
parameter name can be up to 4 characters in length. The input of the parameter name is
accepted when you enter the 4th character or press the Return key. During input of the
parameter name, you can clear the input field by pressing the Escape key.

Define parameter type and data type


When you have entered the parameter name, use the function keys to define the call
parameter type.
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
SINUMERIK S5-HLL Block Generator Menu 5 Version 2.2
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
PL/M Block: FX 004
Block Name: TOOLVERW
Library Number: 9135

inp1
aaaaaaaaaa
aaaaaaaaaa
aaaaa
aaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaa
aaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaa
aaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa

I Q D T C

Menu 5, Define Type of Call Parameter

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–15


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.92
4.7.2 Block with Call Parameters

When you have defined the parameter type, the meaning of the function keys changes; now
you can use them to enter the data type.
The following function keys are available for selecting the data type for input and output
parameters (parameter types I and Q):
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaa
aaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaa
aaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaa
aaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaa
Bit Byte Word DWord

Function Key Assignment in Menu 5 for Defining the Data Type (Parameter Type I/Q)

When you use constants as the input parameter (parameter type D), the following function
keys are available for selecting the data type:
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaa
aaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaa
aaaaaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaa
KM KH KY KC KF KT KZ KG
a
a
a
a

a
a
a
a

a
aa
a
aa

a
a
aa
a

a
a
a
aa

a
a
a
a
a

a
a
a
a
aa

aa
aa
aa
a
a
a
a

a
a
a
a

a
aa
a
aa

a
a
aa
a

a
a
a
aa

a
a
a
a
a

a
a
a
a
aa

aa
a
aa
a
a
a
a

a
a
a
a

a
a
a
a

a
a
a
a

a
a
a
a

a
a
a
a
a

a
a
a
a
a

a
a
a
a
Function Key Assignments in Menu for Defining the Data Type (Parameter Type D)

When you use timer and counter information as input parameters (parameter types T and C),
the format is fixed; the definition of the new parameter is complete when you have entered the
parameter type.

The new call parameter is subsequently displayed as a terminal on the block symbol. If you
name the first call parameter of your block INP1, as in the last example, and then press F1
twice, your block in Menu 5 will look like this:

INP1 I Bit

Representation of the Parameter on the Block Symbol

4.7.2.2 Change Call Parameters

Select the call parameter you want to change with the cursor control keys or Tab key.

Change parameter name


Change the parameter name by overwriting the displayed parameter name. You must then
define the parameter type and data type, as when you define a new call parameter.

Change parameter type and data type


If you only want to change the parameter type and data type, please press the Return key
only. The name of the parameter remains unchanged. You can now change the parameter
type and data type using the function keys.

4–16 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 4 Operation
4.7.3 Exit Menu 5

4.7.3 Exit Menu 5


You exit Menu 5 "Define/Change Call Parameters" automatically if you answer the block
generator prompt "Should the block have a parameter?" with F2 "No".
If the block has parameters, you can exit Menu 5 by pressing the Insert key or the Page Down
key. During subsequent processing, the block generator creates the declarations for the call
parameters defined in Menu 5.
Menu 6, Define/Change System Interface always follows Menu 5.

4.7.4 Function Keys and Special Keys in Menu 5

The function keys in Menu 5 are only active in specific situations and are therefore not always
displayed (see previous sections).
The function keys in Menu 5 have multiple assignments. The meaning of the function keys
changes the first time you press a function key.

First level of function keys


The first level of function keys allows you to choose the type for the active call parameter.

Function key Parameter type


F1 I Input parameter
F2 Q Output parameter
F3 D Constant as input parameter
F4 T Timer information as input parameter
F5 C Counter information as input parameter

Second level of function keys


The second level of function keys identifies the data type.
The following function keys are available for parameter types I and Q:

Function key Parameter type


F1 Bit Byte with one significant bit, possibly with mask
F2 Byte Byte
F3 Word Word
F4 DWord Doubleword
The following function keys are available for parameter type D:

Function key Parameter type


F1 KM Bit map
F2 KH Hexadecimal number
F3 KY Byte value
F4 KS ASCII value
F5 KF Fixed-point number
F6 KT Timer value
F7 KC Counter value
F8 KG Floating-point number

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–17


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.91
4.7.4 Function Keys and Special Keys in Menu 5

The data type is permanently assigned for timers and counters; no choice is therefore
provided for these types of parameters.
Please refer also to the details of data format and data format conversion for call parameters in
the section entitled "Call Parameters of HLL Blocks".
The special keys in Menu 5 are only active when the function key assignment is not visible.

, , Tab
Use these keys to select the call parameter you want to edit. The cursor can only be moved
vertically with the arrow keys. You can move to the call parameters on the opposite side of the
block symbol with the Tabulator key.

End
The End key moves you to the input field for new call parameters.

Ctrl-End
You can delete a parameter that you have already entered by pressing the Control key and
End key simultaneously.

, , Del, BS
These keys are used to edit the parameter name.

Esc
The Escape key clears your present entry in the input field as long as the input of the
parameter name has not been completed. (If input of the parameter name is complete, you
must also define the parameter type and data type. You can delete the complete defined
parameter again by pressing Ctrl-End).

Ret
The Return key terminates input of a parameter name.

Ins, PgDn
These keys accept the parameters in Menu 5 and advance you to Menu 6 "Define System
Interface".

4–18 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 4 Operation
4.8 Define/Change System Interface (Menu 6)

4.8 Define/Change System Interface (Menu 6)


In Menu 6, you define the scope of the system interface for the function block. All system data
of the PLC which can be accessed by HLL blocks are listed in Menu 6, together with all
system routines which are available to the HLL blocks.
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
SINUMERIK S5-HLL Block Generator Menu 6 Version 2.2

Call other HLL blocks No


Call resident function macros No
Call STEP 5 blocks Yes
Block address list No
Process data blocks Yes
Boundary addresses of user memory Yes
Interpreter data No
I/O address list (I/Q) No
Process image (I/Q/F/T/C) No
System stop from HLL user program No
Extended I/O address list [I/Q] No
Semaphores (LIM, SIM) No
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
aaaaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
aa
aaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Yes No
a
a
a
a
a
a

a
a
aa
a
a
a
a
a
a

a
a
aa
a
a
a
a
a
a

a
a
a

Menu 6, Define/Change System Interface

The interface options displayed depend on the PLC system set in Menu 1 and can vary.

The individual items in Menu 6 have the following meaning:


Call other...: Select this item if you want to call other HLL blocks.
Call resident...: Select this item if you want to call specific standard function
blocks (macros).
Call STEP 5...: Select this item if you want to call STEP 5 blocks.
Block address list: Select this item if you require the block address lists, e.g. to
check whether a specific block exists.
Process...: Select this item if you want to open data blocks (DB/DX); this
also provides you with the current data block length.
Boundary addresses...: Select this item if you want to query the start, end and assigned
addresses of the user memory.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–19


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.92
4.8 Define/Change System Interface (Menu 6)

Interpreter data: Select this item if you want to query the STEP 5 status bits for
binary and digital operations or the number of the current OB.
I/O address list...: Select this item if you require direct access to the I/O
(corresponds to L PY, T PY in STEP 5).
Process image...: Select this item if you want to access the process image of the
inputs, outputs, flags, timers and counters.
System stop from...: Select this item if you want to branch to the stop state from the
HLL block in the event of an error.
Extended I/O...: Select this item if you want to access the extended I/O (only on
systems with ACOP).
Semaphores: Select this item if you want to set and clear the disable
identifiers (corresponds to the commands SIM and LIM in STEP
5; only on systems with ACOP).

You will find more information on the individual items in the section entitled "Interfaces of the
HLL block".

4.8.1 Function Keys and Special Keys in Menu 6


F1 Yes
F2 No
You use function keys F1 "Yes" and F2 "No" to specify for each option whether you want to
use the option in the function block.

,
Use these keys to move the line cursor. The current line of the table is displayed in inverse
format.

Ins
The Insert key accepts your settings. The block generator now creates (or replaces) the
declarations for the call parameters defined in Menu 5 and the system interface defined in
Menu 6. The generated declarations are entered in the HLL block by the block generator. Any
existing declarations for the block interface are replaced (please refer also to the section
entitled "Format of the Module Header").
Any changes to the library number and the block name that you have made in Menu 1 are now
activated.

4–20 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 4 Operation
4.9 Edit HLL Block

4.9 Edit HLL Block


If you have selected the step "Create Block Program" in Menu 2 "Select Processing Steps",
the program editor which was set during the installation is called up. You can now edit the HLL
block.
The operating method depends on the editor you are using. If you have any queries, you
should consult the documentation of the editor.
When editing the block program, please remember that you may not change declarations,
compiler commands and comments which have been created by the block generator (see also
the section entitled "Format of the Module Header").
The block generator is reactivated when you exit the program editor.

4.10 Compile and Link HLL Block (Menu 3)


In Menu 3, you define the optimization level for the compiler and the objects which are to be
linked to the block. The parameters produced by the block generator are generally sufficient. If
the need arises, however, these parameters can be extended or modified. You should not
attempt to do this without accurate knowledge of the technical requirements (see notes). The
default settings for the assembler header and footer should never be changed.

Notes:
• Optimization level 0 should be set for testing the HLL block with the on-line or off-line
debugger. The tested block can subsequently be compiled with a higher optimization level.
• To ensure that the HLL block operates correctly if it has been compiled with a higher
optimization level, you should perform a test run with the optimized block.
• In addition to the default modules, you can link a further 5 object files or libraries to the
block. The number of individual object files or libraries is irrelevant, i.e. you can link 5
object files to the block.
• You can use standard intel libraries or your own libraries (created with intel-LIB86). Please
note that the functions used may not access the hardware or operating system.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–21


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.92
4.10 Compile and Link HLL Block (Menu 3)

a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
SINUMERIK S5-HLL Block Generator Menu 3 Version 2.2
aaaaa
aaaaa a
aaaaa a
aaaaa a
aaaaa a
aaaaa
aaaaa a
a
aaaaa a
aaaaa a
aaaaa
aaaaa a
aaaaa a
aaaaa a
aaaaa
aaaaa a
aaaaa a
aaaaa a
aaaaa
aaaaa a
a
aaaaa a
aaaaa a
aaaaa
aaaaa a
aaaaa a
aaaaa a
aaaaa
aaaaa a
aaaaa a
aaaaa a
aaaaa
aaaaa a
a
aaaaa a
aaaaa a
aaaaa
aaaaa a
aaaaa a
aaaaa a
aaaaa
aaaaa a
aaaaa a
aaaaa a
aaaaa
aaaaa a
a
aaaaa a
aaaaa a
aaaaa
aaaaa a
aaaaa a
aaaaa a
aaaaa
aaaaa a
aaaaa a
aaaaa a
aaaaa
aaaaa a
a
aaaaa a
aaaaaa
aaaaa
aaa
PL/M Function Block: >PFX004< Name: >TOOLVERW<
Compile:
Optimization Level >0< for debugger

Link:
Block Link Modules: > AFX004.OBJ< Assembler Header
> PFX004.OBJ< PL/M Block Body
> . < Additional Object File
> . < Additional Object File
> . < Additional Object File
> DAT_COM2.LOC< System Addresses
> . < Additional Library
> . < Additional Library
> AFXEND.OBJ< Assembler Footer
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
aaaaaa
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
aaa
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
aaaaa
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
aaaaa
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a

a
a

aa

a
a

a
a
a
aa
a
aa
Continue Back
a
a
a
a
a
a
a
a
aa
a
a
a

a
a

aa

a
a

a
a
a
aa
a
aa
a
a
a
a
a
a
a
a
aa
a
a
a

a
a

aa

a
a

a
a
a
aa
a
aa
a
a
a
a
a
a
a
a
a
a
a
a

a
a

a
a

a
a
a
a
a
a
Menu 3, Compile and Link HLL Blocks

4.10.1 Function Keys and Special Keys for Menu 3


F1 Continue
The entered data are accepted. The HLL source program is compiled, linked, located and
converted to hexadecimal format. The files which are generated during this process are stored
in the appropriate directories (see the section on "Installation" and the description of
Menu 1.1).
If an error is encountered during compilation of the HLL source program, the block is not
linked; the following message appears:
Call up editor? [n]/y
If you answer n(o), the block generator calls up the "Select Processing Steps" menu. If you
answer y(es), the editor is called up and you can correct the source file with reference to the
error messages in the list file.
If you have selected several steps in Menu 2 "Select Processing Steps", the block generator
may run these steps before compiling and linking the block. Menu 3 is used for entering the
data required for compiling and linking; the associated actions are not necessarily performed
directly after you exit the menu (other steps of the block generation may be performed first).

F8 Back
You exit Menu 3, but the data you have entered are retained. The block is not compiled or
linked.

4–22 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 4 Operation
4.11 Generate S5-DOS Block File (Menu 4)

4.11 Generate S5-DOS Block File (Menu 4)


In Menu 4, you can define which blocks are to be combined in an S5-DOS block file. The S5-
DOS block file is the output medium of the block generator for completely processed HLL
blocks; the latter can be transferred to the programming device in the S5-DOS block file.
The block generator also transfers all link files and program lists which it finds for the HLL
blocks defined in Menu 4 to the destination directory for the S5-DOS block file.
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
SINUMERIK S5-HLL Block Generator Menu 4 Version 2.2

PL/M Function Block: >PFX004< Name: >TOOLVERW<

Name of the S5-DOS Block File: >@@@@@@ST.S5D<

Blocks to be Transferred

1. > PFX004< 8. > < 15. > <


2. > < 9. > < 16. > <
3. > < 10. > < 17. > <
4. > < 11. > < 18. > <
5. > < 12. > < 19. > <
6. > < 13. > < 20. > <
7. > < 14. > < 21. > <
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
aaaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
aaaaa
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
aaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
aaaa
a
a
a
a
a
Continue Back
a
a
a
a
a
a
a
a
a
aa

a
a

a
aa

aa

a
aa

a
a

a
a
a
aa
a
a
a
a
a
a
a
a
a
a
aa

a
a

a
aa

aa

a
aa

a
a

a
a
a
aa
a
a
a
a
a
a
a
a
a
a
aa

a
a

a
a

a
a

a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

Menu 4, Generate S5-DOS Block File

4.11.1 Define S5-DOS Block File Name and Block List


Name of the S5-DOS block file
Here you can enter the name and the extension for the S5-DOS block file in which the HLL
blocks are to be transferred.

Blocks to be transferred
Enter the identifiers of the blocks you want to include in the S5-DOS block file in the fields in
the table.
The identifier for an HLL block is composed of 3 letters and a three-digit decimal number.
• The first letter indicates the language in which the block has been created.
P stands for PL/M
C stands for C

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 4–23


SINUMERIK 840/880 Part 1 (PJ)
4 Operation 11.92
4.11.1 Define S5-DOS Block File Name and Block List

• The 2nd and 3rd letters indicate the block type.


FB stands for an HLL function blockof type FB
FX stands for an HLL function blockof type FX
• The three-digit decimal number identifies the number of the block; the value range is from
000 to 255.

4.11.2 Function Keys and Special Keys in Menu 4

F1 Continue
The defined blocks are transferred to the S5-DOS block file. The S5-DOS block file is created
in the S5-DOS directory defined in Menu 1.1. All link files and program lists of the HLL blocks
transferred to the S5-DOS block file are also copied into this directory. No warning is given if
program lists or link files are missing.

Note:
Pressing F1 "Continue" always creates a new block file. If a file of the same name already
exists in the destination directory, it is overwritten without warning.

F8 Back
You exit Menu 4 but the data you have entered are retained.

, , , , Ret, PgUp, PgDn, Home, End


You can use these keys to select the input field. The active input field is displayed in inverse
format.

, , Ins, Del, BS
These key functions are available for editing text in the input fields.

4–24 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 5 Interfaces of the HLL Block
5.1 Type and Scope of the Block Interfaces

5 Interfaces of the HLL Block

5.1 Type and Scope of the Block Interfaces

An HLL block can have the following interfaces:


• Call parameters
• Interface to PLC system data
• Interface to PLC system functions

These interfaces presented by the block generator offer enormous scope. You should not
require all of the interface components provided.
The scope of the individual interfaces is defined interactively with the block generator. The
block generator uses the data you enter in Menus 5 and 6 (see the section entitled
"Operation") to generate the declarations for the interfaces required in the HLL block and
present the corresponding external references.
The block generator records the current scope of the block interfaces in the header of the HLL
source code file. It uses a special syntax based on STEP 5 for this purpose. This syntax is
described in the section entitled "Format of the Module Header". Unlike earlier versions of the
block generator, you do not have to use this syntax yourself in Version 2.1. Please note,
however, that the block generator deletes and overwrites certain areas in the source text of the
block when you make changes to the block interface.

5.2 STEP 5-Specific Data Format

All data are stored on the PLC in STEP 5 format. The STEP 5 format and the intel format used
with PL/M and C are not compatible.
In the case of data fields which are stored in a word, the low byte and high byte in the STEP 5
format are opposite to those in the intel data format. Similarly, the high word and low word in
doublewords are also exchanged.

Examples:
• The same word is saved at different memory locations
If you write the value 1234H into a data word in STEP 5, the high byte (which contains
12H) is stored in the byte at the lower address; the low byte (which contains 34H) is
stored at the next higher address.

STEP 5 data format: 12H 34H

Address Address+1

© Seimens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–1


SINUMERIK 840/880 Part 1 (PJ)
5 Interfaces of the HLL Block 11.92
5.2 STEP 5-Specific Data Format

If you save the same value in the intel format used with PL/M and C, the higher-value byte
(which contains 12H) is stored in the higher address in the word, while the lower byte
(which contains 34H) is written to the lower address.

intel data format: 34H 12H

Address Address+1

• Reading the same stored doubleword produces different results


Memory contents:

12H 34H ABH CDH

Address Address+1 Address+2 Address+3

The doubleword read access to this data array produces the value 0CDAB3412H in PL/M
and C (or 0xCDAB3412 in C notation).
The doubleword read access in STEP 5 returns the value 1234ABCDH.
a
a
a
a
aaaaaaaaaaaaaaaaaaaaaaaaaaa
a

a
a
a
a
aaaaaaa
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
Caution:
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
aaaaaaaaaaaaaa
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
Please remember the different data formats
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
used in STEP 5 and PL/M and C when accessing data.
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
aaaaaaa
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
a
a
a
a
a

a
a
a
a
a
The PLC operating system can convert the call parameters of an HLL block to the intel data
format. The conversion must be requested explicitly (see the section entitled "Conversion of
Call Parameters").
In addition to the opposite representations used for the high and low byte, differences also
arise in the indexing of arrays. For example, the data word n in a STEP 5 data block is
interpreted by STEP 5 as consisting of the data bytes DL n and DR n. The data bytes in the
data word are thus addressed with the same index as the data word itself. PL/M and C,
however, interpret data word n as consisting of data bytes 2n and 2n + 1.
You will find further examples of the different data formats in the sections entitled
"Programming with PL/M", "Programming with C" and "Program Examples".

5–2 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 5 Interfaces of the HLL Block
5.3 Call Parameters of HLL Blocks

5.3 Call Parameters of HLL Blocks


5.3.1 Types of Call Parameters

An HLL function block can have input parameters and output parameters. Parameters which
are both input and output parameters, i.e. variable parameters, are not possible. They can,
however, be simulated.
All parameters are passed via the stack (either the value or the address of the parameter).
The block generator distinguishes between the following types of call parameter:

Parameter type: STEP 5 Passed to the stack:


notation:

Output parameters:
Bit Q BI Pointer plus mask byte
Byte Q BY Pointer
Word QW Pointer
Doubleword QD Pointer

Input parameters:
Bit I BI Data byte plus mask byte
Byte I BY Byte
Word IW Word
Doubleword ID Doubleword

Constants:
ASCII value D KS Word
Fixed-point number D KF Word, with leading sign
Floating-point number D KG Doubleword
Hexadecimal number D KH Word
Bit map D KM Word
Byte value D KY Word
Timer value D KT Word
Counter value D KC Word

Timer T Word
Counter C Word

In this overview, the parameter types constant, timer and counter are treated as special types
of input parameter for HLL blocks.

Notes:
• Call parameters are passed to HLL blocks via the stack; please therefore refer also to the
information on the stack loading in the section entitled "Information for the Use of the
Block Generator".
• Call parameters can be converted to the intel data format by the PLC operating system
(see next section).
• Two variants can be used for passing bit parameters (see next section).

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–3


SINUMERIK 840/880 Part 1 (PJ)
5 Interfaces of the HLL Block 11.92
5.3.2 Data Format Conversion for Call Parameters

5.3.2 Data Format Conversion for Call Parameters


Call parameters of HLL blocks can be converted by the PLC operating system. There are two
conversion functions:
• Convert input parameters from STEP 5 data format to intel data format
• Pass bit (input) parameter as value

Both format conversions must be requested explicitly in the STEP 5 program calling the HLL
block. This is performed by enabling operating system data bits (in the followin gabbreviated as
BS) BS 0.0 and BS 0.1.

Activate conversion to intel data format


BS 0.0 = 1: The input parameters are converted to the intel data format, i.e. the high and
low bytes or words are converted.
= 0: The input parameters are passed to the HLL block in the STEP 5 format.

Select format for bit transfer


Conversion of the bit parameters is only possible for input parameters. Bit parameters (input
parameters) consist of 2 bytes. One byte contains data, the other contains a mask.
BS 0.1 = 1: The value of the bit parameter (0 or 1) is specified directly in the byte which
represents the bit parameter. If the bit is enabled, the call parameter contains
the value 1; if the bit is disabled, the call parameter contains the value 0.
The mask byte for the bit call parameter is always 0 with this bit transfer
variant.
BS 0.1 = 0: The bit parameter contains a byte value in which only one bit is significant.
The accompanying mask byte is used to mask all of the irrelevant bits. In the
mask byte, one bit is enabled at the position of the relevant bit.

System data BS 0 is valid for all levels. For example, if BS 0.0 is set to "1" in OB 1 (= format
conversion from intel data format to STEP 5 format) and OB 1 is then interrupted by a higher-
priority level (e.g. by a process interrupt), bit BS 0.0 is also set to "1" in OB 3 (which is now
active). If you do not want the format conversion in OB 3, the bit must be reset explicitly.
When you return to OB 1, the original value is reloaded in BS 0 (in this example BS 0.0 is set
to "1" again).
Examples with bit parameters are provided in the program examples and in the sections on
programming with PL/M and C.

5.4 PLC System Functions

Contained in the PLC operating system are special system functions which can be called from
HLL blocks. These system functions are used as a substitute for important STEP 5 commands
which are difficult to reproduce in a high-level language. They also enable other program
sections to be called from HLL blocks. The system function HLL_MACRO() can be used to
call up function macros of the PLC operating system.

5–4 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 5 Interfaces of the HLL Block
5.4.1 Overview

5.4.1 Overview
The following system functions can currently be used in HLL blocks:
Name: Task:
HLL_ADB() Open data block
HLL_S5() Call STEP 5 blocks
HLL_MACRO() Call function macros
HLL_HLL() Call HLL blocks
HLL_LIM(), HLL_SIM() Disable/enable processing levels
HLL_STOP() Initiate PLC system stop from HLL block

The parentheses following the names of the system functions indicate that the system
functions have call parameters. System functions HLL_LIM() and HLL_SIM() are only
available on PLC systems with ACOP.
The system functions and their parameters are described in the following sections.

5.4.2 HLL_ADB(), Open Data Blocks

HLL_ADB() is used to open a data block. The data segment of the HLL block is set to the
data segment of the opened data block in order to associate the data block declared in the
data segment of the HLL block with the opened data block.
The assignment of the data block declared in the HLL block to the opened data block remains
active until a new data block is opened with HLL_ADB().
Each time HLL_ADB() is called, system data DB_Laenge passes the length of the opened
data block.

Parameters of system function HLL_ADB():

Parameter Type Value range Meaning

1 String constant 'DB' or 'DX' Selects the type of the


Length: 2 (large case only) data block to be opened

2 Word 0...255 Specifies the number of


the data block to be
opened

Example:
Open data block DB 100:
PL/M: call HLL_ADB ('DB', 100);
C: HLL_ADB ('DB', 100);

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–5


SINUMERIK 840/880 Part 1 (PJ)
5 Interfaces of the HLL Block 11.92
5.4.3 HLL_S5(), Call STEP 5 Program Blocks

5.4.3 HLL_S5(), Call STEP 5 Program Blocks


System function HLL_S5() can be used to call STEP 5 blocks from the HLL block (e.g. for
efficient bit processing). Permissible block types are PB (program blocks) and SB (step
blocks). You can program code to read the result of the external binary operations from the
status bits in BIN_ERGA, DIG_ERGA or BIN_DIGA.

Parameters of system function HLL_S5()

Parameter Type Value range Meaning

1 String constant 'PB' or 'SB' Selects the type of the


Length: 2 (large case only) STEP 5 data block to be
opened
2 Word 0 ... 255, numbers of Specifies the number of the
existing STEP 5 STEP 5 data block to be
blocks only opened

Example:
Call program block PB 255:
PL/M: call HLL_S5('PB',255);
C: HLL_S5('PB',255);

5.4.4 HLL_MACRO(), Call Function Macro

Function macros made available by the PLC operating system for use in application programs
can be called with system function HLL_MACRO(). The parameters for the function macro
are specified as call parameters of system function HLL_MACRO().

Parameters of system function HLL_MACRO():


The number of call parameters of HLL_MACRO() is variable and depends on the function
macro to be called with HLL_MACRO(). The first parameter of HLL_MACRO() is always the
last parameter of the function macro; the other parameters of the macro follow in reverse
order. The number of the function macro is always specified in the last parameter of
HLL_MACRO().

5–6 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 5 Interfaces of the HLL Block
5.4.4 HLL_MACRO(), Call Function Macro

Parameter Type Value range Meaning

1 Depends on function macro called Last call parameter of function


macro
2 Depends on function macro called Second last call parameter of
function macro

(n - 1) Depends on function macro called First call parameter of function


macro

n Byte Numbers of function Number of function macro to be


macros permitted called
(see following table)

You will find examples of the HLL_MACRO() function in the sections entitled "Brief Examples
in PL/M" or "Brief Examples in C".

5.4.4.1 Available Function Macros

The following function macros can presently be called with system function HLL_MACRO():

FB no. FB name Function

11 EINR-DB Set up data blocks

12 WDTRG Watchdog trigger


61 NCD-LESE Read NC data

62 NCD-SCHR Write NC data


65 M STACK Flag parameter flag stack

66 STACK M Flag stack flag parameter


72 T:NCK DB Transfer NC channel DB channel

73 T:DB NCK Transfer DB channel NC channel


74 T:SPI DB Transfer spindle DB spindle

75 T:DB SPI Transfer DB spindle spindle


76 T:ACH DB Transfer axis DB axis

77 T:DB ACH Transfer DB axis axis

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–7


SINUMERIK 840/880 Part 1 (PJ)
5 Interfaces of the HLL Block 11.92
5.4.4 HLL_MACRO(), Call Function Macro

aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
Separate documentation is obtainable for the function macros:
"Function Macros" Configuring Guide

5.4.4.2 Passing Parameters to Function Macros


The procedure for passing parameters to function macros when calling them from an HLL
block is mainly identical to calling from a STEP 5 program. The following differences and
special cases apply:
• When calling from an HLL block, the order of the parameters is opposite to the order in
STEP 5 calls. The last parameter for the function macro must be passed first when calling
from an HLL block; the block number is specified as the last parameter.
• Variable passing of flag parameters to function blocks FB 11, FB 61 and FB 62 is not
supported in calls made from HLL blocks.
• In the case of FB 61 and FB 62, the parameter NSBY is a constant of type D KF.
• When using bit parameters as input parameters for function macros, the bit must always
be passed as bit 0. The other bits are ignored.
• Parameters of type constant must always be passed in a word, since the function macros
always evaluate these parameters as words.

Examples for the use of function macros can be found in the sections for programming with
PL/M or C, and in the program examples.

5.4.5 HLL_HLL(), HLL Block Calls HLL Block

System function HLL_HLL() can be used to call other HLL blocks from an HLL block.
Recursive calls of the same HLL block are not permitted.

Parameters of system function HLL_HLL():


The number of parameters of the system function HLL_HLL() is variable and depends on the
HLL block to be called. The call parameters of the HLL block to be called, and the block type
and block number must be specified.
The call parameters for the called HLL block are specified in the same order as they appear in
that block.

Note:
String constants are not permitted as parameters when calling HLL_HLL() except to specify
the type of block called.

5–8 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 5 Interfaces of the HLL Block
5.4.5 HLL_HLL(), HLL Block Calls HLL Block

Parameter Type Value range Meaning

1 Depends on HLL block to be called First parameter of HLL block


to be called
2 Depends on HLL block to be called Second parameter of HLL block
to be called

(n - 2) Depends on HLL block to be called Last parameter of HLL block


to be called

(n - 1) String 'FB' or 'FX' Type of HLL block to be called


constant (upper case only)
Length: 2
n Byte Numbers of Block number of HLL block
existing HLL blocks to be called

Example:
Call HLL block FB 123 with 2 parameters:
PL/M: call HLL_HLL (start, end, 'FB', 123);
C: HLL_HLL (start, end, 'FB', 123);

5.4.6 HLL_LIM(), HLL_SIM(), Disable and Enable OBs

System functions HLL_LIM() and HLL_SIM() correspond to the STEP 5 commands LIM and
SIM; they are used to set and clear disable identifiers for the processing levels of the PLC
program. The disabling of processing levels is intended to protect program sections from
interruption by higher-level processing levels (e.g. timed interrupt processing).
The disable identifiers are stored in a byte. The disable identifier byte is read with the
HLL_LIM() function and written back with HLL_SIM(). The HLL program can change the
disable identifier between reading and writing the disable identifier byte.

Parameters of system functions HLL_LIM() and HLL_SIM():

Parameter Type Value range Meaning

1 Pointer See below Pointer to byte with disable


identifier for OB 2 to OB 7

Example:
Read disable identifiers:
PL/M: call HLL_LIM (@ dis_id_byte);
C: HLL_LIM (& dis_id_byte);

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–9


SINUMERIK 840/880 Part 1 (PJ)
5 Interfaces of the HLL Block 11.92
5.4.6 HLL_LIM(), HLL_SIM(), Disable and Enable OBs

Structure of the disable identifier byte:


The disable identifiers for the processing levels are stored in a byte in which the numbers of
the bits correspond to the assigned OB number:
Bit number: 7 6 5 4 3 2 1 0
Processing level: OB 7 OB 6 OB 5 OB 4 OB 3 OB 2 --- ---

An enabled bit means that the processing level is disabled. A disabled bit means that the
processing level is enabled.

Procedure for enabling and disabling processing levels


Read disable identifiers: Call HLL_LIM(), parameter: pointer to byte for storing disable
identifiers
Enable disable identifier(s): Set identifiers (bits) of OBs to be disabled by logical OR
operation with a mask
Write disable identifiers: Call HLL_SIM(), parameter: pointer to byte with the modified
disable identifiers
... the protected program section begins at this point. Requests for the disabled OB or OBs
are saved by the PLC operating system. Not more than one request is saved for each disabled
OB. Further requests are lost, but are counted for diagnostics purposes (DB 1).
Read disable identifiers: Call HLL_LIM(), parameter: pointer to byte for storing disable
identifiers
Clear disable identifier(s): Clear identifiers (bits) of disabled OBs by logical AND
operation with a mask
Write disable identifiers: Call HLL_SIM(), parameter: pointer to byte with the modified
disable identifiers
... the protected program section ends at this point. The requests saved by the PLC operating
system for the disabled OBs are now processed. If required, you can read from diagnostics
data block DB 1, DW 16...21 how many, if any, requests for the various OBs have been lost.

Notes:
• No processing level should be disabled for longer than absolutely necessary.
• When processing disable identifiers, only those identifiers should be modified which are
relevant for the protection of the program section. This applies both to setting and
resetting of disable identifiers.
• Several disable identifiers can be set or cleared simultaneously.
• If a request for the OB was saved when the disable identifier was reset, the previously
disabled processing level is processed before the HLL program is continued after the
disable identifiers are reset.
• The indication of lost requests in DB 1 may already have been changed by the previously
disabled processing level before the HLL program evaluates the data stored there.
• Flag FB 6.1 indicates whether a request for an OB has been lost (group identifier for all
OBs).

5–10 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 5 Interfaces of the HLL Block
5.4.7 HLL_STOP(), Initiate System Stop

5.4.7 HLL_STOP(), Initiate System Stop


System function HLL_STOP() is used to branch to the defined stop state of the PLC
operating system. When HLL_STOP() is called, an error number defined by the HLL
programmer can be passed as a call parameter.
The fine error coding of the PLC can be queried at address 0F0000H. When a system stop is
initiated by HLL_STOP(), identifier 0DDH is stored there; the error number passed as a
parameter to HLL_STOP() can be read out from address 0F0001H.

Parameter of system function HLL_STOP():

Parameter Type Value range Meaning

1 Word 0...65535 Error number defined by HLL


programmer

Example:
System stop with error number 1234:
PL/M: call HLL_STOP (1234);
C: HLL_STOP (1234);

5.5 PLC System Data

In the following sections, please note:


The names used in the description of the system data are the identifiers assigned to the
system data by the block generator. Names beginning with X (e.g. XBINERG) identify pointers.

5.5.1 Overview

The following list provides an overview of the available system data. The specified names are
reserved for the system interface to the PLC. They may not be used to declare other objects.
The HLL function blocks can presently access the following PLC system data:
Name: Task:
E_Byte Input area
A_Byte Output area
M_Byte Flag area
Zeit STEP 5 timers
Zaehler STEP 5 counters

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–11


SINUMERIK 840/880 Part 1 (PJ)
PeA
PeE

QeA
QeE

5–12
5.5.2
FX_LST
FB_LST
SB_LST
PB_LST
DX_LST
DB_LST

OB_LST
Sp_Verw
Bin_DigA
Bin_ErgA
Dig_ErgA
XBINERG
XDIGERG

XDBLAEN

XDSPVER

GREBESP
PHENDEP
PHANFGP

GREBESD
PHENDED
PHANFGD
XAKOBNR

GREBEOP

GREBEOD
Akt_OB_Nr

DB_Laenge
5.5.1 Overview

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
a
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaa
aa
a
5 Interfaces of the HLL Block

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaa

I/Q/F/C/T Areas
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a

"
"
"
"
"
"
"
"
"
"
"
"
"

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaa

List
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aaaa
aaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaa
a

"
"
"
"
"
"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a

with
aaaaaaa
"

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
a
Status bits

aa
aa
aa
aa
aa
aa
aaa
Pointer to

"
"
"
"
"
"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
Active OB no.

"

aaaaaaaa

I/O address list


aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaa
End address "
End address "

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
a
" "
" "

aaaaaaaaa

" "
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaa
Length of opened DB

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaa
aa
a
status bits

" "
" "
Pointer to active OB no.

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaa
block addresses
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaa

"
"
"
"
"
"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
a

Address list for extended I/O


"
"

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aaa
aaaaaaaaa
and

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaa

"
"
"
"
"
"
"
"
Pointer to length array DB_Laenge

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaa
Start address of user data memory

aaaaaaaa
"

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaa

The meaning of the I/Q/F areas is described


Pointer to memory management data

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa a
aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaa
Start address of user program memory

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaa
COP

aaaaaaaa

© Siemens AG 1990 All Rights Reserved


in the "Configuring the PLC 135 WB" documentation.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaa
Structure with memory management data
for PLC system with ACOP

aaaaaaa

You will find further information on counters and timers


aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
a
identifiers

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aa
aa
aa
aa
aa
aa
aaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaa

in the Configuring Guide "Interface Description Part 1, Signals".


aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aa
aa
aa
aa
aa
aa
aa
aa
aaaaaaaaaaaaaaaaaaaaaaa a
Boundary address of assigned user data memory
Boundary address of assigned user program memory

6FC5197-0AC00-0BP0
SINUMERIK 840/880 Part 1 (PJ)
11.92
11.92 5 Interfaces of the HLL Block
5.5.2 I/Q/F/C/T Areas

5.5.2.1 Process Images


Input area, image of inputs

E_Byte: IB 0
IB 1

IB 127

Output area, image of outputs

A_Byte: QB 0
QB 1

QB 127

E_Byte, A_Byte: Byte arrays of defined size; for a description, please refer to the
Configuring Guide "Interface Description Part 1, Signals".

5.5.2.2 Flag Area and Extended Flag Area


Flag area

M_Byte: FB 0
FB 1

FB 255

M_Byte: Array with flag bytes FB 0 to FB 255.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–13


SINUMERIK 840/880 Part 1 (PJ)
5 Interfaces of the HLL Block 11.92
5.5.2 I/Q/F/C/T Areas

5.5.2.3 Timers and Counters


Timers

Timer T0
T1

T 127 (255)

Format of a timer:

Bit no. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aaaaaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
Timer value (0...999)
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aa
a
a
a
a
a
a
aa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
FMF: Edge flag for FT command
FMS: Edge flag for Sxt command
Time base: 00 =ˆ 0.01 seconds
01 =ˆ 0.1
10 =ˆ 1.0
11 =ˆ 10.0
ZKS: Additional identifier for status generation
0 = Timer not running
1 = Timer running
ZWG: Identifier for "timer valid"

Note:
FT command: Input a timer
SxT command: Start a timer
Timer: Array with timer data, one word long. The number of available timers
depends on the version of software on the PLC.
On PLC systems with ACOP, the timers cannot be started from HLL
blocks.

5–14 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 5 Interfaces of the HLL Block
5.5.2 I/Q/F/C/T Areas

Counters

Counters: C0
C1

C 127 (255)

Format of a counter:

Bit no. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa

aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaa
aaaaaa
0 Counter value (0...999)

Counter value (0...999)


FMF: Edge flag for FZ command
FMS: Edge flag for SZ command
FMR: Edge flag for ZRZ command
FMV: Edge flag for ZVZ command
Counter status: 0 =ˆ Contents 0
1 =ˆ Contents > 0

Note:
FZ command: Enable counter
SZ command: Set counter
ZRZ command: Counter countdown
ZVZ command: Counter count up
Counter: Array with counter data one word in length. The number of available
counters depends on the version of software on the PLC.
On PLC systems with ACOP, the counters cannot be started from HLL
blocks.

5.5.3 Interpreter Data

The interpreter data comprise the status bits for binary and digital operations as well as the
active OB number.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–15


SINUMERIK 840/880 Part 1 (PJ)
5 Interfaces of the HLL Block 11.92
5.5.3 Interpreter Data

5.5.3.1 Status Bits on PLC Systems with COP/ACOP


The format of the status bits is different on PLC systems with COP and PLC systems with
ACOP.

Status bits on PLC systems with COP:

OR
FC
RLO

Bit 7 ...... 2 1 0

XBINERG Bin_ErgA

XBINERG: Pointer to the status bits for binary operations


Bin_ErgA: Byte with status bits OR, FC, RLO; please refer to "Configuring the
PLC 135 WB" for description

OVER
OS
CC1
CC0

Bit 7 ... 3 2 1 0

XDIGERG Dig_ErgA

XDIGERG: Pointer to the status bits for digital operations


Dig_ErgA: Byte with status bits OVER, OS, CC0 and CC1; please refer to
"Configuring the PLC 135 WB" for a description

5–16 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 5 Interfaces of the HLL Block
5.5.3 Interpreter Data

Status bits on PLC systems with ACOP:


The status bits for binary and digital operations are combined in one word on PLC systems
with ACOP:

OS
OVER OR
CC0 FC
CC1 RLO
Bit 15 ... ... 8 7 6 5 4 3 2 1 0

XBINERG Bin_DigA

XBINERG: Pointer to status bits


Bin_DigA: Word with status bits for binary and digital operations

5.5.3.2 Active OB No.

XAKOBNR Akt_OB_Nr

XAKOBNR: Pointer to active OB no.


Akt_OB_Nr: Number of active organization block; corresponds to the processing
level in which the HLL block has been called up.

5.5.4 Processing of Data Blocks

For data memory, the user can choose from data blocks of both types (DB and DX) up to a
length of 2043 words each. Data blocks are also used as an interface to the various
components of the numerical control and other PLC programs. The efficient processing of data
blocks is a key factor in HLL programming.
When data blocks are accessed from HLL blocks, the PLC operating system is not capable of
performing the usual STEP 5 checks for range violations. Particular care must therefore be
taken in the HLL program to ensure that data are not read or written beyond the boundaries of
the data block. Accesses to non-existent data blocks should also be avoided.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–17


SINUMERIK 840/880 Part 1 (PJ)
5 Interfaces of the HLL BLock 11.92
5.5.4 Processing of Data Blocks

5.5.4.1 Global Declaration of Data Blocks


Data blocks must be declared in the data segment of the HLL block (i.e. global in PL/M; global
or static in C). Since only one data block can be active at a time, it is sufficient to reserve
enough memory for the longest data block used. If several data blocks of different structures
are used, the memory reserved for the longest data block must be redefined by appropriate
declarations.
The data block declared in the HLL block must be the only object declared in the data
segment of the HLL block. The data block must be located at the beginning of the data
segment; this is automatically the case if the data block is the only globally defined object and
no ORG or similar instruction is used.

5.5.4.2 Opening Data Blocks

Each data block must be opened before the data are processed. System function HLL_ADB()
is provided for opening data blocks. Opening a data block has the effect of associating the
data block declared globally in the HLL block with the opened data block. Accesses to the DB
declared in the HLL block are then applied directly to the open DB.

Caution:
A DB must be opened before the first access to the DB declared in the HLL block. Data
blocks using offsets in OB 180 (addressing of data words greater than 255) must be opened
again, since the size of the offset is not detected by the PLC system.

5.5.4.3 Length of the Active Data Block

XDBLAEN DB_Laenge

XDBLAEN: Pointer to a word in which the length of the opened data block is
given. XDBLAEN is returned by system function HLL_ADB().
DB_Laenge: DB_Laenge specifies the number of the last data word in the open
DB.

5–18 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 5 Interfaces of the HLL BLock
5.5.4 Processing of Data Blocks

5.5.4.4 Processing of Data Blocks with Pointers


Data blocks can also be processed using pointers. The required addresses are stored in the
block address lists DB_LST and DX_LST (see the section entitled "Block Address Lists").
The advantage of processing data blocks with pointers is that you can access several data
blocks simultaneously, since you do not have to open the data blocks.
Data blocks have a data block header before the first data word (DW 0). The length of the data
block can be read from the DB header. The length array, which is one word in length, is the
word immediately before DW 0 of the data block.
You will find an example for processing data blocks with pointers in the section entitled
"Programming with C". It is also possible to process data blocks using pointers in PL/M. Since
the use of pointers in PL/M is restricted due to safety reasons, it is necessary to perform type
redefinitions on the pointers for convenient address calculation.

Note:
The reader is reminded that range checks should be included in the HLL block. It is the
responsibility of the programmer to ensure that the data block being processed actually exists
and that no accesses are made beyond the boundaries of the block.

5.5.5 Memory Management

Certain key memory management data are made available to the HLL program by the PLC.
The start and end addresses of the user program memory and the user data memory are
stored in a table (structure Sp_Verw) along with the start address of the remaining free
memory.
The start and end address parameters for memory management always refer to paragraph
boundaries. An offset therefore does not have to be specified for these addresses. The offset
must be added by the HLL program according to the method described below.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 5–19


SINUMERIK 840/880 Part 1 (PJ)
5 Interfaces of the HLL BLock 11.91
5.5.5 Memory Management

The address parameters of the memory management are byte-oriented.

XDSPVER PHANFGP Start of the user program memory

PHENDEP End of the user program memory

PHANFGD Start of the user data memory

PHENDED End of the user data memory

GREBESP
Boundary of the assigned user program
memory (segment, offset)
GREBEOP

GREBESD
Boundary of the assigned user data
memory (segment and offset)
GREBEOD

The boundary addresses of the assigned user program and user data memory each indicate
the address of the first free byte. The individual entries (PHANFGP, ...) are addressed via the
structure Sp_Verw.

Format of the memory boundary addresses; offset to be added

Bit 19 4 3 0
a
a
a
a
a
a
a
a
aaaaa
a

PHANFGP Absolute start address of user program memory 0


a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a

PHENDEP Absolute end address of user program memory F


a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aaaaa
a
a
a
a
a
a
a
a
a
a

PHANFGD Absolute start address of user data memory 0


a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aaaaaaaaa
aaaaaaaaa a
aaaaaaaaa a
aaaaaaaaaa
aaaaaaaaa
a
a

PHENDED Absolute end address of user data memory F

Bit 19 4
GREBESP Absol. address of assigned user progr. memory

Bit 3 0
GREBEOP Residual offset

GREBESD Absolute address of assigned user data memory

GREBEOD Residual offset

5–20 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)


aaaaaaaaaaaaaaaaaa

L
L
aaaaaaaaaaaaaaaaaa

H
H
11.92

a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
5.5.6

aaaaaaaaaaaaaaaaaaaaaa

Notes:
aaa
aaaa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a

FX_LST
FB_LST
PB_LST
SB_LST
DX_LST
DB_LST

OB_LST
aaaaaa aaaaaaaaaaaa

exist.
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aaa
aa
aa
aa
a aaa
aa
aa
aa
aa
aa
aa
aa
aaaa
aaa
a
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a aaaa
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
a
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa a
aa
aa
aa
a
aa
a aaaa

COP

Offset
aa
aaa
aa
aa
aa
a aaa
aa
aa
aa
aa
aa
aa
aa
aa
aaa aaaa
aaaaaa aaaaaaaaaaaa aaaa

Segment
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
a
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a aaa
aaaa
a
aaaaaa aaaaaaaaaaaa

length of a doubleword.
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaa aaaaaaaaaaaa

address is to be used.

SINUMERIK 840/880 Part 1 (PJ)


aaaaaa aaaaaaaaaaa
aaaaaa aaaaaaaaaaaaa

© Siemens AG 1990 All Rights Reserved


for organization blocks
for STEP 5 step blocks
for data blocks of type DX
for data blocks of type DB

for STEP 5 program blocks

for function blocks of type FX


for function blocks of type FB
Block and I/O Address Lists

The following block address lists are provided:

aaaaaaaaaaaaaaaaaa

L
L
H
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aaa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa
aaaaaa
7

6FC5197-0AC00-0BP0
aa
aaaaaaaaaaaaaaaaaaaaa
aa
a aaaaaaaaaaa aaaaaa aaaaa
aa
a
aaa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aaa aa
aaa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aaa
parameters in the block lists depends on the PLC system.

a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aaa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aaaa
aaa
a aa
aaa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aaaa
aaa
a
aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa aaaaaa
X X X X
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa aaaaaaaaaa

STEP 5 blocks
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a aaaaaaaaaaa aa
H Add. 4 MSB 0
aaaaaaaaaaa aaa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa aaaaaaaaaa

<> 0 = HLL block


00 = Step 5 block
aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa aaaaaaaaaa

System identifiers
ACOP

a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
0

aDistinction between
aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa aaaaaaaaaa
high-level language/
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aaaaa aaaaaaaaaa
Address 16 LSB

aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa aaa


aa
aa
aa
a a
aa
aa
aa
aa
aa
aaaaa
0

aa
aaa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aaaa
aaa
a aa
aaa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aaa
aa
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a
5.5.6.1 Block Address Lists on PLC Systems with COP/ACOP

aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa aaaaaa


0
0

a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a
aa
aaaaaaaaaaaaaaaaaaaaa
aa
a aaaaaa
aaaaaa aaaaaa aaaaa
aa
a
a
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
aaa
a
aa
aaa
aa
aa
aa aa
aaa
aa
aaa
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a

On PLC systems with ACOP, bits 0...11 must be masked in the segment part if the
aaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaa
a
each of the blocks. The block number serves as an index in the table; each entry has the

All block address lists have 256 entries numbered from 0 to 255. The format of the address
The address parameters in the block address lists contain the start and jump addresses for

If an address entry has the value 0 (e.g. the 16 LSB and the 4 MSB), the block does not
5 Interfaces of the HLL Block

5–21
5.5.6 Block and I/O Address Lists



aaaaaaaaaaaaaaaaa

L
L
aaaaaaaaaaaaaaaaaa

H
H
PeA
PeE

QeA
QeE
aaaaaaaaaaaaaaaaaaaaaa
a

5–22
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a

Notes:
aaa
aaaa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aaa
aa
aa
aa
a aaa
aa
aa
aa
aa
aa
aa
aa
aaaa
aaa
a
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
a aa
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
a a
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a aa
aaa
aaaa

COP

Offset
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
a aa

Segment
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
a aa
a
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa a
aa
aa
aaa
aa
a
5 Interfaces of the HLL Block

aa
aaa
aa
aa
aa
a aaa
aa
aa
aa
aa
aa
aa
aa
aa
aaa
aaaaaa aaaaaaaaaaaa

0
a aaaaa

address is to be used.
aa
aa
aa
aa
aa
a aaa
aa
aa
aa
aa
aa
aaaaa
5.5.6 Block and I/O Address Lists

aaaaaa
a
Address list for inputs of I/O
The following I/O lists are provided:

Address list for outputs of I/O

available on PLC systems with ACOP.

assigned, i.e. the I/O does not exist.


Address list for inputs of extended I/O
Address list for outputs of extended I/O

a
aa
aa
aa
aa
aa
aaaaaaaaaaaaa

L
aaaaaaaaa
L
aaa

H
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aaaa
aa
aa
aa
a
a aaaaaaaaaaaaaaaaaa
7

aa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aa
a aa
aaa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aaaaa
aa aa
a aa
aaa
aaa
aaa
aa
a
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
a a
aa
aa
aa
aa
a

HLL program must update the process image explicitly.


aaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa a aaaaa

access
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
a a
aa
aa
aa
aa
a
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a aaaaaaaaaaa aaaaaa a aaaa
aa
a
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a
aa
a
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
a a
a
aa
a
aa
a
aa
a
aa
a
aa
a
a a
a
aa
a
aa
a
aa
a
aa
aaa
a
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
a a
aa
aa
aa
aa
aaa
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
a a
aa
aa
aa
aa
aa
aa
a
aaaa
H Add. 4 MSB 0
aa
aaaaaaaaaaaaaaaa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
a a
aa
aa
aa
aa
aa
aa
a
aaaa
a
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
a
aa
aaa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
a a
aa
aa
aa
aa
aa
aa
a
aaaa
ACOP

aaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa a aaaaaaa aaaa


0
X X X X X X

aaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa a aaaaaaa


different format of the address lists (e.g. through conditional compilation).

aaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa a aaaaaaa aaaa

© Siemens AG 1990 All Rights Reserved


0 = Byte access only
aaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa a aaaaaaa aa

1 = Word access also


Address 16 LSB

aaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa a aaaaaaa


5.5.6.2 I/O Address Lists on PLC Systems with COP/ACOP

aa
a a aa
0
X

aa
aaa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aaa aa
aaa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
aaaa
aa
aa
aa
aaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaa a aaaaa
Identifier for byte or word

a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
a a
aa
aa
aa
aa
a
aaaaaaaaaaaaaaaaa aa
0

aaaaaaaaa aaaaaa a aaaaa


0

a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a a
aa
aa
aa
aa
aa
a a
a a
aa
aa
aa
aa
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a aa
aaa
aa
aaa
aa aa
a aa
aaaa
aaa
a
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
aa
a aaaaaa aaaaaaa
aaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaa
a

On PLC systems with ACOP, bits 0...11 must be masked in the segment part if the
programs when changing to PLC systems with ACOP, allowance must be made for the
255); a distinction is made between inputs and outputs. The lists QeE and QeA are only

the PLC system. In order to avoid having to make changes to the source code of existing

STEP 5 programs. This is not the case on direct accesses made from HLL blocks. The
The process image for the addressed I/O is updated on direct accesses to the I/O from
If an address entry has the value 0 (e.g. the 16 LSB and the 4 MSB), the I/O byte is not
The format of the I/O address lists is, like the format of the block address lists, dependent on
The address lists consist of 256 address entries for I/O bytes PY 0 to PY 255 (or QY 0 to QY

6FC5197-0AC00-0BP0
SINUMERIK 840/880 Part 1 (PJ)
11.92
11.92 6 Format of the Module Header
6.1 Task of the Module Header

6 Format of the Module Header

6.1 Task of the Module Header

The module header contains the following information for the block generator:
• Block type and block number
• Block name and library number
• PLC system
• Names and types of call parameters for block

The parameters in the module header of the block can be edited by the user; in earlier
versions of the block generator this was the only way of modifying the block interface.

Notes:
• It is not necessary to modify the module header for blocks created with Version 2.2 of the
block generator.
• Errors can arise in certain cases where blocks created with earlier versions of the block
generator are processed by the new block generator. Always create a backup copy of the
block before it is processed. Please refer also to the notes in the section entitled
"Operation".
• You will find examples of module headers in the section entitled "Example Programs" and
in the descriptions of the module bodies for PL/M and C.
• The interface of the HLL block to the system data and the system functions cannot be
modified by editing the source program.
• The compiler statements entered in the module body by the block generator may not be
changed.

6.2 Call Parameter Definitions in the Module Header


With effect from Version 2.1 of the block generator, it is no longer necessary to define call
parameters by entering them directly in the module header, however it is still possible to do
this.

Changing the block key data


The following points should be considered when changing the block key data in the module
header:
• The texts "Type", "Number", "Name", "Lib. Number" and "PLC System" may not be
changed; the appended colon may not be deleted. No distinction is made between upper
and lower case during evaluation of the fields. Permissible value ranges are:
– Block type: "FB" or "FX"
– Block number: 0...255
– Block name: Up to 8 characters of STEP 5 character set beginning with a
letter
– Library number: 0...99999; if no library number is specified, 0 is used as the
default.
– PLC system: One of the following texts:
"1 (PLC 135WB with COP)"
"2 (PLC 135WB with ACOP)"

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 6–1


SINUMERIK 840/880 Part 1 (PJ)
6 Format of the Module Header 11.92
6.2 Call Parameter Definitions in the Module Header

Modification and addition of call parameters


When defining call parameters directly in the module header, please note:
• All call parameters must be defined in a contiguous block. Empty lines can, however, be
inserted for greater clarity of presentation.
• Each parameter entry must be inserted between comment characters. The comment can
extend over several lines; the parameter definition is terminated only with the end of the
comment. All characters between the parameter declaration and the end of the comment
are treated as comments and are not evaluated.
• All comment entries which do not conform to the standard definition of a call parameter are
deleted during processing of the block interface in Menu 5 "Define/Change Block
Interface".
• The definition of call parameters within comment characters consists of the parameter
name, colon and parameter type (in that order). The name can be up to 4 characters in
length and must begin with a letter. All characters permitted in PL/M or C variable
declarations may follow, with the exception of the underscore (_). Please note with C that
a distinction is made between upper and lower case letters. The block generator creates
parameter names in upper case letters.

Example:
/* INP1: I BI */

• The declaration of parameter type and data type must use the following identifiers:

Q BI for output Bit


Q BY for output Byte
Q D for output Doubleword
Q W for output Word

D KS for constant ASCII


D KF for constant Fixed point
D KG for constant Floating point
D KH for constant Hexa
D KM for constant Bit map
D KT for constant Timer value
D KY for constant Byte
D KC for constant Counter value
I BI for input Bit
I BY for input Byte
I D for input Doubleword
I W for input Word

T for timer
C for counter

• The block of the parameter definition is complete when


– a comment does not contain a colon, or
– an illegal parameter name is specified between the start of the comment and the colon
(e.g. longer than 4 characters) and an illegal data type follows the colon.

6–2 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 6 Format of the Module Header
6.2 Call Parameter Definitions in the Module Header

Examples of valid parameter definitions:


/* TYPE : FB */
/* Number : 234 */
/* Name : EXAMPLE */

/* emil : I BI Parameter 1 */
/* q123 : T Time between a) event 1 and
b) event 2 */
/* a$a : C */

/* TYPE : FX */
/* Number : 234 */
/* Name : N@n0n@N */

/* e : I BI */
/* q123 : T Time between event 1 and event 2 */
/* a$a : Z */

Examples of illegal parameter definitions:


/* TYPE FB */
/* Number : 234 */
/* Lib.Number : 1234 */
/* Name : N_n:n_N */

/* emil_1 : I BI Parameter 1 */
/* q123 : T Time between a) event 1 and */
b) event 2 */
a$a : C */
/* e@aus : C */
/* kenn : Q Bit */
/* 1.par : D KS */

Missing colon, i.e. start of parameter block is not detected


Incorrect syntax in identification text
Incorrect sequence of parameters
Illegal character in block name (_)
Name too long
Comment for parameter is terminated at the end of each line, i.e. the next line is
interpreted as the end of the parameter block
No comment start, i.e. is not interpreted as parameter
Illegal character in parameter name
Incorrect parameter type
Name does not begin with a letter

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 6–3


SINUMERIK 840/880 Part 1 (PJ)
6 Format of the Module Header 11.92
6.3 Evaluation of the Module Header by the Block Generator

6.3 Evaluation of the Module Header by the Block Generator


6.3.1 Operating Situations in which the Module Header is Evaluated

The block generator interprets the entries in the module body in the following operating
situations:
• When the block key data are entered in Menu 1 (block name, library number and PLC
system)
• When the block interface is modified in Menu 5 "Define/Change Call Parameters", the call
parameters in the module header are used to generate the block symbol. (When you exit
Menu 5, a new block header is written).
• Before the block is compiled, the block header is interpreted and new declarations are
generated for the call parameters.
• Before the program editor is called from the block generator, new declarations are
generated for the call parameters on the basis of the parameters in the module header.

6.3.2 Criteria for Cancellation of Evaluation of the Module Header


The block generator terminates the evaluation of the module header if
• the block type, number, name, library number or PLC system contain errors
• comment lines contain illegal call parameter definitions
• it detects a line that is not a comment line.

6–4 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 7 Programming with PL/M
7.1 Language-Specific Features of PL/M

7 Programming with PL/M

7.1 Language-Specific Features of PL/M

This chapter describes the language-specific features of HLL block generation with the PL/M-
86 programming language.
• The PL/M module body and its declarations are language-specific; the PL/M module body
is created by the block generator as a starting basis for your PL/M block.
• The option of performing a parameter check when calling other HLL blocks is only
available for PL/M.
• The "Example Programs" section contains a collection of small program excerpts.
• Notes are provided for the use of upper and lower case letters in PL/M blocks.
• The PL/M identifiers reserved by the block generator are listed.

You will find further information for the generation of HLL blocks in Chapter 5. This chapter
contains special information which is not dependent on the programming language used.

7.2 Format of the PL/M Module Body

The block generator creates a module body when generating a new PL/M function block. This
module is the starting basis for your PL/M block.
The components of the module body are described below. This description is followed by a
listing of a PL/M module body containing declarations of all PLC system data and functions
and all parameter data types. The listing is based on a PL/M block intended for use on a PLC
system with ACOP. Fewer system data and functions can be used on PLC systems with COP;
certain other deviations also arise in the format of the status bits (see the section entitled
"System Data").
The PL/M module body consists of the following components:

Module header
The block generator stores the block data in comment lines in the module header (see the
section entitled "Format of the Module Header").

Compiler statements
The compiler statements define the memory model required by the PL/M function block for
operation on the PLC 135 WB. A subsystem is also specified that contains the components of
the interface to the PLC system data and functions. FAR references are generated to these
system interface components; NEAR references are used within the PL/M block.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 7–1


SINUMERIK 840/880 Part 1 (PJ)
7 Programming with PL/M 11.92
7.2 Format of the PL/M Module Body

Label and module block


The PL/M block contains a label corresponding to the abbreviation for the block (see the
description of Menu 4). The counterpart of the external DO block, which surrounds the
module, is the END statement in the last line of the block program. The block abbreviation is
specified again at this point.

Literally declarations
The literallies for the parameter types BIT, CHAR and MASK are declared here. User literallies
can also be declared here.

External declaration of the system functions and data


The system data and functions which you define in Menu 6 are declared here. The start and
end of this component are indicated by comments:

/* S5HLL System Data START */

:
Declarations
:

/* S5HLL System Data END */

These comments are an essential part of the module body and may not be deleted or
modified.
When changes are made to the block interfaces, the block generator deletes the entire area
between the two comments and generates a new one. If you have made changes in this area,
the changes are deleted.

Constants
This component is used for the declaration of constants.

Procedure declaration for the main program


The main program for each PL/M block is called "function". The statement "END function" for
the procedure declaration can be found in the penultimate program line.
The procedure declaration contains the list of call parameters which you have defined in Menu
5. Some of the parameters are passed to the stack in a different format than used in the
program (for example, pointers are passed for output parameters).
The procedure has the attributes PUBLIC and REENTRANT. The PUBLIC attribute means that
the main program of the PL/M block can be called from other programs. The procedure must
be REENTRANT so that the local data of the procedure are stored in the stack instead of the
data segment. (The data segment of an HLL block is reserved solely for the processing of data
blocks; please see the section entitled "Processing of Data Blocks").

Parameter declaration
The parameters of the parameter list are declared here. For output parameters, the appropriate
"BASED" declaration for the passed pointer is included here for the parameter used in the
program. The masks for bit parameters are also included at this point.

7–2 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 7 Programming with PL/M
7.2 Format of the PL/M Module Body

Local data
You can declare local data for your PL/M block after the declarations generated by the block
generator for the call parameters. Please remember that local data are not retentive, i.e. the
content of local data is undefined every time the block is called. Data which are to retain their
value across multiple block calls (retentive data) must be stored in data blocks.

Main procedure statement part


The PL/M program text for the main program of the PL/M block begins at this point.

7.2.1 Module Body of a PL/M Block

Headings are inserted in the following listing for the purposes of clarity. The headings are not a
component of the PL/M module body.

7.2.1.1 Module Header

/* SIEMENS Block Generator S5-PL/M */


/* Date: 27.03.91 Time: 19:52:19 */

/* Type : FB */
/* Number : 000 */

/* Name : TOOLVERW */
/* Lib.number : 9135 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* IBI : I BI */
/* IBY : I BY */
/* IW : I W */
/* ID : I D */
/* DKH : D KH */
/* DKM : D KM */
/* DKF : D KF */
/* DKY : D KY */
/* DKS : D KS */
/* DKC : D KC */
/* DKT : D KT */
/* DKG : D KG */
/* T : T */
/* C : C */
/* QBI : Q BI */
/* QBY : Q BY */
/* QW : Q W */
/* QD : Q D */

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 7–3


SINUMERIK 840/880 Part 1 (PJ)
7 Programming with PL/M 11.91
7.2.1 Module Body of a PL/M Block

7.2.1.2 Compiler Statements


$LARGE ( SUBS has DAT_COM; EXPORTS HLL_HLL, HLL_MACRO, HLL_S5,
$ DB_LST, SB_LST, PB_LST, FB_LST, OB_LST, DX_LST, FX_LST,
$ HLL_ADB, XDBLAEN, XDSPVER, XBINERG, XAKOBNR, PeE, PeA,
$ E_Byte, A_Byte, M_Byte, Zeit, Zaehler, HLL_STOP,
$ S_Merker, QeE, QeA, HLL_LIM, HLL_SIM)

$COMPACT ROM

$eject

7.2.1.3 Module Block and Literally Declarations

PFB000: DO;

/***************************/
/* Literallies */
/***************************/

DECLARE DCL LITERALLY 'DECLARE',


LIT LITERALLY 'LITERALLY';

DCL BIT LIT 'BYTE',


CHAR LIT 'BYTE',
MASK LIT 'BYTE';

$EJECT

7.2.1.4 External Declarations of System Data and Functions

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

declare HLL_HLL pointer external;

declare HLL_MACRO pointer external;

declare HLL_S5 pointer external;

declare ( DB_LST, SB_LST, PB_LST, FB_LST,OB_LST, DX_LST, FX_LST ) (256) pointer


external;

declare XDBLAEN pointer external;


declare DB_Laenge based XDBLAEN word;

HLL_ADB: procedure (a,b) external;


declare a word;
declare b word;
end HLL_ADB;

7–4 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 7 Programming with PL/M
7.2.1 Module Body of a PL/M Block

declare XDSPVER pointer external;


declare Sp_Verw based XDSPVER structure
(PHANFGP word, PHENDEP word, PHANFGD word,
PHENDED word, GREBESP word, GREBEOP word,
GREBESD word, GREBEOD word);

declare (XBINERG, XAKOBNR) pointer external;


declare Bin_DigA based XBINERG word;
declare Akt_OB_Nr based XAKOBNR byte;

declare PeE (256) pointer external;


declare PeA (256) pointer external;

declare E_Byte (128) byte external;


declare A_Byte (128) byte external;
declare M_Byte (256) byte external;
declare Zeit (256) word external;
declare Zaehler (256) word external;

declare HLL_STOP pointer external;

declare S_Merker (4096) byte external;

declare QeE (256) pointer external;


declare QeA (256) pointer external;

declare HLL_LIM pointer external;


declare HLL_SIM pointer external;

/* S5HLL System Data END */

/**************************/
/* Constants */
/**************************/

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 7–5


SINUMERIK 840/880 Part 1 (PJ)
7 Programming with PL/M 11.91
7.2.1 Module Body of a PL/M Block

7.2.1.5 Procedure Declaration of Main Program, Call Parameters


function:
PROCEDURE ( IBI,
IBI_MSK,
IBY,
IW,
ID,
DKH,
DKM,
DKF,
DKY,
DKS,
DKC,
DKT,
DKG,
T,
C,
QBI_ADR,
QBI_MSK,
QBY_ADR,
QW_ADR,
QD_ADR) PUBLIC REENTRANT;

DCL IBI BIT,


IBI_MSK MASK,
IBY BYTE,
IW WORD,
ID DWORD,
DKH WORD,
DKM WORD,
DKF WORD,
DKY WORD,
DKS WORD,
DKC WORD,
DKT WORD,
DKG DWORD,
T WORD,
C WORD,
QBI_ADR POINTER,
QBI BASED QBI_ADR BIT,
QBI_MSK MASK,
QBY_ADR POINTER,
QBY BASED QBY_ADR BYTE,
QW_ADR POINTER,
QW BASED QW_ADR WORD,
QD_ADR POINTER,
QD BASED QD_ADR DWORD;

7–6 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 7 Programming with PL/M
7.2.1 Module Body of a PL/M Block

7.2.1.6 Local Data and Statement Part

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

END function;

END PFB000;

7.3 Parameter Check for HLL Calls in PL/M

If required, the block generator can check whether the call parameters passed by the PL/M
block when calling other PL/M blocks formally match the call parameters of the called block.
During the parameter check, the block generator calculates the number, sequence and type of
call parameters passed from the PL/M block to system function HLL_HLL(). The block
generator compares these values with the comments stored in the module header of the called
PL/M block which describe the input and output parameters.
Only the PL/M data types of the PL/M variables or constants specified in the HLL_HLL() call
are compared. If the called block is a C block, it is not possible to perform a parameter check.
During the parameter check, the block generator expands any existing literallies and
incorporates include files.
When passing constants in the HLL_HLL() call, the block generator makes allowance for the
fact that PL/M passes them as bytes, words or doublewords, according to their size, if no
explicit type conversion functions (LOW, HIGH, INT, etc.) are used.
String constants are illegal when calling HLL_HLL(), except to specify the type of block called.

7.3.1 Parameter Data Types Recognized in the Parameter Check

The parameter check can only be performed on single variables. In other words, the
HLL_HLL() call may not contain expressions or other function calls (even literallies). The only
exceptions to this rule are the following built-in functions:
DOUBLE, LOW, HIGH, ROL, ROR, SHL, SHR, SAL, SAR, BUILD$PTR, OFFSET$OF, SIZE,
LAST, LENGTH, SIGNED, UNSIGN, INT, IBS
Any expressions, including function calls, can be entered at index positions (array index) or
after the address operator. The type of array elements or (in the case of an address operator)
a pointer is returned as the variable type.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 7–7


SINUMERIK 840/880 Part 1 (PJ)
7 Programming with PL/M 11.92
7.3.2 Cross-Reference List

7.3.2 Cross-Reference List


When the block generator checks the compatibility of the parameters in HLL_HLL() calls, it
generates a list (cross-reference list) of the HLL function blocks which are invoked by the
function block checked.
The directory in which the lists are stored then contains a file named PFX???.CRF or
PFB???.CRF with the following structure:

***********************************************************
* *
* SINUMERIK Block Generator S5-PL/M Version 2.2 Date 10.08.91 *
* Directory of all blocks called from: FB 8 Page 1 *
* *
***********************************************************

Block Called in
Type Number Name File name Line Parameters

FB 2 I/Q/F PFB008.PLM 99 NR : D KF
NR1 : I BY

7.4 Brief Examples for PL/M

Example 1: Differences in parameter formats


This example shows the effects of the different data formats in PL/M and STEP 5.
Logic operation:
All bits in DW 100 are to be masked, except for bit 14. The result is to be transferred to DW
200.
STEP 5: L KH 4000
L DW 100
UW
T DW 200
PL/M: DW(200) = DW(100) and 0040h;
(with corresponding PL/M declaration of IW as input word and IB as input byte)
Example 2: Evaluate bit parameter
This example shows the effect of bit parameter conversion on the formulation of queries.
Assumption: You have defined a binary input parameter INP1. You want to program a branch
based on the state of this input bit.

7–8 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 7 Programming with PL/M
7.4 Brief Examples for PL/M

With conversion of the input bit parameter (operating system data BS 0.1 = 1), the query is as
follows, for example:
:
if (INP1 = 1) then
:
else
:

Without conversion (BS 0.1 = 0):


:
if (INP1_MSK = (INP1 and INP1_MSK)) then
:
else
:

Example 3: Indexing of data words in PL/M and STEP 5


Here again, the difference between Step 5 and PL/M relates to the addressing method.
STEP 5 PL/M
IW 5 =ˆ IB5 IB6 IW(5) =ˆ IB(10) IB(11)
ID 5 =ˆ IB5 IB6 ID(5) =ˆ IB(20) IB(21)
IB7 IB8 IB(22) IB(23)
(with corresponding PL/M declaration of IW as an input word and IB as an input byte)
Example 4: Constant as word parameter for function macros
Call FB 61 from PL/M block:
Read in R parameter 50 from Channel 1 in DB 200, DW 250 and 251.
Numeric format: Fixed point
Interface byte: No. 1 (DB 36/DL 0)
Read signal: Flag 200.5
Direct specification of parameters in the call:
CALL HLL_MACRO ( 'DB', 250, 200, 'F0', 0, 50, 1, ' ', 'NC', 'RP', 1, 1,
SHR (M_BYTE (200), 5), 61);

Here, all numeric values (such as DW number 250) are passed as bytes; the high byte of the
parameter is undefined. In certain circumstances, this can lead to error messages in FB 61.
The FB 61 call should therefore be programmed as follows:
DECLARE NSBY WORD DATA (1);
DECLARE ANZ WORD DATA (1);
DECLARE DTY1 WORD DATA ('RP');
DECLARE DTY2 WORD DATA ('NC');
DECLARE DTY3 WORD DATA (' ');
DECLARE WER1 WORD DATA (1);
DECLARE WER2 WORD DATA (50);
DECLARE WER3 WORD DATA (0);
DECLARE ZFPN WORD DATA ('F0');
DECLARE DBZI WORD DATA (200);
DECLARE DWZI WORD DATA (250);
DECLARE TYZI WORD DATA ('DB');

CALL HLL_MACRO ( TYZI, DWZI, DBZI, ZFPN, WER3, WER2, WER1, DTY3, DTY2, DTY1, ANZ, NSBY,
SHR (M_BYTE (200), 5), 61);

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 7–9


SINUMERIK 840/880 Part 1 (PJ)
7 Programming with PL/M 11.92
7.4 Brief Examples for PL/M

Example 5: Use of the status bits after HLL_S5()


The example shows how to query the result of binary logic after a STEP 5 program or step
block call.
:
if (bin_processing = 1) then
do;
call HLL_S5 ('PB', 122);

if ((Bin_ErgA and 01H) = 1) then /* RLO equal to 1 ? */


do;
:
end;
end;
else
:

Example 6: System stop and passing of error number


In this case, an error number is passed on a user-initiated system stop.
DECLARE FEHL_COD_A LITERALLY 204

:
if (error_flag = 1) then
do:
call HLL_STOP (FEHL_COD_A):
:

7.5 Rules for Upper and Lower Case Notation

No distinction is made in PL/M between upper and lower case letters. There are two
exceptions, however. The block generator or PLC system expects the pseudoparameters 'DB'
and 'DX' when a data block is opened, and 'FB' or 'FX' when an HLL block is called in upper
case letters.

7.6 Reserved Identifiers

In addition to the PL/M identifiers listed below, which are reserved either for the block
generator or PL/M itself, the names of PLC system data and functions may not be used in user
declarations. The identifiers reserved by the system data and system functions are described
in the sections entitled "Overview of System Data" and "Overview of System Functions".
Please consult the compiler manual for information about identifiers reserved for the compiler.

Identifiers reserved for the block generator:


function
Type
Number
Name
Lib.number
BIT
CHAR
MASK

7–10 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 7 Programming with PL/M
7.6 Reserved Identifiers

Identifiers reserved for the PL/M compiler:

ABS ADJUSTRPL ADRESSINITIAL


AND AT BASED
BLOCKINPUT BLOCKINWORD BLOCKOUTPUT
BLOCKOUTWORD BUILDPTR BY
BYTE CALL CARRY
CASE CAUSEINTERRUPT CMPB
CMPW DATA DEC
DECLARE DISABLE DO
DOUBLE DWORD ELSE
ENABLE END EOF
EXTERNAL FINDB FINDRB
FINDRW FINDW FIX
FLAGS FLOAT GETREALERROR
GO GOTO HALT
HIGH IABS IF
INPUT INT INTEGER
INTERRUPT INTERRUPTR INTREALMATHUNIT
INWORDSETB LABEL LAST
LENGTH LITERALLY LOCKSET
LOW MEMORY MINUS
MOD MOVB MOVE
MOVRB MOVRW MOVW
NIL NOT OFFSETOF
OR OUTPUT OUTWORD
PARITY PLUS POINTER
PROCEDURE PUBLIC REAL
REENTRANT RESTOREREALSTATUS RETURN
ROL ROR SAL
SAR SAVEREALSTATUS SCL
SCR SELECTOR SELECTOROF
SETINTERRUPT SETW SHL
SHR SIGNED SIZE
SKIPB SKIPRB SKIPRW
SKIPW STACKBASE STACKPTR
STRUCTURE THEN TIME
TO UNSIGN WHILE
WORD XLAT XOR
ZERO

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 7–11


SINUMERIK 840/880 Part 1 (PJ)
11.92 8 Programming with C
8.1 Language-Specific Features of C

8 Programming with C

8.1 Language-Specific Features of C

This chapter describes the language-specific features of HLL block generation with the C
programming language.
• The C module body and its declarations are language-specific; the C module body is
created by the block generator as a starting basis for your C block.
• In contrast to PL/M, the option of performing a parameter check when calling other HLL
blocks is not provided.
• The "Programming Examples" section contains a collection of small program excerpts.
• The chapter shows how various type of data blocks can be accessed from C blocks.
• A description is given of how C macros can be used to access data in STEP 5 format.
• Notes are provided for the use of upper and lower case letters in C blocks.
• The C identifiers reserved by the block generator are listed.

You will find further information for the generation of HLL blocks in Chapter 5. This chapter
contains special information which is not dependent on the programming language used.

8.2 Format of the C Module Body

The block generator creates a C module body when generating a new C function block. This
module is the starting basis for your C block.
The components of the module body are described below. This description is followed by a
listing of a C module body containing declarations of all PLC system data and functions and all
parameter data types. The listing is based on a C block intended for use on a PLC system
with ACOP. Fewer system data and functions can be used on PLC systems with COP; certain
other deviations also arise in the format of the status bits (see the section entitled "System
Data").
The C module body consists of the following components:

Module header
The block generator stores the block data in comment lines in the module header (see the
section entitled "Format of the Module Header").

Definition of types and constants


The parameter data types byte, mask, bit, word, sword and dword are defined here.
User constants and types can also be defined here.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 8–1


SINUMERIK 840/880 Part 1 (PJ)
8 Programming with C 11.91
8.2 Format of the C Module Body

External declaration of the system functions and data


The system data and functions which you define in Menu 6 are declared here. The start and
end of this component are indicated by comments:
/* S5HLL System Data START */

:
Declarations
:

/* S5HLL System Data END */

These comments are an essential part of the module body and may not be deleted or
modified.
When changes are made to the block interfaces, the block generator deletes the entire area
between the two comments and generates a new one. If you have made changes in this area,
the changes are deleted.

Procedure declaration for the main program


The main program for each HLL block is called "FUNCTION".
The procedure declaration contains the list of call parameters which you have defined in Menu
5. Some of the parameters are passed to the stack in a different format than used in the
program (for example, pointers are used for output parameters).

Parameter declaration
The parameters of the parameter list are declared here. The pointers for output parameters are
also declared here.
The masks for bit parameters are also included at this point.

Local data
You can declare local data for your C block after the declarations generated by the block
generator for the call parameters. Please remember that local data are not retentive, i.e. the
content of local data is undefined every time the block is called. Data which are to retain their
value across multiple block calls (retentive data) must be stored in data blocks.

Main procedure statement part


The C program text for the main program of the C block begins at this point.

8.2.1 Module Body of a C Block

Headings are inserted in the following listing for the purposes of clarity. The headings are not a
component of the C module body.

8–2 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 8 Programming with C
8.2.1 Module Body of a C Block

8.2.1.1 Module Header


/* SIEMENS Block Generator S5-C */
/* Date: 11.04.91 Time: 13:43:12 */

/* Type : FX */
/* Number : 000 */

/* Name : TOOLVERW */
/* Lib.number : 9136 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* IBI : I BI */
/* IBY : I BY */
/* IW : I W */
/* ID : I D */
/* DKH : D KH */
/* DKM : D KM */
/* DKF : D KF */
/* DKY : D KY */
/* DKS : D KS */
/* DKC : D KC */
/* DKT : D KT */
/* DKG : D KG */
/* T : T */
/* C : C */
/* QBI : Q BI */
/* QBY : Q BY */
/* QW : Q W */
/* QD : Q D */

8.2.1.2 Definition of Types of Constants

/******************************/
/* Typedef and Constants */
/******************************/

typedef unsigned char byte;


typedef unsigned char mask;
typedef unsigned char bit;
typedef unsigned int word;
typedef int sword;
typedef unsigned long int dword;

8.2.1.3 External Declarations of System Data and Functions

/*************************/
/* System Functions */
/* and */
/* System Data */
/*************************/

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 8–3


SINUMERIK 840/880 Part 1 (PJ)
8 Programming with C 11.91
8.2.1 Module Body of a C Block

/* S5HLL System Data START */

/* Call other HLL blocks */

extern far void (* far HLL_HLL) ();

/* Call resisdent function macros */

extern far void (* far HLL_MACRO) ();

/* Call STEP 5 blocks */

extern far void (* far HLL_S5) ();

/* Process data blocks */

extern far void HLL_ADB (unsigned short int, unsigned short int);

#define DB_Laenge XDBLAEN

extern unsigned short far * far DB_Laenge;

/* Block address list */

extern unsigned short int * far DB_LST[256];


extern unsigned short int * far SB_LST[256];
extern unsigned short int * far PB_LST[256];
extern unsigned short int * far FB_LST[256];
extern unsigned short int * far OB_LST[256];
extern unsigned short int * far DX_LST[256];
extern unsigned short int * far FX_LST[256];

/* Boundary addresses for user memory */

#define Sp_Verw XDSPVER


extern struct
{
unsigned short int PHANFGP;
unsigned short int PHENDEP;
unsigned short int PHANFGD;
unsigned short int PHENDED;
unsigned short int GREBESP;
unsigned short int GREBEOP;
unsigned short int GREBESD;
unsigned short int GREBEOD;
} * far Sp_Verw;

/* Interpreter data */

#define Bin_ErgA XBINERG


extern unsigned int far * far Bin_ErgA;
#define Akt_OB_Nr XAKOBNR
extern unsigned char far * far Akt_OB_Nr;

8–4 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 8 Programming with C
8.2.1 Module Body of a C Block

/* Process image [I/Q/F/T/C] */

extern unsigned char far E_Byte [128];


extern unsigned char far A_Byte [128];
extern unsigned char far M_Byte [256];
extern unsigned short int far Zeit [256];
extern unsigned short int far Zaehler [256];

/* I/O address list [I/Q] */

extern unsigned short int far * far PeE [256];


extern unsigned short int far * far PeA [256];

/* System stop from HLL user program */

extern far void (* far HLL_STOP) (unsigned short int);

/* Extended flag area */

extern unsigned char far S_Merker [512];

/* Extended I/O address list [I/Q] */

extern unsigned short int far * far QeE [256];


extern unsigned short int far * far QeA [256];

/* Semaphores (LIM, SIM) */

extern far void (* far HLL_LIM) (unsigned char *);


extern far void (* far HLL_SIM) (unsigned char *);

/* S5HLL System Data END */

8.2.1.4 Procedure Declaration of Main Program, Call Parameters

FUNCTION (IBI,
IBI_MSK,
IBY,
IW,
ID,
DKH,
DKM,
DKF,
DKY,
DKS,
DKC,
DKT,
DKG,
T,
C,
QBI_ADR,
QBI_MSK,
QBY_ADR,
QW_ADR,
QD_ADR)

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 8–5


SINUMERIK 840/880 Part 1 (PJ)
8 Programming with C 11.92
8.2.1 Module Body of a C Block

bit IBI;
mask IBI_MSK;
byte IBY;
word IW;
dword ID;
word DKH;
word DKM;
word DKF;
word DKY;
word DKS;
word DKC;
word DKT;
dword DKG;
word T;
word C;
bit * QBI_ADR;
mask QBI_MSK;
byte * QBY_ADR;
word * QW_ADR;
dword * QD_ADR;

8.2.1.5 Local Data and Statement Part


{

/*************************/
/* Declaration of */
/* Local Data */
/*************************/

/*************************/
/* Statement Part */
/* Main Procedure */
/*************************/

8.3 Brief Examples for C


Example 1: Differences in parameter formats
This example shows the effects of the different data formats in C and STEP 5.
Logic operation:
All bits in DW 100 are to be masked, except for bit 14. The result is to be transferred to DW
200.
STEP 5: L KH 4000
L DW 100
UW
T DW 200
C: DW[200] = DW[100] & 0x40;
(with corresponding C declaration of IW as input word and IB as input byte)

8–6 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 8 Programming with C
8.3 Brief Examples for C

Example 2: Evaluate bit parameter


This example shows the effect of bit parameter conversion on the formulation of queries.
Assumption: You have defined a binary input parameter INP1. You want to program a branch
based on the state of this input bit.
With conversion of the input bit parameter (operating system data BS 0.1 = 1), the query is as
follows, for example:
:
if (INP1 == 1)
{
:
}
else
{
:
}
:

Without conversion (BS 0.1=0):


:
if (EIN1_MSK == (INP1 & INP1_MSK)) then
{
:
}
else
{
:
}
:

Example 3: Indexing of data words in C and STEP 5


The difference between STEP 5 and C relates to the addressing method.

STEP 5 C
IW 5 =ˆ IB5 IB6 IW[5] =ˆ IB[10] IB[11]
ID 5 =ˆ IB5 IB6 ID[5] =ˆ IB[20] IB[21]
IB7 IB8 IB[22] IB[23]
(with corresponding C declaration of IW as an input word and IB as an input byte)
Example 4: Constant as word parameter for function macros
Constants used as call parameters for function macros must always be passed as a word
parameter. Constants are always passed as word parameters in C programs and therefore
problems do not arise in this case. Two methods for calling function macros are shown below.

Call FB 61 from C block:


Read in R parameter 50 from Channel 1 in DB 200, DW 250 and 251.
Numeric format: Fixed point
Interface byte: No. 1 (DB 36/DL 0)
Read signal: Flag 200.5
Direct specification of parameters in the call:
HLL_MACRO ( 'DB', 250, 200, 'F0', 0, 50, 1, '', 'NC', 'RP', 1, 1,
(M_Byte[200] >> 5), 61);

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 8–7


SINUMERIK 840/880 Part 1 (PJ)
8 Programming with C 11.92
8.3 Brief Examples for C

Define and pass parameters as constants:


#define NSBY 1
#define ANZ 1
#define DTY1 'RP'
#define DTY2 'NC'
#define DTY3 ''
#define WER1 1
#define WER2 50
#define WER3 0
#define ZFPN 'F0'
#define DBZI 200
#define DWZI 250
#define TYZI 'DB'

HLL_MACRO ( TYZI, DWZI, DBZI, ZFPN, WER3, WER2, WER1, DTY3, DTY2,
DTY1, ANZ, NSBY, (M_Byte[200] >> 5), 61);

The names of the STEP 5 application interface enhance the legibility of the program.

Example 5: Use of the status bits after HLL_S5()


The example shows how to query the result of binary logic after a STEP 5 program or step
block call.
:
if (bin_processing == 1)
{
HLL_S5 ('PB', 122);

if ((Bin_ErgA & 0x01) == 1) /* RLO is equal to 1? */


{
:
}
}
:

Example 6: System stop and passing of error number


In this case, an error number is passed on a user-initiated system stop.
#define FEHL_COD_A 204

:
if (error_flag == 1)
{
HLL_STOP (FEHL_COD_A);
:
}
:

8–8 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 8 Programming with C
8.4 Processing of Data Blocks

8.4 Processing of Data Blocks


Data blocks are declared in the HLL block as a global data area. In C blocks, data blocks can
also be declared at procedure level; they must then be assigned the attribute "static".
There are various ways of declaring a data block in C:
• Declare data block as word array:
unsigned int dat_blk[300]; /* Declare global array */
/* with 300 words */
FUNCTION (...) /* Main procedure of C block */
:
:
HLL_ADB ('DB', 100); /* Open DB 100 */
for (i=0; i<50; i++)
dat_blk [i] = 0xff00; /* Process DB 100 */
:
HLL_ADB('DX', 200); /* Open DX 200 */
for (i=0; i<150; i++)
dat_blk [i] = 0xbcd; /* Process DX 200 */
:

• Declare data block as data structure:


struct {
unsigned int tool_no;
unsigned int tool_tech;
unsigned char tool_name[10];
unsigned int tool_station;
}dat_blk[140]; /* Declare global array */
/* with 140 structure elements */

FUNCTION(...) /* Main procedure of C block */


:
:
HLL_ADB('DB', 100); /* Open DB 100 */
for (i=0; i<140; i++)
dat_blk[i].tool_no = i; /* Process DB 100 */

• Declare data block with different data structures:


union {
unsigned int dat_arr[300]; /* Declare global array */
/* with 300 words */

struct {
unsigned int tool_no;
unsigned int tool_tech;
unsigned char tool_name[10];
unsigned int tool_station;
} dat_str[140]; /* Declare global array */
/* with 140 structure elements */
} dat_blk;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 8–9


SINUMERIK 840/880 Part 1 (PJ)
8 Programming with C 11.92
8.4 Processing of Data Blocks

FUNCTION(...) /* Main procedure of C block */


:
HLL_ADB('DB', 100); /* Open DB 100 */
for (i=0; i<50; i++)
dat_blk.dat_arr[i]=0xff00; /* Process DB 100 */

:
:
HLL_ADB('DX', 200); /* Open DX 200 */
for (i=0; i<50; i++)
dat_blk.dat_str[i].wz_tech = i; /* Process DX 200 */
:

• Declare data block at procedure level:


FUNCTION(...) /* Main procedure of C block */
:
static unsigned int dat_blk[300]; /* Declare local array */
/* with 300 words */

:
HLL_ADB('DB', 100); /* Open DB 100 */
for (i=0; i<50; i++)
dat_blk[i] = 0xff00; /* Process DB 100 */
:

• Access data blocks via pointer:


:
#define NULL 0L
:
FUNCTION(...) /* Main procedure of C block */
:
unsigned short int * far ptr_db_A; /* Declare pointer for */
unsigned short int * far ptr_db_B; /* access to data blocks */

ptr_db_A = ptr_db_B = NULL; /* Initialize pointer */

ptr_db_A = DB_LST[100]; /* Pointer to DB 100 */


ptr_db_B = DX_LST[200]; /* Pointer to DX 200 */

if ((ptr_db_A == NULL) ¦¦ (ptr_db_B == NULL))


HLL_STOP(22); /* Data block does not exist */

for (i=0; i<200; i++) /* Copy data blocks */


*(ptr_db_A + i) = *(ptr_db_B + i);

Notes:
• The user program is responsible for checking the processed data blocks.
• When HL_ADB() is called, the number of the last data word of the opened DB is entered
in system data DB_Laenge. This system cell can be addressed for checking purposes.
• When processing data blocks via pointers, the length can be read from the block header.
• The "access data blocks via pointer" example can only be used in this form for PLC
systems with COP. Bits 0...11 of the segment part of the address must be masked on PLC
systems with ACOP.

8–10 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 8 Programming with C
8.5 Use of C Macros

8.5 Use of C Macros


By defining macros, it is possible in C to implement data accesses in STEP 5 format or to
support conversion to the intel format. It is also possible to transfer the notation when
accessing data from STEP 5.
The macros below are described together with examples for their use.
• Read and write in byte format:
#define EB(x) E_Byte[x]
#define AB(x) A_Byte[x]
#define MB(x) M_Byte[x]

• Read in word format:


#define EW(x) (((unsigned short int) E_Byte[x] << 8) ¦ E_Byte[(x)+1])
#define AW(x) (((unsigned short int) A_Byte[x] << 8) ¦ A_Byte[(x)+1])
#define EW(x) (((unsigned short int) M_Byte[x] << 8) ¦ M_Byte[(x)+1])

• Read timers and counters:


#define T(x) ((Zeit[x] << 8)¦((unsigned short int) Zeit[x] >> 8))
#define Z(x) ((Zaehler[x] << 8)¦((unsigned short int) Zaehler[x] >> 8))

• Read I/O bytes:


#define E_PY(x) ((unsigned char) *PeE[x])
#define A_PY(x) ((unsigned char) *PeA[x])

• Byte and word access to data blocks:


For these macros, the data block must be declared in the C block as a global word array
DB.
#define DL(x) ((unsigned char) DB[x])
#define DR(x) ((unsigned char) ((unsigned short int) DB[x] >> 8))
#define DW(x) ((DB[x] << 8) ¦ ((unsigned short int) DB[x] >> 8))

• Doubleword access to inputs/outputs/flags/data blocks:


For these macros, the preceding macros must be declared in the C block.
#define ED(x) ((((long int) EW(x)) << 16)¦EW((x)+2))
#define AD(x) ((((long int) AW(x)) << 16)¦AW((x)+2))
#define MD(x) ((((long int) MW(x)) << 16)¦MW((x)+2))
#define DD(x) ((((long int) DW(x)) << 16)¦DW((x)+2))

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 8–11


SINUMERIK 840/880 Part 1 (PJ)
8 Programming with C 11.91
8.5 Use of C Macros

• Wordwise write access to inputs/outputs/flags/timers/counters/data blocks:


For the last of these macros, the data block must be declared in the C block as a global
word array.
#define TBY(z) ((((unsigned short int) z) >> 8) ¦ ((z) << 8))

#define WEW(x,y) (*((unsigned short int far *) &(E_Byte[x])) = TBY(y))


#define WAW(x,y) (*((unsigned short int far *) &(A_Byte[x])) = TBY(y))
#define WMW(x,y) (*((unsigned short int far *) &(M_Byte[x])) = TBY(y))
#define WTW(x,y) (*((unsigned short int far *) &(Zeit[x])) = TBY(y))
#define WZW(x,y) (*((unsigned short int far *) &(Zaehler[x])) = TBY(y))
#define WDW(x,y) (*((unsigned short int far *) &(DB[x])) = TBY(y))

• Examples for the use of the macros:


:
const unsigned char LED_BY_AN = 0xFF, LED_BY_AUS = 0;
:
unsigned int var1, var2; /* Local variables */
unsigned char var3;
:
:
var1 = DW(3); /* Read third data word */
AB(6) = MB(8) + 1; /* Read flag byte and write output byte */
var2 = EW(8) + EW(20); /* Read input words and process */
DL(2) = 1; /* Assign left byte from data word 2 */

if (MB(200) & 0x10) /* Branch depending on bit in flag byte */


AB(8) = LED_BY_AN;
else
AB(8) = LED_BY_AUS;

var3 = E_PY(5); /* Read input I/O byte */


WDW(120, 0xAA55); /* Write constant to data word 120 */
WAW(10, DW(4)); /* Write data word 4 to output word */

8.6 Rules for Upper and Lower Case Notation

A distinction is made in C between upper and lower case letters.


The block generator creates the call parameters of an HLL block in upper case letters. This
should always be remembered when using the parameters in the C function block.
The block generator or PLC system expects the pseudoparameters 'DB' and 'DX' when a data
block is opened, and 'FB' or 'FX' when an HLL block is called in upper case letters.

8–12 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 8 Programming with C
8.7 Reserved Identifiers

8.7 Reserved Identifiers


In addition to the C identifiers listed below, which are reserved either for the block generator or
C itself, the names of PLC system data and functions may not be used in user declarations.
The identifiers reserved by the system data and system functions are described in the sections
entitled "Overview of System Data" and "Overview of System Functions".
Please consult the compiler manual for information about identifiers reserved for the compiler.
Reserved for the block generator:
function
Type
Number
Name
Lib.Number
byte
mask
bit
word
sword
dword

Reserved for the C compiler:

auto break case


char const continue

default do double
else enum extern

float for goto


if int long

register return short

signed sizeof static


struct switch typedef

union unsigned void


volatile while

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 8–13


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1 Examples in PL/M

9 Example Programs

This chapter contains examples of function blocks programmed in the high-level languages
PL/M and C. These examples illustrate the use of the system interfaces, but are not intended
for user programs.

9.1 Examples in PL/M

9.1.1 FB 1, Access to Data Blocks


FB 1 shows how to access a data block from a PL/M block.
The data block is declared globally. The various redefinitions (... at(@dataword (0))) allow byte,
word or doubleword-oriented access to the data block. Access in STEP 5 format is also
supported.
The data block must be opened before the first access (system function HLL_ADB()).

/* SIEMENS Block Generator S5-PL/M */


/* Date: 08.04.91 Time: 15:18:29 */

/* Type : FB */
/* Number : 001 */

/* Name : DBZUGR */
/* Lib.number : 12345 */

/* PLC System : 1 (PLC 135WB with COP) */

/* DBNR: D KF */ /* Number of DB to be opened */


/* DNR : I BY */ /* Number of a DW in the DB */
/* DTYP: D KS */ /* Data block type (DB or DX) */
/* INHA: I BY */ /* Desired value of the DW in the DB */
/* ERR : Q BI */ /* Error bit for parameter errors */

$LARGE (SUBS has DAT_COM; EXPORTS DB_LST, SB_LST, PB_LST, FB_LST, OB_LST, DX_LST,
$ FX_LST, HLL_ADB, XDBLAEN, E_Byte, A_Byte, M_Byte, Zeit, Zaehler)

$COMPACT ROM

$eject

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–1


SINUMERIK 840/880 Part 1 (PJ)
9 Program Exampels 11.91
9.1.1 FB 1, Access to Data Blocks

PFB001: DO;

/**************************/
/* Literallies */
/**************************/

DECLARE DCL LITERALLY 'DECLARE',


LIT LITERALLY 'LITERALLY';

DCL BIT LIT 'BYTE',


CHAR LIT 'BYTE',
MASK LIT 'BYTE';

$EJECT
/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

declare ( DB_LST, SB_LST, PB_LST, FB_LST,


OB_LST, DX_LST, FX_LST ) (256) pointer external;

declare XDBLAEN pointer external;


declare DB_Laenge based XDBLAEN word;

HLL_ADB:procedure (a,b) external;


declare a word;
declare b word;
end HLL_ADB;

declare E_Byte (128) byte external;


declare A_Byte (128) byte external;
declare M_Byte (256) byte external;
declare Zeit (128) word external;
declare Zaehler (128) word external;

/* S5HLL System Data END */

/***********************************************************/
/* Definition of an array for addressing */
/* in in data blocks (max. size: 2043 words); */
/* refers to the currently open DB */
/***********************************************************/

dcl dataword (256) word;

9–2 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 9 Example Programs
9.1.1 FB 1, Access to Data Blocks

/**************************/
/* Constants */
/**************************/

function:
PROCEDURE (DBNR,
DNR,
DTYP,
INHA,
ERR_ADR,
ERR_MSK) PUBLIC REENTRANT;

DCL DBNR WORD,


DNR BYTE,
DTYP WORD,
INHA BYTE,
ERR_ADR POINTER,
ERR BASED ERR_ADR BIT,
ERR_MSK MASK;

/**************************/
/* Declaration */
/* of Local Data */
/**************************/

/* The following declarations can be used to address */


/* a data block after the block has been opened with */
/* HLL_ADB(). Byte, word and doubleword-oriented or */
/* structured accesses (data left, data right) are supported */

dcl data byte (512) byte at (@dataword (0));

dcl dw1 (256) structure (dataleft byte, dataright byte) at (@dataword(0));

dcl ddw (128) dword at (@dataword(0));

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–3


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.1 FB 1, Access to Data Blocks

/***************************/
/* Statement Part */
/* Main Procedure */
/**************************/

if ((dtyp = 'DB') and (DB_LST(dbnr) <> 0) or


(dtyp = 'DX') and (DX_LST(dbnr) <> 0)) then

do; /* DB type equals DB,DX and DB exists */

err = err and not err_msk; /* Clear error bit */

call HLL_ADB(dtyp,dbnr); /* Open data block */


/* Now the above declarations */
/* can be used to access the data */
/* of the open data block using */
/* various methods */

/****************************************************/
/* Examples for accessing data block */
/****************************************************/

dataword(dnr) = inha; /* Write parameter to DW */

databyte(9) = E_Byte(1); /* DR4 = contents of input byte */

dw1(10).dataleft = E_Byte(2); /* DL10 = input byte */

ddw(7) = 0abcd1234h; /* Write constant to doubleword */

databyte(8) = E_Byte(2) and 01h; /* A I 2.0 –> Data 8 */

/* If ddw(7) is assigned, as above, by the high-level language, */


/* the following applies to word-oriented access: */
/* Access from high-level language to dataword(14) and dataword(15): */
/* dataword(14) = 1234, dataword(15) = abcd */
/* */
/* Access from STEP5 side to dataword14 and dataword15: */
/* dataword14 = 3412, dataword15 = cdab */
/* Reason: different formats of STEP 5/HLL */
/* */
/* STEP 5: High byte is stored at lower address in memory */
/* HLL: Low byte is stored at lower address in memory */
/* The high and low word are also exchanged */
/* with 32-bit variables. */

end;

9–4 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.1 FB 1, Access to Data Blocks

else do;
/* Set error bit if DTYP not DB or DX */
/* or DB, DX do not exist */

err = err or err_msk;


end;

/**************************/
/* End of */
/* Main Procedure */
/**************************/

END function;

END PFB001;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–5


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.2 FB 2, Access to Process Image

9.1.2 FB 2, Access to Process Image


Function block FB 2 shows how to access the process image (special inputs, outputs and
flags) from a PL/M block.
It also illustrates how you can use various redefinitions (...at(@E_Byte(0))) to perform word
and doubleword-oriented accesses to the process image.

/* SIEMENS Block Generator S5-PL/M */


/* Date: 08.04.91 Time: 15:21:17 */

/* Type : FB */
/* Number : 002 */

/* Name : EAM */
/* Lib.number : 34343 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* NR : D KF */ /* Number of input byte */


/* NR1 : E BY */ /* Number of output byte */

$LARGE (SUBS has DAT_COM; EXPORTS E_Byte, A_Byte, M_Byte, Zeit, Zaehler)

$COMPACT ROM

$eject

PFB002: DO;

/**************************/
/* Literallies */
/**************************/

DECLARE DCL LITERALLY 'DECLARE',


LIT LITERALLY 'LITERALLY';

DCL BIT LIT 'BYTE',


CHAR LIT 'BYTE',
MASK LIT 'BYTE';

$EJECT

9–6 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.2 FB 2, Access to Process Image

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

declare E_Byte (128) byte external;


declare A_Byte (128) byte external;
declare M_Byte (256) byte external;
declare Zeit (256) word external;
declare Zaehler (256) word external;

/* S5HLL System Data END */

/**************************/
/* Constants */
/**************************/

function:
PROCEDURE (NR,
NR1) PUBLIC REENTRANT;

DCL NR WORD,
NR1 BYTE;

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

/* Declarations for word and doubleword access */

dcl Inputword(64) word at(@E_Byte(0));


dcl Inputd_word(32) dword at(@E_Byte(0));
dcl Flagword(128) word at(@M_Byte(0));

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–7


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.2 FB 2, Access to Process Image

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

/*************************************************/
/* Examples of accesses to process image */
/*************************************************/

A_Byte(nr1) = E_Byte(nr); /* Copy input byte to */


/* output byte */

Flagword(100) = Inputword(0) /* Copy input word to */


/* flag word */
/* At STEP 5 level, */
/* flag word 200 is addressed */

Flagword(102) = Inputd_word(0); /* Copy input doubleword to */


/* two flag words and */
/* swap high and low words */

Flagword(103) = shr(Inputd_word(0),16); /* At STEP 5 level, */


/* flag words 204 and 206 */
/* are addressed */

/* Flag word (x) in PL/M = flag word (2*x) in STEP 5 */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

END function;

END PFB002;

9–8 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.3 FB 4, Processing of Counters and Timers

9.1.3 FB 4, Processing of Counters and Timers


Function block FB 4 shows how to read counter and timer values from a PL/M block and how
to start the counters and timers. The latter is only possible on PLC systems with COP.
FB 4 also illustrates word-oriented accesses to flags by redefinition (...at(@M_Byte(0))).

/* SIEMENS Block Generator S5-PL/M */


/* Date: 08.04.91 Time: 15:23:49 */

/* Type : FB */
/* Number : 004 */

/* Name : TZMB */
/* Lib.number : 12349 */

/* PLC System : 1 (PLC 135WB with COP) */

/* TNR : D KF */ /* Number of counter */


/* ZNR : D KF */ /* Number of timer cell */
/* MWT : D KF */ /* Number of flag word for counter value */
/* MWZ : D KF */ /* Number of flag word for timer */

$LARGE (SUBS has DAT_COM; EXPORTS E_Byte, A_Byte, M_Byte, Zeit, Zaehler)

$COMPACT ROM

$eject

PFB004: DO;

/**************************/
/* Literallies */
/**************************/

DECLARE DCL LITERALLY 'DECLARE',


LIT LITERALLY 'LITERALLY';

DCL BIT LIT 'BYTE',


CHAR LIT 'BYTE',
MASK LIT 'BYTE';

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–9


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.3 FB 4, Processing of Counters and Timers

$EJECT
/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

declare E_Byte (128) byte external;


declare A_Byte (128) byte external;
declare M_Byte (256) byte external;
declare Zeit (128) word external;
declare Zaehler (128) word external;

/* S5HLL System Data END */

/**************************/
/* Constants */
/**************************/

function:
PROCEDURE (TNR,
ZNR,
MWT,
MWZ) PUBLIC REENTRANT;

DCL TNR WORD,


ZNR WORD,
MWT WORD,
MWZ WORD;

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

dcl flagword (128) word at(@M_Byte(0)); /* Flag word structure for wordwise */
/* access */
dcl aux_var word; /* Auxiliary variable */

9–10 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.3 FB 4, Processing of Counters and Timers

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

flagword(mwz) = counter(cno) and 0ff03h; /* Read counter value, but caution: */


/* counter is an array with */
/* STEP 5 data; exchange high and */
/* low bytes; therefore only */
/* bits 0, 1, 8...15 relevant */

counter(cno + 1) = 06400h; /* Initialize counter(cno+1) */


/* with 100dec */
/* Caution here also: STEP 5 data */

flagword(mwt) = (timer(tno) and 0ff03h); /* Read timer value */

aux_var = (timer(1) and 0ff03h); /* Read timer value from cell 1 */

if ((E_Byte(0) and 01h) = 1) then


do;

timer(1) = 19A8h; /* Initialize timer(1) with */


/* 25 sec and start; */
/* Caution here also: STEP 5 data */

A_Byte(0) = (A_Byte(0) or 01h); /* Set Q0.0 = 1 */


end;

if (aux_var = 0) then
do;
A_Byte(0) = (A_Byte(0) and 0feh); /* If time expired, */
/* set Q0.0 = 0 */

end;

/**************************/
/* End of */
/* Main Procedure */
/**************************/

END function;

END PFB004;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–11


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.4 FB 6, Search in Data Block

9.1.4 FB 6, Search in Data Block


Function block FB 6 shows how you can search easily from a PL/M block for a defined value
in a data block.
Only the address of the block is required in order to access the data block. The address is
read from the block address list. The block is opened (system function HLL_ADB()) in order
to access the length of the block.

/* SIEMENS Block Generator S5-PL/M */


/* Date: 08.04.91 Time: 15:27:04 */

/* Type : FB */
/* Number : 006 */

/* Name : SUCH */
/* Lib.number : 23456 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* DBNR: D KF */ /* Number of the DB in which


the search is to be performed */
/* MUST: I W */ /* Search criteria */
/* GEF : Q W */ /* Number of the data word found */
/* ERR : Q BI */ /* Error message if DB does not exist */

$LARGE ( SUBS has DAT_COM; EXPORTS DB_LST, SB_LST, PB_LST, FB_LST, OB_LST, DX_LST,
$ FX_LST, HLL_ADB, XDBLAEN)

$COMPACT ROM

$eject

PFB006: DO;

/**************************/
/* Literallies */
/**************************/

DECLARE DCL LITERALLY 'DECLARE',


LIT LITERALLY 'LITERALLY';

DCL BIT LIT 'BYTE',


CHAR LIT 'BYTE',
MASK LIT 'BYTE';

9–12 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.4 FB 6, Search in Data Block

$EJECT
/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

declare ( DB_LST, SB_LST, PB_LST, FB_LST,


OB_LST, DX_LST, FX_LST ) (256) pointer external;

declare XDBLAEN pointer external;


declare DB_Laenge based XDBLAEN word;

HLL_ADB:procedure (a,b) external;


declare a word;
declare b word;
end HLL_ADB;

/* S5HLL System Data END */

/**************************/
/* Constants */
/**************************/

function:
PROCEDURE (DBNR,
MUST,
GEF_ADR,
ERR_ADR,
ERR_MSK) PUBLIC REENTRANT;

DCL DBNR WORD,


MUST WORD,
GEF_ADR POINTER,
GEF BASED GEF_ADR WORD,
ERR_ADR POINTER,
ERR BASED ERR_ADR BIT,
ERR_MSK MASK;

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

dcl var word;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–13


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.92
9.1.4 FB 6, Search in Data Block

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

if DB_LST(dbnr) = 0 then
do;
err = err or err_msk; /* DB does not exist, set error bit */

end;

else do;

err = err and not err_msk; /* DB exists; clear error bit */

call HLL_ADB('DB', dbnr); /* Open data block */

var = db_laenge + 1; /* Determine DB length */

/* Search process is performed with a built-in function */


/* gef = no. of data word found */
/* gef = -1 search criteria not found in DB */

gef = findw(DB_LST(dbnr), must, var);

end;

/**************************/
/* End of */
/* Main Procedure */
/**************************/

END function;

END PFB006;

9–14 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.5 FB 8, Call Other HLL Procedures

9.1.5 FB 8, Call Other HLL Procedures


Function block FB 8 shows how to call other HLL function blocks from a PL/M block (system
function HLL_HLL()).
It also illustrates how to declare and call local procedures in a PL/M block.

/* SIEMENS Block Generator S5-PL/M */


/* Date: 08.04.91 Time: 15:30:55 */

/* Type : FB */
/* Number : 008 */

/* Name : PLM-PLM */
/* Lib.number : 32189 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* AUS : I BY */ /* Parameters which are passed to FB 2 */


/* NN : D KF */
/* BYTN: D KF */ /* Number of an output byte */
/* BITN: D KF */ /* Number of bit position */
/* WER1: D KF */ /* Condition for shift operation */

$LARGE (SUBS has DAT_COM; EXPORTS HLL_HLL, E_Byte, A_Byte, M_Byte, Zeit, Zaehler)

$COMPACT ROM

$eject

PFB008: DO;

/**************************/
/* Literallies */
/**************************/

DECLARE DCL LITERALLY 'DECLARE',


LIT LITERALLY 'LITERALLY';

DCL BIT LIT 'BYTE',


CHAR LIT 'BYTE',
MASK LIT 'BYTE';

$EJECT

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–15


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.5 FB 8, Call Other HLL Procedures

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

declare HLL_HLL pointer external;

declare E_Byte (128) byte external;


declare A_Byte (128) byte external;
declare M_Byte (256) byte external;
declare Zeit (256) word external;
declare Zaehler (256) word external;

/* S5HLL System DATA END */

/**************************/
/* Constants */
/**************************/

function:
PROCEDURE (AUS,
NN,
BYTN,
BITN,
WER1) PUBLIC REENTRANT;

DCL AUS BYTE,


NN WORD,
BYTN WORD,
BITN WORD,
WER1 WORD;

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

call HLL_HLL (nn, aus, 'FB', 2); /* Call FB 2 with parameters */

call BITMAN(BYTN, BITN, WER1); /* Call a local function */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

END function;

9–16 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.5 FB 8, Call Other HLL Procedures

/**************************/
/* Local */
/* Functions */
/**************************/

BITMAN:PROCEDURE (abnr, bitnr, value) REENTRANT;


DCL (abnr, bitnr, value) BYTE;

if value = 1 then
A_Byte(abnr) = (A_Byte(abnr) OR SHL(1h, bitnr));

else
A_Byte(abnr) = (A_Byte(abnr) AND ROL(0FEH, bitnr));

end BITMAN;

END PFB008;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–17


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.6 FB 10, FB 15, Use of Semaphores

9.1.6 FB 10, FB 15, Use of Semaphores


Function blocks FB 10 and FB 15 show how to set and clear the OB disable identifiers in PL/M
blocks.
The disable identifier for OB 5 is set in FB 10 and subsequently cleared again in FB 15.
System functions HLL_LIM() and HLL_SIM() are used.

/* SIEMENS Block Generator S5-PL/M */


/* Date: 08.04.91 Time: 15:36:01 */

/* Type : FB */
/* Number : 010 */

/* Name : SPERR0B5 */
/* Lib.number : 09131 */

/* PLC System : 2 (PLC 135WB with ACOP) */

$LARGE (SUBS has DAT_COM; EXPORTS HLL_LIM, HLL_SIM)

$COMPACT ROM

$eject

PFB010: DO;

/**************************/
/* Literallies */
/**************************/

DECLARE DCL LITERALLY 'DECLARE',


LIT LITERALLY 'LITERALLY';

DCL BIT LIT 'BYTE',


CHAR LIT 'BYTE',
MASK LIT 'BYTE';

$EJECT

9–18 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.6 FB 10, FB 15, Use of Semaphores

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

declare HLL_LIM pointer external;


declare HLL_SIM pointer external;

/* S5HLL System Data END */

/**************************/
/* Constants */
/**************************/

dcl disable_mask_OB5 byte data(20h); /* Disable identifier mask for OB 5*/

function:
PROCEDURE PUBLIC REENTRANT;

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

dcl disable_id byte; /* OB disable identifier */

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

call HLL_LIM (@disable_id); /* Read current disable identifier */

disable_id = disable_id or
disable_mask_OB5; /* Set disable identifier for OB 5 */

call HLL_SIM (@disable_id); /* Disable OB 5 */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

END function;

END PFB010;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–19


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.6 FB 10, FB 15, Use of Semaphores

/* SIEMENS Block Generator S5-PL/M */


/* Date: 08.04.91 Time: 15:37:02 */

/* Type : FB */
/* Number : 015 */

/* Name : FREIGOB5 */
/* Lib.number : 01936 */

/* PLC System : 2 (PLC 135WB with ACOP) */

$LARGE (SUBS has DAT_COM; EXPORTS HLL_LIM, HLL_SIM)

$COMPACT ROM

$eject

PFB015: DO;

/**************************/
/* Literallies */
/**************************/

DECLARE DCL LITERALLY 'DECLARE',


LIT LITERALLY 'LITERALLY';

DCL BIT LIT 'BYTE',


CHAR LIT 'BYTE',
MASK LIT 'BYTE';

$EJECT
/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

declare HLL_LIM pointer external;


declare HLL_SIM pointer external;

/* S5HLL System Data END */

9–20 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 9 Example Programs
9.1.6 FB 10, FB 15, Use of Semaphores

/**************************/
/* Constants */
/**************************/

dcl enable_mask_OB5 byte data (0dfh); /* Disable identifier mask for OB 5 */

function:
PROCEDURE PUBLIC REENTRANT;

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

dcl disable_id byte; /* OB disable identifier */

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

call HLL_LIM (@disable_id); /* Read current disable identifier */

disable_id = disable_id and


enable_mask_OB5; /* Clear disable identifier for OB 5 */

call HLL_SIM (@disable_id); /* Enable OB 5 */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

END function;

END PFB015;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–21


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.7 FB 20, I/O Processing

9.1.7 FB 20, I/O Processing


FB 20 shows how to access the I/O directly from a PL/M block.
The access is performed via the I/O address list. The process image is not updated
automatically, and this must be performed in the PL/M block.
The PL/M function block FB 20 copies a defined area of inputs into the outputs. The area is
defined by the call parameters.
It is assumed that the defined I/O area (inputs and outputs) exists and is contiguous.

/* SIEMENS Block Generator S5-PL/M */


/* Date: 08.04.91 Time: 15:33:49 */

/* Type : FB */
/* Number : 020 */

/* Name : PERI */
/* Lib.number : 20005 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* STRT : D KF */ /* Start of area to be copied */


/* END: D KF */ /* End of area to be copied */

$LARGE ( SUBS has DAT_COM; EXPORTS DB_LST, SB_LST, PB_LST, FB_LST, OB_LST, DX_LST,
$ FX_LST, HLL_ADB, XDBLAEN, PeE, PeA, E_Byte, A_Byte, M_Byte, Zeit, Zaehler)

$COMPACT ROM

$eject

PFB020: DO;

9–22 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.7 FB 20, I/O Processing

/**************************/
/* Literallies */
/**************************/

DECLARE DCL LITERALLY 'DECLARE',


LIT LITERALLY 'LITERALLY';

DCL BIT LIT 'BYTE',


CHAR LIT 'BYTE',
MASK LIT 'BYTE';

$EJECT
/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

declare ( DB_LST, SB_LST, PB_LST, FB_LST,


OB_LST, DX_LST, FX_LST ) (256) pointer external;

declare XDBLAEN pointer external;


declare DB_Laenge based XDBLAEN word;

HLL_ADB:procedure (a,b) external;


declare a word;
declare b word;
end HLL_ADB;

declare PeE (256) pointer external;


declare PeA (256) pointer external;

declare E_Byte (128) byte external;


declare A_Byte (128) byte external;
declare M_Byte (256) byte external;
declare Zeit (256) word external;
declare Zaehler (256) word external;

/* S5HLL System Data END */

dcl dataword (20) word; /* Structure for access to data blocks */

/**************************/
/* Constants */
/**************************/

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–23


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.1.7 FB 20, I/O Processing

function:
PROCEDURE (STRT,
END) PUBLIC REENTRANT;

DCL STRT WORD,


END WORD;

/* The following requirements must be met:


--- Inputs exist in contiguous form from STRT to END
--- Outputs exist in contiguous form from STRT to END
*/

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

/* Declaration of pointers for word and doubleword access */

dcl dd_inp dword at(@dataword(0));


dcl ptr_inp pointer at(@dataword(0));
dcl base_inp selector at(@dataword(1));
dcl offset_inp word at(@dataword(0));

dcl ptr_adr_inp pointer;


dcl proc_inp based ptr_adr_inp byte;

dcl dd_out dword at(@dataword(2));


dcl ptr_out pointer at(@dataword(2));
dcl base_out selector at(@dataword(3));
dcl offset_out word at(@dataword(2));
dcl ptr_adr_out pointer;

dcl n byte;

9–24 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.1.7 FB 20, I/O Processing

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

call HLL_ADB('DB', 200); /* Open DB 200 */

do n = strt to end;

ptr_inp = PeE(n); /* Pass address of nth input byte */


/* to data block */
/* Offset in dataword(0), */
/* segment in dataword(1) */

dataword(1) = (dataword(1) and 0f000h); /* Clear bits 0 to 11 of segment */

ptr_adr_inp = buildptr(base_inp,
offset_inp); /* Create pointer */
/* to real address */
/* of the nth input byte */

ptr_out = PeA(n); /* Pass address of the nth output */


/* byte to data block */
/* Offset in dataword(2), */
/* segment in dataword(3) */

dataword(3) = (dataword(3) and 0f000h); /* Clear bits 0 to 11 of segment */

ptr_adr_out = buildptr(base_out,
offset_out); /* Create pointer */
/* to real address */
/* of the nth output byte */

call movb(ptr_adr_inp, ptr_adr_out, 1); /* Call built-in function */


/* The value of the nth input byte */
/* is passed to the nth output byte; */
/* the process image */
/* is circumnavigated */

A_Byte(n) = proc_inp; /* Correction to process image, as */


/* otherwise the transferred byte */
/* would be overwritten */
/* by the process image later */

end;

/**************************/
/* End of */
/* Main Procedure */
/**************************/

END function;

END PFB020;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–25


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2 Examples in C

9.2 Examples in C
9.2.1 FX 1, Access to Data Blocks

FX 1 shows how to access a data block from a C block.


The data block is declared here globally as a union. This enables byte, word or doubleword-
oriented access to the data block. Access in STEP 5 format is also supported.
The data block must be opened before the first access (system function HLL_ADB()).

/* SIEMENS Block Generator S5-C */


/* Date: 03.04.91 Time: 15:16:12 */

/* Type : FX */
/* Number : 001 */

/* Name : DBZUGR */
/* Lib.number : 3491 */

/* PLC System : 1 (PLC 135WB with COP) */

/* DBNR: D KF */ /* Number of DB to be opened */


/* DNR : I BY */ /* Number of a DW in the DB */
/* DTYP: D KS */ /* Data block type (DB or DX) */
/* INHA: I BY */ /* Desired value of the DW in the DB */
/* ERR : Q BI */ /* Error bit for parameter errors */

/**************************/
/* Typedef and constants */
/**************************/

typedef unsigned char byte;


typedef unsigned char mask;
typedef unsigned char bit;
typedef unsigned int word;
typedef int sword;
typedef unsigned long int dword;

/* S5HLL System Data START */

/* Process data blocks */

extern far void HLL_ADB (unsigned short int, unsigned short int);

#define DB_Laenge XDBLAEN


extern unsigned short far * far DB_Laenge;

9–26 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.1 FX 1, Access to Data Blocks

/* Block address list */

extern unsigned short int * far DB_LST[256];


extern unsigned short int * far SB_LST[256];
extern unsigned short int * far PB_LST[256];
extern unsigned short int * far FB_LST[256];
extern unsigned short int * far OB_LST[256];
extern unsigned short int * far DX_LST[256];
extern unsigned short int * far FX_LST[256];

/* Process image [I/Q/F/T/C] */

extern unsigned char far E_Byte [128];


extern unsigned char far A_Byte [128];
extern unsigned char far M_Byte [256];
extern unsigned short int far Zeit [128];
extern unsigned short int far Zaehler [128];

/* S5HLL System Data END */

/***********************************************************/
/* Definition of an array for addressing */
/* in data blocks (max. size: 2043 words); */
/* refers to the currently open DB */
/***********************************************************/

typedef struct { unsigned char dataleft;


unsigned char dataright;
} d_l_r;

union { unsigned char databyte [512];


unsigned int dataword [256];
unsigned long int ddw [128];
d_l_r dw1 [256];
} datablock;

/* The global declaration of the 'datablock' union can be used to address */


/* a data block after the block has been opened with */
/* HLL_ADB(). Byte, word and doubleword-oriented or */
/* structured accesses (dataleft, dataright) are supported */

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BBP0 9–27


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.1 FX 1, Access to Data Blocks

/**************************/
/* Constants */
/**************************/

#define not_exist 0l

FUNCTION (DBNR,
DNR,
DTYP,
INHA,
ERR_ADR,
ERR_MSK)

word DBNR;
byte DNR;
word DTYP;
byte INHA;
bit * ERR_ADR;
mask ERR_MSK;

{
/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

if ((DType == 'DB') && (DB_LST[DBNR] != not_exist) ¦¦


(DType == 'DX') && (DX_LST[DBNR] != not_exist))

{ /* DB Type equal DB,DX and DB exist */

*ERR_ADR &= ~ERR_MSK; /* Clear error bit */

HLL_ADB(DTYP, DBNR); /* Open data block */


/* Now the global union */
/* declared above can be used */
/* to access the data of the */
/* open data block using */
/* various methods */

9–28 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 9 Example Programs
9.2.1 FX 1, Access to Data Blocks

/****************************************************/
/* Examples for accessing data block */
/****************************************************/

datablock.dataword[DNR] = INHA; /* Write parameter to DW */

datablock.databyte[9] = E_Byte[1]; /* DR4 = contents of input byte */

datablock.dw1[10].dataleft = E_Byte[2]; /* DL10 = input byte */

datablock.ddw[7] = 0xabcd1234; /* Write constant */


/* to doubleword */

datablock.databyte[8] = E_Byte[2] & 0x01; /* A I 2.0 - Data 8 */

/* If ddw(7) is assigned, as above, by the high-level language, */


/* the following applies to word-oriented access: */
/* Access from high-level language to dataword(14) and dataword(15): */
/* dataword(14) = 1234, dataword(15) = abcd */
/* */
/* Access from STEP5 side to dataword14 and dataword15: */
/* dataword14 = 3412, dataword15 = cdab */
/* Reason: different formats of STEP 5/HLL */
/* */
/* STEP 5: High byte is stored at lower address in memory */
/* HLL: Low byte is stored at lower address in memory */
/* The high and low word are also */
/* exchanged with 32-bit variables. */
}

else

{ /* Set error bit if DTYP not DB or DX */


/* or DB, DX do not exist*/

*ERR_ADR ¦= ERR_MSK;

/**************************/
/* End of */
/* Main Procedure */
/**************************/

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–29


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.2 FX 2, Access to Process Image

9.2.2 FX 2, Access to Process Image


Function block FX 2 shows how to access the process image (special inputs, outputs and
flags) from a C block.
It also illustrates how you can use pointers and type redefinitions to perform word and
doubleword-oriented accesses to the process image.

/* SIEMENS Block Generator S5-C */


/* Date: 03.04.91 Time: 16:36:51 */

/* Type : FX */
/* Number : 002 */

/* Name : EAM */
/* Lib.number : 73737 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* NR : D KF */ /* Number of input byte */


/* NR1 : I BY */ /* Number of output byte */

/**************************/
/* Typedef and constants */
/**************************/

typedef unsigned char byte;


typedef unsigned char mask;
typedef unsigned char bit;
typedef unsigned int word;
typedef int sword;
typedef unsigned long int dword;

9–30 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.2 FX 2, Access to Process Image

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

/* Process image [I/Q/F/T/C] */

extern unsigned char far E_Byte [128];


extern unsigned char far A_Byte [128];
extern unsigned char far M_Byte [256];
extern unsigned int far Zeit [256];
extern unsigned int far Zaehler [256];

/* S5HLL System Data END */

FUNCTION (NR,
NR1)

word NR;
byte NR1;

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

/* Definition of pointers for word and doubleword access */

int *Inputword;

long int *Inputd_word;

int *Flagword;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–31


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.2 FX 2, Access to Process Image

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

/* Initialize pointers */

Inputword = (int *)E_Byte;

Inputd_word = (long int *)E_Byte;

Flagword = (int *)M_Byte;

/*************************************************/
/* Examples of accesses to process image */
/*************************************************/

A_Byte[NR1] = E_Byte[NR]; /* Copy input byte */


/* to output byte */

Flagword[100] = Inputword[0]; /* Copy input word */


/* to flag word */
/* At STEP 5 level, flag */
/* word 200 is addressed */

Flagword[102] = Inputd_word[0]; /* Copy input doubleword */


/* to two flag words */
/* and swap high and */
/* low words */
Flagword[103] = Inputd_word[0] >> 16; /* At STEP 5 level, flag */
/* words 204 and 206 */
/* are addressed */

/* Flagword[x] in C = Flagword[2*x] in STEP 5! */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

9–32 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.3 FX 4, Processing of Counters and Timers

9.2.3 FX 4, Processing of Counters and Timers


Function block FX 4 shows how to read counter and timer values from a C block and how to
start the counters and timers. The latter is only possible on PLC systems with COP.
FX 4 also illustrates word-oriented accesses to flags using pointers and type redefinitions.

/* SIEMENS Block Generator S5-C */


/* Date: 04.04.91 Time: 17:04:59 */

/* Type : FX */
/* Number : 004 */

/* Name : TZMB */
/* Lib.number : 85344 */

/* PLC System : 1 (PLC 135WB with COP) */

/* TNR : D KF */ /* Number of counter */


/* ZNR : D KF */ /* Number of timer cell */
/* MWT : D KF */ /* Number of flag word for counter value */
/* MWZ : D KF */ /* Number of flag word for timer */

/**************************/
/* Typedef and constants */
/**************************/

typedef unsigned char byte;


typedef unsigned char mask;
typedef unsigned char bit;
typedef unsigned int word;
typedef int sword;
typedef unsigned long int dword;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–33


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.3 FX 4, Processing of Counters and Timers

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

/* Process image [I/Q/F/T/C] */

extern unsigned char far E_Byte [128];


extern unsigned char far A_Byte [128];
extern unsigned char far M_Byte [256];
extern unsigned short int far Zeit [128];
extern unsigned short int far Zaehler [128];

/* S5HLL System Data END */

FUNCTION (TNR,
ZNR,
MWT,
MWZ)

word TNR;
word ZNR;
word MWT;
word MWZ;

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

word aux_var;
word far *flagword; /* Pointer for word access */

9–34 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.3 FX 4, Processing of Counters and Timers

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

flagword = (word *)M_Byte; /* Initialize counter */


/* equiv. (word *)&M_Byte [0] */

flagword[MWZ] = counter[CNO] & 0xFF03; /* Read counter value, but caution:*/


/* counter is an array with */
/* STEP 5 data; exchange high and */
/* low bytes; therefore only */
/* bits 0, 1, 8...15 relevant */

counter[CNO+1] = 0x6400; /* Initialize counter (CNO+1) */


/* with 100dec */
/* Caution here also: STEP 5 data */

flagword[MWT] = (timer[TNO] & 0xFF03); /* Read timer value */

aux_var = timer[1] & 0xFF03; /* Read timer value from cell 1 */

if ((E_Byte[0] & 0x01) == 1)


{
timer[1] = 0x19A8; /* Initialize timer(1) with */
/* 25 sec and start; */
/* Caution here also: STEP 5 data */

A_Byte[0] ¦= 0x01; /* Set Q0.0 = 1 */


}

if (aux_var == 0)
A_Byte[0] &= 0xFE; /* If time expired, */
/* set Q0.0 = 0 */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–35


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.4 FX 6, Search in Data Block

9.2.4 FX 6, Search in Data Block


Function block FX 6 shows how you can search easily from a C block for a defined value in a
data block.
Only the address of the block is required in order to access the data block. It is therefore
sufficient to declare the data block as an array with a length of 1.
The block must be opened (system function HLL_ADB()) before the first access.

/* SIEMENS Block Generator S5-C */


/* Date: 04.04.91 Time: 17:58:17 */

/* Type : FX */
/* Number : 006 */

/* Name : SUCH */
/* Lib.number : 23456 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* DBNR: D KF */ /* Number of the DB in which


the search is to be performed */
/* MUST: I W */ /* Search criteria */
/* GEF : Q W */ /* Number of the data word found */
/* ERR : Q BI */ /* Error message if DB does not exist */
Q
/**************************/
/* Typedef and Constants */
/**************************/

typedef unsigned char byte;


typedef unsigned char mask;
typedef unsigned char bit;
typedef unsigned int word;
typedef int sword;
typedef unsigned long int dword;

9–36 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.4 FX 6, Search in Data Block

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

/* Process data blocks */

extern far void HLL_ADB (unsigned int, unsigned int);

#define DB_Laenge XDBLAEN


extern unsigned int far * far DB_Laenge;

/* Block address list */

extern unsigned int * far DB_LST[256];


extern unsigned int * far SB_LST[256];
extern unsigned int * far PB_LST[256];
extern unsigned int * far FB_LST[256];
extern unsigned int * far OB_LST[256];
extern unsigned int * far DX_LST[256];
extern unsigned int * far FX_LST[256];

/* S5HLL System Data END */

/* Data block declaration */


/* only important for the address of the DB */
word dataword[1];

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–37


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.92
9.2.4 FX 6, Search in Data Block

FUNCTION (DBNR,
MUST,
GEF_ADR,
ERR_ADR,
ERR_MSK)

word DBNR;
word MUST;
word * GEF_ADR;
bit * ERR_ADR;
mask ERR_MSK;

/**************************/
/* Declaration of */
/* Local Data */
/**************************/
word max_limit; /* Number of last word in DB */
word position; /* Index for search in DB */

word far *search_array; /* Define pointer for word access */

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

if (DB_LST[DBNR] == 0)
{
*ERR_ADR ¦= ERR_MSK; /* DB does not exist; set error bit */
}
else
{
*ERR_ADR &= ~ERR_MSK; /* DB exists; clear error bit */

HLL_ADB('DB', DBNR); /* Open data block */

max_limit = *DB_Laenge; /* Determine last assigned position */

search_array = (word far *) dataword /* Address from which search is


to be performed */

9–38 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.4 FX 6, Search in Data Block

for (position = 0; position <= max_limit; position++)


{
if (search_array[position] == MUST)
{
*GEF_ADR = position; /* Pass index of data word */
break; /* Break loop */
}
else
{
*GEF_ADR = 0XFFFF; /* Pass identifier for not found */
}
} /* The loop could also be implemented */
/* by calling a standard */
/* C library function */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–39


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.5 FX 8, Call Other HLL Procedures

9.2.5 FX 8, Call Other HLL Procedures


Function block FX 8 shows how to call other HLL function blocks from a C block (system
function HLL_HLL()).
It also illustrates how to declare and call local procedures in a C block.

/* SIEMENS Block Generator S5-C */


/* Date: 05.04.91 Time: 14:42:59 */

/* Type : FX */
/* Number : 008 */

/* Name : CC */
/* Lib.number : 32189 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* AUS : I BY */ /* Parameters which are passed to FB 2 */


/* NN : D KF */
/* BYTN: D KF */ /* Number of an output byte */
/* BITN: D KF */ /* Number of bit position 0 ... 7 */
/* WER1: D KF */ /* Condition for shift operation */

/**************************/
/* Typedef and Constants */
/**************************/

typedef unsigned char byte;


typedef unsigned char mask;
typedef unsigned char bit;
typedef unsigned int word;
typedef int sword;
typedef unsigned long int dword;

9–40 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.5 FX 8, Call Other HLL Procedures

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

/* Call other HLL blocks */

extern far void (* far HLL_HLL) ();

/* Process image [I/Q/F/T/C] */

extern unsigned char far E_Byte [128];


extern unsigned char far A_Byte [128];
extern unsigned char far M_Byte [256];
extern unsigned int far Zeit [256];
extern unsigned int far Zaehler [256];

/* S5HLL System Data END */

/* Standard ANSI Prototypes */

void BITMAN(sword abnr, sword bitnr, sword value);


byte ROL(byte num, sword digits);

FUNCTION (AUS,
NN,
BYTN,
BITN,
WER1)

byte AUS;
word NN;
word BYTN;
word BITN;
word WER1;

{
/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

HLL_HLL(NN,AUS,'FB',2); /* Call FB 2 with parameters */

BITMAN(BYTN,BITN,WER1); /* Call a local function */

/**************************/
/* End of */
/* Main Procedure */
/**************************/
}

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–41


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.5 FX 8, Call Other HLL Procedures

/**************************/
/* Local */
/* Procedures */
/**************************/

void BITMAN(sword abnr, sword bitnr, sword value) /* Standard ANSI declaration */
{
if (value == 1)

A_Byte[abnr] ¦= (0x01 << bitnr);

else

A_Byte[abnr] &= ROL(0xFE,bitnr);

byte ROL(byte num,sword digits) /* Standard ANSI declaration */


{
union { word _16_BIT;
byte _8_BIT[2];
} trickvariable;

trickvariable._16_BIT = (word)num;

trickvariable._16_BIT <<= digits;

return(trickvariable._8_BIT[0] ¦ trickvariable._8_BIT[1]);

9–42 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.6 FX 10, FX 15, Use of Semaphores

9.2.6 FX 10, FX 15, Use of Semaphores


Function blocks FX 10 and FX 15 show how to set and clear the OB disable identifiers in C
blocks.
The disable identifier for OB 5 is set in FX 10 and subsequently cleared again in FX 15.
System functions HLL_LIM() and HLL_SIM() are used.

/* SIEMENS Block Generator S5-C */


/* Date: 05.04.91 Time: 16:15:31 */

/* Type : FX */
/* Number : 010 */

/* Name : SPERROB5 */
/* Lib.number : 0911 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/**************************/
/* Typedef and Constants */
/**************************/

typedef unsigned char byte;


typedef unsigned char mask;
typedef unsigned char bit;
typedef unsigned int word;
typedef int sword;
typedef unsigned long int dword;

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

/* Semaphores (LIM, SIM) */

extern far void (* far HLL_LIM) (unsigned char *);


extern far void (* far HLL_SIM) (unsigned char *);

/* S5HLL System Data END */

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–43


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.6 FX 10, FX 15, Use of Semaphores

FUNCTION ( )

{
/**************************/
/* Declaration of */
/* Local Data */
/**************************/

byte disable_id; /* OB disable identifier */

#define disable_mask_OB5 0x20; /* Disable identifier mask for OB 5 */

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

HLL_LIM (&disable_id); /* Read current disable identifier */

disable_id ¦= disable_mask_OB5; /* Set disable identifier for OB 5 */

HLL_SIM (&disable_id); /* Disable OB 5 */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

9–44 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.6 FX 10, FX 15, Use of Semaphores

/* SIEMENS Block Generator S5-C */


/* Date: 05.04.91 Time: 16:20:45 */

/* Type : FX */
/* Number : 015 */

/* Name : FREIGOB5 */
/* Lib.number : 0912 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/**************************/
/* Typedef and Constants */
/**************************/

typedef unsigned char byte;


typedef unsigned char mask;
typedef unsigned char bit;
typedef unsigned int word;
typedef int sword;
typedef unsigned long int dword;

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

/* Semaphores (LIM, SIM) */

extern far void (* far HLL_LIM) (unsigned char *);


extern far void (* far HLL_SIM) (unsigned char *);

/* S5HLL System Data END */

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–45


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.6 FX 10, FX 15, Use of Semaphores

FUNCTION ( )

{
/**************************/
/* Declaration of */
/* Local Data */
/**************************/

byte disable_id; /* OB disable identifier */

#define enable_mask_OB5 0xDF; /* Disable identifier mask for OB 5 */

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

HLL_LIM (&disable_id); /* Read current disable identifier */

disable_id &= enable_mask_OB5; /* Clear disable identifier for OB 5 */

HLL_SIM (&disable_id); /* Enable OB 5 */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

9–46 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.91 9 Example Programs
9.2.7 FX 20, I/O Processing

9.2.7 FX 20, I/O Processing


FX 20 shows how to access the I/O directly from a C block.
The access is performed via the I/O address list. The process image is not updated
automatically, and this must be performed in the C block.
The C function block FX 20 copies a defined area of inputs into the outputs. The area is
defined by the call parameters.
It is assumed that the defined I/O area (inputs and outputs) exists and is contiguous.

/* SIEMENS Block Generator S5-C */


/* Date: 05.04.91 Time: 15:35:23 */

/* Type : FX */
/* Number : 020 */

/* Name : PERI */
/* Lib.number : 20005 */

/* PLC System : 2 (PLC 135WB with ACOP) */

/* STRT: D KF */ /* Start of area to be copied */


/* END: D KF */ /* End of area to be copied */

/**************************/
/* Typedef and Constants */
/**************************/

typedef unsigned char byte;


typedef unsigned char mask;
typedef unsigned char bit;
typedef unsigned int word;
typedef int sword;
typedef unsigned long int dword;

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–47


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.7 FX 20, I/O Processing

/**************************/
/* System Functions */
/* and */
/* System Data */
/**************************/

/* S5HLL System Data START */

/* Process data blocks */

extern far void HLL_ADB (unsigned int, unsigned int);

#define DB_Laenge XDBLAEN


extern unsigned int far * far DB_Laenge;

/* Block address list */

extern unsigned int * far DB_LST[256];


extern unsigned int * far SB_LST[256];
extern unsigned int * far PB_LST[256];
extern unsigned int * far FB_LST[256];
extern unsigned int * far OB_LST[256];
extern unsigned int * far DX_LST[256];
extern unsigned int * far FX_LST[256];

/* Process image [I/Q/F/T/C] */

extern unsigned char far E_Byte [128];


extern unsigned char far A_Byte [128];
extern unsigned char far M_Byte [256];
extern unsigned int far Zeit [256];
extern unsigned int far Zaehler [256];

/* I/O address list [I/Q] */

extern unsigned char far * far PeE [256];


extern unsigned char far * far PeA [256];

/* S5HLL System Data END */

#define MSB_mask 0xF000 /* Mask for the 4 MSB */

int dataword[20]; /* Global declaration of a DB */

9–48 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 9 Example Programs
9.2.7 FX 20, I/O Processing

FUNCTION (STRT,
END)

word STRT;
word END;

/* The following requirements must be met:


--- Inputs exist in contiguous form from STRT to END
--- Outputs exist in contiguous form from STRT to END
*/

/**************************/
/* Declaration of */
/* Local Data */
/**************************/

int n; /* loop counter */

/* Declaration of pointers for word and doubleword access */

dword far *ptr_inp;


dword far *ptr_out;
word far *segment_inp;
word far *offset_inp;
word far *segment_out;
word far *offset_out;
byte far *ptr_adr_inp;
byte far *ptr_adr_out;

/**************************/
/* Statement Part */
/* Main Procedure */
/**************************/

HLL_ADB ('DB', 200); /* Open data block */

/* Pointer initialization */

ptr_inp = (dword far *)&dataword[0]; /* Pointer to dataword[0] and */


/* and dataword[1] */

segment_inp = (word far *)&dataword[1]; /* Pointer to segment part */

offset_inp = (word far *)&dataword[0]; /* Pointer to offset part */

ptr_out = (dword far *)&dataword[2]; /* Pointer to dataword[2] and */


/* dataword[3] */

segment_out = (word far *)&dataword[3]; /* Pointer to segment part */

offset_out = (word far *)&dataword[2]; /* Pointer to offset part */

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 9–49


SINUMERIK 840/880 Part 1 (PJ)
9 Example Programs 11.91
9.2.7 FX 20, I/O Processing

for(n = STRT; n <= END ; n++)


{
*ptr_inp = (dword)PeE[n]; /* Pass address of nth input byte */
/* to data block */
/* Offset in dataword[0], */
/* segment in dataword[1] */

*segment_inp &= MSB_mask; /* Clear bits 0 to 11 of segment */


/* Create pointer to real address */
/* of the nth input byte */
ptr_adr_inp = (byte far *)(((dword)*segment_inp << 16) ¦ *offset_inp);

*ptr_out = (dword)PeA[n]; /* Pass address of the nth output */


/* byte to data block */
/* Offset in dataword[2], */
/* segment in dataword[3] */
*segment_out &= MSB_mask /* Clear bits 0 to 11 of segment */

/* Create pointer to real address */


/* of the nth output byte */
ptr_adr_out = (byte far *)(((dword)*segment_out << 16) ¦ *offset_out);

*ptr_adr_out = *ptr_adr_inp; /* The value of the nth input byte */


/* is passed to the nth output byte; */
/* the process image is circumnavigated */

A_Byte[n] = (unsigned short int)*ptr_adr_inp;


/* Correction to process image, as */
/* otherwise the transferred byte would be */
/* overwritten by the process image later */

}; /* End of for-loop */

/**************************/
/* End of */
/* Main Procedure */
/**************************/

9–50 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 10 Information for the Use of the Block Generator
10.1 Information for the Use of HLL Programs on the Programmable Controller

10 Information for the Use of the Block


Generator

This chapter contains important information about


• the use of HLL programs on the programmable controller
• restrictions which occur with the use of the block generator on the development computer,
and
• restrictions which should be considered when programming HLL blocks.

10.1 Information for the Use of HLL Programs on the Programmable


Controller
The block generator creates HLL programs for use on the programmable controller PLC 135
WB. The user should exercise the greatest care in the development of these programs.
The use of operating system data allows the user to access memory areas and system
programs. The manufacturer cannot accept any liability for damages resulting from the misuse
of system data or programs.
The responsibility for the generated programs and the resulting impact on the running process
lies with the user, who must implement quality assurance measures to ensure the correct
development of the programs.

It is therefore recommended
• not to modify the defined system variables, but to process them in read-only accesses to
the largest possible extent
• to call system programs in the described form only
• always to make sure that the destination address (the address of the pointer) is correct in
indirect data accesses or program branches (which use pointers)
• to remember that cross-segment program branches (FAR CALL) may not be performed,
and
• to remember that HLL blocks always run in special mode, irrespective of the setting in the
machine data.

Calling non-existent blocks in HLL1)


On an attempt to open a missing data block with the function HLL_ADB or call a missing
program block with the function HLL_S5, the system program calls organization block OB 19
(if it exists). The value 0B000hex is also assigned to the DS data segment if you attempt to
open a data block that does not exist. A hardware write-protect feature is provided for this
area, with the result that a timeout is generated on access to data of a non-existent block, and
the PLC switches to the stop state with error message '9B' ( timeout when processing high-
level language). The supplementary message parameter F0004 indicates with the value
0001hex that no data block has been opened.

_______
1) GA2, SW 1 and higher (SINUMERIK 880) or SW 2 and higher (SINUMERIK 840)

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 10–1


SINUMERIK 840/880 Part 1 (PJ)
10 Information for the Use of the Block Generator 11.92
10.1 Information for the Use of HLL Programs on the Programmable Controller

If non-existent blocks are called up with the functions HLL_HLL and HLL_MACRO, the PLC
always switches to the stop state with an error message. In this case, the program cannot
continue because of the unknown number of passed parameters; OB 19 is not called.
For further information, please refer to the "PLC 135 WB Configuring Guide".

10.2 Restrictions for the Use of the Block Generator

Memory requirements
A large number of tables of the block generator must be processed in the main memory of the
development computer. For this reason, the available memory should be as large as possible.
If the free memory is not sufficient, part of the tables have to be stored on the hard disk. This
reduces the processing speed considerably (especially with large programs).
At least 1 MB free memory must be available on the hard disk for the output files and stored
data.

Number of open files


When the block generator creates an HLL block, it accesses several files on the hard disk. In
the worst case (when performing a parameter check), ten files may be open at the same time.
The MS-DOS operating system limits the number of files which can be opened simultaneously.
You can define the limit in the FILES statement in the CONFIG.SYS file; a suitably high setting
should be chosen.

10.3 Restrictions for Programming

10.3.1 General Restrictions

The following restrictions should be observed when implementing PL/M and C blocks.

Stack requirements
The stack area available to HLL blocks is limited to:
• 2 K words on the cyclic level
• 0.5 K words on the further processing levels

As the user, you must ensure that the stack requirements of your HLL block do not exceed
this limit. If a stack overflow does occur, the PLC branches to a defined stop state, however
the cause of the error cannot be detected or displayed.
Following compilation, you can calculate the stack requirements of an HLL block from the
program listing, according to the following factors:
• All variables declared in the "Declaration of Local Data" section are stored on the stack.
Larger data arrays should therefore be stored in data blocks.

10–2 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)
11.92 10 Information for the Use of the Block Generator
10.3.1 General Restrictions

• In system calls, the call parameters are passed to the stack. This also applies to
parameters passed to other blocks (HLL_HLL(), HLL_MACRO()).

Procedures
• Local procedures in PL/M blocks must be declared with the attribute REENTRANT,
otherwise processing errors may occur.
• Procedures in C blocks are always reentrant; the attribute does not have to be specified.
• The implementation of interrupt procedures is not permitted.
• With the exception of system functions, no external procedures may be called; i.e. "FAR
CALLS" are not permitted.

Data declarations
• The declarations created by the block generator may not be modified.
• The declaration of global data in a HLL data block is only allowed for components which
refer to data blocks. This also applies to the declaration of "static" data in C blocks.

Recursion
Recursive calls are not permitted in HLL blocks.

Memory model
HLL blocks may only be compiled in the compact model.

Libraries
You link standard intel libraries or your own libraries (created with intel LIB86) to your HLL
block. Please remember, however, that the functions used may not access the hardware or
the operating system.

Block size
The block generator restricts HLL blocks to a code size of 8 Kbytes.

10.3.2 Further Restrictions for C Blocks

Further restrictions must be observed for the implementation of C blocks, in addition to the
restrictions described above.

Parameter check
It is not possible to perform a parameter check for C blocks on the block generator.

Definitions ("#define")
"#define" statements may not exceed 255 characters in length. This applies especially to the
definition of macros.

Line length
A line in the source program of a C block may not exceed 255 characters in length.

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 10–3


SINUMERIK 840/880 Part 1 (PJ)
11.92 11 Error Messages and Warnings
11.1 Error Messages from the HLL Block

11 Error Messages and Warnings

Both the block generator and the generated block output error messages. The block generator
also issues warnings.

11.1 Error Messages from the HLL Block


If serious errors occur when an HLL block is running, the PLC branches to the stop state
(system stop). An identifier is entered in the fine error coding section (memory cells in the PLC
for error codes). The identifier indicates the cause of the error. The following listing shows the
events for which errors can be detected, together with the error codes and their meaning.

Error on loading HLL block:


53: Illegal PL/M block in user program memory (option not enabled)
54: Illegal C block in user program memory (option not enabled)

Error on calling HLL block from STEP 5:


D0: Unknown type identifier in parameter declaration of called block
D1: Illegal type identifier in HLL block
D2: Current input parameter in calling FB incorrect
D3: Current output parameter in calling FB incorrect

Error in HLL_HLL() procedure:


D4: Unknown pseudoparameter on stack
D5: HLL block does not exist
D6: HLL block paragraphs not aligned
D7: Called block is not an HLL block

Error in HLL_ADB() procedure:


D8: Incorrect pseudoparameter ('DB' or 'DX' permitted)
D9: DB/DX to be opened does not exist
DA: DB/DX to be opened paragraphs not aligned

Error in HLL_MACRO() procedure:


DC: Called function macro does not exist or not permitted for HLL

Error in HLL_STOP() procedure:


DD: System stop by HLL block; user error identifier in supplementary error parameter

Error in HLL_S5() procedure:


DE: Unknown pseudoparameter on stack or illegal block type parameter
DF: Called STEP 5 block does not exist
E0: Called STEP 5 block paragraphs not aligned
E1: Called block is not a STEP 5 block

© Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0 11–1


SINUMERIK 840/880 Part 1 (PJ)
11 Error Messages and Warnings 11.92
11.2 Error Messages of Block Generator

11.2 Error Messages of Block Generator


In the event of an error where the input cannot be detected and/or where a suitable response
from the block generator is not possible, the execution of the block generator is cancelled
following output of an appropriate error message.
In the event of an error which can be detected at the time of input, an error message is output
and the corresponding input screen is called up again. When the input error has been
corrected, the block generator continues to run.
In the event of an error which cannot be detected at the time of input, but where the block
generator can continue running, an error message is written to an error file (file S5HLL.ERR).
A corresponding error message is also output in the last input screen if possible. The block
generator subsequently continues to run.

The block generator outputs the following error messages:


• Declaration of too many literallies; a maximum of 1000 literallies (defines) can be declared.
• Nesting levels of include files too deep; the compiler supports a maximum of 5 levels for
the nesting of include statements.
• Nesting level for literallies too deep; literallies (defines) may be nested in up to 5 levels.

11.3 Warnings of Block Generator


Warnings are output, where possible, in the last input screen. The warnings are also written to
an error file. Execution of the block generator is not cancelled on the output of warnings.

The block generator outputs the following warnings:


• Literallies stored on disk
Up to approximately 200 literallies (defines) can be held in memory (depending on the
amount of main memory available). If further literallies are defined above this limit, they are
stored in a file on the hard disk. This can result in a substantial increase in the processing
time. A total maximum of 1000 literallies can be stored.
• Identifiers stored on disk
Depending on the memory expansion of the development computer, up to approximately
2000 identifiers can be stored directly in main memory (on the heap). Identifiers which
cannot be managed on the heap are stored in a file on the hard disk. The maximum
number of identifiers is determined by the upper limit of the compiler or the free hard disk
capacity. The processing time can be substantially increased, however, by too many hard
disk accesses.
• Function block has no name
• Function block has no parameters
• Integer variable passed in HLL_HLL procedure call
• Literally or identifier not found
• Literally declared twice
• Link file not found

Warning 66, "START ADDRESS NOT SPECIFIED IN OUTPUT MODULE", always appears
when a block is being prepared and does not inhibit correct operation.

11–2 © Siemens AG 1990 All Rights Reserved 6FC5197-0AC00-0BP0


SINUMERIK 840/880 Part 1 (PJ)

You might also like