Académique Documents
Professionnel Documents
Culture Documents
102
Version
Typ1 osa / CC 220
E 1993
Contents
Page
1. Introduction
Notes and Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1−1
2. Basic elements of CPL
Program structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 1
NC block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 2
CPL block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 3
Program start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 4
Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 4
Parallel processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 4
Autostart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 4
Clamp mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 4
Symbolic names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 5
Reserved instruction words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 5
Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 6
Integer constant (INTEGER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 6
Floating−point constant (REAL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 6
Double−precision constant and double−precision operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 7
Character string constant (STRING) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 8
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 8
Integer variable (INTEGER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 10
Floating−point variable (REAL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 10
Logic variable (BOOLEAN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 10
Character string variable (STRING) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 11
Array variable (ARRAY) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 11
DIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 12
Overview of variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 12
Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 12
NUL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 13
Mathematical operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 13
SQRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 14
ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 14
ROUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 14
INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 14
SIN, COS, TAN, ASIN, ACOS, ATAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 14
Logic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 15
NOT, AND, OR, XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 15
Repeat instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 16
REPEAT − UNTIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 16
WHILE − DO − END . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 16
FOR − STEP − TO − NEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 17
Unconditional jump instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 18
GOTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 18
Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 18
Branch instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 19
IF − THEN − ELSE − ENDIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 − 19
Contents 1
CC 220/320
Contents
Flexible Automation CPL Programming Instructions
4. System functions
General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 1
WAIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 1
Axis positions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 3
CPOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 3
MPOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 3
PPOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 4
AXO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 4
Zero offsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 4
FXC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 4
Tool compensations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 5
TC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 5
CS table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 6
TD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 6
Active system data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 7
SD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 7
BIN, BCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 11
T word, part counter data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 11
SDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 12
Variable axis address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 13
AXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 13
PLC interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 13
Communication by means of variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 13
Interface access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 14
IC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 14
MIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 14
Time recording . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 15
DATE, TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 15
CLOCK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 − 15
5. String processing
Dimensioning character arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5−1
Reading characters from an arbitrary location in a string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5−1
MID$ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5−1
Modifying character strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5−2
MID$ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5−2
Length of a character string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5−3
LEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5−3
Search for a character string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5−3
INSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5−3
Contents 2
CC 220/320
Contents
Flexible Automation CPL Programming Instructions
6. File processing
Interface data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6−1
Sequential file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6−1
Random file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6−1
Opening a file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6−2
OPENW, OPENR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6−2
Writing a file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6−7
PRN# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6−7
LJUST, NJUST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 10
REWRITE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 11
Reading a file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 11
INP# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 11
Reading interface data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 13
INP# function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 13
File end recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 14
EOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 14
Closing a file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 14
CLOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 14
Reading the file pointer position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 15
FILEPOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 15
Setting the file pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 17
SEEK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 17
File size determination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 19
FILESIZE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 19
File deletion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 21
ERASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 21
Text files (language changeover) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 24
TXT$ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 − 24
7. Dialog programming
Comments and messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7−1
MSG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7−1
REM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7−1
( ... ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7−1
Data output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7−2
DSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7−2
CHR$( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7−4
DLG, ENDDLG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7−5
PRN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7−5
Contents 3
CC 220/320
Contents
Flexible Automation CPL Programming Instructions
8. Graphics programming
9. Screen editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 − 1
10. Annex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 − 1
11. Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 − 1
Contents 4
CC 220/320
1. Introduction
Flexible Automation CPL Programming Instructions
1. Introduction
The programming language CPL ("Customer Programming Language") was ba
sically developed to extend the range of capabilities offered byDIN programming
for the user. CPL makes it possible to create and store any machining sequence as
a part subroutine with variable notation. Despite its complexity, CPL is easily
learned as its main features and its choice of elements are based on the BASIC
standard. Structure elements similar to PASCAL are additionally available for ad
vanced applications.
‘ shorter program when repeat sequences and comparable routines are in
volved,
In addition, CPL permits intervention in the machine control system through com
munication with the programmable controller (PLC).
The CPL functions described in this manual can be used during the machining se
quence in both the main program and subroutines.
NOTE !
Information concerning the current software version of ’your’ control is displayed in
This manual contains the information required − with respect to its title − for the
normal use of the control. For reasons of transparency, however, it cannot provide
all details for all possible combinations of functions. It is not possible, either, to con
sider any viable case of integration or operation since the control usually forms part
of major plants or systems.
If you desire more profound information, or if you have specific problems in han
dling the control which are not treated at all or not sufficiently in detail in this
manual, please contact your Bosch service department or our customer service
department.
The present description only refers to CPL programming of the CNC. For DIN pro
gramming, a separate manual is available.
1−1
CC 220/320
1. Introduction
Flexible Automation CPL Programming Instructions
By programming the control, you might influence the axis movements (e.g. posi
tioning, etc.), processing technology (e.g. feedrate, speed, etc.), and the process
ing sequence (e.g. tool change, compensation, output of auxiliary functions, etc.).
For this reason, general programming knowledge (e.g. for program logic, etc.) as
well as knowledge concerning the technology of the process involved is indispens
able.
WARNING!
Programming by personnel with insufficient or inexistent training or lack in experi
! ence may result in severe damages to the machine, drives, tools, parts or even per
sonal injury!
First you should carefully test the programs without axis movement! For this pur
! pose, the control provides the TEST ON softkey in the NC (AUTOMATIC) group op
erating mode. When this softkey is displayed in inverse video, no axis movements
will be carried out that are directly initiated by a part program.
BOSCH shall not be liable for consequential damages resulting from process
! ing of an NC or CPL program, an individual NC block or manual movement of
the axes! BOSCH shall not be liable, either, for consequential damages which
could have been avoided by appropriate PLC programming!
Please note our comprehensive range of training courses on this subject. For more
information, please contact our training center in Erbach
(phone: −49−6062−78258).
1−2
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
Program structure
As a rule, a program is made up of two parts, one containing statements and the
other containing declarations; in the case of CPL, however, this second part is not
obligatory but can be useful. The declaration part can be used, for example, to add
comments on the names given to variables, to dimension array variables or pre−
assign variables. It can also be used to list invariable values in a list of constants,
reducing the amount of work involved in making any changes required later. This
will be described in more detail below. The statement part contains a symbolic de
scription of a program sequence using statements with symbolic names and oper
ators to connect data.
P DECLARATIONS
R
O
G
R STATEMENTS
A
M
Other programs or routines can be called up and run from a program by calling
subroutines. When they have been executed, the calling program continues its run
starting after the subroutine call concerned. Subroutines can also be called up in
other subroutines. Up to 7−fold nesting is possible in CPL.
CPL statements are always written in capital letters taking into account form stan
dards. One form standard concerns the correct syntax of reserved instruction
words; this is important in order to prevent confusion with the names of variables.
The importance of "clean programing" increases with the length of the program.
This term is used to describe not only unmistakable names for constants and vari
ables, but also
‘ structured programming,
‘ software ergonomics.
2−1
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
Error−tolerant ("Forgiving") programs are a very difficult matter, for the operator’s
creativity and imagination during the input dialog are, as a rule, very much greater
than those of the most creative and most imaginative programmers. Nevertheless,
it is important to make a program as crash−proof and error−tolerant as possible.
The number of input errors can also be reduced by ergonomic software. Menu op
tions, for example, can be emphasized optically without difficulty. The computer’s
capabilities should be utilized without going to extremes, particularly with regard to
the number of colors used. Further details can be found in DIN standard 66234.
NC block
A complete CPL statement is also known as a CPL block, in accordance with DIN
programming. Since both NC blocks and CPL blocks can be used simultaneously
during part programming, we shall briefly describe the structure of an NC block
here.
NC blocks are defined in DIN 66025 and contain standard information, such as pre
paratory functions, axis positioning and auxiliary functions. They must be pro
grammed either with an N block number or without any block number at all.
Example:
CPL also makes it possible to vary the word contents of an address in an NC block
(except N address), so that machining operations can be parameterized. However,
this cannot be used to influence the program flow during execution in a way that
had not yet been considered before linking the program. The following example
shows how variables can be used in a subroutine with the three parameters P1, P2
and P3.
2−2
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
Example:
.
5 XVALUE=P1 : FEED=P2 : OFFSET TABLE=P3 : PROGEND=30
.
N10 G1 X XVALUE F FEED*2+1000
N20 G22 K OFFSET TABLE
.
N30 M PROGEND
.
Parameters are entered in the subroutine call of the main program.The square
brackets [ ] indicate that variables are used. In block N10 it is clear that not only
variable names but entire CPL expressions can be used inside the square brack
ets. Block N30 is only valid if the program also includes M2 or M30.
All addresses calling a subroutine and the addresses G23, G24, G33, G75 and G92
are not intended for variable notation.
CPL block
A CPL block is made up of a statement or declaration combined with a line number.
If a CPL block ends with a colon ":", or with a ":<LINE FEED>", it must be followed
by another CPL block without a line number.
Example:
.
.
30 IF X%=3 THEN GOTO 150 ENDIF:
REM TARGET1
40 IF X%=4 THEN GOTO 200 ENDIF : REM TARGET2
50 WAIT : XPOS=MPOS(1) : YPOS=MPOS(2) : ZPOS=MPOS(3)
N100 G90
N110 G1 X XPOS Y YPOS Z ZPOS
.
.
A <LINE FEED> indicates the programmed end of a line. In edit mode, it is auto
matically inserted into the program text when ENTER is pressed. The <LINE
FEED> character is not visible on the screen or on the printout. If a CPL block does
not end with ":", it must be followed by a CPL block with line number or by an NC
block.
2−3
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
Program start
Usually, a program is selected in mode and started via CYCLE START. The
programs may exclusively consist of CPL blocks, or they may be composed of NC
blocks and CPL blocks.
If the control is in the highest level of the mode, a program defined in ma
chine parameter P4016 can be activated via the DIRECT CALL softkey or the inter
face input signal 6.1. NC and/or CPL instructions may be used in this program.
However, "M30−specific" actions will not be executed, i.e., the program will be
treated as a subroutine. The program is again started via CYCLE START.
Linking
When the program has been selected, or via the GENERATE LINK TAB. softkey, the
program is first examined for correct syntax and possible jump destinations and
subroutine calls. During this process called "linking", a so−called link table is gen
erated. Only programs that have already been linked can be started.
Parallel processing
The CPL programs specified via machine parameter P4011 can be directly started
via a softkey provided that the link tables have been generated for these programs.
(. Section 3 − Subroutines and cycles).
Autostart
If the control is in the highest level of the mode, the CPL program defined
under [MAC] via parameter P4011 can be started via the CPL DIALOGUE softkey
or the interface input signal 6.3..
Since machine parameter P9916 can also be used to define the mode as the
first mode after start−up of the control, it is possible to automatically start a CPL
program with this feature.
Clamp mode
In order to protect a program defined in P4011 against being interrupted without a
definition in parallel processing by a change of the mode, the interface input signal
6.4 "Clamp mode" should be set. If the signal is high, the mode is not changed if the
group mode keys are depressed.
It must be noted, however, that the system changes over to the highest level of the
currently active mode when the signal edges occur (when switching on and off).
Since the user should not notice the activation of this signal by the CPL program,
the activation instruction should be inserted directly at the beginning of the pro
gram.
2−4
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
Symbolic names
Symbolic programming is a typical feature of programming languages like CPL.
Symbolic names represent variable or invariable numerical values and logic in
structions for these data. The keywords reserved only for instruction words are
listed below.
Example:
Keywords:
@ % $ : ( ) = > + *
2−5
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
point in decimal numbers and as a label identifier for jump destinations. The full
stop is interpreted as a punctuation character within character strings. In texts
(character strings), it is also possible to use the following characters: ~ ", ^" or
" ", _" or z ", ’ " or \". Differences between the keyboard symbol, representa
tion in NC mode and representation in graphic mode are shown by the following
table:
_ z _
n " n
’ ’
_. : :
Constants
If numerical values are defined for the program sequence which are to remain un
changed (constant), it is possible to use these values in the instructions directly as
digits.
Example:
NUMBER% = 4
INTEGER constant
Example:
PI = 3.141593
REAL constant
2−6
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
2−7
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
20 D0! = 123456789.123456
22 D1! = 1.12345678901234
24 D2! = –123456789012345
26 D3! = –1234.123456
Example:
STRING constant
Variables
If data is to be changeable (variable) during the program run, then such data items
are described using variables. Variables are arbitrary symbol names for which sev
eral conventions must be agreed in CPL. The most important convention is an un
ambiguous choice of the variable name. Variable names must not be reserved in
struction words (keywords). The variable name can consist of arbitrary letters and
digits, whereby a letter must be the first character. The first 8 characters of the vari
able name are significant, i.e. only these are used for distinguishing between vari
ables. The variable name itself may be longer, however, in order to permit better
documentation of a program. Conventions are also necessary as regards the
scope of variable action owing to the possibility of using subroutines and the pos
sible necessity of buffering variable values independently of the respective pro
gram.
2−8
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
‘ local variables
‘ global variables
‘ permanent variables
Local variables act only within the program in which they have been declared.
These variables are deleted after the program run when the program is quit and the
occupied program memory space is released again. In the case of a subroutine
call, a local variable name for the calling program is not defined for the subroutine
and may possibly be used again there. The original local variable is available again
with the value which it possessed directly before the subroutine call after the return
to the calling program. A 32 Kbytes memory location is available for local variables
in each program (subroutine).
Permanent variables can be addressed by every active program under the desig
nation @1 ... @50. The variables of the INTEGER type are permanently preserved.
Deletion is possible only by specific overwriting. Permanent variables are not
stored in the variable memory area. Deletion of the whole memory therefore does
not affect permanent variables.
In order to permit the program to be read more easily, the designation of a perma
nent variable may be supplemented by appending letters to the number.
NUMBER% = 4
#NUMBER% = 4
@36 = 4
@ 36QUANTITY = 4
2−9
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
Example:
NUMBER% = 4
INTEGER variable
Example:
PI = 3.141593
If a ! symbol follows the variable name, the variable is interpreted as a REAL vari
able of double precision. In this case, the variable occupies 64 bits of the memory
area. The value range is +/− 10308. This corresponds to 15 significant places be
fore and after the decimal point.
Example:
PI! = 3.141592653589793
Example:
START? = FALSE
BOOLEAN variable
2 − 10
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
Example:
STRING variable
Example:
1 DIM ABC$(1)
2 DIM BCDE$(10)
3 ABC$ = ”Z”
4 BCDE$ = CHR$(90)
2 − 11
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
DIM
The index range or array size must be dimensioned before the first access to the
array variable with INTEGER constants. This is done with the DIM instruction.
Overview of variables
The following overview table summarizes the possibilities of using variables in
CPL:
REAL single−precision
local max. 8 characters
! REAL double−precision
? BOOLEAN
$ STRING
global # max. 8 characters
% INTEGER
@ % INTEGER
permanent 1 − 50
$ CHARACTER
arrays max. 8 characters REAL single−precision
% INTEGER
Instructions
It is possible to assign values to local and global variables. This is done with the
equals symbol =".
X1MIN! = 2097.876
value (max. 7 digits)
assignment symbol
double−precision REAL variable
2 − 12
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
The variable to which a value is to be assigned must be on the left−hand side, and
the respective value on the right−hand side of the assignment symbol. This con
vention must be observed in particular if a variable value is to be assigned to
another variable.
NUL
If no value has been assigned to the variable #VARIABLE, it has the value NUL
(zero), i.e. the statement »#VARIABLE = NUL« is true. We can see here that the
equals symbol can also be contained in comparisons or conditions.
XSET = NUL
Mathematical operations
In addition to the assignment of a value as a constant expression (digits) or as a
variable, the value of a CPL expression can also be assigned to a variable. Func
tions with constants and variables may be contained in a single CPL expression.
The simplest functions include the basic mathematical operations:
Addition »+«
Subtraction »−«
Multiplication »*«
Division »/«
The mathematic rule of multiplication and division before addition and subtraction
applies. In addition, it is possible to use brackets, whereby 7−fold nesting is pos
sible for simple expressions (without function calls).
Example:
XSET = 4/(100–I%)+XACTUAL
2 − 13
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
SQRT
This function is used to form the square root of an initial value. The initial value must
not be negative, since negative values are not defined.
Example: SQRT
XSET = 4*SQRT(100+I%)
ABS
This function serves to supply the absolute value of the initial value, i.e. negative
values become positive, positive ones remain positive.
Example: ABS
XVALUE = 2 * SQRT(ABS(100+I%))
ROUND
This function converts the initial value into a whole number (INTEGER) by rounding
up or down, The initial value may be a REAL expression.
Example: ROUND
INT
This function converts the initial value (REAL) into a whole number (INTEGER) by
cutting off the decimal places (rounding down). The initial value may be a constant
or variable.
Example: INT
Example:
2 − 14
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
YVALUE! = SIN(ANGLE!)
Logic operations
Logic operations can be performed in binary form with logic variables and in deci
mal form with INTEGER variables. They can be represented with the usual logic
operation symbols, the »·« symbol and the »+« symbol (−not in CPL−), as shown
in the description of the binary operations below. Here, too, »multiplication and di
vision are performed before addition and subtraction«, i.e. the AND operation acts
before the OR operation. Up to 7−fold bracket nesting is possible.
‘ the OR function OR
E1 E1 E1
E1 1 o− A & A >1 A =1 A
E2 E2 E2
E1 = A E1 . E2 = A E1 + E2 = A E1 . E2+E1 . E2=A
E1 0 L 0 0 L L 0 0 L L 0 0 L L
E2 − − 0 L 0 L 0 L 0 L 0 L 0 L
A L 0 0 0 0 L 0 L L L 0 L L 0
Logic operations can be used for masking bits. Permanent variables are stored in
the dual−port memory area in the case of PLC coupling CC220/320−PC600 (refer
to respective manual). This area can also be addressed by the PLC. If certain signal
states are to be transferred from the PLC to the CC220/320, these can also be
coded in a permanent INTEGER variable. Logic operations are used in order to de
code these signal states again.
2 − 15
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
Repeat instructions
If one or more instructions − referred to as a "routine" in this manual − are to be
executed repeatedly under certain conditions, it is possible to program repeat in
structions. The repeated program run is also called a "loop".
REPEAT − UNTIL
If the loop abort condition is to be executed only after the routine has been exe
cuted for the first time, it is possible to say: "Repeat the routine until the condition is
satisfied !". The REPEAT loop thus has the following structure:
WHILE − DO − END
If the abort condition is to be interrogated before the first loop run, the following de
scription would be possible: "While the condition is satisfied, do the routine!". The
WHILE loop is structured as follows:
In both cases, the condition need not necessarily result directly from execution of
the routine, but may also be determined by the status of the interface signals or by
the changing value of a permanent variable. A condition may assume the state
»satisfied« or »not satisfied«. Interrogation for equality and inequality is permitted:
not equal to » <> « less than or equal to » <= « less than »<«
2 − 16
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
<routine>
The characters with ordinal numbers 1 to 127 are written into a file. The ”I%" ap
pended to the ”NEXT” instruction in line 40 is only for clarity’s sake and can be
omitted.
It is also possible to program FOR−NEXT loops with variable step increments. The
step increment variable should be of the same variable type as the counting vari
able.
.
10 OPENW(1,”P222”,130,”TESTFILE”)
20 STEPNO%=2 : START%=1 : END%=3500 : NJUST
30 FOR COUNTER%=START% STEP STEPNO% TO END%
40 STEPNO%=ROUND(STEPNO%*SQRT(STEPNO%))
50 PRN#(1, ”COUNTER: ”,COUNTER%, ”INCREMENT: ”, STEPNO%)
60 NEXT
70 CLOSE(1)
.
COUNTER: 1 INCREMENT: 3
COUNTER: 4 INCREMENT: 5
COUNTER: 9 INCREMENT: 11
COUNTER: 20 INCREMENT: 36
COUNTER: 56 INCREMENT: 216
COUNTER: 272 INCREMENT: 3175
COUNTER: 3447 INCREMENT: 178902
2 − 17
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
GOTO
Unconditional program jumps are programmed with the GOTO instruction. A line
number, block number or label can be specified as the jump destination.
Label
A label can be written as a jump destination within a CPL block only. A label identi
fier consists of a space, decimal point and up to 8 significant ASCII characters,
whereby the first character must be a letter.
2 − 18
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
Branch instruction
If a certain condition is satisfied, then execute the routine, or else execute the other
routine!".
Analogously to the abort conditions for the loop instructions, it is possible to use
arithmetic, trigonometric and logic operations in the condition of the IF instructions.
Nesting is also possible. The IF instruction can also be written without ELSE in
struction, however, it must always be terminated with an ENDIF instruction. Other
wise, the end of the routine or alternative routine will not be recognized. Since the
location of the ENDIF instruction depends on the program sequence logic, the
computer cannot always clearly recognize a missing ENDIF instruction. Mislead
ing error messages would occur in this case. The completeness of the IF instruc
tion must therefore be thoroughly verified by the programmer.
. .END
90
2 − 19
CC 220/320
2. Basic Elements
Flexible Automation CPL Programming Instructions
2 − 20
CC 220/320
3. Subroutines and Cycles
Flexible Automation CPL Programming Instructions
3−1
CC 220/320
3. Subroutines and Cycles
Flexible Automation CPL Programming Instructions
.
. G81 [ 1,2,3,4 ]
N1 A modally active subroutine is pending
.
N20 X127 Y150 Z32 F2500
N30 M10 [20,2.3] Subroutine call with M function
N40 X110 Y120 Z0 with parameter transfer
.
.
N20 X127 Y150 Z32 F2000
N30 B10 [20,2.3] Subroutine call by means of auxiliary
N40 X110 Y120 Z0 function with parameter transfer
.
3−2
CC 220/320
3. Subroutines and Cycles
Flexible Automation CPL Programming Instructions
CALL
Since NC blocks are not read when the CPL dialog is called in the above−named
operating modes, the CPL instruction CALL is required in order to call subroutines
in these modes. The CALL instruction must be located in a separate CPL block. The
keyword CALL is followed by the program number: this number may then be fol
lowed by parameters contained between square brackets..
The parameters transferred as a result of the subroutine call are initially always
called P1, P2, P3, etc. in accordance with the sequence of parameter transfer.
In subroutine P999, P1 thus has the value 2.75, P2 has the value of variable X% at
the time of parameter transfer, and P3 has the value 0. If P2 is to represent an IN
TEGER value in the subroutine as well, this may be done by appending a % symbol
to P2. This identification of the variable type is also possible analogously for the
other variable types.
3−3
CC 220/320
3. Subroutines and Cycles
Flexible Automation CPL Programming Instructions
3−4
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
4. System functions
General
CPL offers the possibility of accessing system data of the NC control. For some in
structions, however, the control used must have a bus link with the PC 600.
WAIT
WAIT(READY)
For some functions, it is necessary to stop block preparation and wait until the pre
vious blocks have been executed. This can be done by means of the ”WAIT” or
”WAIT(READY)” instructions. Both instructions have the same meaning. If the
control recognizes ”WAIT” or ”WAIT(READY)”, block preparation (max. 12
blocks) is stopped at this point until all blocks preceding ”WAIT” or
”WAIT(READY)” have been executed. Afterwards, block preparation continues
automatically. ”WAIT” or ”WAIT(READY)” only act in programs which were
WAIT(ACTIVE)
If, on the other hand, the system is to wait only until the previous NC block has been
prepared and is active − i.e. has not yet been executed − this can be achieved by
programming ”WAIT(ACTIVE)”. ”WAIT(ACTIVE)” also acts only in programs
If only one of the parameters is programmed, all commas on the left of the parame
ter must be used as dummies for non−programmed parameters. In contrast, there
must be no comma on the right of the last−programmed parameter.
Examples:
.
1 WAIT(,TIME%,E%) Application of parameters <time> and
<result variable>
.
1 WAIT(,TIME%) Application of parameter <time>
If the parameters <IC condition> and <time> are used together, the following
blocks are not interpreted unless either the <IC condition> has been satisfied or
the <time> has elapsed.
4−1
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
<nummer> designates the bit number of a CNC input signal and can be an arbi
trary arithmetic expression, <status> is a BOOLEAN expression.
If the parameter <result variable> is used, the variable contained therein may be
interrogated with respect to the event which has occurred. This parameter can be
programmed only in conjunction with at least one of the other parameters.
If the <result variable> variable has the value 0, the <IC condition> was already
satisfied when the call occurred.
If the <result variable> has the value 1, the <time> has elapsed.
If the <result variable> has the value 2, the interface signal has changed.
Example: WAIT
:
1 WAIT(IC(2)=TRUE) ! Wait until interface signal 2 is set.
:
1 WAIT(IC((A%+B%)*2)=(E1? OR E2?)) ! Wait until the interface signal (A%+B%)*2 has
the value of the logic expression (E1? OR
E2?).
:
1 WAIT(NOT (IC(230)),,C%) ! Wait until the interface signal 230 has the
1 IF C%=0 THEN value FALSE. The result variable C% supplies
1 DSP(10,10,”Cond. already satisf”) either the value 0, if the condition was already
1 ENDIF satisfied when the WAIT instruction was
called, or the value 2, if the condition was
satisfied during the wait.
:
1 WAIT(,TIME%,E%) ! Wait until the time TIME% has elapsed. The
result variable E% is assigned the value 1.
:
1 WAIT(IC(232)=E7?,250,ERG%) ! Wait until the interface signal 232 has the
1 IF ERG%=0 THEN value of variable E7? or 250 milliseconds
1 DSP(10,10,”Not waited!”):ENDIF have elapsed. The value of the result variable
1 IF ERG%=2 THEN depends on the event which has satisfied the
1 DSP(10,10,”> 250 ms waited!”) condition.
1 ENDIF
4−2
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
Restrictions:
1. The WAIT function cannot be programmed with active cutter radius compensa
tion. If this restriction is not observed, the error message "TOO MANY BLOCKS
SUPPR." appears.
3. The reaction time of the control to fulfillment of the enable condition for further
execution of the subsequent blocks depends on the control load and the respec
tive operating mode under which the CPL program was started.
Programs which were started under the or modes are treated with
higher priority by the control operating system than programs started in all other
operating modes.
Axis positions
CPOS
The last programmed absolute position of the individual axes can be determined
via the instruction CPOS (−> command position = programmed axis setpoint).
The axis is addressed by a number which is appended in brackets. The corre
sponding axis address is defined in the machine parameters (P102).
Example: CPOS
.
N2 X150
30 XVALUE = CPOS(1) ! The last−programmed value for the X
. axis (=150.0) is assigned to the vari
. able XVALUE.
N1 X50
N2 G91 X10
30 XVALUE = CPOS(1) ! Absolute position of XVALUE is 60.0
.
MPOS
Interrogation of the current axis position referred to the reference point is possible
with MPOS. MPOS indicates the current actual value of the respective axis. In order
to ensure that the last position traversed to is stored, the WAIT instruction should be
programmed before MPOS. The axis address is defined in the machine parame
ters analogously to the CPOS instruction.
Example: MPOS
.
20 WAIT
30 XPOS = MPOS(1) ! The current value of the X axis is as
. signed to the variable XPOS
.
4−3
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
PPOS
If switching measuring probes are connected to terminal X51 of the control loop
board, the axis position is interrogated at the switching point of the measuring
probe with the PPOS instruction. The axis address is defined in the machine pa
rameters analogously to the CPOS instruction.
Example: PPOS
.
G75 X250 ! The X axis is traversed in the direction of the speci
80 WAIT : XMEAS = PPOS(1) fied position. When the measuring probe switches,
.
the current position is stored, the distance to go is
deleted and G75 is rendered inactive. The stored
position is transferred to the XMEAS variable.
AXO
The AXO instruction permits interrogation of a G92 shift or a shift which was gener
ated by manual zeroing. The axis address is defined in the machine parameters
analogously to the CPOS instruction.
Example: AXO
.
G1 X100 Y200 F2000
G92 X75 Y125
90 XD = AXO(1):YD = AXO(2) ! The variables XD and YD assume the current value of
. the shift.
Zero offsets
FXC
The "FXC" instruction provides direct access to the zero offset tables stored in the
NC. The instruction has the following structure:
4−4
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
If <zero offset table> is programmed with G functions 52, 60, 99, or 160, an error
message will be output.
Examples: FXC
70 FXC(1,54,1) = 80 ! The value 80 is stored under G54 in zero offset table
. 1 for the X axis.
70 FXC(–2,54,1) = 80 ! The value 80 is added to the old value under G54 in
. zero offset table 1 for the Y axis.
70 A = FXC(1,54,1) ! The X value of the offset G54 is assigned from zero off
. set table 1 to the variable A.
70 A = FXC(1) !
The total of the active table zero offsets, i.e. G53..59,
. G153..159 and G253..259 plus active programmed
zero offset (G67, G60) plus active current external zero
offset (G167, G160) of the last prepared block is calcu
lated for the X axis.
The term "current" in the explanation of the FXC examples means . at the time of
CPL block preparation. Block preparation can be interrupted by the WAIT instruc
tion.
Tool compensations
TC
The TC instruction provides access to tool compensation tables.
The structure of the instruction is as follows:
TC(<selection>[,<group>[,<table>]])
Example: TC
10 TC(1,10,25) = A ! The value of the variables A or B is assigned to com
20
.
TC(2,20,25) = B ! pensation group 10 for H or D, respectively, in tool com
pensation table 25.
10 TC(1,10,25) = A ! In this case, the value of A and B in the compensation
20
.
TC(2,20,25) = B ! group is changed additively.
20 A = TC(1,10,25) ! The values for H and D are transferred from compensa
30 B = TC(2,10,25) ! tion group 10 in table 25 to the variables A and B.
.
30
. TC(1,10) = A ! The length compensation value in A is transferred to
. compensation group 10 of the active compensation
.
table.
30 B = TC(2) ! The active radius compensation value is transferred to
variable B.
4−5
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
WARNING !
! Special feature of CC 220 T
CS table
TD
If a CS table is used in CC 220/320 M, it is possible to access this table with CPL.
CS table organization
<group>
<Data selection> #1 #2 #3 ...
1
2
3
...
max. 26
The data of the CS table can be read and overwritten. Since the structure of the CS
table can be freely defined, when working with the CS table attention should be
4−6
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
paid to the data type required by the CS table. If a table value in INTEGER format is
agreed in a line, for example, this must be observed when using variables in CPL.
Example: TD
.
30 A = TD(1,5,1) ! The value of the first column in group 5 of the
. CS table is transferred to REAL variable A.
.
30 TD(3,5,1) = A% ! INTEGER format is defined in the third line of
. group 5 of CS table 1. An INTEGER variable
. must therefore also be chosen for transferring
.
. values to the table.
WARNING !
! Special feature of CC 220 T
With CC 220 T, the TD instruction provides access to the tool life table.
<table number>:
The admissible value range is 1...999 999 999. If <table number> is omitted the
active table is selected.
SD
It is possible to use CPL to read active system data of the NC control using the SD
instruction. The instruction has the following structure:
SD(<group>[,<index1>[,<index2>]])
INTEGER values are output by the SD function.
4−7
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
4−8
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
4−9
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
Examples: SD
.
10 A% = SD(1,2) ! The active G function from the index range
. 2 is contained in A%, e.g. the value 1, if G1
. is active
20
. B% = SD(1,4) ! B% contains either 90 or 91
30 A% = SD(2,1) !
. A% contains the active position of the
feed potentiometer in %
40 B% = SD(5.1) !
. The variable B% contains the active feedrate
50 DUMMY% = SD(16,0) ! No further computing run or subroutine call
60 DUMMY% = SD(16,1) ! Further computing run and subroutine call
1 − 25 64, 65
2 0−3, 5, 10−13, 33, 73 26 68, 69
3 70, 71 27 98, 99
4 90, 91 28 145..845,146..846
5 63, 66 29 114,115
6 140, 143..843,144..844 30 160,167
7 93−95 31 490,491,993,994
8 40−44 32 51,52
9 6, 7 33 −
10 17−20 34 −
11 8, 9 35 −
12 25−27,125,126 36 −
13 14, 15 37 −
14 28, 29 38 −
15 78, 79 39 −
16 80−89 40 −
17 130−132 41 −
18 53−59 42 −
19 153−159 43 −
20 253−259 44 −
21 60, 67 45 −
22 37−39 46 −
23 61, 62 47 −
24 − 48 −
In the SD example (measuring probe interrogtion), the X axis is traversed in the di
rection of the specified position. When the position is reached while the measuring
probe was not deflected, a message is output (line N7), and the program jumps to
the .ERRROR. label. If the measuring probe is deflected, the current position can be
stored in XMEAS.
4 − 10
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
BIN, BCD
The group number 6 of the SD function (auxiliary functions) is indexed in accor
dance with the auxiliary function address defined in the machine parameters
(P2001), i.e. the index corresponds to the input sequence there. The output value
of SD(6,<index1>) can be transferred to BCD format in accordance with P2004.
This format can be converted to binary format by the instruction
<binary value> = BIN(<BCD value>).
Conversely, it is also possible to convert binary format into BCD format. This is
done by means of the instruction:
<BCD value> = BCD(<binary value>)
WARNING !
! Special feature of CC 220 T
4 − 11
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
SDR
The SDR function provides read access to system data in REAL format. The instruc
tion format and application correspond to those of the SD function.
SDR(<group>[,<index1>[,<index2>]])
5 1 2 Last−programmed speeds
5 3 2 Feedrate in input unit per minute
Spindle speed in rpm
(SDR(5,3,2)=0 if C axis is active or no spindle is applied)
5 4 2 Spindle speed in rpm (2nd spindle)
5 3 3 Actual spindle speed in rpm
SDR(5,3,3)=0 if C axis is active or no spindle feedback is
present or no spindle is applied
5 4 3 Actual 2nd spindle speed in rpm.
12 Last−programmed spindle position for M19
(0 is returned if M19 is not programmed)
12 1 Last−programmed position of the 2nd spindle for M19
4 − 12
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
AXP
Using this function, part and measuring programs can be written on a plane−inde
pendent basis.
This function is used in an NC block. It must be written in square brackets "[ ]" and is
programmed instead of the address values.
Example:
.
N30 G90
N40 G1 [AXP(A%,C)] [AXP(B%,D)] F1000
N50 G20 G2 [AXP(A%,E)] [AXP(B%,F)] R[RA]
.
.
The axes determined by the variables A% and B% traverse to the position defined by
the variables C and D (line N40). Plane selection is then carried out by means of
A%, B% and G20, and the axes traverse in an arc defined by the variables E and F
(end point) and RA (radius).
PLC interface
4 − 13
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
Interface access
IC
The interface between the NC and PLC controls can be accessed by means of the
following instructions. All inputs and outputs of the NC control can be polled.
IC(<bit number>[<index>])
Example:
.
30 A?=IC(210) OR IC(211) The states of input bits 210 and 211 are log
. ically combined with the OR function and
. then assigned to the logic variable A?.
.
.
The meaning of the interface signals is described in "Interface conditions". The in
put bit 216.0 "Drive on 1st axis" corresponds to IC(0), while the state of input bit
247.7 can be polled correspondingly via IC(255).
The output bits 205.0 (−>IC(232)) to bit 207.7 (−>IC(255)) can be set and reset if
this area has not been further restricted by machine parameter P4010.
Example:
.
30 IC(240)=TRUE
. Output bit 206.0 is set
.
All output signals can be polled if an <index> with the value 0 is added. If the <in
dex> is 1, an input signal is read. Other <index> values are not admissible.
Example:
1 R%=0
1 S?=IC(233,R%)! Polling of an output signal
Output bits 207.6 and 207.7 are currently occupied by the drilling cycles G86 and
G84.
MIC
If a bidirectional transfer of max. 32 bits is to be carried out in parallel between the
NC and the PLC, the multi−interface can be used for this purpose. The time se
quence of the transfer and control signals is described in the "Interface conditions".
Example:
.
30 MIC = 12 A bit pattern representing the binary number 12 is assigned to
. the multi−interface output.
.
40 MIC = A% The MI output can also be assigned INTEGER variables.
.
.
50 B% = MIC The current information at the MI input is assigned to the INTEGER
. variable B%.
.
4 − 14
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
The NC control processes data in binary form. If a BCD signal is present at the mul
ti−interface output, conversion with the BIN instruction must be carried out before
further processing. If a BCD signal is to be output at the multi−interface output by
the NC, conversion from binary into BCD code must be performed using the BCD
instruction.
Time recording
DATE, TIME
The DATE and TIME instructions provide for an interrogation of the current values
for date and time.
CLOCK
The clock instruction permits interrogation of the current status of a time counter in
milliseconds. The counter is generated from the internal system time. The updating
time is twice the servo clock time.
Example: CLOCK
.
30 STARTTIME% = CLOCK
N4 G1 X50 Y70
50 WAIT : ENDTIME% = CLOCK : DIFF% = ENDTIME%–STARTTIME
.
4 − 15
CC 220/320
4. System Functions
Flexible Automation CPL Programming Instructions
4 − 16
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
5. String processing
The CHARACTER data type offers the possibility of forming character arrays
(fields) with a defined length and of processing these STRINGs. The implicit decla
ration of this data type is by means of a $ symbol as a suffix in conjunction with the
corresponding array dimensioning. A character array is thus a dimensioned
STRING variable. If there is no dimensioning, a STRING variable is involved.
The CPL instructions MID$, LEN, INSTR, ASC, STR$, VAL, and TRIM$ are available
for string processing.
Example:
1 DIM VWX$(14)
In this example, the maximum array length of the VWX$ is 14 characters. However, if
only the first three characters of the array are written, the character array VWX$ has a
length of 3 (= number of allocated components).
If the value range for the character array length of 1 to 127 is exceeded, the follow
ing error message appears:
1 DIM ABC$(1)
2 DIM BCDE$(10)
3 ABC$ = ”Z”
4 BCDE$ = CHR$(90)
MID$
This function takes parts out of a <STRING expression> and outputs them as text.
The result may be transferred to a STRING variable or to a correspondingly dimen
sioned character array.If chaining (e.g. MID$(A$+B$,2,3)) is programmed
within the MID instruction, the result may only be assigned to a character array.
5−1
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
<starting point> defines the position within the character array <STRING expres
sion> from which the characters are to be taken. <number of characters> deter
mines the number of characters to be taken. If <number of characters> is not pro
grammed, all characters up to the length end of the character array are taken.
The value range for the 2nd and 3rd parameters includes INTEGER values be
tween 1 and 127. If this value range is exceeded, the following message appears:
RUNTIME ERROR 2184 − INVALID PARAMETER.
"NUL" is returned if a part of the character array is accessed which has not yet been
allocated.
MID$
The MID$ instruction overwrites part of a character array.
The INTEGER expression <starting point> defines the position in the <character
array> as from which the characters are to be overwritten. The INTEGER expres
sion <number of characters> determines the number of characters to be overwrit
ten.
The value range for the 2nd and 3rd parameters includes INTEGER values be
tween 1 and 127. If this value range is exceeded, the following message appears:
Example:
1 DIM A$(10)
2 A$= ”ABC” Length of A$ is 3.
3 MID$(A$,4,3)=”DEF”
The 4th to 6th components of the character array are written. This is permitted since
the first three components have already been allocated.
Example:
1 DIM A$(10)
2 A$= ”ABC” Length of A$ is 3.
3 MID$(A$,5,3)=”DEF”
5−2
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
An attempt is made to write the 5th to 7th components of the character array. How
ever, this leads to the error message
RUNTIME ERROR 2248 − CHAR.FIELD NOT ALLOCATED
since the 4th component has not yet been allocated.
If more characters are allocated than the permitted maximum length of the charac
ter array, these characters are discarded.
LEN
LEN() specifies the number of characters in a STRING expression. The result is an
INTEGER value.
LEN(<STRING expression>)
Example:
1 DIM XYZ$(10)
2 XYZ$=”ABC”
3 I%=LEN(XYZ$)
The INTEGER variable I% has the value 3
INSTR
INSTR(<character string>,<STRING expression>[,<starting point>])
The value range for the 3rd parameter is 1 to 127. If this range is exceeded, the fol
lowing error message is displayed:
RUNTIME ERROR 2184 − INVALID PARAMETER.
Example: INSTR
1 DIM A$(8)
2 DIM B$(16)
3 A$ = ”A” : MID$(A$,2) = ”UVWXYZ”
4 B$ = ”ABCDEF UVWXYZ GH”
5 POSITION1% = INSTR(MID$(A$,2),B$,4)
6 POSITION2% = INSTR(MID$(A$,2,4),B$,10)
7 POSITION3% = INSTR(MID$(A$,2),B$)
Contents of the INTEGER variable POSITION1% : 8
Contents of the INTEGER variable POSITION2% : 0
Contents of the INTEGER variable POSITION3% : 8
5−3
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
ASC
ASC(<character string>)
ASC( ) outputs the ordinal number of the first character (ASCII code) of <character
string> as an INTEGER value.
Example: ASC
10 DIM A$(1)
20 A$ = ”ABC”
30 B$ = ”BCD”
40 I% = ASC(A$)
50 J% = ASC(B$)
Contents of the INTEGER variable I% : 65
Contents of the INTEGER variable J% : 66
STR$
STR$([<format string>,]<value>)
This function converts the numerical expression <value> into a character string
which can be assigned exclusively to a character array. Assignment to a STRING
variable results in a runtime error.
Standard formats:
Example:
10 DIM A$(50)
20 DIM B$(21)
30 A$ = STR$(”Number = ##.###”,(37/3))
40 B$ = STR$(2.5)
5−4
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
VAL
VAL(<STRING expression>)
VAL( ) returns the numerical value for a <STRING expression>. If a character other
than leading blanks, the leading characters "+" or "−", the digits 0 to 9 or the deci
mal point "." occurs in the character string, then conversion is performed up to this
(different) character. Leading blanks are ignored like leading zeros in value calcula
tion. "NUL" is returned if none of the above characters appears. If a decimal point
occurs in the character string, the result may only be assigned to a REAL or
double−precision REAL variable. In this case, assignment to an INTEGER variable
leads to the
RUNTIME ERROR 2175 − INVALID ALLOCATION.
Example:
1 I% = VAL(”1.23DE”)
2 K% = VAL(”123DE”)
3 J% = VAL(”ABC”)
4 R = VAL(”–1.23DE”)
5 Z = VAL(”+ 000001234TEST4365”)
6 X = VAL(”ABC1.23DE”)
7 D! = VAL(”1234567.234567”)
The value of the INTEGER variable K% is 123. The digits 1, 2, 3 are converted
into an INTEGER value. The character ”D” cancels conversion, since it cannot be
long to an INTEGER value. The following characters are not processed.
The value of the INTEGER variable J% is NUL − the variable has not been allocated.
The character ”A” aborts processing of the <STRING expression>.
The value of the REAL variable R is −1.23. The character "−" is recognized as a
sign for the REAL number. The digit 1, character ".", and the digits 2 and 3 are
converted into a REAL number. The character ”D” aborts conversion, since it can
not belong to a REAL number. The character ”E” is not processed.
The value of the REAL variable Z is 1234. The character "+" is recognized as a sign
for the REAL number. The following blanks are ignored like leading zeros in value
generation. The digits 1, 2, 3, and 4 are converted into a REAL number. The
character "T" aborts conversion since it cannot belong to a REAL number. The re
maining characters are not processed.
The REAL variable X is NUL, i.e. not allocated. Conversion is aborted after recogni
tion of the character ”A”.
5−5
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
TRIM$
TRIM$(<character string>)
TRIM$(<character string>,"L")
TRIM$(<character string>,"R")
TRIM$( ) supplies a character string without leading (−> index L) or trailing (−>
index R) blanks when a character array area is assigned to a STRING variable or
character array. The TRIM function without index suppresses both leading and trail
ing blanks.
If chaining (e.g. TRIM$(A$+B$)) occurs within the TRIM instruction, the result
must always be assigned to a character array.
Example:
1 A$ = ” ABCDEF ”
1 B$ = TRIM$(A$,”L”)
1 C$ = TRIM$(A$,”R”)
1 D$ = TRIM$(A$)
1 DSP(10,10,”>”,A$,”<”)
1 DSP(12,10,”>”,B$,”<”)
1 DSP(14,10,”>”,C$,”<”)
1 DSP(16,10,”>”,D$,”<”)
causes the following output:
> ABCDEF <
>ABCDEF <
> ABCDEF<
>ABCDEF<
Programming examples
A STRING expression can be assigned to a STRING variable.
5−6
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
sign a character array or part of the character array to a STRING variable or a differ
ent character array.
Read and write access to part of a character array is performed by means of the
MID$ instruction. The entire character array is addressed if only the character array
name is specified.
If a coherent area of the character array (−> character string) is to be used, this can
be achieved using the MID$ instruction.
Example:
1 DIM A$(13):I%=10:J%=4:A$= ”TEST TEST TES”
2 B$=MID$(A$,I%,J%)
3 DSP(4,9,”>”,A$,”< (A$ previous.)”):DSP(6,9,”>”,B$,”< (B$ prev.)”)
4 A$=ABCDEFGHIJKLM”
5 DSP(8,9,”>”,A$,”< (A$ afterw.)”): DSP(10,9,”>”,B$,”< (B$ af-
terw.)”) The characters 10 to 13 (”TES”) of the character array A$ are assigned to the
STRING variable B$. It must be noted that the contents of B$ also change if the contents of the
character array A$ are changed.
The programming example shown below would lead to the error message
RUNTIME ERROR 2248 − CHAR.FIELD NOT ALLOCATED
since characters 1 to 5 of the character array have not been allocated:
5−7
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
1 DIM XYZ$(15)
2 B$=”ABCDE”
4 MID$(XYZ$,6,5)=B$
The XYZ$ character array is written only with the length of the STRING variable if the
length of the STRING variable is smaller than that of the character array. If this char
acter array is assigned to a STRING variable, only the area which was written pre
viously (−> length of the character array) is allocated and not the whole character
array which was defined by the DIM instruction.
Example:
1 DIM XYZ$(100)
3 MID$(XYZ$,1,10)=”ABCDE”
4 MID$(XYZ$,6,3)=”T”
The contents of the XYZ$ array variable are ”ABCDE” after record 3. The array vari
able has a length of 5. The remaining 95 characters have not been allocated and
are therefore not included in the length.
The contents of the XYZ$ array variable are ”ABCDET” after record 4. The array
variable now has a length of 6. The remaining 94 characters have not been allo
cated and are therefore not included in the length.
1 DIM XYZ$(100)
3 MID$(XYZ$,1,10)=”1234567890”
4 MID$(XYZ$,3,3)=”T”
The contents of the XYZ$ array variable are ”1234567890” after record 3. The
array variable has a length of 10.
The XYZ$ array variable has the contents ”12T4567890” after record 4. The array
variable has a length of 10. The character ”3” is overwritten by ”T”. The charac
ters ”4” and ”5” are preserved.
1 DIM XYZ$(100)
3 MID$(XYZ$,1,6)=”ABCDEF”
5 MID$(XYZ$,9,5)=”TEST”
5−8
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
The XYZ$ array variable contains ”ABCDEF” after record 3. The array variable has
a length of 6.
since the 7th and 8th components have not been allocated.
It is sufficient to specify the variable name if the whole character array is to be ac
cessed.
Example:
1 DIM XYZ$(16)
2 XYZ$=” ”
Contents of the XYZ$ character array: ” ”
Length of the XYZ$ character array: 1
Any excess characters are discarded if the length of the STRING expression ex
ceeds the maximum length of the character array upon assignment.
Example:
1 DIM XYZ$(3)
2 XYZ$=”ABCDEF”
Contents of the XYZ$ character array: ”ABC”
Length of the XYZ$ character array: 3 −−−> maximum length
Example:
1 DIM XYZ$(14)
2 A$=”THIS ”
3 B$=”IS A TEST”
4 C$=”A POST”
5 MID$(XYZ$,1,5)=A$
5−9
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
Example:
6 MID$(XYZ$,6,6)=B$
CONTENTS OF THE CHARACTER ARRAY
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| | | | | | | | | | | | | | |
| T | H | I | S | | I | S | | A | | T | | | |
| | | | | | | | | | | | | | |
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| | |
Length = 11 Area has not
been allocated
7 MID$(XYZ$,6,9)=B$
CONTENTS OF THE CHARACTER ARRAY
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| | | | | | | | | | | | | | |
| T | H | I | S | | I | S | | A | | T | E | S | T |
| | | | | | | | | | | | | | |
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| |
Length = 14 Area has been completely allocated
8 MID$(XYZ$,9,4)=C$
CONTENTS OF THE CHARACTER ARRAY
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| | | | | | | | | | | | | | |
| T | H | I | S | | I | S | | A | | P | O | S | T |
| | | | | | | | | | | | | | |
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| |
Length = 14 Area has been completely allocated
9 XYZ$=MID$(XYZ$,1,5)
CONTENTS OF THE CHARACTER ARRAY
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| | | | | | | | | | | | | | |
| T | H | I | S | | | | | | | | | | |
| | | | | | | | | | | | | | |
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
| | |
Length = 5 Area has not been allocated
5 − 10
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
Example:
1 DIM A$(10)
2 DIM B$(15)
3 A$=”JAMES”
4 B$= ”BILLY”
5 C$=”ABCDE”
6 D$=”VWXYZ”
7 IF A$ < B$ THEN ...
8 IF MID$(A$,2,3) = MID$(B$,1,3) THEN ...
9 Z?=A$ <> ”TEST”
10 IF ”A” <= ”C” THEN ...
11 IF C$ > D$ THEN ...
12 IF A$ = C$ THEN ...
13 IF ”TE” < MID$(D$,2,2) THEN ...
The contents of the STRING expressions are verified for their alphabetical order
corresponding to the ASCII code of the individual characters.
1 DIM A$(3)
2 DIM B$(3)
3 A$ = ”ABC”
4 B$ = ”DEF”
5 C$ = ”GH”
6 D$ = ”JKL”
7 OPENW(1,”P2”,130,”TEST CHAINING”,10)
8 PRN#(1,A$+B$)
9 PRN#(1,A$+C$)
10 PRN#(1,C$+D$)
11 PRN#(1,A$+C$+”TEST”)
12 PRN#(1,”UVW”+”XYZ”)
13 CLOSE(1)
Contents of file P2:
ABCDEF <LF>
ABCGH <LF>
GHJKL <LF>
ABCGHTEST <LF>
UVWXYZ <LF><ETX><LF>
5 − 11
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
Example: STR$
1 DIM A$(50) : DIM B$(21)
1 A$ = STR$(”A$ = ##.###”,(37/3)) : B$ = STR$(2.5)
Contents of character array A$ : ”A$ = 12.333” ;
character array B$ : ” 2.500”
Example: VAL
1 DIM SEQUENCE$(20) : SEQUENCE$ = ”XVALUE –0001.234 MM”
1 X = VAL(MID$(SEQUENCE$,7)) : Z% = VAL(MID$(SEQUENCE$,7,7))
1 Y% = VAL(MID$(SEQUENCE$,15,5)) : X% = VAL(MID$(SEQUENCE$,18))
Contents of the REAL variable X : –1.234
Contents of the INTEGER variable Z% : –1
Contents of the INTEGER variable Y% : 234
Contents of the INTEGER variable X% : NUL
5 − 12
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
Example: LEN
1 DIM Z$(10)
2 Z$ = ”TEST”
3 S$ = ”TEST”
4 A% = LEN(”TEST”)
5 B% = LEN(Z$)
6 C% = LEN(S$)
7 D% = LEN(”TEST”+Z$+S$)
Contents of the INTEGER variable A% : 4
Contents of the INTEGER variable B% : 4
Contents of the INTEGER variable C% : 4
Contents of the INTEGER variable D% : 12
10 DIM A$(4)
20 DIM B$(10)
30 DIM C$(10)
40 DIM D$(10)
50 DIM E$(10)
55 DIM F$(10)
60 A$ = ”ABCD”
70 B$ = MID$(A$,2,2) ––> B$ = ”BC”
80 C$ = MID$(A$,2,5) ––> C$ = ”BCD”
95 E$ = MID$(A$,5,1) ––> E$ = NUL
97 F$ = MID$(A$,2) ––> F$ = ”BCD”
97 F$ = MID$(F$,1,1) ––> F$ = ”B”
10 DIM A$(4)
20 DIM B$(10)
30 DIM C$(10)
40 DIM D$(10)
60 A$ = ”ABCD”
70 B$ = ”1234567890”
80 C$ = ”EFGHIJKLMN”
85 D$ = A$ ––> D$ = ”ABCD”
90 MID$(D$,2,3) = B$ ––> D$ = ”A123”
95 MID$(D$,5,1) = C$ ––> D$ = ”A123E”
97 MID$(D$,4) = B$ ––> D$ =
”A121234567”
Example: TRIM$
1 DIM XYZ$(16)
2 XYZ$ = ”XVALUE = 0.123 ”
3 A$ = MID$(XYZ$,8)
4 B$ = TRIM$(MID$(XYZ$,8))
5 C$ = TRIM$(MID$(XYZ$,8),”L”)
6 D$ = TRIM$(MID$(XYZ$,8),”R”)
5 − 13
CC 220/320
5. String Processing
Flexible Automation CPL Programming Instructions
5 − 14
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
6. File processing
The programming language CPL offers the possibility of reading data from the part
program memory or writing data to the part program memory. This is accom
plished by creating files. These files allow, for example, storage of measured values
and selective output on a printer at any time.
These files are handled in the same way as part program files, i.e. they can be man
aged under different operating modes. A file can be accessed once it has been
opened; when file processing is complete, the file must be closed.
Interface data
The two serial standard interfaces are treated like the files "1" and "2" in the "TTY"
directory.
In contrast to random files, sequential files contain records of different length (max.
length 127 characters). The end of a record is identified by <LF> which is not
counted as part of the length. An <ETX><LF> is inserted after the last record of a
file, representing an EOF pointer. An EOF pointer is a pointer for the end of the use
ful data (<ETX>) in a file.
A random file has the advantage of faster access to the required data. In addition,
the data of a record can be processed and/or modified without changing the struc
ture of the rest of the file. Records which are not completely filled with data are filled
with blanks up to the defined length.
6−1
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
If it is attempted to insert a STRING variable in a random file which is longer than the
record length, the record is filled with the first characters of the STRING variable up
to the defined length, the remaining characters are discarded.
The REWRITE and CLOSE instructions are used in the same way as for sequential
files.
Opening a file
OPENW, OPENR
If the file to be opened does not yet exist, it is created upon opening and the speci
fied memory space reserved. The command for opening a file depends on subse
quent read or write access.
The file pointer is positioned at the first record to which read access is possible
when a file is opened for reading.
The pointer is positioned at the EOF pointer, i.e. after the last file record, when a file
is opened for writing. An additional parameter is used to open a random file which
specifies the length of the records in the file in bytes (1 byte = length of a character).
Otherwise, the command format corresponds to that of a sequential file.
OPENW syntax
The OPENW instruction has two possible formats:
OPENW(<n>,<prog.identifier>[,<length>][,<program name>][,<record
length>])
or
6−2
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
<n>:
Logical number under which the file can be addressed. It is possible to choose val
ues between 1 and 9. The logical number must be programmed as an INTEGER
expression. A logical number must not be allocated for reading and writing a file at
the same time. In other words, up to 9 different files may be opened for reading or
writing. If the value range is not observed, the following error message is displayed:
<program identifier>:
The program identifier must be represented as a STRING expression (directory
and file no.), otherwise the following error message is displayed:
<directory>:
The directory can be programmed as a STRING expression, or can be omitted. A
STRING constant must have the fixed structure ”P” or ”TTY” in order to be able to
open a file for writing. The character string ”P” or ”TTY” must therefore be as
signed to a STRING variable. If no directory is specified during programming, the P
directory is assumed implicitly. If these instructions are not observed, the following
error message is displayed:
<file no.>:
The <file no.> must be represented as an INTEGER expression. If the TTY direc
tory was addressed, the <file no.> can only assume the INTEGER values 1 and 2.
TTY1 designates the serial interface on the control, while TTY2 describes the inter
face on the panel. If neither 1 nor 2 is programmed, the following error message is
displayed:
Otherwise, the value range is 1 to 999 999 999. If the value range is exceeded, the
following error message is displayed:
<length>:
Reserved length for file creation in bytes. If the P directory was previously pro
grammed in the 3rd parameter, the length must be programmed as an INTEGER
expression. A minimum length of 130 bytes is necessary since at least 1 record
(= 130 characters) is generated and stored when writing into the file. If these pa
rameters are not observed, the following error message is displayed:
6−3
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
If the TTY directory was programmed in the 3rd parameter, no length must be pro
grammed. Otherwise, the following error message will be displayed:
<program name>:
Only a STRING expression is permitted for programming the program name pa
rameter. The program name is automatically entered in the file header. If the TTY
directory was programmed in the 3rd parameter, no program name must be pro
grammed. Otherwise, the following error message will be displayed:
<record length>:
Number of bytes in a record; value range: 1...127.
If the value range is exceeded, the following error message will be displayed:
OPENR syntax
The OPENR instruction also has two possible formats:
OPENR(<n>,<prog.identifier>[,<record length>] )
or
<directory>:
The directory can be programmed as a STRING expression, or can be omitted. A
STRING constant must have the fixed structure ”P” or ”L" or ”TTY” in order to be
able to open a file for reading. The character string ”P” or ”L" or ”TTL” must be
assigned to a STRING variable in order to permit a file to be opened for reading
interface data or the contents of another file. If no directory is specified when pro
gramming, the P directory is assumed implicitly. If these parameters are not ob
served, the following error message will be displayed:
Below, there are a few examples on programming the OPENW instruction. They
can be transferred analogously to the OPENR instruction.
6−4
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
When the file is opened for writing, the system verifies whether the random struc
ture is still preserved.
Example:
1 OPENW(2,2,200,”TEST”,10)
2 PRN#(2,”ABC”)
3 CLOSE(2)
4 OPENW(1,2,400,”TEST”,3)
5 CLOSE(1)
The system checks whether the record length of the "P2" file is 3. However, the record length
of this file is 10.
If the structure has been destroyed by means of the editor, the following error mes
sage is displayed:
If addressing is performed via the program identifier or the TTY directory and a re
cord length is programmed simultaneously, the following error message is dis
played:
6−5
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
Example:
10 OPENW(2,2,200,”TEST1”,10)
20 FOR I% = 1 TO 3
30 PRN#(2,”TEST”)
40 NEXT I%
50 CLOSE(2)
Result: ”P2”
TEST <LF>
TEST <LF>
TEST <LF>
<ETX><LF>
When a file is opened for reading, the system verifies whether the random structure
is retained. All components must have the same length as specified in the OPENR
instruction.
Example:
1 OPENW(2,2,200,”TEST”,10)
2 PRN#(2,”ABC”)
3 CLOSE(2)
4 OPENR(1,”P2”,5)
5 CLOSE(1)
The system checks whether the record length of the "P2" file is 5. However, the record length
of this file is 10.
Example:
P1:
N10 G1F10000X1000Y1000Z1000
1 A$=”01234567890123456789”
2 B$=”TEST”
N20 X0
M30
P2:
1 OPENW(1,3,500,”RANDOMFILE”,10)
2 OPENR(2,”P1”)
3 FOR I% = 1 TO 5
4 INP#(2,A$)
5 PRN#(1,A$)
6 NEXT
7 CLOSE(2)
8 CLOSE(1)
RESULT: P3
N10 G1F100<LF>
1 A$=”01<LF>
2 B$=”TE<LF>
N20 X0 <LF>
M30 <LF><ETX><LF>
6−6
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
If the structure has been destroyed by means of the editor, the following warning is
displayed
Writing a file
PRN#
Instruction format: PRN#(<n>,[<expression>] [,<expression>] [,<ex
pression>][,...][;])
If the output of an expression contains more than 127 characters, the following er
ror message is displayed:
If the result cannot be represented in the specified format, the following warning is
output:
6−7
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
A line feed can be initiated during output by means of CHR$(13), i.e. output of the
PRN# instruction is continued in the next line, i.e. in the next record.
Using the CHR$() function, other control characters can also be transmitted, e.g.,
when outputting via a serial interface.
Example:
1 OPENW(2,2,200,35)
2 PRN#(2,”TEST1 FOR PRN INSTRUCTION WITH SEMI–COLON”)
3 PRN#(2,”TEST2 FOR PRN INSTRUCTION WITH SEMI–COLON”)
4 PRN#(2,”TEST3 FOR PRN INSTRUCTION WITH SEMI–COLON”)
6 SEEK(2,1)
7 PRN#(2,”OVERWRITE”;)
8 CLOSE(2)
RESULT in P2:
OVERWRITE PRN INSTRUCTION WITH SEMI–COLON<LF>
TEST2 FOR PRN INSTRUCTION WITH SEMI–COLON<LF>
TEST3 FOR PRN INSTRUCTION WITH SEMI–COLON<LF>
<ETX><LF>
Example:
1 OPENW(2,2,200,35)
1 REWRITE(2)
2 PRN#(2,”TEST1 FOR PRN INSTRUCTION WITHOUT SEMI–COLON”)
3 PRN#(2,”TEST2 FOR PRN INSTRUCTION WITHOUT SEMI–COLON”)
4 PRN#(2,”TEST3 FOR PRN INSTRUCTION WITHOUT SEMI–COLON”)
6 SEEK(2,1)
7 PRN#(2,”OVERWRITE”)
8 CLOSE(2)
RESULT in P2:
OVERWRITE <LF>
TEST2 FOR PRN INSTRUCTION WITHOUT SEMI–COLON <LF>
TEST3 FOR PRN INSTRUCTION WITHOUT SEMI–COLON <LF>
<ETX><LF>
The following error message is displayed if the record length of 127 characters is
exceeded:
6−8
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
If a sequential file is written and the file end reached, the file is automatically copied
and the reserved area is extended by the occupied length if sufficient memory
space is available in the part program memory. Since a large quantity of memory is
used up very rapidly as a result of this feature, it is advisable to reserve a sufficiently
large file length when the file is created with OPENW.
Example:
1 OPENW(1,”P2”,300,”TEST PRN INSTRUCTION”)
2 A$=”TEST”
3 B$=”FOR”
4 C$=”PRN INSTRUCTION”
5 PRN#(1,A$)
6 PRN#(1,B$)
7 PRN#(1,C$)
8 PRN#(1,A$;)
9 PRN#(1,B$;)
10 PRN#(1,C$;)
11 CLOSE(1)
RESULT:
P2:
TEST<LF>
FOR<LF>
PRN INSTRUCTION<LF>
TESTFORPRNINSTRUCTION<LF><ETX><LF>
Example:
10 DIM E$(50)
20 OPENW(1,2,300,”TEST2”)
30 A% = 5000
40 R = 1.231
50 B! = 4/3
60 D$ = ”ABCDE”
70 E$ = ”CDEFGHI”
80 PRN#(1,”10”;)
90 PRN#(1,”#####”,”###.###”,”#.#####”,A%,R,B!,D$,E$)
95 CLOSE(1)
P2 :
10 5000 1.2311.33333ABCDECDEFGHI<LF>
A% R B! D$ E$
6−9
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
Example: PRN#(0,...)
.
1 TIME$=TIME
2 PRN#(0,”The time: ”,TIME$)
.
leads to the following "prompt line" output:
LJUST, NJUST
Changeover to left−justified data output is performed with LJUST (=left JUSTifica
tion). This changeover takes effect for all file outputs up to the end of the program
run. It is possible to switch back to the formatted output mode before that by means
of NJUST (No JUSTification).
A maximum of 7 places (4 places before the decimal point, 3 places after the deci
mal point) is available for output of data to files for the REAL data type. A maximum
of 9 places is available for the INTEGER data type. Leading and trailing zeros are
suppressed. This also applies to left−justified output.
6 − 10
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
REWRITE
If data already exists in the opened file, the new data is normally appended to the
existing data by writing. However, an existing file can be overwritten with REWRITE
without the necessity to previously delete the no longer required contents sepa
rately. If a file is overwritten, the area in the part program memory reserved by the
OPENW instruction is preserved.
Reading a file
INP#
Data can be read out of the file using the following instruction:
The variable type can be freely selected. Index variables and character arrays can
also be used. If a value other than TRUE or FALSE is assigned to a logical variable,
the value NUL is assigned to this variable.
In the case of variable type INTEGER or REAl (simple and double precision), the
characters "0" ... "9", leading signs "−", "+", leading zeros or blanks are converted
into INTEGER or REAL values. If a different character is assigned to an INTEGER or
REAL variable, the value NUL is assigned to this variable. The position within the file
does not change if NUL is assigned to a variable.
If a semi−colon is programmed, the file pointer remains in the record until the re
cord end is reached. Then the next record is processed. However, reading is not
automatically continued. The next record is automatically processed if no semi−
colon is programmed. Only one semi−colon is permitted per INP# instruction.
6 − 11
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
Result:
B% = –12
D$ = ”TEST” ,since max. length of the character array = 4
R(1,1) = 1.23
E$ = ”V”
R(1,2) = 12
A$ = ”ABC” ,since max. length of the character array = 3
C$ = ”D2.4A”
G$ = ”–12TEST1.23V12ABCD2.4A”
H$ = ”–12TEST” ,since max. length of the character array = 7
I$ = ”1.23V12” ,since max. length of the character array = 7
J$ = ”ABCD2.4A”
P3:
1 OPENR(2,2)
2 DIM C$(3)
3 INP#(2,I%,J,L?,C$,K%,D$)
4 CLOSE(2)
RESULT:
I% = NUL
J = NUL
L? = NUL
C$ = ”ABC”
K% = 123456789
D$ = ” ABC”
6 − 12
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
INP# function
If one of the two standard interfaces is selected in the OPENR instruction, it is pos
sible to determine the interface status by means of the INP# function.
6 − 13
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
EOF
Using the EOF function, it is possible to inquire whether the end of a file (EOF . end
of file) has been reached. The EOF function results in the output of the logical value
TRUE if the file end is reached during read access. Otherwise, FALSE is output.
Example:
.
1 OPENR(1,”L”,444) : I%=4
1 WHILE NOT (EOF(1))DO
1 INP#(1,A$)
1 I%=I%+1
1 IF I%>36 THEN CLS : I%=5 ENDIF
1 DSP(I%,1,A$)
1 END
1 REPEAT UNTIL INKEY<>0
1 CLG:CLOSE(1)
M30
.
Closing a file
CLOSE
The file must be closed when read or write operations are terminated. This prereq
uisite must be met in order to be able to access a file again in a similar way.
6 − 14
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
Example:
.
90 WAIT
100 XPOS = MPOS(1)
110 YPOS = MPOS(2)
120 OPENW(1,”P5”,500,”AXISPOS”)
130 REWRITE(1)
140 PRN#(1,”X AXIS”,XPOS,”Y AXIS”,YPOS)
150 CLOSE(1)
160 OPENR(1,”P5”)
170 INP#(1,A$)
180 CLOSE(1)
190 OPENW(2,”TTY1”)
200 PRN#(2,A$)
210 CLOSE(2)
.
In the above example, the current positions of the X axis and the Y axis are trans
ferred to variables (lines 90 to 110). Then, file 1 is opened and stored as part pro
gram No. 5 in directory P (line 120). The file is then written or overwritten and finally
closed (lines 140 to 150). The file is subsequently opened for reading, and the con
tents are assigned to the variable A$. It is closed again after read access (lines 160
to 180). The serial interface at the control is opened in lines 190 to 210 and an in
struction for output of variable A$ is issued. The interface is then closed.
FILEPOS
The FILEPOS( ) function supplies the record number of the current record of a ran
dom file to which access is subsequently possible. In addition, it is possible to de
termine the record offset within the current record of a random file or with respect to
the current byte of a sequential file with the possibility to access this byte. The file
may be either a sequential file or a random file.
The term "Offset" is understood to mean the number of bytes from the start of the
file up to the current byte in a file. The record offset specifies the byte to which posi
tioning is to take place within a record. The record offset starts with the value 1 (=
1st byte in a record) and may assume a maximum value of the record length +1
(last byte in this record is <LF>). The value 1 is returned if the file pointer is located
at the EOF pointer.
<mode> = Mode
If the value range (1..3) is exceeded, the following error message is displayed:
6 − 15
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
If <mode> is not programmed and the file is a sequential file, the instruction sup
plies the offset (. number of bytes from the start of the file to the current byte) with
respect to the current byte which can be read or written.
If <mode> is not programmed and the file is a random file, the instruction supplies
the record number of the current record which can be read or written. If the EOF
pointer has been reached, the result is: number of records +1.
If <mode> is programmed and the file is a sequential file, only the value 1 must be
programmed for the <mode> parameter. The instruction then supplies the offset
(. number of bytes from the start of the file to the current byte) with respect to the
current byte which can be read or written.
If <mode> is programmed and the file is a random file, the <mode> parameter
has the value range 1 to 3.
<mode> = 1:
The instruction supplies the offset (. number of bytes from the start of the file to the
current byte) with respect to the current byte which can be read or written.
<mode> = 2:
The instruction supplies the record number of the current record which can be read
or written. If the EOF pointer has been reached, the result is: number of records +1.
<mode> = 3:
The instruction supplies the record offset within the current record which can be
read or written. The record offset starts with the value 1 (. 1st byte in this record)
and can have a maximum value of the record length +1 (. last byte in this record is
<LF>). If the EOF pointer has been reached, the value 1 is returned and reading
out of the file is not permitted.
6 − 16
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
Result:
POSITION% = 3 −> Byte number
POSITION1% = 3 −> Byte number
POS% = 181 −> Byte number
POS1% = 181 −> Byte number
SEEK
The SEEK instruction is used to position the file pointer to a specific location. The
file may be either a sequential file or a random file.
6 − 17
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
If parameter <o> is not programmed for random files, positioning takes place to
the 1st byte of the record. Then this record can be accessed. Positioning to the
<o>th byte of the record is possible by programming <o> (=record offset). It is
then possible to access this byte.
If the value range 1...9 is exceeded, the following error message is displayed:
The following error message is displayed if a sequential file was opened for writing
and a SEEK instruction is programmed:
<k> = Record
Value range: 0 to last existing record. The record with the EOF pointer is deemed to
be the last existing record. Positioning to the EOF pointer takes place with 0. If the
value range is exceeded or the specified record does not exist, the following error
message is displayed:
The record offset specifies the byte to which positioning is to take place within a
record. This parameter is permitted only for random files.
Value range: 1... record length +1. If the value range is exceeded, the following er
ror message is displayed:
If parameter <o> is programmed although the file is a sequential file (open for
reading), the following error message is displayed:
6 − 18
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
FILESIZE
FILESIZE( ) supplies the size of a file or the limit up to which a file has already been
written. The file may be either a sequential file or a random file.
FILESIZE(<n>[,<k>])
<n> = Logical file number.
If the value range 1...9 is exceeded, the following error message is displayed:
<k>:
Sequential files:
<k> = 1 : Overall size of the memory space occupied by a file (including file
header) in bytes.
<k> = 2 : Size of the memory space occupied from the start of the data area up
to the EOF pointer in bytes (excluding the size of the EOF pointer).
6 − 19
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
Random files:
<k> = 1 : Overall size of the memory space occupied by a file (including file
header) in bytes.
<k> = 2 : Size of the memory space occupied from the start of the data area up
to the EOF pointer in bytes.
<k> = 3 : Maximum number of records in a file. This result depends on the re
cord length with which the file was opened.
<k> = 4 : Number of records from the start of the file up to the EOF pointer. This
result depends on the record length with which the file was opened.
If <k> is not programmed, the memory space occupied by a file is returned in by
tes (like <k> = 1).
If the value ranges for <k> are exceeded, the following error message is dis
played:
6 − 20
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
File deletion
ERASE
The CPL instruction ERASE is used to delete part programs in the P directory.
<file no.> must be represented as an INTEGER expression. The value range is 1 ...
999999999. If the value range is exceeded, the following error message is dis
played:
6 − 21
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
4: File has not been deleted because it is only present in the library.
Beispiele: ERASE
10 IF ERASE(1) <> 0 THEN ...
.
10 I% = ERASE(”P1”)
.
10 WHILE ERASE(”P”,1) <> 0 DO ...
Otherwise, a warning is output for files which do not exist, are delete−protected or
active and therefore cannot be deleted, or files which only exist in the library, and
the program is continued.
Example:
10 OPENW(1,1,200)
20 CLOSE(1)
30 ERASE(1)
6 − 22
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
Example: Deletion of files which are not delete−protected and not active
10 OPENW(1,2,200)
11 OPENW(2,3,200)
12 OPENW(3,4,200)
13 OPENW(4,5,200)
14 OPENW(5,6,200)
14 OPENW(6,7,200)
20 PRN#(1,”TEST1 FOR ERASE”)
21 PRN#(2,”TEST2 FOR ERASE”)
22 PRN#(3,”TEST3 FOR ERASE”)
23 PRN#(4,”TEST4 FOR ERASE”)
24 PRN#(5,”TEST5 FOR ERASE”)
24 PRN#(6,”TEST6 FOR ERASE”)
31 CLOSE(1)
32 CLOSE(2)
33 CLOSE(3)
34 CLOSE(4)
35 CLOSE(5)
36 CLOSE(6)
40 ERASE(”P2”)
41 ERASE(”P”,3)
42 ERASE(4)
43 A$=”P5”
44 ERASE(A$)
45 B$=”P”
46 R%=6
46 ERASE(B$,R%)
47 S%=7
48 ERASE(S%)
Example:
P1 does not exist,
P2 is active,
P3 is delete−protected,
P4 can be deleted.
10 IF ERASE(1) <> 0 THEN
20 PRN#(0,”FILE WAS NOT DELETED”)
30 ENDIF
41 I% = ERASE(”P1”)
42 J% = ERASE(”P2”)
43 K% = ERASE(”P3”)
44 L% = ERASE(”P4”)
47 IF L% = 0 THEN
48 PRN(2,3,”FILE WAS DELETED”)
49 ENDIF
50 IF I% = 1 THEN
60 PRN(3,3,”FILE IS NOT DELETED BECAUSE IT DOES NOT EXIST”)
70 ENDIF
80 IF J% = 2 THEN
90 PRN(4,3,”FILE IS NOT DELETED BECAUSE IT IS ACTIVE”)
91 ENDIF
93 IF K% = 3 THEN
95 PRN(5,3,”FILE IS NOT DELETED BECAUSE IT IS DELETE–PROTECTED”)
97 ENDIF
6 − 23
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
TXT$
TXT$ supplies a text from a text file. The text file is a P file in which the distances to
the beginning of the text and the texts themselves are stored.
TXT$(<n>,<text number>)
<text number> = Text number for the text which is to be read out of the text file. It
must be programmed as an INTEGER expression.
Value range: 1 ... max. text number.
Pm:
<Distance to first text><LF>
.
.
.
<Distance to n−th text><LF>
<Text 1><LF>
.
.
.
<Text N><LF>
Each record containing a distance to the corresponding text must have the same
length.
6 − 24
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
1 REM
1 REM This program converts a list of texts into a format
1 REM which is understood as a text file by the TXT$
1 REM instruction.
1 REM Format of the output file
1 REM Pn <text number1><colon><text 1><LF>
1 REM .
1 REM .
1 REM .
1 REM <text number n><colon><text n><LF>
1 REM
1 REM Format of a target file
1 REM Pm <distance to first text><LF>
1 REM .
1 REM .
1 REM <distance to n–th text><LF>
1 REM <text 1><LF>
1 REM .
1 REM .
1 REM <text n><LF>
1 REM
1 REM whereby the length of a distance component is four
1 REM bytes for a target file size of less than 100000
1 REM bytes, otherwise the length is five
1 REM
1 REM
1 REM for example 1<colon>TEXT1<LF>
1 REM 2<colon>T2<LF>
1 REM 3<colon>TXT3<LF>
1 REM
1 REM
1 REM ==> P4 16 <LF>
1 REM 22 <LF>
1 REM 25 <LF>
1 REM TEXT1<LF>
1 REM T2<LF>
1 REM TXT3<LF>
1 REM
10 DIM WORKVAR$(127)
20 TEXTFILE%=1:DUMMY1FILE%=2:DUMMY2FILE%=3:OUTPUTFILE%=4
30 OPENR(1,TEXTFILE%)
40 OPENW(2,DUMMY1FILE%,1000)
50 OPENW(3,DUMMY2FILE%,1000)
60 NUMBER%=0
70 DISTANCE%=1
80 WHILE NOT (EOF(1)) DO
90 REM The text file is read, leading text number with
100 REM colon removed and stored in buffer file
110 REM DUMMY2FILE%. The distance of the respective
120 REM texts to the start of the file is buffered in DUMMY1FILE%.
130 NUMBER%=NUMBER% + 1
140 INP#(1,WORKVAR$)
150 TEXT$=MID$(WORKVAR$,INSTR(”:”,WORKVAR$)+1,127)
155 REM TEXT$ points to text without number
160 PRN#(2,DISTANCE%)
170 PRN#(3,TEXT$)
180 DISTANCE%=DISTANCE% + LEN(TEXT$) + 1
190 END : REM EOF is reached
6 − 25
CC 220/320
6. File Processing
Flexible Automation CPL Programming Instructions
Example:
P1: 1:TEXT1<LF>
2:T2<LF>
3:TXT3<LF><ETX><LF>
P10 (run CONVERSION PROGRAM)
P4: 16 <LF>
22 <LF>
25 <LF>
TEXT1<LF>
T2<LF>
TXT3<LF><ETX><LF>
P5: 10 OPENR(1,”P4”)
15 I%=1
20 A$=TXT$(1,3) ’ Contents of A$: ”TXT3”
25 B$=TXT$(1,I%) ’ Contents of B$: ”TEXT1”
30 C$=TXT$(1,(1*2)) ’ Contents of C$: ”T2”
40 CLOSE(1)
6 − 26
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
7. Dialog programming
Dialog programming permits operator−prompted data input and output.
MSG
Notes or messages for the operator can be realized by means of the MSG instruc
tion in a DIN block. The following format must be maintained:
Example: MSG
.
10 FOR I%=1 TO 40
N20 (MSG, MEASURING PROBE DEFECTIVE)
30 NEXT I%
.
10 IF SD(9)=1 THEN
(MSG, MEASURING PROBE NOT DEFLECTED)
20 GOTO .ERROR :ENDIF
.
REM
The CPL instruction REM (remark) can be used if the comment refers to the pro
gram structure documentation.
Example: REM
.
10 REM, ***SUBROUTINE FOR DEMASKING THE STATUS WORD***
.
( ... )
A line in brackets can also indicate a comment, but in this case the opening bracket
must not be followed by the combination "DFS" or "MSG" or "*MSG", if a purely
commentary effect is required.
7−1
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
Data output
DSP
Data can be output to the graphic screen in a predetermined format using the DSP
instruction and specifying the line and column numbers. Instruction format:
Example: DSP
.
10 LINE%=4 : COL%=1
20 FOR I%=1 TO 10
30 DSP(LINE%+I%,COL%,”###.### IS SQUARE ROOT OF ##”, SQRT(I%), I%)
40 NEXT I%
M30
.
Screen output:
1.000 IS SQUARE ROOT OF 1
1.414 IS SQUARE ROOT OF 2
1.732 IS SQUARE ROOT OF 3
.
.
3.162 IS SQUARE ROOT OF 10
7−2
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
Example: DSP
.
1 LINE%=4:COLUMN%=1:CLS
2 TAB$=”POSITION AXIS 1 POSITION AXIS 2 POSITION AXIS 3”
3 FORMAT$= ” ###.### ###.### ###.###”
4 DSP(LINE%,COLUMN%,TAB$)
5 WHILE INKEY=0 DO
6 LINE%=LINE%+1
7 DSP(LINE%,COLUMN%,FORMAT$,MPOS(1),MPOS(2),MPOS(3))
8 IF LINE%>35 THEN CLS:DSP(4,1,TAB$):LINE%=4 ENDIF
9 END.
.
If this program is started under "CPL DIALOG", and a part program is executed, the
current positions are indicated on the screen for as long as no key is pressed.
Screen output:
POSITION AXIS 1 POSITION AXIS 2 POSITION AXIS 3
0.000 0.000 0.000
2.000 3.000 123.000
. . .
. . .
7−3
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
Example:
.
10 A=25 : B=SQRT(A) : Z=5 : S=10
20 DSP(Z,S,”A= ”,A,” B= ”,B,” C= ”,A+B)
.
Screen output:
Example:
.
10 A=25 : B=SQRT(A) : Z%=5 : S%=10
15 FA$=” A= ###.#” : FB$=” B= #.#” : FC$=” C= ##”
.
20 DSP(Z%,S%,FA$,FB$,FC$,A,B,B+A)
.
Screen output:
Example:
.
1X= 1.5:Y = 2.5:B?=TRUE.I%=200:T1$=” MEASURING PROBE=”:T2$=” NO.=”
2DSP (5, 5, ”XPOS ###.### YPOS ###.###”, T1$, B?, X, Y, T2$, I%)
.
Screen output:
CHR$( )
CHR$ (<INTEGER expression>) yields a character, whose ordinal number in the
ASCII table is equal to the value transferred via the parameter <INTEGER expres
sion>. The resultant character can be assigned to a STRING variable. The function
expression itself can also be located in other CPL expressions instead of a STRING
expression.
The parameter <INTEGER expression> can also be calculated within the function
expression and have any value between 0 and 127. If the value does not fall within
this range, the following error message is dislayed: RUNTIME ERROR 2184 − IN
VALID PARAMETER.
For example, CHR$ (13) can be used to specify that the next DSP instruction output
is continued in the first column of the next line.
Example:
.
10 T$ = ”HALLO”
20 CRLF$ = CHR$ (13)
30 DSP (4, 10, T$, CR$, T$, CHR$(13), CR$, T$, CR$, T$, CR$)
.
7−4
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
Screen output:
HALLO
HALLO
HALLO
HALLO
Example:
.
10 A$=CHR$(66)
.
10 A$=CHR$(2*(30+3))
. The value ”B” is assigned to the variable A$
5 I%=66
10 A$=CHR$(I%)
.
DLG, ENDDLG
A number of dialog instructions can be contained in the program delimited by DLG
and ENDDLG. Within this range, there is a number of convenient capabilities for
data input (see next page).
Example:
.
30 DLG Start of dialog
.
. Dialog and other CPL instructions
.
90 ENDDLG End of dialog
.
The following CPL instructions are not permitted between DLG and ENDDLG in
EDIT mode, as they access the current NC data: AXO, CLOCK, CLOSE, CPOS,
DATE, FXC, IC, MIC, MPOS, OPENR, OPENW, PPOS, SD, TC, TD, TIME.
PRN
The following programming option can be used to display dialog text and define
the input format:
<line>:
Constant value between 4 and 42
<column>:
Constant value between 1 and 64
<text>:
Any alphanumeric text ("#" only for format specifications)
<format>:
7−5
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
Defined input format for the variables; "#" reserves space for digits, "." acting as
decimal point.
<variable name>:
If the variable has already been assigned a value, the value is displayed in the de
fined format. If the variable has not yet been assigned a value, the default format is
displayed.
Data input
INP
If a value is to be assigned to a REAL or INTEGER variable, this can be accom
plished via the INP (<variable name>) instruction. In order to execute an INP in
struction, the CPL processor must have previously read a corresponding PRN in
struction with the same variable within the DLG−ENDDLG range.
If it is attempted to assign a STRING variable a value with INP, the instruction is ig
nored, however, the related PRN instruction is executed.
The dialog text is displayed on the screen when the first INP instruction is read.
The INP instruction can be skipped using the cursor keys without making a value
assignment. Any existing value can be deleted by means of the delete key.
The permissible format is checked when a value is input. It is not possible to input a
value exceeding the permissible format length. When input is terminated via EN
TER, the program automatically jumps to the next input instruction.
Example:
.
30 DLG
40 PRN (8, 4, ”MAX. CUTTING WIDTH:###.### MM”, WDTH)
50 PRN (10, 4, ”MAX. CUTTING DEPTH:###.### MM”, DPTH)
60 INP (BR) : INP (TI)
70 ENDDLG
.80 PRN# (0, ”Q900 [”, WDTH, ”,”, DPTH,”]”).
SFK
In the case of data input via softkey, the number of the softkey or the softkey text to
be programmed can be assigned to a variable.
SFK(<variable>,[<text1>],[<text2>],[<text3>],[<text4>],[<text5>])
<variable>:
The number of the softkey pressed is assigned to an INTEGER variable and the text
to a STRING variable.
<text1>...<text5>:
STRING expressions, each of which may occupy 2 lines of text with 10 characters
each. The two lines of text within a STRING expression are separated by a "&".
7−6
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
Example: SFK
.
1 .SOFTKEY1
.
.
1 .SOFTKEY2
1 DLG : KEY% = 0
1 SFK (KEY%,,”CANCEL”,,”ACTION”,) : ENDDLG
1 IF KEY% = 2 THEN GOTO .END ENDIF
1 IF KEY% = .4 THEN GOTO .ACTION ENDIF
1 IF KEY% = 0 THEN GOTO .SOFTKEY1 ELSE GOTO .SOFTKEY2 ENDIF
.
1 .ACTION
.
1 .END
.
Graphic mode is activated via DLG. If graphic mode was not activated before the
SFK function call, the current NC screen display is retained. The softkey texts pro
grammed in the SFK instruction are output instead of the softkey texts specified by
the operating system; an operator input is then expected and the results are trans
mitted to the CPL program.
If the CPL program was started in NC (AUTOMATIC) or MANUAL operating mode,
the screen display must be at the basic level for the operating mode concerned (the
second softkey level is also permissible for NC (AUTOMATIC) mode). If this is not
the case, the warning "CHANGE TO MODE NC" or "CHANGE TO MDI" is output
and the system waits until the basic display of the mode has been resumed.
The programmed softkey bar remains active until the next SFK instruction or a CSF
or CLG instruction, or until the end of the program is reached.
CSF
This instruction is only effective in conjunction with the SFK instruction without
graphic mode and is used to deactivate the SFK function in order to redisplay the
softkeys for the current operating mode. The CLG instruction and the program end
have the same effect.
INKEY
The number of a depressed key not yet used in graphic mode is obtained as a func
tion value via the CPL instruction INKEY. As a result, the user can react to operation
of a particular key.
The INKEY instruction is only possible in graphic mode. The graphic mode is acti
vated via the INKEY instruction.
Execution of the program is not interrupted when the INKEY function is encoun
tered.
The INKEY function can provide values between 0 and 255. The value 0 indicates
that no key has been pressed. Values 1−127 correspond to the decimal values of
the ASCII characters. Separate numbers are assigned to the control panel keys.
The ASCII table and key assignment numbers are listed in the Annex (chapter 10).
7−7
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
The eight last key codes are stored in the key memory. When the INKEY instruction
is reached, the first of the eight key codes stored is retrieved from the memory and
its memory location overwritten by zero.
The key memory is initialized, i.e. all memory places overwritten by zero, following
a change of operating mode and/or execution of the SFK and INP instructions.
However, if one of the graphic instructions SFK or INP was terminated via the level−
return key before the INKEY instruction was encountered, the INKEY instruction
supplies the number of the last key pressed, namely 139 for the level−return key.
Example:
.
1 A$ = ”SOFT1” : B$ = ”SOFT2” : C$ = ”SOFT3”
1 D$ = ”SOFT4” : E$ = ”SOFT5”
1 CALL 20 [ A$,B$,C$,D$,E$ ]
M30
.
(DFS,P 20, 02.10, RWED)
1 Z%=0 : COL(0,7,0)
1 DSP(41,4,P1$) : DSP(41,17,P2$) : DSP(41,30,P3$)
1 DSP(41,43,P4$) : DSP(41,56,P5$)
1 REPEAT
1 REPEAT
1 K%=INKEY
1 UNTIL ((K%=141) OR (K%=142) OR (K%=143) OR (K%=144) OR (K%=145)
OR (K%=139))
1 JZ%=Z%–140 : JK%=K%–140
1 IF ((JZ%>0) AND (JZ%<6)) THEN COL(0,7,0)
1 FOR I%=0 to 2
1 DSP(40+I%,(JZ%–1)*12+JZ%+1,” ”)
1 NEXT I%
1 IF Z%=141 THEN DSP(41,4,P1$) ENDIF
1 IF Z%=142 THEN DSP(41,17,P2$) ENDIF
1 IF Z%=143 THEN DSP(41,30,P3$) ENDIF
1 IF Z%=144 THEN DSP(41,43,P4$) ENDIF
1 IF Z%=145 THEN DSP(41,56,P5$) ENDIF
1 ENDIF
1 IF ((JK%>0) AND (JK%<6)) THEN COL(0,0,7)
1 FOR I%=0 TO 2
1 DSP(40+I%,(JK%–1)*12+JK%+1,” ”)
1 NEXT I%
1 IF K%=141 THEN DSP(41,4,P1$) ENDIF
1 IF K%=142 THEN DSP(41,17,P2$) ENDIF
1 IF K%=143 THEN DSP(41,30,P3$) ENDIF
1 IF K%=144 THEN DSP(41,43,P4$) ENDIF
1 IF K%=145 THEN DSP(41,56,P5$) ENDIF
1 ENDIF
1 Z%=K%
1 UNTIL K%=139 : CLG
M30
.
Example:
.
10 M=10
20 REPEAT
30 KEY%=INKEY
40 LIN(250,10,M,M)
45 M=M+1
50 UNTIL ((KEY%=66) OR (M>300))
60 CLG
.
7−8
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
Example:
.
10 M=2
20 WHILE ((INKEY<>66) AND (M<150)) DO
30 CIR(250,160,M) : M=M+1
40 END
50 CLG
60
.
Example:
.
1 NEW%=0 : OLD%=0
1 WHILE NEW% <>3 DO
1 NEW%=INKEY
1 IF (OLD%<>NEW%) AND (NEW%>0) THEN
1 PRN# (0, ”KEY NUMBER: ”, NEW%, ” – CANCEL VIA CTRL–C”)
1 ENDIF
1 END
1. CLG
7−9
CC 220/320
7. Dialog Programming
Flexible Automation CPL Programming Instructions
7 − 10
CC 220/320
8. Graphics Programming
Flexible Automation CPL Programming Instructions
8. Graphics programming
Using graphics programming it is possible to display text and drawings on the
screen. The following functions are available for this purpose:
‘ Selection of color and line type
‘ Defining the graphics range
‘ Representation of lines and circles
‘ Filling in enclosed contours
‘ Selective deletion
‘ Text output in graphics mode
GMD
The manner in which lines are to be represented on the screen can be selected via
the GMD function:
GMD(<line type>)
<line type>:
May be any INTEGER expression in the value range 0...4.
0 = continuous line
1 = delete line unconditionally
2 = delete line or regenerate deleted line
3 = dot−dash line
4 = dash−dash line
COL
If the control is equipped with a halftone screen, the COL instruction is used to se
lect eight halftones and their flashing displays with 0 corresponding to pure white
and 7 to pure black. Otherwise, the instruction format is identical to color screen
programming. If a color screen is used, a choice of colors is available for graphics,
text, text background and graphics background as well as the status line color:
8−1
CC 220/320
8. Graphics Programming
Flexible Automation CPL Programming Instructions
The <graphics color>, <text color> and <text background color> may be any IN
TEGER expressions (value range 0...7 or 10...17). If only a few colors are to be
changed, those which are to remain unchanged can be omitted. Only color keys 0
to 7 can be used for the graphics background color.
Examples:
.
1 COL(4) Graphics color blue, text and text background color unchanged
.
1 COL(4,6) Graphics color blue, text color light blue, text background
. unchanged
1 COL(7,4,11) Graphics color white, text color blue, text background red flash
. ing
1 COL(7,,11,,1) Graphics color white, text color unchanged, text background
. red flashing, status line red
GWD
The addressable graphics range when the control system is switched on is defined
as follows:
350
Y pixel
0 X pixel 511
If only a section of this graphics range is required, the GWD instruction can be used
to create a rectangular graphics window.
<X left>:
X value of the left−hand edge of the window as an INTEGER expression
(<X left> 0; <X left> smaller than <X right>)
8−2
CC 220/320
8. Graphics Programming
Flexible Automation CPL Programming Instructions
<X right>
X value of the right−hand edge of the window as an INTEGER expression
(<X right> greater than <X left>; <X right> 511)
<Y bottom>
Y value of the bottom edge of the window as an INTEGER expression
(<Y bottom> 0; <Y bottom> smaller than <Y top>)
<Y top>
Y value of the top edge of the window as an INTEGER expression
(<Y top> greater than <Y bottom>; <Y top> 320)
MWD
If the borders of the color graphic window are to assume the values of different
coordinate systems for subsequent graphics programming, this can be accom
plished using the MWD instruction. However, it must be ensured that the relation
ship between the individual parameters of the current graphics window is the same
as for those of the MWD instruction. In other words, the "MWD rectangle" must
have the same side ratio as the "GWD rectangle". The instruction format and pa
rameters are the same as those for the GWD instruction:
Line
LIN
A line is defined by its starting and end point. The LIN instruction can be formulated
as follows:
8−3
CC 220/320
8. Graphics Programming
Flexible Automation CPL Programming Instructions
Circle
CIR
A complete circle can be generated on the screen as follows:
<radius>:
Radius of the full circle as an INTEGER expression.
An incomplete circle (circular arc) is generated in clockwise direction. The starting
point, end point and center of the circle must be defined for this purpose.
FIL
If the screen used is a color screen, a color pattern can be produced inside an en
closed contour.
<fill pattern>:
INTEGER expression with the following meaning:
0 solid color
1 lattice work pattern
ÉÉ
ÉÉ
ÇÇ
2 45° hatching
ËË
3 135° hatching
ÊÊ
4 90° hatching (vertical)
5 0° hatching (horizontal)
8−4
CC 220/320
8. Graphics Programming
Flexible Automation CPL Programming Instructions
<fill color>:
in accordance with the color code in the COL instruction.
<contour color>:
Colors of the enclosing contour in accordance with the color code in the COL in
struction. This only needs to be specified if the color of the contour is not the same
as the fill color.
Clear instructions
CLS
The CLS instruction (CLear Screen) is used to clear the entire screen range valid for
CPL.
CLR
The graphics range defined by GWD is cleared using the CLR statement (CLear
Range).
CLG
(CLear Graphics) is used to clear the screen and at the same time return from
graphics mode to NC mode.
An arrow head is drawn by the last program, the global variables #XX and #YY rep
resenting the coordinates of the arrow head and #WI the angle of the arrow head in
relation to the X axis of the graphics coordinate system. This example also illus
trates that REAL expressions can be used, as they are internally converted into IN
TEGER values.
8−5
CC 220/320
8. Graphics Programming
Flexible Automation CPL Programming Instructions
GPR
If texts are not to be written in lines and columns as is normally the case following
the PRN and DSP instructions, they can also be addressed in graphics coordinates
using the GPR instruction. In this case, the bottom left−hand point of the character
matrix at the beginning of a character string is defined by specifying the screen pix
els in X and Y direction. The instruction has the following format:
<offset>:
Unlike the other graphics instructions, the GPR instruction can also be used to write
softkey text; for this reason, there is a difference of 39 pixels between the Y address
of the GPR instruction and the other graphics instructions. If a uniform Y coordinate
is required, particularly in the case of variable addressing, this difference must be
taken into account by adding 39 pixels. <Y pixel> and <offset> together must not
exceed the defined graphics range.
<text>:
Any STRING expression (constant or variable).
350
Y pixel
0
0 X pixel 511
Example: GPR
.
1 NR%=49 : REM, *** ASCII characters 49 ! ”1” ***
2 FOR W%=0 STEP 45 TO 360
3 X=75+W% : Y=175+100*SIN(W%)
4 N$=CHRS(NR%) : NR%=NR%+1
5 LIN(X,Y+10,X,Y–10) : LIN(X–10,Y,X+10,Y)
6 GPR(X,Y+39,”Point”) : GPR(X+48,Y+39,N$)
7 NEXT W%
.
8−6
CC 220/320
8. Graphics Programming
Flexible Automation CPL Programming Instructions
One limitation, however, is that the FIXB, FIXE and FIX instructions must not be in
serted between the DLG and ENDDLG instructions. On the contrary, all CPL in
structions may be programmed when recording is active.
FIXB
Using FIXB, a fixed picture file is opened for writing in the program memory, and all
subsequent screen outputs initiated by graphics instructions are stored.
FIXB(<filenumber>[,<name>])
<filenumber>:
Number of the fixed picture file in the P directory. When the fixed picture file is
created, it is automatically given read, write, and execute protection. Besides, the
file has a specific extension to mark it as a fixed picture file for the system.
<name>:
Name of the fixed picture file. When the name has not been specified, it is automati
cally called "Fixed CPL picture". The current date is automatically added in the 26th
position of the character string.
As a rule, only one file can be opened for writing. No file operations using the
OPENW and the PRN instructions may be carried out between the beginning and
the end of a fixed picture recording. The screen background color and the color of
the status line of the COL instruction are not recorded, i.e. they should not be pro
grammed for fixed picture recording.
Since it is not possible to program a wait time for an input, no dialogue should be
programmed between the start and the end of a fixed picture recording.
8−7
CC 220/320
8. Graphics Programming
Flexible Automation CPL Programming Instructions
FIXE
The active fixed picture recording is finished by FIXE, and the currently open fixed
picture file is closed.
FIX
A fixed picture stored in the program memory or in the library is displayed via FIX
while the current screen background color is retained.
FIX(<filenumber>)
<filenumber>:
Number of the fixed picture file in the P directory or the P group of the library.
When the fixed picture has been displayed, all settings made via the COL, GMD,
GWD, and MWD instructions prior to the fixed picture display return to their former
value.
8−8
CC 220/320
9. Screen Editor
Flexible Automation CPL Programming Instructions
9. Screen editor
The editor makes it possible to create and modify text files. The BOSCH
CC 220/320 M has two editors: one is a word−oriented editor known as the word
editor and the other a screen−oriented editor known as the screen editor. The word
editor supports the NC program format as per DIN 66025 and can be used for edit
ing a standard NC part program. The screen editor can be used to create and
modify any ASCII files, such as machine parameter programs or CPL programs. In
addition to the basic functions DELETE, INSERT and CURSOR MOVEMENT it also
offers various other capabilities for rapid and effective file processing.
Both editors can be accessed in DATA operating mode for processing CPL pro
grams.
* NC * SCREEN
EDIT EDIT EDIT
If a program is edited when the EDIT softkey is pressed and the control has READY,
WAIT or STOP status, the system first asks whether the active program is to be
edited or not. If a runtime error has occurred, it asks whether the incorrect program
is to be edited. If the answer is YES, the active or incorrect program is automatically
de−selected and editing can commence. When the editor starts, the cursor is set
to the actual position in the active program. This also applies if a subroutine is ac
tive.
A change in the operating mode terminates editing of the program text and the pro
gram is automatically re−selected for execution. If a subroutine was active, the
main program for the subroutine is re−selected. If the program is not to be rese
lected, text editing can be terminated by pressing the level−return key or via the
EXIT function. If a program is activated via the NC interface during editing, the warn
ing "NC ALREADY ACTIVE" appears in the headline.
9−1
CC 220/320
9. Screen Editor
Flexible Automation CPL Programming Instructions
If the active program is only to be viewed, it can be selected via the FOR INSPEC
TION softkey. In this mode, the program text can be read in the editor. However, it is
not possible to store the modified program text in the part program memory by
changing the operating mode or pressing the level−return key. The EXIT function
can be used in this case, however, to leave the editor and at the same time assign a
new program number to the edited text. Any changes are then stored in the part
program memory under this new program number.
When the screen editor has been selected, the so−called multi−softkey bar be
comes available offering the user virtually the entire ASCII character set even if no
ASCII keyboard is connected.
The next softkey bar can be called up by pressing the OTHER COMMANDS soft
key. If KEYBOARD AVAILABLE is activated at the lowest softkey level, the multi−
softkey bar is not displayed, even when entering the editor.
The editor has two buffers. Physically, they are located in the memory area of the
part program memory. The total size of the two buffers must not exceed the total
free memory area of the system.
The first buffer is the text buffer for the file to be edited. If the selected file does not
exist in the part program memory, it is created in the text buffer. If the program exists
and there is enough free memory in the part program memory, the file to be edited
is copied into the text buffer and modified there.
If there is not enough memory available to copy the file into the text buffer, it is edited
in the part program memory itself. In this case, the QUIT command is not effective.
The second buffer is the range buffer. This buffer is empty when the editor is called.
It is filled by means of the SAVE SECTION and APPEND functions. The CUT func
tion causes this buffer to be cleared and re−written. The APPEND function causes
the existing buffer contents to be expanded to include the selected range.
9−2
CC 220/320
9. Screen Editor
Flexible Automation CPL Programming Instructions
In order to leave the editor, either press the level−return key or select an operating
mode. In this case, the contents of the text buffer become a new program file and
the contents of the old file are deleted.
The editor can also be left by means of the QUIT or EXIT function. QUIT causes the
text buffer contents to be discarded, while EXIT causes them to be copied into the
part program memory under a new program number.
The system looks for an M30 or M02 when leaving the editor. The editor automati
cally appends an M30 to the end of the file if no end identifier is found, unless M30
has been deactivated by a changeover sofkey.
The most important editor functions can be called via softkeys. However, it is also
possible to call an editor command line via the ESC key or CTRL, Z; commands can
then be input to this editor command line.
1. ADVANCE FORWARD
2. APPEND APPEND SECTION
3. BACK UP BACKWARD
4. BOTTOM END OF TEXT
5. CALCULATE
6. CHANGE WORD CHANGE WORD DEFINITION
7. CHARACTER
8. CUT MOVE SECTION
9. DEFINE STRING
10. DELETE CHAR
11. DELETE LINE
12. DELETE UNTIL EOL
13. DELETE WORD
14. EOL EOL (END OF LINE)
15. FIND SEARCH FOR A STRING
16. HELP
17. IGNORE
18. INSERT FILE
19. LINE BLOCK
20. OPEN LINE
21. PAGE
22. PASTE GET SECTION
23. QUIT TEXT BUFFER IS DISCARDED
24. REPLACE
25. RESET
26. SECTION 8 LINES
27. SELECT
28. SET INSERT INDENT
29. SET OVERSTRIKE
30. SPECIAL CHARACTER
31. SUBSTITUTE
32. TOP TOP OF TEXT
33. UNDELETE CHARACTER
34. UNDELETE LINE
35. UNDELETE WORD
36. WORD
When entering commands, as many letters must be input as are required for unam
biguous identification. The editor reads the first 5 characters in order to decode the
command input.
If the command is made up of two words, the requisite number of letters must be
entered for each word.
The following examples illustrate various functions which cannot be called via soft
keys.
9−3
CC 220/320
9. Screen Editor
Flexible Automation CPL Programming Instructions
.
COMMAND: DEL U
.
.
COMMAND: E
.
Example: IGNORE − Deletes all characters contained in the Ignore table of the
machine parameters (P5001) from the file.
.
COMMAND: IG
.
.
COMMAND:
. IN
Example: REPLACE − Deletes the selected text and replaces it with the contents
of the text buffer.
.
COMMAND: REP
.
.
COMMAND: SU /old/new/ ("," also possible instead of "/")
.
9−4
CC 220/320
10. Annex
Flexible Automation CPL Programming Instructions
10. Annex
10 − 1
CC 220/320
10. Annex
Flexible Automation CPL Programming Instructions
0 00 NUL 32 20 SP 64 40 @ 96 60 ‘
1 01 SOH 33 21 ! 65 41 A 97 61 a
2 02 STX 34 22 " 66 42 B 98 62 b
3 03 ETX 35 23 # 67 43 C 99 63 c
4 04 EOT 36 24 $ 68 44 D 100 64 d
5 05 ENQ 37 25 % 69 45 E 101 65 e
6 06 ACK 38 26 & 70 46 F 102 66 f
7 07 BEL 39 27 ’ 71 47 G 103 67 g
8 08 BS 40 28 ( 72 48 H 104 68 h
9 09 HT 41 29 ) 73 49 I 105 69 i
10 0A LF 42 2A * 74 4A J 106 6A j
11 0B VT 43 2B + 75 4B K 107 6B k
12 0C FF 44 2C , 76 4C L 108 6C l
_
13 0D CR 45 2D 77 4D M 109 6D m
14 0E SO 46 2E . 78 4E N 110 6E n
15 0F SI 47 2F / 79 4F O 111 6F o
16 10 DLE 48 30 0 80 50 P 112 70 p
17 11 DC1 49 31 1 81 51 Q 113 71 q
18 12 DC2 50 32 2 82 52 R 114 72 r
19 13 DC3 51 33 3 83 53 S 115 73 s
20 14 DC4 52 34 4 84 54 T 116 74 t
21 15 NAK 53 35 5 85 55 U 117 75 u
22 16 SYN 54 36 6 86 56 V 118 76 v
23 17 ETB 55 37 7 87 57 W 119 77 w
24 18 CAN 56 38 8 88 58 X 120 78 x
25 19 EM 57 39 9 89 59 Y 121 79 y
26 1A SUB 58 3A : 90 5A Z 122 7A z
27 1B ESC 59 3B ; 91 5B [ 123 7B {
28 1C FS 60 3C < 92 5C \ 124 7C I
29 1D GS 61 3D = 93 5D ] 125 7D }
30 1E RS 62 3E > 94 5E "( ) 126 7E ~
31 1F US 63 3F ? 95 5F !( _ ) 127 7F DEL
10 − 2
CC 220/320
10. Annex
Flexible Automation CPL Programming Instructions
128 GOM
129 GOM
130 GOM
131 GOM
132 GOM
133 GOM
10 − 3
CC 220/320
10. Annex
Flexible Automation CPL Programming Instructions
10 − 4
CC 220 / 320
11. Keywords
Flexible Automation CPL Programming Instructions
A D
B
F
BCD function 4−11
BIN function 4−11 FALSE 2−10
Block preparation 4−1 FIL instruction 8−4
BOOLEAN variables 2−10 File end 6−14
File pointer 6−11/6−15/6−17
FILEPOS function 6−15
File size 6−19
FILESIZE function 6−19
File status 4−9
C FOR...STEP...TO...NEXT 2−17
FIX, FIXB, FIXE 8−7
Fixed picture recording 8−7
CALL instruction 3−3 FXC function 4−4
CC220T, special features of 4−6/4−7/4−11
CHARACTER 5−1
CHR$ function 7−4
CIR instruction 8−4 G
Clamp mode 2−4/4−9
CLG instruction 8−5
CLOCK function 4−15 G functions 4−8/4−9
CLOSE instruction 6−14 GMD instruction 8−1
CLR instruction 8−5 Go block 4−9/4−11/4−12
CLS instruction 8−5 GOTO instruction 2−18
COL instruction 8−1 GPR instruction 8−6
Color selection 8−1 GWD instruction 8−2
Communication store 2−15/4−6/4−12
Components 6−1
COS function 2−14
CPL/DIALOG call 3−2 H
CPOS function 4−3
CSF instruction 7−7
CS table 4−6 Halftone screen 8−1
11 − 1
CC 220 / 320
11. Keywords
Flexible Automation CPL Programming Instructions
I M
N
J
Nesting 2−1/5−11
Not equal to 2−16
NOT function 2−15
Jump destination 2−1/2−18
NJUST instruction 6−10
Justification of data output 6−10
NUL instruction 2−13
Justify data output 6−10
K Offset 6−16
OPENR instruction 6−4
OPENW instruction 6−2
OR function 2−15
Keyboard 7−7/9−2/10−2/10−3 Override position 4−8/4−12
Key characters, keywords 2−5
Key code 7−7/10−2/10−3
11 − 2
CC 220 / 320
11. Keywords
Flexible Automation CPL Programming Instructions
R W
REAL 2−6/2−10
REM instruction 7−1 WAIT 4−1
REPEAT...UNTIL 2−16 WHILE...DO...END 2−16
REWRITE instruction 6−11 Word contents, varying 2−2
ROUND function 2−14
Rounding down 2−14
Rounding up 2−14
Routine 2−16 X
T
TAN function 2−14
TC instruction 4−5
TD instruction 4−6
Time counter 4−15
TIME function 4−15
Tool life table 4−7
Trigonometric functions 2−14
TRIM$ function 5−6
TRUE 2−10
TTY 6−3
Turning lathe control 4−6/4−7/4−11
T word 4−11
TXT$ function 6−24
V
VAL function 5−5
Variables 2−8
11 − 3
PRN Grid of the 14" color monitor: lines/columns for PRN/DSP, and pixels for GPR and all other graphics instructions (LIN,CIR,...) LIN
DSP 350
CIR
Line
GPR 344
1
Pixel
Y 2 326
3 321
4
347 308
5
6 290
329
7
8 272
311
9
293 10 254
11
12 236
275
13
257 14 218
15
239 16 200
17
18 182
221
19
20 164
203
21
185 22 146
23
167 24 128
25
26 110
149
27
28 92
131
29
30
113 74
31
95 32
56
33
77 34
38
35
36
59 20
37
41 38
2
39 39 0
40 Pixel
23 Y
41 LIN
42 CIR
5 0 etc.
Column: 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 27 28 29 30 31 32 33 34 35 36 37 38 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
Pixel X: 0 16 32 48 64 80 102 112 128 144 160 176 192 204 224 240 256 272 288 306 320 336 352 368 384 408 432 448 464 480 496 511
1070 073 642-102 (93.06) GB · HB NC · AT/VSP · Printed in Germany