bosch CC 220 Instruction Manual

Typ1 osa / CC 220
CPL Programming Instructions
Version
102
Typ1 osa / CC 220
CPL Programming Instructions
1070 073 642-102 (93.06) GB
/Z25 QJ, D25 XA)
by Robert Bosch GmbH,
All rights reserved, including applications for protective rights.
Reproduction or handing over to third parties are subject to our written permission.
Discretionary charge 20.– DM
Flexible Automation
Contents
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
CC 220/320
CPL Programming Instructions
Page
Contents 1
Flexible Automation
3. Subroutines and cycles
Calling subroutines with G, P or Q addresses 3 − 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Handling modal subroutine calls 3 − 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Calling subroutines via any auxiliary or M functions 3 − 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CPL program execution parallel to machining time 3 − 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Calling subroutines via the CALL function 3 − 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CALL 3 − 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
CC 220/320
CPL Programming Instructions
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
Flexible Automation
Character strings and numbers 5 − 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ASC 5 − 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
STR$ 5 − 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
VAL 5 − 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Removal of leading or trailing blanks 5 − 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TRIM$ 5 − 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Programming examples 5 − 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Assignment: STRING expression −> character array 5 − 9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comparison of STRING expressions 5 − 11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Chaining STRING expressions 5 − 11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
CC 220/320
CPL Programming Instructions
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
Flexible Automation
Data input 7 − 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
INP 7 − 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SFK 7 − 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CSF 7 − 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
INKEY 7 − 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8. Graphics programming
Type of line and color selection 8 − 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GMD 8 − 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
COL 8 − 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Defining the graphics range 8 − 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GWD 8 − 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MWD 8 − 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Line 8 − 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LIN 8 − 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Circle 8 − 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CIR 8 − 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Filling enclosed contours 8 − 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FIL 8 − 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Clear instructions 8 − 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CLS 8 − 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CLR 8 − 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CLG 8 − 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Text output in graphics mode 8 − 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GPR 8 − 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Fixed CPL pictures 8 − 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Starting a fixed picture recording 8 − 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FIXB 8 − 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Finish fixed picture recording 8 − 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FIXE 8 − 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Display fixed pictures 8 − 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FIXB 8 − 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents
CC 220/320
CPL Programming Instructions
9. Screen editor 9 − 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10. Annex
11. Keywords
Contents 4
10 − 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11 − 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Flexible Automation
1. Introduction
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.
CPL offers the following advantages:
shorter program when repeat sequences and comparable routines are in
volved,
simplified operation thanks to individual dialog programming,
improved monitoring due to graphics programming,
status−dependent program variations by accessing NC system data.
CPL Programming Instructions
CC 220/320
Notes and Tips
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.
The present manual refers to software versions "Z25 QJ" of the CC 220/320 M control and "D25XA" of CC 220 T.
NOTE !
Information concerning the current software version of ’your’ control is displayed in
the and SOFTWARE VERSION softkeys.
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.
group operating mode after depressing the DIAGNOSTIC CONTROL
The present description only refers to CPL programming of the CNC. For DIN pro gramming, a separate manual is available.
1 − 1
Flexible Automation
1. Introduction
For programming manufacturer−specific cycles please note the description pro vided by the machine manufacturer.
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.
Therefore, programming is reserved to personnel trained for this purpose.
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.
CPL Programming Instructions
CC 220/320
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
Flexible Automation
2. Basic Elements of CPL

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.
2. Basic Elements
CC 220/320
CPL Programming Instructions
P R O G R 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.
Main
program
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
DECLARATIONS
STATEMENTS
Sub− routine
Sub− routine
Sub−
routine
structured programming,
error tolerance and
software ergonomics.
Structured programs are generally easy to understand. By combining comparable sections or frequently required functions into (parameterized) subroutines or jump destinations identified by an unmistakable label (name), programs are not only easier to read, they also reduce the amount of duplication, since these functions are usually also required in other routines. This type of programming does not ex clude the need for the occasional programming tricks, but such tricks should then be commented accordingly in the user’s own interest.
2 − 1
Flexible Automation

NC block

2. Basic Elements
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.
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.
CPL Programming Instructions
CC 220/320
Example:
N100 G1 X150 Y100.525
or
G1 X150 Y100.525
Further details can be found in the Programming instructions P. − N o . 3822.
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
Flexible Automation
2. Basic Elements
CPL Programming Instructions
Example:
.
XVALUE=P1 : FEED=P2 : OFFSET TABLE=P3 : PROGEND=30
5 .
N10
G1 N20 .
N30 .
X XVALUE F
G22
K OFFSET TABLE
M
PROGEND
FEED*2+1000
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.
The following statements could influence the program flow:
WARNING!
Not permissible:
10 CYCLE=81 : TARGET=20
!
N20 G[CYCLE] N30 G23 L[TARGET]
CC 220/320

CPL block

All addresses calling a subroutine and the addresses G23, G24, G33, G75 and G92 are not intended for variable notation.
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
Flexible Automation
Program start
2. Basic Elements
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.
CPL Programming Instructions
CC 220/320
Linking
Parallel processing
Autostart
If the control is in the highest level of the 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.
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.
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).
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..
mode, a program defined in ma
Clamp mode
Since machine parameter P9916 can also be used to define the first mode after start−up of the control, it is possible to automatically start a CPL program with this feature.
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.
mode as the
2 − 4
Flexible Automation

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.

Reserved instruction words

The keywords listed here must stand alone or be contained within special delimit ing characters identifying them as instruction words. Reserved instruction words must not be used when selecting variable names!
Example:
2. Basic Elements
CC 220/320
CPL Programming Instructions
GOTO 10
GOTO10
!
Jump to line 10
Arbitrary symbol name (variable): on its own, it leads
!
to the error message: "RUNTIME ERROR 2167=MISSING", because a value assignment for the variable GOTO10 is expected.
Keywords:
*)
CLS
*)
COL COM COS CPOS
*)
CSF
*)*)
GPR
*)
GWD
NJUST NUL
SIN SQRT
STEP STR$
G:
N:
S:
CALL CHR$
*)
CIR
*)
CLG CLOCK CLOSE
*)
CLR
NEXT NOT
SD SDR
SEEK
*)
SFK
GMD GOTO
ABS ATAN
A: B: C: D:
ACOS AND ASC ASIN
ELSE
E:
END
*)
ENDDLG ENDIF
L:
*)
P:
*)
LEN LIN
PPOS PRN
PRN#
AXO AXP
EOF ERASE
LJUST
BCD BIN
F:
FALSE FILEPOS FILESIZE
*)
FIXB
*)
FIXE
MIC MPOS
M:
MID$
REM
R:
REPEAT ROUND
REWRITE
*)
FOR FXC
*)
FIL
*)
FIX
MWD
I:
O:
T:
TAN
DATE DIM
*)
DLG DO
*)
DSP
IC IF INKEY
*)
INP
OPENR OPENW
TC TD TDR THEN
INP# INSTR
INT
OR
TIME TRIM$
TRUE TXT$
UNTIL
U:
*) Only with option: CPL with graphics/dialogue
V:
WAIT WHILE
W:
X: XORVAL
The following key characters are used by CPL:
#! ?," <−/ &
@
%$:( ) =>+*
][
The comma is normally used as a separating character. It is processed as a punc tuation character only within character strings. The full stop is used as a decimal
2 − 5
Flexible Automation
2. Basic Elements
CPL Programming Instructions
CC 220/320
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:

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.

Integer constant (INTEGER)

Whole numbers (integers) are written without a decimal point.
Example:
Keyboard symbol
( Panel )
_
n
._.
Representation in NC mode
z
"
:
Representation in graphic mode
_
n
:
NUMBER% = 4
Floating−point constant (REAL)
Real numbers (decimal numbers or fractions) are identified by a decimal point (floating point).
Example:
PI = 3.141593
INTEGER constant
REAL constant
2 − 6
Flexible Automation
2. Basic Elements
CPL Programming Instructions
Double−precision constant and double−precision operations
Constants which are assigned to a double−precision REAL variable or which are compared with a double−precision REAL variable are represented with double precision (i.e. exact to 15 places).
If double−precision REAL constants are desired when calculating expressions in comparisons (IF, WHILE, REPEAT), the following rules must be observed:
In the comparison, it must be ensured that a double−precision REAL variable is contained on the far left of the expression which is processed first. It must be re membered here that bracketed expressions are processed first. Equally, it must also be remembered that the double−precision REAL constant must be pro grammed on the right side (2nd operand) of the operands to be compared. If these rules are not observed, the constants are interpreted as single−precision REAL constants.
CC 220/320
Example: Assignment of double−precision REAL constants and comparison of variables with double−precision REAL constants
4 D5! = –1234.123456 + 12345 + 1234.234567 20 D0! = 123456789.123456 22 D1! = 1.12345678901234 24 D2! = –123456789012345 26 D3! = –1234.123456
The following interrogations lead to the result: E? = TRUE
28 IF D0! = 123456789.123456 THEN E? = TRUE ELSE E? = FALSE ENDIF 29 IF D1! = 1.12345678901234 THEN E? = TRUE ELSE E? = FALSE ENDIF 30 IF D2! = –123456789012345 THEN E? = TRUE ELSE E? = FALSE ENDIF 31 IF D3! = –1234.123456 THEN E? = TRUE ELSE E? = FALSE ENDIF 32 IF D0! + 2.1 + 3.1 = 123456789.123456 + 2.1 + 3.1 THEN 33 E? = TRUE 34 ELSE 35 E? = FALSE 36 ENDIF 37 IF (D0! + 2.1) + 3.1 = 123456789.123456 + 2.1 + 3.1 THEN 38 E? = TRUE 39 ELSE 40 E? = FALSE 41 ENDIF
2 − 7
Flexible Automation
2. Basic Elements
CPL Programming Instructions
CC 220/320
Example: Comparison of variables with single−precision REAL constants
20 D0! = 123456789.123456 22 D1! = 1.12345678901234 24 D2! = –123456789012345 26 D3! = –1234.123456
The following interrogations lead to the result: E? = FALSE:
42 IF 123456789.123456 = D0! THEN E? = TRUE ELSE E? = FALSE ENDIF 43 IF 1.12345678901234 = D1! THEN E? = TRUE ELSE E? = FALSE ENDIF 44 IF –123456789012345 = D2! THEN E? = TRUE ELSE E? = FALSE ENDIF 45 IF –1234.123456 = D3! THEN E? = TRUE ELSE E? = FALSE ENDIF 46 IF D0! + (2.1 + 3.1) = 123456789.123456 + 2.1 + 3.1 THEN 47 E? = TRUE 48 ELSE 49 E? = FALSE 50 ENDIF 46 IF 2.1 + D0! + 3.1 = 123456789.123456 + 2.1 + 3.1 THEN 47 E? = TRUE 48 ELSE 49 E? = FALSE 50 ENDIF

Character string constant (STRING)

A STRING constant is delimited by quotation marks.
Example:
EXAMPLE$ = "This is a character string"

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.
STRING constant
2 − 8
Flexible Automation
2. Basic Elements
CPL Programming Instructions
CC 220/320
A distinction is made between
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).
Global variables are identified by a preceding # symbol followed by the variable name. The stored values are preserved for the duration of a program run and can be addressed by the main program and the related subroutine. Global variables are no longer valid after the program end. A 32 Kbytes memory location is available for global variables.
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
local INTEGER variable
#NUMBER% = 4
global INTEGER variable
36 = 4
@
permanent INTEGER variable
@
36QUANTITY = 4
permanent INTEGER variable
Depending on the type of data to be processed, it is expedient to reserve a suitable memory area. Therefore, a distinction is made between variable types. In addition to INTEGER variables, CPL features REAL, STRING, BOOLEAN and ARRAY vari ables.
2 − 9
Flexible Automation

Integer variable (INTEGER)

The INTEGER variable occupies 32 bits of memory space in each case. It is identi fied by a % symbol attached to the variable name. The value range extends from
−2.147.483.648 to +2.147.483.647 .
Example:
NUMBER% = 4
Floating−point variable (REAL)
If no special identification follows the variable name, the variable is interpreted as a REAL variable of single precision. In this case, the variable occupies 32 bits of the memory area. The value range is +/−10 places before and after the decimal point.
2. Basic Elements
INTEGER variable
CC 220/320
CPL Programming Instructions
38
. This corresponds to 7 significant
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 +/− 10 fore and after the decimal point.
Example:
PI! = 3.141592653589793

Logic variable (BOOLEAN)

Logic variables (BOOLEAN variables) can assume only one of the two values TRUE and FALSE. They are used to store the truth value of assumptions which can be tested later. Identification is done by means of a question mark following the variable name.
REAL variable of single precision
308
. This corresponds to 15 significant places be
REAL variable of double precision
Example:
START? = FALSE
BOOLEAN variable
2 − 10
Flexible Automation
2. Basic Elements

Character string variable (STRING)

A STRING variable is identified by a $ symbol following the variable name. The pointer to the character string is stored in the variable if the variable is a simple, non−dimensioned variable.
Example:
EXAMPLE$ = "This is a character string"
If the character string is a dimensioned field of characters (CHARACTER), these characters can be processed with special character string instructions. (Refer to the "Character string processing" section)
Example:
CC 220/320
CPL Programming Instructions
STRING variable

Array variable (ARRAY)

1 DIM ABC$(1) 2 DIM BCDE$(10) 3 ABC$ = ”Z” 4 BCDE$ = CHR$(90)
By using ARRAY variables, it is possible to reserve a one−dimensional or two−di mensional field (ARRAY) in the memory area under a variable name. An array defi nition is possible for REAL and INTEGER variables. The variable is indexed in order to permit access to the individual array elements.
Example: Dimensioning an ARRAY variable
10 DIM ARRAYVAR(2,3)
INTEGER constants for array sizes (index)
Variable name (REAL variable)
DIM instruction word
Example: Access to ARRAY variables
.
100 ARRAYVAR(1,1) = MPOS(1) 110 ARRAYVAR(2,1) = CPOS(1) 120 ARRAYVAR(1,2) = MPOS(2)
130 ARRAYVAR(2,2) = CPOS(2) 140 ARRAYVAR(1,3) = MPOS(3) 150 ARRAYVAR(2,3) = CPOS(3)
2 − 11
Flexible Automation

Overview of variables

2. Basic Elements
CPL Programming Instructions
CC 220/320
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.
DIM <variable name> (<array size1> [,<array size2>])
The following overview table summarizes the possibilities of using variables in CPL:
Variable group Variable name Variablen type

Instructions

local
global #
permanent
arrays max. 8 characters
@
max. 8 characters
max. 8 characters
1 − 50
REAL single−precision REAL double−precision
!
BOOLEAN
?
STRING
$
INTEGER
%
% INTEGER
$ CHARACTER
REAL single−precision
% INTEGER
It is possible to assign values to local and global variables. This is done with the equals symbol =".
Example: Value assignment for a BOOLEAN variable
START? = FALSE
value assignment symbol (logic) variable
Example: Value assignment for a REAL variable
X1MIN! = 2097.876
value (max. 7 digits) assignment symbol double−precision REAL variable
Example: Value assignment between variables
XSET = XMIN!
value (double−precision REAL variable) assignment symbol
single−precision REAL variable
2 − 12
Flexible Automation
2. Basic Elements
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.
CPL Programming Instructions
CC 220/320
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.
If a local or global variable is to be selectively deleted, this can be done by assign ment of the value NUL (zero). A permanent variable cannot be deleted, it can only be overwritten.
Example: Deleting a variable

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 = NUL
XSET = 4/(100–I%)+XACTUAL
In addition, it is also possible to call mathematical functions which act on variables, constants, or CPL expressions located directly after the respective instruction word in round brackets. The function always refers to the internal numerical representa tion of the initial value. This can be checked during program execution using the "Debug" function. In the case of nested expressions, particularly with function calls, attention must be paid to the maximum possible nesting depth which de pends on the memory space required by the bracketed expressions during execu tion.
2 − 13
Flexible Automation
2. Basic Elements
CPL Programming Instructions
CC 220/320

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
XVALUE% has the value 11
XVALUE% = ROUND(10.9)
!
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
XVALUE% has the value 10
XVALUE% = INT(10.9)
!

SIN, COS, TAN, ASIN, ACOS, ATAN

In the case of trigonometric functions, which process angles in degrees, it is expe dient to identify the angles as double−precision REAL variables. 5 places are sig nificant with single precision, and 12 places with double precision. The following trigonometric functions can be used:
SIN COS TAN
Example:
sine function
cosine function
tangent function
2 − 14
ASIN ACOS ATAN
arc sine function
arc cosine function
arc tangent function
Flexible Automation

Logic operations

2. Basic Elements
YVALUE! = SIN(ANGLE!)
CPL Programming Instructions
CC 220/320
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.

NOT, AND, OR, XOR

CPL provides four logic functions:
the NOT function NOT ,
the AND function AND ,
the OR function OR
and the EXCLUSIVE OR function XOR .
E1
E1 E2 A
1&>1=1
o− AA AA
NOT element AND element OR element XOR element
E1 = A E1 E1 + E2 = A E1
NOT AND OR XOR
0
− L
E1 E1 E1
E2E2
.
E2 = A
0
L
− 0
0
L
0
0
0
L
0
L
0
L
L
0
0
L
0
L
0
E2
..
E2+E1 E2=A
L
L
0
0
L
L
L
0
L
L
L
0
L
0
L
0
0
L
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.
Example: Is bit 0 set in @20?
. 20 IF 20 AND 1 <> 0 THEN PRN#(0,”BIT 0 SET”)
30.ELSE PRN#(0,”BIT 0 NOT SET”) ENDIF
@
2 − 15
Flexible Automation

Repeat instructions

2. Basic Elements
CPL Programming Instructions
CC 220/320
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:
REPEAT <routine> UNTIL <condition>
Example: Programming a REPEAT loop
.
REPEAT
30
KEY%=INKEY
40
UNTIL KEY%=3
50
.
Wait loop until CTRL−C is pressed
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:
WHILE <condition> DO <routine> END
Example: Programming a WHILE loop
.
WHILE IC(211)=TRUE DO
30
KEY%=INKEY
40
END
50
.
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:
equals » = « greater than or equal to » >= « greater than » > «
not equal to » <> « less than or equal to » <= « less than » < «
Wait loop while interface 211 is high
2 − 16
Flexible Automation
2. Basic Elements
CPL Programming Instructions
CC 220/320
FOR − STEP − TO − NEXT
If the abort condition is to result directly from routine execution, e.g., a tracking counter is required which need not be programmed separately for the FOR−NEXT loop. A counting variable (INTEGER) is defined whose initial and end counter val ues must be specified. If the counting increment deviates from 1, the increment (STEP) can be defined separately. The structure of a FOR−NEXT loop is as follows:
FOR <counting var.>=<initial value> [STEP <increment>] TO <end value>
<routine>
NEXT [<counting variable>]
Example: FOR−NEXT loop
.
FOR I%=1 TO 127
20
PRN#(1,”ORD.:”,I%,” CHAR.: ”,CHR$(I%))
30
NEXT I%
40
.
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.
Example: FOR−NEXT loop with variable step increments
.
OPENW(1,”P222”,130,”TESTFILE”)
10
20
STEPNO%=2 : START%=1 : END%=3500 : NJUST 30 40 50 60 70
.
FOR COUNTER%=START% STEP STEPNO% TO END% STEPNO%=ROUND(STEPNO%*SQRT(STEPNO%))
PRN#(1, ”COUNTER: ”,COUNTER%, ”INCREMENT: ”, STEPNO%)
NEXT CLOSE(1)
The following is contained in the "Testfile" after execution of this program:
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
Flexible Automation

Unconditional jump instruction

GOTO

Example: GOTO instruction
.
10
GOTO 120
.
10
GOTO N20
.
10.GOTO .DEST1
Unconditional program jumps are programmed with the GOTO instruction. A line number, block number or label can be specified as the jump destination.

Label

2. Basic Elements
!
!
!
Jump to line 120
Jump to block N20
Jump to label .DEST1
CC 220/320
CPL Programming Instructions
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
Flexible Automation

Branch instruction

2. Basic Elements
CPL Programming Instructions
CC 220/320
IF − THEN − ELSE − ENDIF
A branch instruction can be formulated as follows:
If a certain condition is satisfied, then execute the routine, or else execute the other routine!".
This results in the following instruction structure:
IF <condition> THEN <routine> [ELSE <alternative routine>] ENDIF If the ELSE part is omitted, the program continues directly after the ENDIF instruc
tion in the event of non−satisfaction of the condition. Since a division in the pro gram flow is involved in all cases with this instruction, it is called a branch. The THEN and the ELSE routines are program branches which need not be processed in all cases. The condition is programmed in the same line as "IF". It is followed by "THEN" in the same line.
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.
Example: Programming a loop with IF−THEN−ELSE−ENDIF
.
X = 1
10
.START
20
IF X>=100 THEN
30 40 50 60 70
90 .
.
ENDIF
.END
GOTO .END
ELSE X=X+2.75
GOTO .START
2 − 19
Flexible Automation
2. Basic Elements
CC 220/320
CPL Programming Instructions
2 − 20
Flexible Automation

3. Subroutines and Cycles

3. Subroutines and cycles
A subroutine call must always be contained in a separate block.

Calling subroutines with G, P or Q addresses

Pure CPL subroutines can be called from a DIN block via G22 or a P or Q address. Refer to the Programming instructions P. − N o . 4219.
Up to 32 G functions can be defined in machine parameters P4000 to P4004 which are then assigned to a specific part program number. It is also possible to deter mine the number of parameters and a possible modal effect of the G function in this definition. The modal effect of a G function is characterized by the fact that the part program corresponding to the G function is called and executed after every NC block containing an axis address.

Handling modal subroutine calls

CC 220/320
CPL Programming Instructions
The modal effect should be taken into account when calling other subroutines. It is useful to cancel the modal effect by G80 before calling another modal G function in order to avoid undesired superposition effects. It is necessary to distinguish be tween subroutines executed from the part program memory and subroutines exe cuted from the interface. Here are a few examples:
Examples: Modal subroutines executed from the part program memory
.
[
G81 1,2,3,4
N1 .
X100
N2 .
X110 P100
N3 .
X120 Q4711
N4 .
X130 G82 5,6,7
N5 .
X140 M321
N6 .
N7
G80
.
]
[
]
A modally active subroutine is pending Positioning and execution of G81
Positioning and execution of G81 without execu tion of subroutine 100
Positioning and execution of subroutine 4711 with out execution of G81
Positioning and execution of G81 with subsequent execution of G82
Positioning and execution of G81 without execu tion of the subroutine call M321
The modal effect is canceled
3 − 1
Loading...
+ 90 hidden pages