siemens 840D Programming Manual

SINUMERIK
SINUMERIK 840D sl / 828D Job Planning
Programming Manual
Valid for
Software Version CNC software 4.5 SP2
Preface
Flexible NC programming File and Program
Management
Protection zones
Special motion commands Coordinate transformations
(frames)
Transformations
Kinematic chains Collision avoidance with
kinematic chains
Tool offsets
Path traversing behavior
Axis couplings
Synchronized actions
Oscillation
Punching and nibbling
Grinding
Additional functions User stock removal
programs Programming cycles
externally
Tables
Appendix
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16 17 18 19
A
03/2013
6FC5398-2BP40-3BA1
Legal information Warning notice system
This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent damage to property. The notices referring to your personal safety are highlighted in the manual by a safety alert symbol, notices referring only to property damage have no safety alert symbol. These notices shown below are graded according to the degree of danger.
DANGER
indicates that death or severe personal injury will result if proper precautions are not taken.
WARNING
indicates that death or severe personal injury may result if proper precautions are not taken.
CAUTION
indicates that minor personal injury can result if proper precautions are not taken.
NOTICE indicates that property damage can result if proper precautions are not taken.
If more than one degree of danger is present, the warning notice representing the highest degree of danger will be used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to property damage.
Qualified Personnel
The product/system described in this documentation may be operated only by personnel qualified for the specific task in accordance with the relevant documentation, in particular its warning notices and safety instructions. Qualified personnel are those who, based on their training and experience, are capable of identifying risks and avoiding potential hazards when working with these products/systems.
Proper use of Siemens products
Note the following:
WARNING
Siemens products may only be used for the applications described in the catalog and in the relevant technical documentation. If products and components from other manufacturers are used, these must be recommended or approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and maintenance are required to ensure that the products operate safely and without any problems. The permissible ambient conditions must be complied with. The information in the relevant documentation must be observed.
Trademarks
All names identified by ® are registered trademarks of Siemens AG. The remaining trademarks in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owner.
Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware and software described. Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the information in this publication is reviewed regularly and any necessary corrections are included in subsequent editions.
Siemens AG
Industry Sector Postfach 48 48 90026 NÜRNBERG GERMANY
Order number: 6FC5398-2BP40-3BA1 04/2013 Technical data subject to change
Copyright © Siemens AG 1995 - 2013. All rights reserved

Preface

SINUMERIK documentation
The SINUMERIK documentation is organized in the following categories:
● General documentation
● User documentation
● Manufacturer/service documentation
Additional information
You can find information on the following topics at www.siemens.com/motioncontrol/docu:
● Ordering documentation/overview of documentation
● Additional links to download documents
● Using documentation online (find and search in manuals/information)
Please send any questions about the technical documentation (e.g. suggestions for improvement, corrections) to the following address:
docu.motioncontrol@siemens.com
My Documentation Manager (MDM)
Under the following link you will find information to individually compile OEM-specific machine documentation based on the Siemens content:
www.siemens.com/mdm
Training
For information about the range of training courses, refer under:
● www.siemens.com/sitrain
SITRAIN - Siemens training for products, systems and solutions in automation technology
● www.siemens.com/sinutrain
SinuTrain - training software for SINUMERIK
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
3
Preface
FAQs
You can find Frequently Asked Questions in the Service&Support pages under Product Support. http://support.automation.siemens.com
SINUMERIK
You can find information on SINUMERIK under the following link:
www.siemens.com/sinumerik
Target group
This publication is intended for:
● Programmers
● Project engineers
Benefits
With the programming manual, the target group can develop, write, test, and debug programs and software user interfaces.
Standard scope
This Programming Manual describes the functionality afforded by standard functions. Extensions or changes made by the machine tool manufacturer are documented by the machine tool manufacturer.
Other functions not described in this documentation might be executable in the control. This does not, however, represent an obligation to supply such functions with a new control or when servicing.
Further, for the sake of simplicity, this documentation does not contain all detailed information about all types of the product and cannot cover every conceivable case of installation, operation or maintenance.
Technical Support
You will find telephone numbers for other countries for technical support in the Internet under http://www.siemens.com/automation/service&support
Job Planning
4 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Preface
Information on structure and contents
"Fundamentals" and "Job planning" Programming Manual
The description of the NC programming is divided into two manuals:
1. Fundamentals
The "Fundamentals" Programming Manual is intended for use by skilled machine operators with the appropriate expertise in drilling, milling and turning operations. Simple programming examples are used to explain the commands and statements which are also defined according to DIN 66025.
2. Job planning
This "Job planning" Programming Manual is intended for use by technicians with in-depth, comprehensive programming knowledge. By virtue of a special programming language, the SINUMERIK control enables the user to program complex workpiece programs (e.g. for free-form surfaces, channel coordination, ...) and makes programming of complicated operations easy for technologists.
Availability of the described NC language elements
All NC language elements described in the manual are available for the SINUMERIK 840D sl. The availability regarding SINUMERIK 828D can be found in table "Operations: Availability for SINUME
RIK 828D (Page 778)".
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
5
Preface
Job Planning
6 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1

Table of contents

Preface ...................................................................................................................................................... 3
1 Flexible
1.1 Variables
1.1.1 Sy
1.1.2 Predefined user
1.1.3 Predefined user
1.1.4 Definition of us
1.1.
1.1.6 Attribute: Initi
1.1.7 Attribute: Limi
1.1.8 Attribute: Phys
1.1.9 Attribute: Ac
1.1.10 O
1.1.11
1.1.12
1.1.13 D
1.1.14 E
1.1.15 C
1.1.16
1.2
1.2.1 Indirec
1.2.2 Indirec
1.2.3 Indirec
1.2.4 Indirec
NC programming ........................................................................................................................ 17
5 Redefinition of system variables, user variables, and NC language commands (REDEF).........29
verview of definable and redefinable attributes.........................................................................44
Definition and initialization of array variables (DEF, SET, REP) .................................................45
Definition and initialization of array variables (DEF, SET, REP): Further Information.................49
ata types....................................................................................................................................52
xplicit data type conversions (AXTOINT, INTTOAX).................................................................53
heck availability of a variable (ISVAR) ......................................................................................54
Read attribute values / data type (GETVARPHU, GETVARAP, GETVARLIM,
GETVARDFT, GETVARTYP) ......................................................................................................56
Indirec
......................................................................................................................................17
stem variable............................................................................................................................17
variables: Arithmetic parameters (R).................................................................20
variables: Link variables....................................................................................21
er variables (DEF)................................................................................................24
alization value .........................................................................................................32
t values (LLI, ULI)...................................................................................................35
ical unit (PHU) ......................................................................................................37
cess rights (APR, APW, APRP, APWP, APRB, APWB)..........................................39
t programming ...................................................................................................................61
tly programming addresses...............................................................................................61
tly programming G codes..................................................................................................64
tly programming position attributes (GP) ..........................................................................65
tly programming part program lines (EXECSTRING) .......................................................68
1.3 Arithmetic
1.4 Compari
1.5 Prec
1.6 Variabl
1.7 Priority of the operations
1.8 Pos
1.9 String operations
1.9.1 Ty
1.9.2 Ty
1.9.3 Conc
1.9.4 Conv
1.9.5 Determine length
1.9.6 Search for
1.9.7 Selec
1.9.8 Reading and
1.9.9 Formatting a s
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
pe conversion to STRING (AXSTRING) ..................................................................................78
pe conversion from STRING (NUMBER, ISNUMBER, AXNAME) ..........................................79
functions......................................................................................................................69
son and logic operations ................................................................................................71
ision correction on comparison errors (TRUNC) ..................................................................73
e minimum, maximum and range (MINVAL, MAXVAL and BOUND) ..............................74
..............................................................................................................76
sible type conversions ...........................................................................................................77
..........................................................................................................................78
atenation of strings (<<).......................................................................................................81
ersion to lower/upper case letters (TOLOWER, TOUPPER) ..............................................82
of string (STRLEN)..........................................................................................83
character/string in the string (INDEX, RINDEX, MINDEX, MATCH)..........................83
tion of a substring (SUBSTR) .............................................................................................85
writing of individual characters ...............................................................................85
tring (SPRINT) ......................................................................................................87
7
Table of contents
1.10 Program jumps and branches..................................................................................................... 96
1.10.1 Return jump to the start of the program (GOTOS)...................................................................... 96
1.10.2
1.10.3 Program branc
Program jumps to jump markers (GOTOB, GOTOF, GOTO, GOTOC)...................................... 97
h (CASE ... OF ... DEFAULT ...)........................................................................ 100
1.11 R
1.12 C
1.12.1 Conditional st
1.12.2 Continuous
1.12.3 Count loop (F
1.12.4
epeat program section (REPEAT, REPEATB, ENDLABEL, P).............................................. 102
heck structures ....................................................................................................................... 108
atement and branch (IF, ELSE, ENDIF) ............................................................. 110
program loop (LOOP, ENDLOOP)......................................................................... 111
OR ... TO ..., ENDFOR) ...................................................................................... 112
Program loop with condition at start of loop (WHILE, ENDWHILE).......................................... 114
1.12.5 Program loop with condition at the end of the loop (RE
1.12.6 Program ex
1.13
1.14 I
Program coordination (INIT, START, WAITM, WAITMC, WAITE, SETM, CLEARM) .............. 116
nterrupt routine (ASUB)............................................................................................................ 121
1.14.1 Func
1.14.2 Creating an interrupt routine
1.14.3
1.14.4
Assign and start interrupt routine (SETINT, PRIO, BLSYNC) .................................................. 124
Deactivating/reactivating the assignment of an interrupt routine (DISABLE, ENABLE)........... 125
1.14.5 Delete ass
1.14.6
1.14.7
Fast retraction from the contour (SETINT LIFTFAST, ALF) ..................................................... 127
Traversing direction for fast retraction from the contour........................................................... 129
1.14.8 Motion s
1.15 Ax
is replacement, spindle replacement (RELEASE, GET, GETD)........................................... 132
1.16 Transfer axi
1.17 A
ctivate machine data (NEWCONF)......................................................................................... 138
ample with nested check structures ....................................................................... 115
tion of an interrupt routine ................................................................................................. 121
..................................................................................................... 123
ignment of interrupt routine (CLRINT) ..................................................................... 126
equence for interrupt routines ..................................................................................... 132
s to another channel (AXTOCHAN)....................................................................... 137
PEAT, UNTIL) .................................... 115
1.18 Write file (WRITE)
1.19 D
1.20 R
1.21 C
1.22
1.23 R
elete file (DELETE)................................................................................................................. 144
ead lines in the file (READ) .................................................................................................... 146
heck for presence of file (ISFILE)........................................................................................... 148
Read out file information (FILEDATE, FILETIME, FILESIZE, FILESTAT, FILEINFO) ............. 150
oundup (ROUNDUP).............................................................................................................. 153
..................................................................................................................... 139
1.24 Subprogram technique
1.24.1 General information
1.24.1.1 Subprogram
1.24.1.2 Subprogram
1.24.1.3 Nes
1.24.1.4 Searc
ting of subprograms............................................................................................................ 156
h path............................................................................................................................... 157
.............................................................................................................................. 154
names................................................................................................................... 155
1.24.1.5 Formal and ac
1.24.1.6 Parameter trans
1.24.2 Definition of a s
1.24.2.1 Subprogram
1.24.2.2
1.24.2.3
1.24.2.4 Sav
Subprogram with call-by-value parameter transfer (PROC)..................................................... 162
Subprogram with call-by-reference parameter transfer (PROC, VAR)..................................... 163
e modal G functions (SAVE)............................................................................................... 166
1.24.2.5 Suppress si
without parameter transfer ................................................................................... 161
ngle block execution (SBLOF, SBLON) ................................................................. 167
................................................................................................................... 154
tual parameters .................................................................................................. 158
fer .................................................................................................................... 159
ubprogram........................................................................................................ 161
.............................................................................................................. 154
Job Planning
8 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Table of contents
1.24.2.6 Suppress current block display (DISPLOF, DISPLON, ACTBLOCNO).....................................172
1.24.2.7 Identifying subprograms with preparation (PREPRO) ...............................................................175
1.24.2.8 Subprogram return M17
1.24.2.9 RET s
1.24.2.10 P
1.24.3 Subprogram
1.24.3.1 Subprogram
1.24.3.2 Subprogram
ubprogram return .............................................................................................................177
arameterizable subprogram return jump (RET ...) .............................................................178
call.........................................................................................................................184
call without parameter transfer..............................................................................184
call with parameter transfer (EXTERN).................................................................187
1.24.3.3 Number of program repetitions
1.24.3.4 Modal subprogram
1.24.3.5 Indirec
1.24.3.6
Indirect subprogram call with specification of the calling program part (CALL BLOCK ...
t subprogram call (CALL) ................................................................................................193
.............................................................................................................176
(P) ............................................................................................189
call (MCALL) ...............................................................................................191
TO ...) .........................................................................................................................................194
1.24.3.7
1.24.3.8
1.24.3.9 Extend
1.24.3.10 E
1.24.3.11 E
Indirect call of a program programmed in ISO language (ISOCALL)........................................195
Call subprogram with path specification and parameters (PCALL)...........................................196
search path for subprogram calls (CALLPATH)............................................................197
xecute external subprogram (840D sl) (EXTCALL)............................................................198
xecute external subprogram (828D) (EXTCALL) ...............................................................202
1.25 Macro techni
2 File and Program Mana
2.1 Program memory
2.2 Work
3 P
rotection zones.................................................................................................................................... 217
ing memory (CHANDATA, COMPLETE, INITIAL) ............................................................213
3.1 Defining the protec
3.2 Ac
3.3 Che
tivating/deactivating protection zones (CPROT, NPROT).....................................................220
cking for protection zone violation, working area limitation and software limit switches
que (DEFINE ... AS)..............................................................................................205
gement ............................................................................................................. 209
.......................................................................................................................209
tion zones (CPROTDEF, NPROTDEF) .......................................................217
(CALCPOSI)...............................................................................................................................224
4 S
pecial motion commands..................................................................................................................... 229
4.1 Approaching
coded positions (CAC, CIC, CDC, CACP, CACN) ...............................................229
4.2 Spline interpolation (ASPLINE, BSPLINE, CSPLINE,
ENAT, ETAN, PW, SD, PL) .......................................................................................................230
4.3 Spline group (SPLINEPAT
4.4 NC bl
4.5 Poly
4.6 Settable path refe
ock compression (COMPON, COMPCURV, COMPCAD, COMPOF)..............................241
nomial interpolation (POLY, POLYPATH, PO, PL).............................................................244
rence (SPATH, UPATH)................................................................................250
H).....................................................................................................240
BAUTO, BNAT, BTAN, EAUTO,
4.7 Measuri
4.8 Ax
4.9 Spec
4.10
Feedrate reduction with corner deceleration (FENDNORM, G62, G621) .................................267
4.11 P
ng with touch-trigger probe (MEAS, MEAW) ................................................................253
ial measurement (MEASA, MEAWA, MEAC) (option)...........................................................256
ial functions for OEM users (OMA1 ... OMA5, OEMIPO1, OEMIPO2, G810 ... G829).....266
rogrammable end of motion criteria (FINEA, COARSEA, IPOENDA, IPOBRKA,
ADISPOSA)................................................................................................................................268
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
9
Table of contents
5 Coordinate transformations (frames) ..................................................................................................... 271
5.1 Coordinate transformation via frame variables ......................................................................... 271
5.1.1 Predefin
ed frame variable ($P_IFRAME, $P_BFRAME, $P_PFRAME, $P_ACTFRAME)....... 273
5.2 Frame
5.2.1 As
5.2.2 Reading and
5.2.3 Link
5.2.4 Defining new
5.3 Coarse and fine offs
5.4 Ex
5.5 Preset offs
5.6 Frame
5.7 NCU global frames
5.7.1 Channel
5.7.2 Frames
6 Tran
sformations..................................................................................................................................... 299
variables / assigning values to frames........................................................................... 278
signing direct values (axis value, angle, scale) .................................................................... 278
changing frame components (TR, FI, RT, SC, MI).............................................. 280
ing complete frames ........................................................................................................... 282
frames (DEF FRAME) ......................................................................................... 283
ets (CFINE, CTRANS).............................................................................. 284
ternal zero offset ................................................................................................................... 286
et with PRESETON.................................................................................................. 287
calculation from three measuring points in space (MEAFRAME) ................................. 288
.................................................................................................................... 292
-specific frames ($P_CHBFR, $P_UBFR) ................................................................... 293
active in the channel .................................................................................................... 294
6.1 General programming of trans
6.1.1 Orientation mov
6.1.2 Ov
erview of orientation transformation TRAORI....................................................................... 305
6.2 Three, four and fiv
6.2.1 General relationships
6.2.2 Three, four and fiv
6.2.3 Variant
s of orientation programming and initial setting (ORIRESET)....................................... 311
ements for transformations.............................................................................. 301
e axis transformation (TRAORI) .................................................................. 307
of universal tool head............................................................................. 307
e axis transformation (TRAORI) .................................................................. 310
6.2.4 Programming the tool orientation (A..., B
6.2.5 Face milli
6.2.6 Referenc
ng (A4, B4, C4, A5, B5, C5)....................................................................................... 319
e of the orientation axes (ORIWKS, ORIMKS):.......................................................... 321
6.2.7 Programming orientation ax
ORIVIRT1, ORIVIRT2).............................................................................................................. 323
6.2.8
Orientatio
n programming along the peripheral surface of a taper (ORIPLANE,
ORICONCW, ORICONCCW, ORICONTO, ORICONIO).......................................................... 326
6.2.9
Specification
of orientation for two contact points (ORICURVE, PO[XH]=, PO[YH]=,
PO[ZH]=) ................................................................................................................................... 329
formation types ......................................................................... 299
..., C..., LEAD, TILT) ................................................. 313
es (ORIAXES, ORIVECT, ORIEULER, ORIRPY, ORIRPY2,
6.3
6.4 Rotation
6.5 Orientations
Orientation polynomial
s of the tool orientation (ORIROTA, ORIROTR, ORIROTT, ORIROTC, THETA)....... 333
relative to the path ................................................................................................ 336
6.5.1 Orientation types relative to the path
6.5.2 Rotation of the tool orient
s (PO[angle], PO[coordinate])............................................................... 331
........................................................................................ 336
ation relative to the path (ORIPATH, ORIPATHS, angle of
rotation) ..................................................................................................................................... 337
6.5.3
Interpolatio
6.5.4 Smoothing of
6.6 Comp
6.7 Smoothing th
6.8 Kinematic
6.8.1 Milling on turned parts (TRANSMIT):
Job Planning
n of the tool rotation relative to the path (ORIROTC, THETA)................................ 339
orientation characteristic (ORIPATHS A8=, B8=, C8=) ...................................... 341
ression of the orientation (COMPON, COMPCURV, COMPCAD).................................. 342
e orientation characteristic (ORISON, ORISOF) ................................................. 344
transformation .......................................................................................................... 347
........................................................................................ 347
10 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Table of contents
6.8.2 Cylinder surface transformation (TRACYL) ...............................................................................349
6.8.3 Inclined axis (TRAANG).............................................................................................................357
6.8.4 Inc
lined axis programming (G5, G7)..........................................................................................360
6.9 Cartes
ian PTP travel..................................................................................................................362
6.9.1 PTP for TRANSMIT
onstraints when selecting a transformation.............................................................................370
eselecting a transformation (TRAFOOF) ................................................................................371
hained transformations (TRACON, TRAFOOF)......................................................................371
7 K
6.10 C
6.11 D
6.12 C
inematic chains.................................................................................................................................... 375
7.1 Deletion of components (DELOBJ)
7.2 Index determi
8 Collision a
voidance with kinematic chains ............................................................................................. 379
8.1 Check
8.2 Req
uesting a recalculation of the collision model (PROTA)......................................................380
8.3 Setting the protec
8.4 Determining the c
9 Tool
offsets............................................................................................................................................ 385
9.1 Offs
et memory............................................................................................................................385
9.2 Additiv
9.2.1 Selec
9.2.2 Specify
9.2.3 Delete additive offs
for collision pair (COLLPAIR) .........................................................................................379
e offsets...........................................................................................................................388
ting additive offsets (DL) ...................................................................................................388
nation by means of names (NAMETOINT) ..........................................................377
tion zone status (PROTS)..............................................................................382
learance of two protection zones (PROTD)...................................................383
wear and setup values ($TC_SCPxy[t,d], $TC_ECPxy[t,d]).........................................389
ets (DELDL).................................................................................................390
...................................................................................................................366
............................................................................................375
9.3 Special handl
9.3.1 Mirroring of tool lengths
9.3.2 Wear s
9.3.3 Coo
rdinate system of the active machining operation (TOWSTD, TOWMCS, TOWWCS,
ing of tool offsets ..................................................................................................391
.............................................................................................................393
ign evaluation .................................................................................................................394
TOWBCS, TOWTCS, TOWKCS)...............................................................................................395
9.3.4
Tool length a
9.4 Online tool of
9.5 Ac
tivate 3D tool offsets (CUT3DC..., CUT3DF...)......................................................................404
9.5.1 Activating 3
9.5.2 3D tool offset
9.5.3 3D tool offset
9.5.4 3D tool offset
9.5.5 3D tool offset
9.5.6 3D tool offset
9.5.7 3D tool offset
9.6 Tool ori
9.7 Free assignm
9.7.1 Free a
9.7.2 Free a
9.7.3 Free a
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
nd plane change....................................................................................................398
fset (PUTFTOCF, FCTDEF, PUTFTOC, FTOCON, FTOCOF)............................399
D tool offsets (CUT3DC, CUT3DF, CUT3DFS, CUT3DFF, ISD)............................404
peripheral milling, face milling .............................................................................406
Tool shapes and tool data for face milling...........................................................408
Offset on the path, path curvature, insertion depth (CUT3DC, ISD)...................409
Inside/outside corners and intersection procedure (G450/G451) .......................412
3D circumferential milling with limitation surfaces...............................................413
: Taking into consideration a limitation surface (CUT3DCC, CUT3DCCD)..........414
entation (ORIC, ORID, OSOF, OSC, OSS, OSSE, ORIS, OSD, OST).........................418
ent of D numbers, cutting edge numbers.............................................................424
ssignment of D numbers, cutting edge numbers (CE address) ......................................424
ssignment of D numbers: Checking D numbers (CHKDNO)...........................................424
ssignment of D numbers: Rename D numbers (GETDNO, SETDNO)...........................425
11
Table of contents
9.7.4 Free assignment of D numbers: Determine T number to the specified D number
(GETACTTD) ............................................................................................................................ 426
9.7.5 Free ass
ignment of D numbers: Invalidate D numbers (DZERO) ............................................ 427
9.8 Toolholder k
9.9 Tool length
TCOFRX, TCOFRY, TCOFRZ)................................................................................................. 433
9.10 O
9.11
10 Path trav
10.1
nline tool length compensation (TOFFON, TOFFOF)............................................................ 436
Cutting data modification for tools that can be rotated (CUTMOD) .......................................... 439
ersing behavior........................................................................................................................ 445
Tangential control (TANG, TANGON, TANGOF, TLIFT, TANGDEL)....................................... 445
10.2 Feedrate charac
10.3 Accel
10.3.1 Accel
10.3.2
10.3.3
eration behavior................................................................................................................ 457
eration mode (BRISK, BRISKA, SOFT, SOFTA, DRIVE, DRIVEA) ................................ 457
Influence of acceleration on following axes (VELOLIMA, ACCLIMA, JERKLIMA)................... 459
Activation of technology-specific dynamic values (DYNNORM, DYNPOS, DYNROUGH,
DYNSEMIFIN, DYNFINISH) ..................................................................................................... 461
10.4
Traversing wi
10.5 Programmable c
10.6
Program sequence with preprocessing memory (STOPFIFO, STARTFIFO, FIFOCTRL,
STOPRE) .................................................................................................................................. 466
10.7
Program sections that can be conditionally interrupted (DELAYFSTON, DELAYFSTOF)....... 469
10.8 Prevent program pos
inematics ............................................................................................................... 427
compensation for orientable toolholders (TCARR, TCOABS, TCOFR,
teristic (FNORM, FLIN, FCUB, FPO).............................................................. 452
th feedforward control (FFWON, FFWOF) .......................................................... 463
ontour accuracy (CPRECON, CPRECOF)..................................................... 464
ition for SERUPRO (IPTRLOCK, IPTRUNLOCK)................................... 474
10.9
Repositioning to the contour (REPOSA, REPOSL, REPOSQ, REPOSQA, REPOSH,
REPOSHA, DISR, DISPR, RMIBL, RMBBL, RMEBL, RMNBL)............................................... 476
10.10 I
10.10.1 Percentage jerk
10.10.2 Percentage veloc
nfluencing the motion control ................................................................................................... 484
correction (JERKLIM) ..................................................................................... 484
ity correction (VELOLIM)............................................................................... 486
10.10.3 Program example for JE
Programmable contour/orientation tolerance (CTOL, OTOL, ATOL) ....................................... 488
olerance for G0 motion (STOLF) ............................................................................................ 492
lock change behavior with active coupling (CPBC)................................................................ 494
11 A
10.11
10.12 T
10.13 B
xis couplings........................................................................................................................................ 495
11.1 Coupled motion (TRAILON, TRAILOF)
11.2 Curv
11.2.1 Define
11.2.2 Check
11.2.3 Delete
11.2.4
11.2.5
e tables (CTAB)................................................................................................................. 500
curve tables (CTABDEF, CATBEND)............................................................................ 501
for presence of curve table (CTABEXISTS) .................................................................. 507
curve tables (CTABDEL) ............................................................................................... 507
Locking curve tables to prevent deletion and overwriting (CTABLOCK, CTABUNLOCK) ....... 509
Curve tables: Determine table properties (CTABID, CTABISLOCK, CTABMEMTYP,
CTABPERIOD).......................................................................................................................... 510
11.2.6
Read curve table values (CTABTSV, CTABTEV, CTABTSP, CTABTEP, CTABSSV,
CTABSEV, CTAB, CTABINV, CTABTMIN, CTABTMAX)......................................................... 512
RKLIM and VELOLIM......................................................................... 488
..................................................................................... 495
Job Planning
12 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Table of contents
11.2.7 Curve tables: Check use of resources (CTABNO, CTABNOMEM, CTABFNO, CTABSEGID, CTABSEG, CTABFSEG, CTABMSEG, CTABPOLID, CTABPOL,
CTABFPOL, CTABMPOL).........................................................................................................517
Ax
11.3
ial master value coupling (LEADON, LEADOF) ....................................................................518
11.4 Elec
11.4.1 Defining an electronic
11.4.2
11.4.3 Switching-i
11.4.4
11.4.5 Rotational feedrate
11.5 Sy
11.5.1
tronic gear (EG) ..................................................................................................................523
gear (EGDEF) ........................................................................................524
Switch-in the electronic gearbox (EGON, EGONSYN, EGONSYNE).......................................525
n the electronic gearbox (EGOFS, EGOFC) ............................................................529
Deleting the definition of an electronic gear (EGDEL)...............................................................530
(G95) / electronic gear (FPR).....................................................................530
nchronous spindle..................................................................................................................531
Synchronous spindle: Programming (COUPDEF, COUPDEL, COUPON, COUPONC,
COUPOF, COUPOFS, COUPRES, WAITC).............................................................................531
Generic
Master/slave coupling (MASLDEF, MASLDEL, MASLON, MASLOF, MASLOFS) ...................549
12 S
11.6
11.7
ynchronized actions............................................................................................................................. 553
12.1 Definition of a s
13 Oscillation
.............................................................................................................................................. 555
coupling (CP...).............................................................................................................541
ynchronized action ............................................................................................553
13.1 Asynchronous oscillation (OS, OSP1, OSP2, OST1, OST2, OSCTRL, OSNS
OSB) ..........................................................................................................................................555
13.2 Oscillation
14 P
unching and nibbling ........................................................................................................................... 569
14.1 Ac
14.1.1 Punc
tivation, deactivation ..............................................................................................................569
controlled by synchronized actions (OSCILL)..........................................................560
hing and nibbling on or off (SPOF, SON, PON, SONS, PONS, PDELAYON,
PDELAYOF, PUNCHACC) ........................................................................................................569
C, OSE,
14.2
Automatic
14.2.1 Path s
14.2.2 Path s
15 Gri
nding................................................................................................................................................. 581
15.1
Grinding-specific tool monitoring in the part program (TMON, TMOF)......................................581
16 Additional fun
16.1 Ax
is functions (AXNAME, AX, SPI, AXTOSPI, ISAXIS, AXSTRING, MODAXVAL) .................583
16.2 Repl
16.3 Ax
is container (AXCTSWE, AXCTSWED, AXCTSWEC) ..........................................................590
16.4 Wait for valid
16.5 Programmable parameter
16.6 Check
16.7
Interactively call the window from the part program (MMC) ......................................................598
16.8 Program runtime/part c
path segmentation ....................................................................................................574
egmentation for path axes ...............................................................................................577
egmentation for single axes.............................................................................................579
ctions................................................................................................................................ 583
aceable geometry axes (GEOAX)......................................................................................585
axis position (WAITENC) .....................................................................................592
set changeover (SCPARA)..............................................................593
scope of NC language present (STRINGIS)...................................................................594
ounter....................................................................................................600
16.8.1 Program runtime/part count
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
er (overview) ..................................................................................600
13
Table of contents
16.8.2 Program runtime ....................................................................................................................... 600
16.8.3 Workpiece counter .................................................................................................................... 604
16.9 Process
16.10 Alarms
16.11 E
xtended stop and retract (ESR) .............................................................................................. 616
16.11.1 NC-controlled ESR
16.11.1.1
DataShare - output to an external device/file (EXTOPEN, WRITE, EXTCLOSE)...... 605
(SETAL) ........................................................................................................................ 614
.................................................................................................................... 617
NC-controlled retraction (POLF, POLFA, POLFMASK, POLFMLIN) .................................. 617
16.11.1.2 NC-controlled stopping
16.11.2 Driv
e-integrated ESR ................................................................................................................ 622
16.11.2.1 Configuring drive-integrated stoppi
16.11.2.2 Configuring driv
17 Use
r stock removal programs................................................................................................................ 625
17.1 Supporting function
e-integrated retraction (ESRS) ................................................................... 623
s for stock removal..................................................................................... 625
17.2 Generate contour table (CONTP
17.3 Generate coded c
17.4
17.5
17.6 Calc
Determine point of intersection between two contour elements (INTERSEC) ......................... 635
Execute the contour elements of a table block-by-block (EXECTAB)...................................... 637
ulate circle data (CALCDAT) ............................................................................................. 638
17.7 Deac
18 P
rogramming cycles externally.............................................................................................................. 641
18.1 Tec
hnology cycles..................................................................................................................... 641
18.1.1 Introduc
18.1.2 Drilling, centering -
tivate contour preparation (EXECUTE) ............................................................................ 640
tion ............................................................................................................................... 641
ontour table (CONTDCON) .......................................................................... 632
CYCLE81 ................................................................................................... 642
18.1.3 Drilling, counterboring - CY
18.1.4 Reaming -
18.1.5 Deep-hole drilling - CY
18.1.6 Boring -
CYCLE85................................................................................................................. 644
CLE83................................................................................................... 645
CYCLE86..................................................................................................................... 648
18.1.7 Tapping without compensating chuck -
18.1.8 Tapping with
compensating chuck - CYCLE840....................................................................... 652
18.1.9 Thread milling - CYCLE78
18.1.10 F
18.1.11 R
18.1.12 G
18.1.13 C
18.1.14 Face milling - CYCLE61
18.1.15 M
18.1.16 Milling a ci
18.1.17 R
18.1.18 C
reely programmable positions - CYCLE802 ........................................................................... 656
ow of holes - HOLES1............................................................................................................ 657
rid or frame - CYCLE801........................................................................................................ 658
ircle of holes - HOLES2.......................................................................................................... 659
............................................................................................................ 661
illing a rectangular pocket - POCKET3 .................................................................................. 662
rcular pocket - POCKET4......................................................................................... 665
ectangular spigot milling - CYCLE76...................................................................................... 667
ircular spigot milling - CYCLE77............................................................................................. 669
18.1.19 Multiple-edge - CYCLE79
18.1.20 Longitudinal
18.1.21 C
ircumferential slot - SLOT2..................................................................................................... 675
slot - SLOT1.......................................................................................................... 673
18.1.22 Mill open slot - CYCLE899
18.1.23 E
18.1.24 T
18.1.25 E
longated hole - LONGHOLE................................................................................................... 679
hread milling - CYCLE70 ........................................................................................................ 681
ngraving cycle - CYCLE60...................................................................................................... 683
........................................................................................................ 621
ng (ESRS)..................................................................... 622
RON) ..................................................................................... 626
CLE82............................................................................................ 643
CYCLE84 ................................................................... 649
........................................................................................................ 654
......................................................................................................... 671
........................................................................................................ 677
Job Planning
14 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Table of contents
18.1.26 Contour call - CYCLE62.............................................................................................................685
18.1.27 Path milling - CYCLE72 .............................................................................................................685
18.1.28 P
18.1.29 Milling a contour pocket -
18.1.30 S
18.1.31 G
18.1.32 U
18.1.33 Thread turning - CYCLE99
18.1.34 T
18.1.35 C
18.1.36 C
18.1.37 C
18.1.38 S
18.1.39 H
redrilling a contour pocket - CYCLE64....................................................................................688
CYCLE63..........................................................................................689
tock removal - CYCLE951.......................................................................................................692
roove - CYCLE930 ..................................................................................................................694
ndercut forms - CYCLE940 .....................................................................................................696
........................................................................................................699
hread chain - CYCLE98...........................................................................................................702
ut-off - CYCLE92 .....................................................................................................................705
ontour cutting - CYCLE95 .......................................................................................................706
ontour grooving - CYCLE952 ..................................................................................................708
wiveling - CYCLE800...............................................................................................................712
igh Speed Settings - CYCLE832.............................................................................................714
19 Tables
19.1 Operations
19.2 Operations: Availability for
19.3 Currently set language in t
.................................................................................................................................................... 717
..................................................................................................................................717
SINUMERIK 828D ..........................................................................778
he HMI .............................................................................................802
A Appendix.....................................................
A.1 List of abbreviations
G
I
A.2 Doc
lossary ................................................................................................................................................ 813
ndex...................................................................................................................................................... 835
umentation overview............................................................................................................812
...................................................................................................................803
........................................................................................... 803
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
15
Table of contents
Job Planning
16 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1

Flexible NC programming

1.1 Variables

The use of variables, especially in conjunction with arithmetic functions and check structures, enables part programs and cycles to be set up with extremely high levels of flexibility. The system provides three different types of variables.
● System variables
System variables are variables with a fixed predefined meaning; they are defined in the system and made available to the user. They are also read and written by the system software. Example: Machine data
The meaning of a system variable is permanently set by the system. However, minor modifications can be made to the properties by the user in the form of redefinition. See "Redefinition of system variables, user variables, and NC language (Page 29)"
● User variable
User variables are variables whose meaning is not known to the system; they are not evaluated by the system. The meaning is defined exclusively by the user.
User variables are subdivided into:
s
ands (REDEF)
comm
1
– Predefined user variables
Predefined user variables are variables which have already been defined in the system and whose number simply has to be parameterized by the user via specific machine data. The user can make significant changes to the properties of these variables. See "Redefinition of system variables, user variables, and NC language comm
ands (REDEF) (Page 29)".
– User-defined
User-defined variables are variables which are defined exclusively by the user and are not created by the system until runtime. Their number, data type, visibility, and all other properties are defined exclusively by the user.
See "Definition of user variables (DEF) (Page 24)"

1.1.1 System variable

System variables are variables which are predefined in the system and enable access to the current parameter settings of the control, as well as to machine, control, and process states, in part programs and cycles.
variables
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
17
Flexible NC programming
1.1 Variables
Preprocessing variables
Preprocessing variables are system variables that are read and written in the context of preprocessing; in other words, at the point in time at which the part program block in which the system variable is programmed is interpreted. Preprocessing variables do not trigger preprocessing stops.
Main run variables
Main run variables are system variables which are read and written in the context of the main run; in other words at the point in time at which the part program block in which the system variable is programmed is executed. The following are main run variables:
● System variables which can be programmed in synchronized actions (read/write)
● System variables which can be programmed in the part program and trigger preprocessing stops (read/write)
● System variables which can be programmed in the part program and whose value is calculated during preprocessing but not written until the main run (main run synchronized: write only)
Prefix system
In order that they can be specifically identified, the names of system variables are usually preceded by a prefix comprising the $ sign followed by one or two letters and an underscore.
$ + 1st letter Meaning: Data type System variables which are read/written during preprocessing $M Machine data 1) $S Setting data, protection zones 1) $T Tool management data $P Programmed values $C Cycle variables of ISO envelope cycles $O Option data R R-parameters (arithmetic parameters) 2) System variables which are read/written during the main run $$M Machine data 1) $$S Setting data 1) $A Current main run data $V Servo data $R R-parameters (arithmetic parameters) 2)
1)
Whether machine and setting data is treated as preprocessing or main run variables depends on whether they are written with one or two $ characters. The notation is freely selectable for the specific application.
2)
When an R-parameter is used in the part program/cycle as a preprocessing variable, the prefix is omitted, e.g. R10. When it is used in a synchronized action as a main run variable, a $ sign is written as a prefix, e.g. $R10.
Job Planning
18 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
2nd letter Meaning: Visibility N NCK-global variable (NCK) C Channel-specific variable (Channel) A Axis-specific variable (Axis)
Supplementary conditions
Exceptions in the prefix system
The following system of variables deviate from the prefix system specified above:
● $TC_...: Here, the 2nd letter C does not refer to channel-specific system variables but to toolholder-specific system variables (TC= tool carrier).
● $P_ ...: Channel-specific system variables
Use of machine and setting data in synchronized actions
When machine and setting data is used in synchronized actions, the prefix can be used to define whether the machine or setting data will be read/written synchronous to the preprocessing run or the main run.
References
If the data remains unchanged during machining, it can be read synchronous to the preprocessing run. For this purpose, the machine or setting data prefix is written with a $ sign:
ID=1 WHENEVER $AA_IM[z] < $SA_OSCILL_REVERSE_POS2[Z]–6 DO $AA_OVR[X]=0
If the data changes during machining, it must be read/written synchronous to the main run. For this purpose, the machine or setting data prefix is written with two $ signs:
ID=1 WHENEVER $AA_IM[z] < $$SA_OSCILL_REVERSE_POS2[Z]–6 DO $AA_OVR[X]=0
Note Writing machine data
When writing an item of machine or setting data, it is important to ensure that the access level which is active when the part program/cycle is executed permits write access and that the data is set to take "IMMEDIATE" effect.
A list of the properties of all system variables appears in:
Parameter Manual, System Variables
See also
Variables (Page 17)
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
19
Flexible NC programming
1.1 Variables

1.1.2 Predefined user variables: Arithmetic parameters (R)

Function
Arithmetic parameters or R parameters are predefined user variables with the designation R, defined as an array of the REAL data type. For historical reasons, notation both with array index, e.g.
R[10], and without array index, e.g. R10, is permitted for R parameters.
Syntax
Meaning
When using synchronized actions, the $ sign must be included as a prefix, e.g.
$R10.
When used as a preprocessing variable:
R<n> R[<expression>]
When used as a main run variable:
$R<n> $R[<expression>]
R: Identifier when used as a preprocessing variable, e.g. in the part program $R: Identifier when used as a main run variable, e.g. in synchronized actions
Type: REAL Range of values: For a non-exponential notation:
± (0.000 0001 ... 9999 9999) Note:
A maximum of 8 decimal places are permitted.
For an exponential notation:
± (1*10
-300
... 1*10
+300
)
Note:
Notation: <Mantisse>EX<exponent> e.g. 8.2EX-3 A maximum of 10 characters are permitted including
sign and decimal point.
<n>:
Number of the R parameter Type: INT Range of values: 0 - MAX_INDEX
Note MAX_INDEX is calculated from the parameterized number of R-parameters: MAX_INDEX = (MD28050 $MN_MM_NUM_R_PARAM) - 1
<expression>: Array index
Any expression can be used as an array index, as long as the result of the expression can be converted to the INT data type (INT, REAL, BOOL, CHAR).
Job Planning
20 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Example
Assignments to R-parameters and use of R-parameters in mathematical functions:
Program code Comment
R0=3.5678 ; Assignment in preprocessing
R[1]=-37.3 ; Assignment in preprocessing
R3=-7 ; Assignment in preprocessing
$R4=-0.1EX-5 ; Assignment in main run: R4 = -0.1 * 10^-5
$R[6]=1.874EX8 ; Assignment in main run: R6 = 1.874 * 10^8
R7=SIN(25.3) ; Assignment in preprocessing
R[R2]=R10 ; Indirect addressing using R-parameter
R[(R1+R2)*R3]=5 ; Indirect addressing using math. expression
X=(R1+R2) ; Traverse axis X to the position resulting from the
sum of R1 and R2
Z=SQRT(R1*R1+R2*R2) ; Traverse axis Z to the square root position (R1^2 +
R2^2)
See also
Variables (Page 17)

1.1.3 Predefined user variables: Link variables

Function
Link variables can be used in the context of the "NCU-Link" function for cyclic data exchange between NCUs which are linked on a network. They facilitate data-format-specific access to the link variables memory. The link variables memory is defined both in terms of size and data structure on a system-specific basis by the user/machine manufacturer.
Link variables are system-global user variables which can be read and written in part programs and cycles by all NCUs involved in a link if link communication has been configured. Unlike global user variables (GUD), link variables can also be used in synchronized actions.
On systems without an active NCU link, link variables can be used locally on the controller as additional global user variables alongside global user variables (GUD).
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
21
Flexible NC programming
1.1 Variables
Syntax
$A_DLB[<index>] $A_DLW[<index>] $A_DLD[<index>] $A_DLR[<index>]
Meaning
$A_DLB:
$A_DLW:
$A_DLD:
$A_DLR:
<index>:
Link variable for BYTE data format (1 byte) Data type: UINT Range of values: 0 ... 255 Link variable for WORD data format (2 bytes) Data type: INT Range of values: -32768 ... 32767 Link variable for DWORD data format (4 bytes) Data type: INT Range of values: -2147483648 ... 2147483647 Link variable for REAL data format (8 bytes) Data type: REAL Range of values: ±(2.2*10
-308
… 1.8*10
+308
) Address index in bytes, counted from the start of the link variable memory Data type: INT Range of values: 0 - MAX_INDEX
Note MAX_INDEX is calculated from the parameterized size
of the link variables memory: MAX_INDEX = (MD18700 $MN_MM_SIZEOF_LINKVAR_DATA) - 1
Only indices may be programmed, so that the bytes
addressed in the link variables memory are located on a data format limit Index = n * bytes, where n = 0, 1, 2, etc.
$A_DLB[i]: i = 0, 1, 2, ...
– –
$A_DLW[i]: i = 0, 2, 4, ...
$A_DLD[i]: i = 0, 4, 8, ...
$A_DLR[i]: i = 0, 8, 16, ...
Example
An automation system contains 2 NCUs (NCU1 and NCU2). Machine axis AX2 is connected to NCU1. It is traversed as a link axis of NCU2.
NCU1 writes the actual current value ($VA_CURR) of axis AX2 cyclically to the link variables memory. NCU2 reads the actual current value transmitted via link communication cyclically and displays alarm 61000 if the limit value is exceeded.
Job Planning
22 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
The data structure in the link variables memory is illustrated in the following figure. The actual current value is transmitted in the REAL value.
/LQNYDULDEOHVPHPRU\ 0'01B00B6,=(2)B/,1.9$5B'$7$ 
,QGH[
%<7( %<7( :25' ':25'

':25' ':25'
5($/
NCU1 NCU1 uses link variable $A_DLR[ 16 ] to write the actual current value of axis AX2 to the link variables memory cyclically in the interpolation cycle in a static synchronized action.
Program code
N111 IDS=1 WHENEVER TRUE DO $A_DLR[16]=$VA_CURR[AX2]
NCU2 NCU2 uses link variable $A_DLR[ 16 ] to read the actual current value of axis AX2 from the link variables memory cyclically in the interpolation cycle in a static synchronized action. If the actual current value is greater than 23.0 A, alarm 61000 is displayed.
Program code
N222 IDS=1 WHEN $A_DLR[16] > 23.0 DO SETAL(61000)
See also
Variables (Page 17)
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
23
Flexible NC programming
1.1 Variables

1.1.4 Definition of user variables (DEF)

Function
The DEF command is used to define user-specific variables and assign values to them. To set them apart from system variables, these are called user-defined variables or user variables (user data).
According to the range of validity (in other words, the range in which the variable is visible) there are the following categories of user variable:
● Local user variables (LUD)
Local user variables (LUD) are variables defined in a part program which is not the main program at the time of execution. They are created when the part program is called and deleted at the end of the part program or when the NC is reset. Local user variables can only be accessed within the part program in which they are defined.
● Program-global user variables (PUD)
Program-global user variables (PUD) are user variables defined in a part program used as the main program. They are created when the part program starts up and deleted at the end of the part program or when the NC is reset. It is possible to access PUD in the main program and in all subprograms of the main program.
Syntax
● Global user variables (GUD)
Global user variables (GUD) are NC or channel-global variables which are defined in a data block (SGUD, MGUD, UGUD, GUD4 to GUD9) and are retained following shutdown and restart. GUD can be accessed in all part programs.
User variables must be defined before they can be used (read/write). The following rules must be observed in this context:
● GUD have to be defined in a definition file, e.g. _N_DEF_DIR/_M_SGUD_DEF.
● PUD and LUD have to be defined in a definition section of the part program.
● The data must be defined in a dedicated block.
● Only one data type may be used for each data definition.
● Several variables of the same data type can be defined for each data definition.
LUD and PUD
DEF <type> <phys_unit> <limit values> <name>[<value_1>, <value_2>, <value_3>]=<init_value>
GUD
DEF <range> <pp_stop> <access_rights> <type> <phys_unit> <limit values> <name>[<value_1>, <value_2>, <value_3>]=<init_value>
Job Planning
24 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Meaning
DEF: Command for defining GUD, PUD, LUD user variables <range>:
<PP_stop>:
<access rights>:
<type>:
<phys_unit>:
<limit values>:
Range of validity, only relevant for GUD:
NCK: NC-global user variable CHAN: Channel-global user variable
Preprocessing stop, only relevant for GUD (optional)
SYNR: Preprocessing stop when reading SYNW: Preprocessing stop when writing SYNRW: Preprocessing stop when reading/writing
Protection level for reading/writing GUD via part program or OPI (optional)
APRP <protection level>: Read: Part program APWP <protection level>: Write: Part program APRB <protection level>: Read: OPI APWB <protection level>: Write: OPI
<protection level>: Range of values: 0 ... 7 See "Attribute: Access rights (APR, APW, APRP, APWP, APRB,
APWB) (Page 39)" Data type:
INT: Integer with sign REAL: Real number (LONG REAL to IEEE) BOOL: Truth value TRUE (1)/FALSE (0) CHAR: ASCII character STRING[<MaxLength>]: Character string of a defined length AXIS: Axis/spindle identifier FRAME: Geometric data for a static coordinate
transformation See "Data types (Page 52)" Physical unit (optional)
PHU <unit>: Physical unit
See "Attribute: Physical unit (PHU) (Page 37)" Lower/upp
LLI <limit value>: Lower limit value (lower limit) ULI <limit value>: Upper limit value (upper limit)
er limit value (optional)
See "Attribute: Limit values (LLI, ULI) (Page 35)"
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
25
Flexible NC programming
1.1 Variables
<name>
: Name of variable
Note
Maximum 31 characters The first two characters must be a letter and/or an underscore.The $ sign is reserved for system variables and must not be
used.
[<value_1>, <value_2>,
<value_3>]
:
Specification of array sizes for 1- to max. 3-dimensional array variables (optional)
For the Initialization of array variables see "Definition and initialization of array
<init_value>: Initialization value (optional)
variables (DEF, SET, REP) (Page 45)"
See "Attribute: Initialization value (Page 32)" For the Initializa
initialization of array
tion of array variables see "Definition and
variables (DEF, SET, REP) (Page 45)"
Examples
Example 1: Definition of user variables in the data block for machine manufacturers
Program code Comment
%_N_MGUD_DEF ; GUD block: Machine manufacturer
$PATH=/_N_DEF_DIR
DEF CHAN REAL PHU 24 LLI 0 ULI 10 STROM_1, STROM_2
;Description
;Definition of two GUD items: STROM_1, STROM_2
;Range of validity: Throughout the channel
;Data type: REAL
PP stop: Not programmed => default value = no PP stop
;Physical unit: 24 = [A]
;Limit values: Low = 0.0, high = 10.0
;Access rights: Not programmed => default value = 7 = key-operated switch position 0
;Initialization value: Not programmed => default value = 0.0
DEF NCK REAL PHU 13 LLI 10 APWP 3 APRP 3 APWB 0 APRB 2 ZEIT_1=12, ZEIT_2=45
;Description
;Definition of two GUD items: ZEIT_1, ZEIT_2
;Range of validity: Throughout the NCK
;Data type: REAL
PP stop: Not programmed => default value = no PP stop
;Physical unit: 13 = [s]
;Limit values: low = 10.0, high = not programmed => upper definition range limit
Job Planning
26 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Program code Comment
;Access rights:
;Part program: Write/read = 3 = end user
;OPI: Write = 0 = Siemens, read = 3 = end user
;Initialization value: ZEIT_1 = 12.0, ZEIT_2 = 45.0
DEF NCK APWP 3 APRP 3 APWB 0 APRB 3 STRING[5] GUD5_NAME = "COUNTER"
;Description
;Definition of one GUD item: GUD5_NAME
;Range of validity: Throughout the NCK
;Data type: STRING, max. 5 characters
PP stop: Not programmed => default value = no PP stop
;Physical unit: Not programmed => default value = 0 = no phys. unit
;Limit values: Not programmed => definition range limits: low = 0, high = 255
;Access rights:
;Part program: Write/read = 3 = end user
;OPI: Write = 0 = Siemens, read = 3 = end user
;Initialization value: "COUNTER"
M30
Example 2: Global program and local user variables (PUD/LUD)
Program code Comment
PROC MAIN ;Main program
DEF INT VAR1 ;PUD definition
...
SUB2 ;Subprogram call
...
M30
Program code Comment
PROC SUB2 ;Subprogram SUB2
DEF INT VAR2 ;LUD DEFINITION
...
IF (VAR1==1) ;Read PUD
VAR1=VAR1+1 ;Read & write PUD
VAR2=1 ;Write LUD
ENDIF
SUB3 ;subprogram call
...
M17
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
27
Flexible NC programming
1.1 Variables
Program code Comment
PROC SUB3 ;Subprogram SUB3
...
IF (VAR1==1) ;Read PUD
VAR1=VAR1+1 ;Read & write PUD
VAR2=1 ;Error: LUD from SUB2 not known
ENDIF
...
M17
Example 3: Definition and use of user variables of data type AXIS
Program code Comment
DEF AXIS ABSCISSA ;1st geometry axis
DEF AXIS SPINDLE ;Spindle
...
IF ISAXIS(1) == FALSE GOTOF CONTINUE
ABSCISSA = $P_AXN1
CONTINUE:
...
SPINDLE=(S1) ;1st spindle
OVRA[SPINDLE]=80 ;Spindle override = 80%
SPINDLE=(S3) ;3rd spindle
Supplementary conditions
Global user variables (GUD)
In the context of the definition of global user variables (GUD), the following machine data has to be taken into account:
No. Identifier: $MN_ Meaning 11140 GUD_AREA_ SAVE_TAB Additional save for GUD blocks 18118 1) MM_NUM_GUD_MODULES Number of GUD files in the active file system 18120 1) MM_NUM_GUD_NAMES_NCK Number of global GUD names 18130 1) MM_NUM_GUD_NAMES_CHAN Number of channel-spec. GUD names 18140 1) MM_NUM_GUD_NAMES_AXIS Number of axis-spec. GUD names 18150 1) MM_GUD_VALUES_MEM Memory location for global GUD values 18660 1) MM_NUM_SYNACT_GUD_REAL Number of configurable GUD of the REAL data type 18661 1) MM_NUM_SYNACT_GUD_INT Number of configurable GUD of the INT data type 18662 1) MM_NUM_SYNACT_GUD_BOOL Number of configurable GUD of the BOOL data type 18663 1) MM_NUM_SYNACT_GUD_AXIS Number of configurable GUD of the AXIS data type 18664 1) MM_NUM_SYNACT_GUD_CHAR Number of configurable GUD of the CHAR data type 18665 1) MM_NUM_SYNACT_GUD_STRING Number of configurable GUD of the STRING data type
1)
For SINUMERIK 828D, MD can only be read!
Job Planning
28 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Program-global user variables (PUD)
Note Visibility of program-global user variables (PUD)
Program-global user variables (PUD) defined in the main program will only be visible in subprograms if the following machine data is set:
MD11120 $MN_LUD_EXTENDED_SCOPE = 1
If MD11120 = 0 the program-global user variables defined in the main program will only be visible in the main program.
Cross-channel use of an NCK-global user variable of the AXIS data type
An NCK-global user variable of the
AXIS data type initialized during definition in the data
block with an axis identifier can then only be used in other NC channels if the axis has the same channel axis number in these channels.
If this is not the case, the variable has to be loaded at the start of the part program or, as in the following example, the AXNAME(...) function has to be used.
Program code Comment
DEF NCK STRING[5] ACHSE="X" ;Definition in the data block
...
N100 AX[AXNAME(ACHSE)]=111 G00 ;Use in the part program

1.1.5 Redefinition of system variables, user variables, and NC language commands (REDEF)

Function
The REDEF command can be used to change the attributes of system variables, user variables and NC language commands. A fundamental condition of redefinition is that it has to post-date the corresponding definition.
Multiple attributes cannot be changed simultaneously during redefinition. A separate statement has to be programmed for each attribute to be changed.
If two or more concurrent attribute changes are programmed, the last change is always active.
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
REDEF
29
Flexible NC programming
1.1 Variables
Resetting attribute values
Syntax
The attributes for access rights and initialization time change with default values by reprogramming
REDEF, followed by the name of the variable or the NC
REDEF can be reset to their
language command:
● Access rights: Protection level 7
● Initialization time: No initialization or retention of the current value
Redefinable attributes
See "Overview of definable and redefinable attributes (Page 44)"
Local u
ser va
riables (PUD/LUD)
Redefinitions are not permitted for local user variables (PUD/LUD).
REDEF <name> <PP_stop>
REDEF <name> <phys_unit>
REDEF <name> <limit_values>
REDEF <name> <access_rights>
REDEF <name> <init_time>
REDEF <name> <init_time> <init_value>
Meaning
REDEF <name>
REDEF: Command for redefinition of a certain attribute or to reset the
"Access rights" and/or "Initialization time" attributes of system variables, user variables and NC language commands
<name>: Name of an already defined variable or an NC language
command
<PP stop>:
<phys_unit>:
Preprocessing stop
SYNR: Preprocessing stop when reading SYNW: Preprocessing stop when writing SYNRW: Preprocessing stop when reading/writing
Physical unit
PHU <unit>: Physical unit
See "Attribute: Physical unit (PHU) (Page 37)" Note
Cannot be re
defined for:
System variables Global user data (GUD) of the data types:
FRAME
BOOL, AXIS, STRING,
Job Planning
30 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
<limit values>:
Lower/upper limit
LLI <limit value>: Lower limit value (lower limit) ULI <limit value>: Upper limit value (upper limit)
See "Attribute: Limit values (LLI, ULI) (Page 35)" Note
Cannot be re
defined for:
System variables Global user data (GUD) of the data types:
FRAME
<access rights>:
Access rights for reading/writing via part program or OPI
APX <protection level>: Execute: NC language element APRP <protection level>: Read: Part program APWP <protection level>: Write: Part program APRB <protection level>: Read: OPI APWB <protection level>: Write: OPI
<protection level>: Range of values: 0 ... 7 See "Attribute: Access rights (APR, APW, APRP, APWP, APRB,
APWB) (Page 39)"
<init_time>:
Point in time at which the variable is reinitializ
INIPO: Power On INIRE: End of main program, NC reset or Power On INICF: NewConfig or end of main program, NC reset or
Power On
PRLOC: End of main program, NC reset following local
change or Power On
See "Attribute: Initialization value (Page 32)"
<init_value>: Initialization value
When redefining the initialization value, an initialization time always has to be specified also (see <init_time>).
See "Attribute: Initialization value (Page 32)" For the Initializa
tion of array variables see "Definition and
initialization of array Note
Cannot be re
defined for system variables, except setting data.
BOOL, AXIS, STRING,
ed
variables (DEF, SET, REP) (Page 45)"
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
31
Flexible NC programming
1.1 Variables
Example
Redefinitions of system variable $TC_DPC1 in the data block for machine manufacturers
Program code
%_N_MGUD_DEF ; GUD block: Machine manufacturer
N100 REDEF $TC_DPC1 APWB 2 APWP 3
N200 REDEF $TC_DPC2 PHU 21
N300 REDEF $TC_DPC3 LLI 0 ULI 200
N400 REDEF $TC_DPC4 INIPO (100, 101, 102, 103)
; N100: Write access: OPI = protection level 2, part program = protection level 3
; Note
; When using ACCESS files the redefinition of access rights has to be moved from
; _N_MGUD_DEF to _N_MACCESS_DEF
; N200: Physical unit = [ % ]
; N300: Limit values: Lower limit value = 0, upper limit value = 200
; N400: The array variable is initialized with the four values at POWER ON.
; Reset of the "Access rights" and/or "Initialization time" attribute values
N800 REDEF $TC_DPC1
N900 REDEF $TC_DPC4
M30
Supplementary conditions
Granularity
A redefinition is always applied to the entire variable which is uniquely identified by its name. Array variables do not, for example, support the assignment of different attributes to individual array elements.

1.1.6 Attribute: Initialization value

Definition (DEF) of user variables
During definition an initialization value can be preassigned for the following user variables:
● Global user variables (GUD)
● Program-global user variables (PUD)
● Local user variables (LUD)
Job Planning
32 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Redefinition (REDEF) of system and user variables
During redefinition an initialization value can be preassigned for the following variables:
● System data
– Setting data
● User data
– R parameters
– Synchronized action variables ($AC_MARKER, $AC_PARAM, $AC_TIMER)
– Synchronized action GUD (SYG_xy[ ], where x=R, I, B, A, C, S and y=S, M, U, 4 to 9)
– EPS parameters
– Tool data OEM
– Magazine data OEM
– Global user variables (GUD)
Reinitialization time During redefinition the point in time can be specified at which the variable should be reinitialized, i.e. reset to the initialization value.
INIPO (POWER ON)
The variable is reinitialized at Power On.
INIRE (reset)
The variable is reinitialized on NC reset, mode group reset, at the end of the part program (
M02/M30) or at Power On.
INICF (NewConfig)
The variable is reinitialized on a NewConf request via the HMI, with part program command
NEWCONFIG or on an NC reset, mode group reset, at the end of the part program
(M02/M30) or at Power On.
PRLOC (program-local change)
The variable is only reinitialized on an NC reset, mode group reset or at the end of the part program (M02/M30) if it has changed during the current part program.
The
PRLOC attribute may only be changed in conjunction with programmable setting data
(see the table below).
Table 1- 1 Programmable setting data
1)
Number Identifier G command
42000 $SC_THREAD_START_ANGLE 42010 $SC_THREAD_RAMP_DISP DITS/DITE 42400 $SA_PUNCH_DWELLTIME 42800 $SA_SPIND_ASSIGN_TAB 43210 $SA_SPIND_MIN_VELO_G25 43220 $SA_SPIND_MAX_VELO_G26 43230 $SA_SPIND_MAX_VELO_LIMS
SF
PDELAYON SETMS G25 G26 LIMS
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
33
Flexible NC programming
1.1 Variables
Number Identifier G command 1)
43300 $SA_ASSIGN_FEED_PER_REV_SOURCE 43420 $SA_WORKAREA_LIMIT_PLUS 43430 $SA_WORKAREA_LIMIT_MINUS 43510 $SA_FIXED_STOP_TORQUE 43520 $SA_FIXED_STOP_WINDOW 43700 $SA_OSCILL_REVERSE_POS1 43710 $SA_OSCILL_REVERSE_POS2 43720 $SA_OSCILL_DWELL_TIME1 43730 $SA_OSCILL_DWELL_TIME2 43740 $SA_OSCILL_VELO 43750 $SA_OSCILL_NUM_SPARK_CYCLES 43760 $SA_OSCILL_END_POS 43770 $SA_OSCILL_CTRL_MASK 43780 $SA_OSCILL_IS_ACTIVE 43790 $SA_OSCILL_START_POS
1) This G command is used to address the setting data.
FPRAON G26 G25 FXST FXSW OSP1 OSP2 OST1 OST2 FA OSNSC OSE OSCTRL OS OSB
Supplementary conditions
Initialization value: Global user variables (GUD)
● Only
(GUD) with the
● In addition to
initialization time for global user variables (GUD) with the
● In the case of global user variables (GUD) with the
INICF (NewConfig) initialization time, for an NC reset, mode group reset and
or NewConfig, the variables are only reinitialized in the channels in which the named events were triggered.
Initialization value: FRAME data type
It is not permitted to specify an initialization value for variables of the Variables of the
Initialization value: CHAR data type
For variables of the ASCII character can be programmed in quotation marks, e.g. "A".
Initialization value: STRING data type
In the case of variables of the
quotation marks, e.g. ...= "MACHINE_1"
INIPO (Power On) can be defined as the initialization time for global user variables
NCK range of validity.
INIPO (Power On), INIRE (reset) or INICF (NewConfig) can be defined as the
CHAN range of validity.
CHAN range of validity and INIRE (reset)
FRAME data type.
FRAME data type are initialized implicitly and always with the default frame.
CHAR data type, instead of the ASCII code (0...255), the corresponding
STRING data type, the character string must be enclosed in
Initialization value: AXIS data type
In the case of variables of the
AXIS data type, for an extended address notation, the axis
identifier must be enclosed in brackets, e.g. ...=(X3).
Job Planning
34 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Initialization value: System variable
For system variables, redefinition cannot be used to define user-specific initialization values. The initialization values for the system variables are specified by the system and cannot be changed. However, redefinition can be used to change the point in time (
INIRE, INICF) at
which the system variable is reinitialized.
Implicit initialization value: AXIS data type
See also
For variables of the
AXIS data type the following implicit initialization value is used:
● System data: "First geometry axis"
● Synchronized action GUD (designation: SYG_A*), PUD, LUD: Axis identifier from machine data: MD20082 $MC_AXCONF_CHANAX_DEFAULT_NAME
Implicit initialization value: Tool and magazine data
Initialization values for tool and magazine data can be defined using the following machine data: MD17520 $MN_TOOL_DEFAULT_DATA_MASK
Note Synchronization
The synchronization of events triggering the reinitialization of a global variable when this variable is read in a different location is the sole responsibility of the user/machine manufacturer.
Variables (Page 17)

1.1.7 Attribute: Limit values (LLI, ULI)

An upper and a lower limit of the definition range can only be defined for the following data types:
● INT
● REAL
● CHAR
Definition (DEF) of user variables: Limit values and implicit initialization values
If no explicit initialization value is defined when defining a user variable of one of the above data types, the variable is set to the data type's implicit initialization value.
● INT: 0
● REAL: 0.0
● CHAR: 0
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
35
Flexible NC programming
1.1 Variables
If the implicit initialization value is outside the definition range specified by the programmed limit values, the variable is initialized with the limit value which is closest to the implicit initialization value:
● Implicit initialization value < lower limit value (LLI) initialization value = lower limit value
● Implicit initialization value > upper limit value (ULI) initialization value = upper limit value
Examples:
Program code Comment
DEF REAL GUD1 ;
DEF REAL LLI 5.0 GUD2 ;
DEF REAL ULI –5 GUD3 ;
Lower limit value = definition range limit
;
Upper limit value = definition range limit
;
No initialization value programmed
;
=> Implicit initialization value = 0.0
Lower limit value = 5.0
;
Upper limit value = definition range limit
;
=> Initialization value = 5.0
Lower limit value = definition range limit
;
Upper limit value = -5.0
;
=> Initialization value = -5.0
Redefinition (REDEF) of user variables: Limit values and current actual values
If, when the limit values of a user variable are redefined, they change to the extent that the current actual value is outside the new definition range, an alarm will be issued and the limit values will be rejected.
Note Redefinition (REDEF) of user variables
When the limit values of a user variable are redefined, care must be taken to ensure that the following values are changed consistently:
Limit values Actual value Initialization value on redefinition and automatic reinitialization on the basis of INIPO,
INIRE or INICF
See also
Variables (Page 17)
Job Planning
36 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables

1.1.8 Attribute: Physical unit (PHU)

A physical unit can only be specified for variables of the following data types:
● INT
● REAL
Programmable physical units (PHU)
The physical unit is specified as fixed point number: PHU <unit>
The following physical units can be programmed:
<unit> Meaning Physical unit
0 Not a physical unit ­1 Linear or angular position 2 Linear position 2) [ mm ], [ inch ] 3 Angular position [ degree ] 4 Linear or angular velocity 5 Linear velocity 2) [ mm/min ] 6 Angular velocity [ rpm ] 7 Linear or angular acceleration 8 Linear acceleration 2) [ m/s2 ], [ inch/s2 ]
9 Angular acceleration [ rev/s2 ] 10 Linear or angular jerk 11 Linear jerk 2) [ m/s3 ], [ inch/s3 ] 12 Angular jerk [ rev/s3 ] 13 Time [ s ] 14 Position controller gain [ 16.667/s ] 15 Revolutional feedrate 2) [ mm/rev ], [ inch/rev ] 16 Temperature compensation 18 Force [ N ] 19 Mass [ kg ] 20 Moment of inertia 3) [ kgm2 ] 21 Percent [ % ] 22 Frequency [ Hz ] 23 Voltage [ V ] 24 Current [ A ] 25 Temperature [ °C ] 26 Angle [ degree ] 27 KV [ 1000/min ] 28 Linear or angular position 3) [ mm ], [ inch ], [ degree ] 29 Cutting rate 2) [ m/min ], [ feet/min ]
1)2)
[ mm ], [ inch ], [ degree ]
1)2)
[ mm/min ], [ inch/min ], [ rpm ]
1)2)
[ m/s2 ], [ inch/s2 ], [ rev/s2 ]
1)2)
[ m/s3 ], [ inch/s3 ], [ rev/s3 ]
1)2)
[ mm ], [ inch ]
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
37
Flexible NC programming
1.1 Variables
<unit> Meaning Physical unit
30 Peripheral speed 2) [ m/s], [ feet/s ] 31 Resistance [ ohm ] 32 Inductance [ mH ] 33 Torque 3) [ Nm ] 34 Torque constant 3) [ Nm/A ] 35 Current controller gain [ V/A ] 36 Speed controller gain 3) [ Nm/(rad*s) ] 37 Speed [ rpm ] 42 Power [ kW ] 43 Current, low [ μA ] 46 Torque, low 3) [ μNm ] 48 Per mil ­49 - [ Hz/s ] 65 Flow rate [ l/min ] 66 Pressure [ bar ] 67 Volume 3) [ cm3 ] 68 Controlled-system gain 3) [ mm/(V*min) ]
69 Force controller controlled-system gain [ N/V ] 155 Thread lead 3) [ mm/rev ], [ inch/rev ] 156 Change in thread lead 3) [ mm/rev / rev ], [ inch/rev / rev ]
1) The physical unit depends on the axis type: Linear or rotary axis
2) System of units changeover G70/G71(inch/metric)
After changing over the basic system (MD10240 $MN_SCALING_SYSTEM_IS_METRIC) with G70/G71, for read/write operations to system and user variables involving a length, then the values are not converted (actual value, default value and limit values)
G700/G710(inch/metric) After changing over the basic system (MD10240 $MN_SCALING_SYSTEM_IS_METRIC) with G700/G710, for read/write operations to system and user variables involving a length, then the values are converted (actual value, default value and limit values)
3) The variable is not converted to the NC's current measuring system (inch/metric) automatically. Conversion is the sole responsibility of the user/machine manufacturer.
Note Level overflow due to format conversion
The internal storage format for all user variables (GUD/PUD/LUD) with physical units of length is metric. Excessive use of these types of variable in the NCK's main run, e.g in synchronized actions, can lead to a CPU time overflow at interpolation level when the measuring system is switched over, generating alarm 4240.
Job Planning
38 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Note Compatibility of units
When using variables (assignment, comparison, calculation, etc.) the compatibility of the units involved is not checked. Should conversion be required, this is the sole responsibility of the user/machine manufacturer.
See also
Variables (Page 17)

1.1.9 Attribute: Access rights (APR, APW, APRP, APWP, APRB, APWB)

The following protection levels, which have to be specified during programming, correspond to the access rights:
Access right Protection level System password 0 Machine manufacturer password 1 Service password 2 End user password 3 Key-operated switch position 3 4 Key-operated switch position 2 5 Key-operated switch position 1 6 Key-operated switch position 0 7
Definition (DEF) of user variables
Access rights (APR.../APW...) can be defined for the following variables:
● Global user data (GUD)
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
39
Flexible NC programming
1.1 Variables
Redefinition (REDEF) of system and user variables
Access rights (APR.../APW...) can be redefined for the following variables:
● System data
– Machine data
– Setting data
– FRAME
– Process data
– Leadscrew error compensation data (LEC)
– Sag compensation (CEC)
– Quadrant error compensation (QEC)
– Magazine data
– Tool data
– Protection zones
– Toolholder with orientation capability
– Kinematic chains
– 3D protection zones
– Working area limitation
– ISO tool data
● User data
– R parameters
– Synchronized action variables ($AC_MARKER, $AC_PARAM, $AC_TIMER)
– Synchronized action GUD (SYG_xy[ ], where x=R, I, B, A, C, S and y=S, M, U, 4 to 9)
– EPS parameters
– Tool data OEM
– Magazine data OEM
– Global user variables (GUD)
Note
During redefinition the access right can be freely assigned to a variable between the lowest protection level 7 and the dedicated protection level, e.g. 1 (machine manufacturer).
Job Planning
40 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Redefinition (REDEF) of NC language commands
The access or execution right (APX) can be redefined for the following NC language commands:
● G functions/Preparatory functions
References:
Programming Manual, Fundamentals; Section: G functions/Preparatory functions
● Predefined functions
References:
Programming Manual, Fundamentals; Section: Predefined functions
● Predefined subprogram calls
References:
Programming Manual, Fundamentals; Section: Predefined subprogram calls
DO operation with synchronized actions
● Cycles program identifier
The cycle must be saved in a cycle directory and must contain a PROC operation.
Access rights in relation to part programs and cycles (APRP, APWP)
The various access rights facilitate the following with regard to access in a part program or cycle:
APRP 0/APWP 0
– During part program processing the system password has to be set.
– The cycle has to be stored in the _N_CST_DIR directory (system).
– The execution right must be set to system for the _N_CST_DIR directory in MD11160
$MN_ACCESS_EXEC_CST.
APRP 1/APWP 1 or APRP 2/APWP 2
– During part program processing the machine manufacturer or service password has to
be set.
– The cycle has to be stored in the _N_CMA_DIR (machine manufacturer) or
_N_CST_DIR (system) directory.
– The execution rights must be set to at least machine manufacturer for the
_N_CMA_DIR or _N_CST_DIR directories in machine data MD11161 $MN_ACCESS_EXEC_CMA or MD11160 $MN_ACCESS_EXEC_CST respectively.
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
41
Flexible NC programming
1.1 Variables
APRP 3/APWP 3
– During part program processing the end user password has to be set.
– The cycle has to be stored in the _N_CUS_DIR (user), _N_CMA_DIR or _N_CST_DIR
directory.
– The execution rights must be set to at least end user for the _N_CUS_DIR,
_N_CMA_DIR or _N_CST_DIR directories in machine data MD11162 $MN_ACCESS_EXEC_CUS, MD11161 $MN_ACCESS_EXEC_CMA or MD11160 $MN_ACCESS_EXEC_CST respectively.
APRP 4...7/APWP 4...7
– During part program processing the key-operated switch must be set to 3 ... 0.
– The cycle has to be stored in the _N_CUS_DIR, _N_CMA_DIR or _N_CST_DIR
directory.
– The execution rights must be set to at least the corresponding key-operated switch
position for the _N_CUS_DIR, _N_CMA_DIR or _N_CST_DIR directories in machine data MD11162 $MN_ACCESS_EXEC_CUS, MD11161 $MN_ACCESS_EXEC_CMA or MD11160 $MN_ACCESS_EXEC_CST respectively.
Access rights in relation to OPI (APRB, APWB)
The access rights (APRB, APWB) restrict access to system and user variables via the OPI equally for all system components (HMI, PLC, external computers, EPS services, etc.).
APR/APW access attributes
Note Local HMI access rights
When changing access rights to system data, care must be taken to ensure that such changes are consistent with the access rights defined using HMI mechanisms.
For compatibility reasons, attributes APR and APW are implicitly mapped to the attributes APRP /
APRB and APWP / APWB:
APR x APRP x APRB x
APW y APWP y APWB y
Job Planning
42 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Setting access rights using ACCESS files
When using ACCESS files to assign access rights, redefinitions of access rights for system data, user data, and NC language commands may only continue to be programmed in these ACCESS files. Global user data (GUD) is an exception. For this data, access rights have to continue to be redefined (if this appears necessary) in the corresponding definition files.
For continuous access protection, the machine data for the execution rights and the access protection for the corresponding directories have to be modified consistently.
In principle, the procedure is as follows:
● Creation of the necessary definition files:
– _N_DEF_DIR/_N_SACCESS_DEF
– _N_DEF_DIR/_N_MACCESS_DEF
– _N_DEF_DIR/_N_UACCESS_DEF
● Setting of the write right for the definition files to the value required for redefinition:
– MD11170 $MN_ACCESS_WRITE_SACCESS
– MD11171 $MN_ACCESS_WRITE_MACCESS
– MD11172 $MN_ACCESS_WRITE_UACCESS
● For access to protected elements from cycles, the execution and write rights for cycle directories _N_CST_DIR, _N_CMA_DIR, and _N_CST_DIR have to be modified.
Execution rights
– MD11160 $MN_ACCESS_EXEC_CST
– MD11161 $MN_ACCESS_EXEC_CMA
– MD11162 $MN_ACCESS_EXEC_CUS
Write rights
– MD11165 $MN_ACCESS_WRITE_CST
– MD11166 $MN_ACCESS_WRITE_CMA
– MD11167 MN_ACCESS_WRITE_CUS
The execution right has to be set to at least the same protection level as the highest protection level of the element used.
The write right must be set to at least the same protection level as the execution right.
● The write rights of the local HMI cycle directories must be set to the same protection level as the local NC cycle directories.
References:
Operating Manual
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
43
Flexible NC programming
1.1 Variables
Subprogram calls in ACCESS files
To structure access protection further, subprograms (SPF or MPF identifier) can be called in ACCESS files. The subprograms inherit the execution rights of the calling ACCESS file.
Note
Only access rights can be redefined in the ACCESS files. All other attributes have to continue to be programmed/redefined in the corresponding definition files.
See also
Variables (Page 17)

1.1.10 Overview of definable and redefinable attributes

The following tables show which attributes can be defined (DEF) and/or redefined (REDEF) for which data types.
System data
Data type Init. value Limit values Physical unit Access rights Machine data --- --- --­Setting data
REDEF
--- --­FRAME data --- --- --­Process data --- --- --­Leadscrew error comp. (EEC) --- --- --­Sag compensation (CEC) --- --- --­Quadrant error compensation (QEC) --- --- --­Magazine data --- --- --­Tool data --- --- --­Protection zones --- --- --­Toolholder, with orientation capability --- --- --­Kinematic chains --- --- --­3D protection zones --- --- --­Working area limitation --- --- --­ISO tool data --- --- ---
REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF
Job Planning
44 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
User data
Data type Init. value Limit values Physical unit Access rights R-parameters Synchronized action variable ($AC_...) Synchronized action GUD (SYG_...) EPS parameters Tool data OEM Magazine data OEM Global user variables (GUD) Local user variables (PUD/LUD)
REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF REDEF
DEF/REDEF DEF DEF DEF/REDEF
DEF DEF DEF
---
See also
Variables (Page 17)

1.1.11 Definition and initialization of array variables (DEF, SET, REP)

Function
A user variable can be defined as a 1- up to a maximum of a 3-dimensional array.
● 1-dimensional:
● 2-dimensional:
● 3-dimensional:
Note
STRING data type user variables can be defined as up to a maximum of 2-dimensional arrays.
Data types
User variables can be defined as arrays for the following data types: BOOL, CHAR, INT, REAL, STRING, AXIS, FRAME
Assignment of values to array elements
Values can be assigned to array elements at the following points in time:
● During array definition (initialization values)
DEF <data type> <variable name>[<n>]
DEF <data type> <variable name>[<n>,<m>]
DEF <data type> <variable name>[<n>,<m>,<o>]
● During program execution
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
45
Flexible NC programming
1.1 Variables
Values can be assigned by means of:
● Explicit specification of an array element
● Explicit specification of an array element as a starting element and specification of a value list (
SET)
● Explicit specification of an array element as a starting element and specification of a value and the frequency at which it is repeated (
Note
REP)
FRAME data type user variables cannot be assigned initialization values.
Syntax (DEF)
DEF <data type> <variable name>[<n>,<m>,<o>] DEF STRING[<string length>] <variable name>[<n>,<m>]
Syntax (DEF...=SET...)
Using a value list:
● During definition:
DEF <data type> <variable name>[<n>,<m>,<o>]=SET(<value1>,<value2>, etc.)
Equivalent to:
DEF <data type> <variable name>[<n>,<m>,<o>]=(<value1>,<value2>, etc.)
Note
SET does not have to be specified for initialization via a value list.
● During value assignment:
<variable name>[<n>,<m>,<o>]=SET(<VALUE1>,<value2>, etc.)
Syntax (DEF...=REP...)
Using a value with repetition
● During definition:
DEF <data type> <variable name>[<n>,<m>,<o>]=REP(<value>)
DEF <data type> <variable name>[<n>,<m>,<o>]=REP(<value>, <number_array_elements>)
● During value assignment:
<variable name>[<n>,<m>,<o>]=REP(<value>)
DEF <data type> <variable name>[<n>,<m>,<o>]=REP(<value>,<number_array_elements>)
Job Planning
46 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Meaning
DEF: Command to define variables <data type>:
<string length>: Maximum number of characters for a STRING data type <variable name>: Variable name. [<n>,<m>,<o>]: Array sizes or array indices <n>:
<m>:
<o>:
SET: Value assignment using specified value list (<value1>,<value2>, etc.): Value list REP: Value assignment using specified <value> <value>: Value, which the array elements should be written when
<number_array_elements>: Number of array elements to be written with the specified
Data type of variables Range of values: for system variables:
BOOL, CHAR, INT, REAL, STRING, AXIS
for GUD or LUD variables:
BOOL, CHAR, INT, REAL, STRING, AXIS, FRAME
Array size or array index for 1st dimension Type: INT (for system variables, also AXIS) Range of values: Max. array size: 65535
Array index: 0 ≤ n ≤ 65534 Array size or array index for 2nd dimension Type: INT (for system variables, also AXIS) Range of values: Max. array size: 65535
Array index: 0 ≤ m ≤ 65534 Array size or array index for 3rd dimension Type: INT (for system variables, also AXIS) Range of values: Max. array size: 65535
Array index: 0 ≤ o ≤ 65534
initializing with
<value>. The following apply to the remaining array elements,
REP.
dependent on the point in time: Initialization when defining the array:
→ Zero is written to the remaining array elements.
Assignment during program execution:
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
→ The actual values of the array elements remain unchanged.
If the parameter is not programmed, all array elements are written with
<value>.
If the parameter equals zero, the following apply dependent on the point in time:
Initialization when defining the array:
→ All elements are pre-assigned zero
Assignment during program execution:
→ The actual values of the array elements remain unchanged.
47
Flexible NC programming
1.1 Variables
Array index
The implicit sequence of the array elements, e.g. in the case of value assignment using SET or REP, is right to left due to iteration of the array index.
Example: Initialization of a 3-dimensional array with 24 array elements:
DEF INT FELD[2,3,4] = REP(1,24)
FELD[0,0,0] = 1 FELD[0,0,1] = 1 FELD[0,0,2] = 1 FELD[0,0,3] = 1 ... FELD[0,1,0] = 1 FELD[0,1,1] = 1 ... FELD[0,2,3] = 1 FELD[1,0,0] = 1 FELD[1,0,1] = 1 ... FELD[1,2,3] = 1
1st array element 2nd array element 3rd array element 4th array element
5th array element 6th array element
12th array element 13th array element 14th array element
24th array element
corresponding to:
FOR n=0 TO 1
FOR m=0 TO 2
FOR o=0 TO 3
ENDFOR
FELD[n,m,o] = 1
ENDFOR
ENDFOR
Example: Initializing complete variable arrays
For the actual assignment, refer to the diagram.
Program code
N10 DEF REAL FELD1[10,3]=SET(0,0,0,10,11,12,20,20,20,30,30,30,40,40,40,)
N20 ARRAY1[0,0] = REP(100)
N30 ARRAY1[5,0] = REP(-100)
N40 FELD1[0,0]=SET(0,1,2,-10,-11,-12,-20,-20,-20,-30, , , ,-40,-40,-50,-60,-70)
N50 FELD1[8,1]=SET(8.1,8.2,9.0,9.1,9.2)
Job Planning
48 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
$UUD\LQGH[

GHILQLWLRQ




7KHDUUD\HOHPHQWV>@WR >@KDYHEHHQLQLWLDOL]HG ZLWKWKHGHIDXOWYDOXH




,QLWLDOL]DWLRQIRU
1




11
,QLWLDOL]DWLRQZLWK LGHQWLFDOYDOXH






























11,QLWLDOL]DWLRQZLWK YDULRXVYDOXHV








7KHDUUD\HOHPHQWV>@WR >@KDYHEHHQLQLWLDOL]HG ZLWKWKHGHIDXOWYDOXH 7KHDUUD\HOHPHQWV>@WR >@KDYHQRWEHHQFKDQJHG
















See also
Definition and initialization of array variables (DEF, SET, REP): Further Information (Page 49)
Variables (Page 17)

1.1.12 Definition and initialization of array variables (DEF, SET, REP): Further Information

Further information (SET)
initialization during definition
● Starting with the 1st array element, as many array elements are assigned with the values from the value list as there are elements programmed in the value list.
● A value of 0 is assigned to array elements without explicitly declared values in the value list (gaps in the value list).
● For variables of the AXIS data type, gaps in the value list are not permitted.
● If the value list contains more values than there are array elements defined, an alarm will be displayed.
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
49
Flexible NC programming
1.1 Variables
Value assignment in program execution
In the case of value assignment in program execution, the rules described above for definition apply. The following options are also supported:
● Expressions are also permitted as elements in the value list.
● Value assignment starts with the programmed array index. Values can be assigned selectively to subarrays.
Example:
Program code Comments
DEF INT ARRAY[5,5] ; Array definition
ARRAY[0,0]=SET(1,2,3,4,5) ; Value assignment to the first 5 array
elements [0,0] - [0,4]
FELD[0,0]=SET(1,2, , ,5) ; Value assignment with gap to the first 5
array elements [0,0] - [0,4], array elements[0,2] and [0,3] = 0
ARRAY[2,3]=SET(VARIABLE,4*5.6) ; Value assignment with variable and
expression starting at array index [2,3]: [2,3] = VARIABLE [2,4] = 4 * 5.6 = 22.4
Further information (REP)
initialization during definition
● All or the optionally specified number of array elements are initialized with the specified value (constant).
● Variables of the FRAME data type cannot be initialized.
Example:
Program code Comments
DEF REAL varName[10]=REP(3.5,4) ; Initialize array definition and array
Value assignment in program execution
In the case of value assignment in program execution, the rules described above for definition apply. The following options are also supported:
● Expressions are also permitted as elements in the value list.
● Value assignment starts with the programmed array index. Values can be assigned selectively to subarrays.
Examples:
Program code Comments
DEF REAL varName[10] ; Array definition
varName[5]=REP(4.5,3) ; Array elements [5] to [7] = 4.5
elements [0] to [3] with value 3.5.
Job Planning
50 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Program code Comments
R10=REP(2.4,3) ; R-parameters R10 to R12 = 2.4
DEF FRAME FRM[10] ; Array definition
FRM[5] = REP(CTRANS (X,5)) ; Array elements [5] to [9] = CTRANS(X,5)
Further information (general)
Value assignments to axial machine data
In principle axial machine data have an array index of the value assignments to an axial item of machine data using
AXIS data type. In the case of SET or REP, this array index is
ignored or not processed.
Example: Value assignment to machine data MD36200 $MA_AX_VELO_LIMIT
$MA_AX_VELO_LIMIT[1,AX1]=SET(1.1, 2.2, 3.3)
Is equivalent to:
$MA_AX_VELO_LIMIT[1,AX1] = 1.1 $MA_AX_VELO_LIMIT[2,AX1] = 2.2 $MA_AX_VELO_LIMIT[3,AX1] = 3.3
Note Value assignments to axial machine data
In the case of value assignments to axial machine data using
SET or REP, the AXIS data type
array index is ignored or not processed.
Memory requirements
Data type Memory requirement per element
BOOL CHAR INT REAL STRING FRAME AXIS
1 byte 1 byte 4 bytes 8 bytes (string length + 1) bytes 400 bytes, depending on the number of axes 4 bytes
See also
Definition and initialization of array variables (DEF, SET, REP) (Page 45)
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
51
Flexible NC programming
1.1 Variables

1.1.13 Data types

The following data types are available in the NC:
Data type Significance Value Range INT Integer with sign -2147483648 ... +2147483647 REAL Real number (LONG REAL to IEEE) ±(2.2*10 BOOL Truth value TRUE (1) and FALSE (0) 1, 0 CHAR ASCII character ASCII code 0 to 255 STRING Character string of a defined length Maximum of 200 characters (no special characters) AXIS Axis/spindle identifier Channel axis identifier FRAME Geometric parameters for static coordinate
transformation (translation, rotation, scaling, mirroring)
---
-308
1.8*10
Implicit data type conversions
The following data type conversions are possible and are performed implicitly during assignments and parameter transfers:
+308
)
See also
from ↓/ to → REAL INT BOOL REAL x o & INT x x & BOOL x x x x : Possible without restrictions o: Data loss possible due to the range of values being overshot alarm;
rounding: decimal place value ≥ 0.5 round up, decimal place value < 0.5 round down &: value ≠ 0 TRUE, value== 0 FALSE
Variables (Page 17)
Job Planning
52 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables

1.1.14 Explicit data type conversions (AXTOINT, INTTOAX)

Function
The data type of an axis variable can be converted explicitly with the predefined functions AXTOINT and INTTOAX.
Type conversion AXIS → INT
Syntax:
<result>=AXTOINT(<value>)
Meaning:
<result>:
AXTOINT: AXTOINT converts the data type of a axis variable from AXIS to INT <value>:
INT representation of the axis variables ( axis index <n>) In case of fault = 7 NO_AXIS, i.e. <value> contains the value "no axis" = -1 <value> is not an axis name of type AXIS
Geometry axis name (MD20060 $MC_AXCONF_GEOAX_NAME_TAB[<n>]) or Channel axis name (MD20080 $MC_AXCONF_CHANAX_NAME_TAB[<n>]) or Machine axis name (MD10000 $MN_AXCONF_MACHAX_NAME_TAB[<n>]) Data type: AXIS
Type conversion INT → AXIS
Syntax:
<result>=INTTOAX(<value>)
<result>:
INTTOAX: INTTOAX converts the data type of a axis variable from INT to AXIS
AXIS representation of the axis variables ( axis name) In case of fault = NO_AXIS <value> contains the value "no axis"? = -1 <value> is an INT value for which there is no axis name of type
INT value of the axis variables <value>: Range of
values:
Example
See example of GETVARDFT at "Read attribute values / data type (GETVARPHU, GETVARAP, GETVARLIM, GETVARDFT, GETVARTYP) (Page 56)".
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
AXIS?
0 - 32
53
Flexible NC programming
1.1 Variables

1.1.15 Check availability of a variable (ISVAR)

Function
The predefined ISVAR function can be used to check whether a system/user variable (e.g. machine data, setting data, system variable, general variables such as GUD) is known in the NCK.
Syntax
<Result>=ISVAR(<variable>)
Meaning
The transfer parameter
Undimensioned $ variable:
One-dimensional $ variable without array index:
One-dimensional $ variable with array index:
Two-dimensional $ variable without array index:
Two-dimensional $ variable with array index:
<result>:
ISVAR: Checks whether system/user variable is known in the NCK
<variable> can be set up as follows:
$<identifier>
$<identifier>[ ]
$<identifier>[<n>]
$<identifier>[,]
$<identifier>[<n>,<m>]
Return value Data type: BOOL Range of values:
Name of the system/user variables <identifier>: Data type: STRING Array index for first dimension <n>: Data type: INT Array index for second dimension <m>: Data type: INT
1 Variable available 0 Variable unknown
The following checks are made in accordance with the transfer parameter:
● Does the identifier exist
● Is it a 1- or 2-dimensional array
● Is the array index permitted
Only if all these checks have a positive result will TRUE (1) be returned. If a check has a negative result or if a syntax error has occurred, it will return FALSE (0).
Job Planning
54 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Examples
Program code Comment
DEF INT VAR1
DEF BOOL IS_VAR=FALSE
N10 IS_VAR=ISVAR("VAR1") ; IS_VAR is in this case TRUE.
Program code Comment
DEF REAL VARARRAY[10,10]
DEF BOOL IS_VAR=FALSE
N10 IS_VAR=ISVAR("VARARRAY[,]") ; IS_VAR is in this case TRUE, is a two-
dimensional array.
N20 IS_VAR=ISVAR("VARARRAY") ; IS_VAR is TRUE, variable exists.
N30 IS_VAR=ISVAR("VARARRAY[8,11]") ; IS_VAR is FALSE, array index is not
permitted.
N40 IS_VAR=ISVAR("VARARRAY[8,8") ; IS_VAR is FALSE, "]" missing (syntax
error).
N50 IS_VAR=ISVAR("VARARRAY[,8]") ; IS_VAR is TRUE, array index is
permitted.
N60 IS_VAR=ISVAR("VARARRAY[8,]") ; IS_VAR is TRUE, array index is
permitted.
Program code Comment
DEF BOOL IS_VAR=FALSE
N100 IS_VAR=ISVAR("$MC_GCODE_RESET_VALUES[1]" ; Transfer parameter is a
machine data item, IS_VAR is TRUE.
Program code Comment
DEF BOOL IS_VAR=FALSE
N10 IS_VAR=ISVAR("$P_EP") ; IS_VAR is in this case TRUE.
N20 IS_VAR=ISVAR("$P_EP[X]") ; IS_VAR is in this case TRUE.
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
55
Flexible NC programming
1.1 Variables

1.1.16 Read attribute values / data type (GETVARPHU, GETVARAP, GETVARLIM, GETVARDFT, GETVARTYP)

The attribute values of system/user variables can be read with the predefined GETVARPHU, GETVARAP, GETVARLIM and GETVARDFT functions, the data type of a system/user variable with GETVARTYP.
Read physical unit
Syntax:
<Result>=GETVARPHU(<name>)
Meaning:
<result>:
GETVARPHU: Reading of the physical unit of a system/user variable <name>: Name of the system/user variables
Data type: STRING
Numeric value of the physical unit Data type: INT Range of
values:
See Table in "Attribute: Physical unit (PHU) (Page 37)" In case of fault
- 2 The specified <name> has not been assigned to a system parameter or a user variable.
Example:
The NCK contains the following GUD variables:
DEF CHAN REAL PHU 42 LLI 0 ULI 10000 electric
Program code Comment
DEF INT result=0
result=GETVARPHU("electric") ; Determine the physical unit of the GUD
variables.
IF (result < 0) GOTOF error
The value 42 is returned as result. This corresponds to the physical unit [kW].
Note
GETVARPHU can be used, for example, to check whether both variables have the expected physical units in a variable assignment a = b.
Job Planning
56 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Read access right
Syntax:
<Result>=GETVARAP(<name>,<access>)
Meaning:
<result>:
GETVARAP: Reading of the access right to a system/user variable
<access>:
Protection level for the specified <access> Data type: INT Range of
values:
0 ... 7 See "Attribute: Access rights (APR, APW, APRP,
APWP, APRB, APWB) (Page 39)".
In case of fault
- 2 The specified <name> has not been assigned to a system parameter or a user variable.
- 3 Incorrect value for
Name of the system/user variables <name>: Data type: STRING Type of access Data type: STRING Range of
values:
"RP": Read via part program "WP": Write via part program "RB": Read via OPI "WB": Write via OPI
<access>
Example:
Program code Comment
DEF INT result=0
result=GETVARAP("$TC_MAP8","WB") ; Determine the access protection for
the system parameter "magazine position" with regard to writing via OPI.
IF (result < 0) GOTOF error
The value 7 is returned as result. This corresponds to the key switch position 0 (= no access protection).
Note
GETVARAP can be used, for example, to implement a checking program that checks the access rights expected by the application.
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
57
Flexible NC programming
1.1 Variables
Read limit values
Syntax:
<Status>=GETVARLIM(<name>,<limit value>,<result>)
Meaning:
<Status>:
GETVARLIM: Reading of the lower/upper limit value of a system/user variables
<limit value>:
Function status Data type: INT Range of
values:
1 OK
-1 No limit value defined (for variables of type AXIS, STRING, FRAME)
-2 The specified <name> has not been assigned to a system parameter or a user variable.
-3 Incorrect value for
<limit value>
Name of the system/user variables <name>: Data type: STRING specifies which limit value should be read out Data type: CHAR Range of
values:
"L": = lower limit value "U": = upper limit value
Return of the limit value <result>: Data type: VAR REAL
Example:
Program code Comment
DEF INT state=0
DEF REAL result=0
state=GETVARLIM("$MA_MAX_AX_VELO","L",result) ; Determine the lower limit
value for MD32000 $MA_MAX_AX_VELO.
IF (result < 0) GOTOF error
Job Planning
58 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.1 Variables
Read default value
Syntax:
<Status>=GETVARDFT(<name>,<result>[,<index_1>,<index_2>,<index_3>])
Meaning:
<Status>:
GETVARDFT: Reading of the default value of a system/user variable
<result>:
<index_1>:
<index_2>:
<index_3>:
Function status Data type: INT Range of
values:
Name of the system/user variables <name>: Data type: STRING Return of the default value Data type:
Index to the first dimension (optional) Data type: INT Not programmed means = 0 Index to the second dimension (optional) Data type: INT Not programmed means = 0 Index to the third dimension (optional) Data type: INT Not programmed means = 0
1 OK
-1 No default value available (e.g. because <result> has the wrong type for <name>)
-2 The specified <name> has not been assigned to a system parameter or a user variable.
-3 Incorrect value for <index_1>, dimension less than one (= no array = scalar)
-4 Incorrect value for <index_2>
-5 Incorrect value for <index_3>
VAR REAL (when reading the default value of variables of the types INT, REAL, BOOL, AXIS)
VAR STRING (when reading the default value of variables of the types STRING and CHAR)
VAR FRAME (when reading the default value of variables of the type FRAME)
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
59
Flexible NC programming
1.1 Variables
Example:
Program code Comment
DEF INT state=0
DEF REAL resultR=0 ; Variable to accept the default
values of the types INT, REAL, BOOL, AXIS.
DEF FRAME resultF=0 ; Variable to accept the default
values of the type FRAME
IF (GETVARTYP("$MA_MAX_AX_VELO") <> 4) GOTOF error
state=GETVARDFT("$MA_MAX_AX_VELO", resultR, AXTOINT(X)) ; Determine the default value of
the "X" axis.
; AXTOINT converts the axis name
"X" to the appropriate access index.
IF (result < 0) GOTOF error
IF (GETVARTYP("$TC_TP8") <> 3) GOTOF error
state=GETVARDFT("$TC_TP8", resultR)
IF (GETVARTYP("$P_UBFR") <> 7) GOTOF error
state=GETVARDFT("$P_UBFR", resultF )
Read data type
Syntax:
<Result>=GETVARTYP(<name>)
Meaning:
<result>:
GETVARTYP: Reading of the data type of a system/user variable
Data type of the specified system/user variables Data type: INT Range of
values:
1 = BOOL 2 = CHAR 3 = INT 4 = REAL 5 = STRING 6 = AXIS 7 = FRAME In case of fault < 0 The specified
<name> has not been assigned to a system
parameter or a user variable.
Name of the system/user variables <name>: Data type: STRING
Job Planning
60 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.2 Indirect programming
Example:
Program code Comment
DEF INT result=0
DEF STRING name="R"
result=GETVARTYP(name) ; Determine the type of the R parameter.
IF (result < 0) GOTOF error
The value 4 is returned as result. This corresponds to the REAL data type.

1.2 Indirect programming

1.2.1 Indirectly programming addresses

Function
Syntax
Meaning
When indirectly programming addresses, the extended address (<index>) is replaced by a variable with a suitable type.
Note
It is not possible the indirectly program addresses for:
N (block number) L (subprogram) Settable addresses
(e.g. X[1] instead of X1 is not permissible)
<ADDRESS>[<Index>]
Element Description
<ADDRESS>[...]: Fixed address with extension (index)
<index>: Variable, e.g. for spindle number, axis, ....
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
61
Flexible NC programming
1.2 Indirect programming
Examples
Example 1: Indirectly programming a spindle number
Direct programming:
Program code Comment
S1=300 ; Speed in rpm for the spindle number 1.
Indirect programming:
Program code Comment
DEF INT SPINU=1 ; Defining variables, type INT and value assignment.
S[SPINU]=300 ; Speed 300 rpm for the spindle, whose number is saved in
the SPINU variable (in this example 1, the spindle with the number 1).
Example 2: Indirectly programming an axis
Direct programming:
Program code Comment
FA[U]=300 ; Feed rate 300 for axis "U".
Indirect programming:
Program code Comment
DEF AXIS AXVAR2=U ; Defining a variable, type AXIS and value assignment.
FA[AXVAR2]=300 ; Feed rate of 300 for the axis whose address name is saved
in the variables with the name AXVAR2.
Example 3: Indirectly programming an axis
Direct programming:
Program code Comment
$AA_MM[X] ; Read probe measured value (MCS) of axis "X".
Indirect programming:
Program code Comment
DEF AXIS AXVAR3=X ; Defining a variable, type AXIS and value assignment.
$AA_MM[AXVAR3] ; Read probe measured value (MCS) whose name is saved in the
variables AXVAR3.
Job Planning
62 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.2 Indirect programming
Example 4: Indirectly programming an axis
Direct programming:
Program code
X1=100 X2=200
Indirect programming:
Program code Comment
DEF AXIS AXVAR1 AXVAR2 ; Defining two type AXIS variables.
AXVAR1=(X1) AXVAR2=(X2) ; Assigning the axis names.
AX[AXVAR1]=100 AX[AXVAR2]=200 ; Traversing the axes whose address names are
saved in the variables with the names AXVAR1 and AXVAR2
Example 5: Indirectly programming an axis
Direct programming:
Program code
G2 X100 I20
Indirect programming:
Program code Comment
DEF AXIS AXVAR1=X ; Defining a variable, type AXIS and value
assignment.
G2 X100 IP[AXVAR1]=20 ; Indirect programming the center point data for
the axis, whose address name is saved in the variable with the name AXVAR1.
Example 6: Indirectly programming array elements
Direct programming:
Program code Comment
DEF INT ARRAY1[4,5] ; Defining array 1
Indirect programming:
Program code Comment
DEFINE DIM1 AS 4 ; For array dimensions, array sizes must be
specified as fixed values.
DEFINE DIM2 AS 5
DEF INT ARRAY[DIM1,DIM2]
ARRAY[DIM1-1,DIM2-1]=5
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
63
Flexible NC programming
1.2 Indirect programming
Example 7: Indirect subprogram call
Program code Comment
CALL "L" << R10 ; Call the program, whose number is located in R10
(string cascading).

1.2.2 Indirectly programming G codes

Function
Indirect programming of G codes permits cycles to be effectively programmed.
Syntax
G[<group>]=<number>
Meaning
G[...]: G command with extension (index) <group>:
Index parameter: G function group Type: INT
<number>:
Variable for the G code number Type: INT or REAL
Note
Generally, only G codes that do not determine the syntax can be indirectly programmed.
Only G function group 1 is possible from the G codes that determine the syntax. The syntax-determining G codes of G function groups 2, 3 and 4 are not possible.
Note
Arithmetic functions are not permitted in the indirect G code programming. If it is necessary to calculate the G code number, this must be done in a separate part program line before the indirect G code programming.
Job Planning
64 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.2 Indirect programming
Examples
Example 1: Settable zero offset (G function group 8)
Program code Comment
N1010 DEF INT INT_VAR
N1020 INT_VAR=2
...
N1090 G[8]=INT_VAR G1 X0 Y0 ; G54
N1100 INT_VAR=INT_VAR+1 ; G code calculation
N1110 G[8]=INT_VAR G1 X0 Y0 ; G55
Example 2: Level selection (G function group 6)
Program code Comment
N2010 R10=$P_GG[6] ; read active G function of G function
group 6
...
N2090 G[6]=R10
References
For information on the G function groups, see: Programming Manual, Fundamentals; Section "G function groups"

1.2.3 Indirectly programming position attributes (GP)

Function
Position attributes, e.g. the incremental or absolute programming of the axis position, can be indirectly programmed as variables in conjunction with the key word
Application
The indirect programming of position attributes is used in replacement cycles, as in this case, the following advantage exists over programming position attributes as keyword (e.g.
IC, AC, ...):
As a result of the indirect programming as variable, no would otherwise branch for all possible position attributes.
GP.
CASE instruction is required, which
Syntax
<POSITIONING COMMAND>[<axis/spindle>]= GP(<position>,<position attribute) <axis/spindle>=BP(<position>,<position attribute)
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
65
Flexible NC programming
1.2 Indirect programming
Meaning
<POSITIONING COMMAND>[]: The following positioning commands can be programmed
together with the key word GP:
POS, POSA,SPOS, SPOSA
Also possible: All axis and spindle identifiers present in the channel:
<axis/spindle>
Variable axis/spindle identifier
<axis/spindle>: Axis/spindle that is to be positioned GP(): Key word for positioning <position>: Parameter 1
Axis/spindle position as constant or variable
<position attribute>: Parameter 2
Position attribute (e.g. position approach mode as a variable (e.g. $P_SUB_SPOSMODE) or as key word (IC, AC, ...)
AX
The values supplied from the variables have the following significance:
Value Meaning Permissible for: 0 No change to the position attribute 1 AC POS, POSA,SPOS, SPOSA,AX, axis address 2 IC POS, POSA,SPOS, SPOSA,AX, axis address 3 DC POS, POSA,SPOS, SPOSA,AX, axis address 4 ACP POS, POSA,SPOS, SPOSA,AX, axis address 5 ACN POS, POSA,SPOS, SPOSA,AX, axis address 6 OC ­7 PC ­8 DAC POS, POSA,AX, axis address 9 DIC POS, POSA,AX, axis address 10 RAC POS, POSA,AX, axis address 11 RIC POS, POSA,AX, axis address 12 CAC POS, POSA 13 CIC POS, POSA 14 CDC POS, POSA 15 CACP POS, POSA 16 CACN POS, POSA
Job Planning
66 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.2 Indirect programming
Example
For an active synchronous spindle coupling between the leading spindle S1 and the following spindle S2, the following replacement cycle to position the spindle is called using
SPOS command in the main program.
the
Positioning is realized using the instruction in
N2230:
SPOS[1]=GP($P_SUB_SPOSIT,$P_SUB_SPOSMODE) SPOS[2]=GP($P_SUB_SPOSIT,$P_SUB_SPOSMODE)
The position to be approached is read from the system variable $P_SUB_SPOSIT; the position approach mode is read from the system variable $P_SUB_SPOSMODE.
Program code Comment
N1000 PROC LANG_SUB DISPLOF SBLOF
...
N2100 IF($P_SUB_AXFCT==2)
N2110 ; Replacement of the SPOS / SPOSA / M19
command for an active synchronous spindle coupling
N2185 DELAYFSTON ; Start of Stop delay area
N2190 COUPOF(S2,S1) ; Deactivate synchronous spindle
coupling
N2200 ; Position leading and following spindle
N2210 IF($P_SUB_SPOS==TRUE) OR ($P_SUB_SPOSA==TRUE)
N2220 ; Positioning the spindle with SPOS:
N2230 SPOS[1]=GP($P_SUB_SPOSIT,$P_SUB_SPOSMODE)
SPOS[2]=GP($P_SUB_SPOSIT,$P_SUB_SPOSMODE)
N2250 ELSE
N2260 ; Positioning the spindle using M19:
N2270 M1=19 M2=19 ; Position leading and following spindle
N2280 ENDIF
N2285 DELAYFSTOF ; End of Stop delay area
N2290 COUPON(S2,S1) ; Activate synchronous spindle coupling
N2410 ELSE
N2420 ; Query on further replacements
...
N3300 ENDIF
...
N9999 RET
Supplementary conditions
● The indirect programming of position attributes is not possible in synchronized actions.
References
Function Manual Basic Functions; BAG, Channel, Program Operation, Reset Response (K1), Section: Replacement of NC functions by subprograms
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
67
Flexible NC programming
1.2 Indirect programming

1.2.4 Indirectly programming part program lines (EXECSTRING)

Function
Using the part program command EXECSTRING, it is possible to execute a previously generated string variable as part program line.
Syntax
EXECSTRING is programmed in a separate part program line:
EXECSTRING (<string_variable>)
Meaning
EXECSTRING: Command to execute a string variable as part program line <string variable>: Type STRING variable, that includes the actual part program line
to be executed
Note
Example
With
EXECSTRING all part program constructions that can be programmed in the program
section of a part program can be extracted. This means that
PROC and DEF instructions are
excluded as well as the general use in INI and DEF files.
Program code Comment
N100 DEF STRING[100] BLOCK ; Definition of string variables to
accept the part program line to be executed.
N110 DEF STRING[10] MFCT1="M7"
...
N200 EXECSTRING(MFCT1 << "M4711") ; Execute part program line "M7 M4711".
...
N300 R10=1
N310 BLOCK="M3"
N320 IF(R10)
N330 BLOCK = BLOCK << MFCT1
N340 ENDIF
N350 EXECSTRING(BLOCK) ; Execute part program line "M3 M7".
Job Planning
68 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.3 Arithmetic functions

1.3 Arithmetic functions

Function
The arithmetic functions are primarily for R parameters and variables (or constants and functions) of type REAL. The types INT and CHAR are also permitted.
Operator / arithmetic function Meaning
+
­* /
DIV
MOD
: Sin() COS() TAN() ASIN() ACOS() ATAN2(,) SQRT() ABS() POT() TRUNC()
ROUND() LN() EXP() MINVAL ()
MAXVAL ()
Addition Subtraction Multiplication Division Notice:
(type INT)/(type INT)=(type REAL); example: 3/4 = 0.75 Division, for variable type INT and REAL Notice:
(type INT)DIV(type INT)=(type INT); example: 3 DIV 4 = 0 Modulo division (only for type INT) supplies remainder of an
INT division Example: 3 MOD 4 = 3 Chain operator (for FRAME variables) Sine Cosine Tangent Arc sine Arc cosine Arc tangent 2 Square root Absolute value 2nd power (square) Integer component The accuracy for comparison commands can be set using
TRUNC (see "Precision correction on comparison errors
RUNC) (Page 73)")
(T Round to integer Natural logarithm Exponential function Lower value of two variables (see "Variable minimum, maximum and range (MINVAL,
MAXVAL and BOUND) (
Page 74)") Larger value of two variables (see "Variable minimum, maximum and range (MINVAL,
MAXVAL and BOUND) (
Page 74)")
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
69
Flexible NC programming
1.3 Arithmetic functions
Programming
Examples
BOUND ()
Variable value within the defined value range (see "Variable minimum, maximum and range (MINVAL,
CTRANS() CROT () CSCALE() CMIRROR()
MAXVAL and BOUND) ( Offset Rotation Change of scale Mirroring
Page 74)")
The usual mathematical notation is used for arithmetic functions. Priorities for execution are indicated by parentheses. Angles are specified for trigonometry functions and their inverse functions (right angle = 90°).
Example 1: ATAN2
The arithmetic function ATAN2 calculates the angle
5 $7$1

of the total vector from two mutually perpendicular vectors.
The result is in one of four
VWYHFWRU
QGYHFWRU
$QJOH r

quadrants (-180° < 0 < +180°).
The angular reference is
5 $7$1
$QJOH r

always based on the 2nd value in the positive direction.
VWYHFWRU

QGYHFWRU
Example 2: Initializing complete variable arrays
Program code Comment
R1=R1+1 ; New R1 = old R1 +1
R1=R2+R3 R4=R5-R6 R7=R8*R9
R10=R11/R12 R13=SIN(25.3)
R14=R1*R2+R3 ; Multiplication or division takes precedence
over addition or subtraction.
Job Planning
70 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.4 Comparison and logic operations
Program code Comment
R14=(R1+R2)*R3 ; Parentheses are calculated first.
R15=SQRT(POT(R1)+POT(R2)) ; Inner parentheses are resolved first:
R15 = square root of (R1+R2)
RESFRAME=FRAME1:FRAME2
FRAME3=CTRANS(…):CROT(…)
; The concatenation operator links frames
to form a resulting frame or assigns values to frame components.

1.4 Comparison and logic operations

Function
Comparison operations can be used, for example, to formulate a jump condition. Complex expressions can also be compared.
Programming
The comparison operations are applicable to variables of type code value is compared with the For types for
STRING, AXIS and FRAME, the following are possible: == and <>, which can be used
STRING type operations, even in synchronous actions.
The result of comparison operations is always of
CHAR type.
BOOL type.
Logic operators are used to link truth values.
The logical operations can only be applied to type applied to the
CHAR, INT and REAL data types via internal type conversion.
BOOL variables. However, they can also be
For the logic (Boolean) operations, the following applies to the types:
● 0 corresponds to: FALSE
● Not equal to 0 means: TRUE
Bit-by-bit logic operators
Logic operations can also be applied to single bits of types
CHAR and INT. Type conversion is
automatic.
Relational operator Meaning
== <> > < >= <=
Equal to Not equal to Greater than Less than Greater than or equal to Less than or equal to
CHAR, INT, REAL and BOOL. The
BOOL, CHAR, INT and REAL data
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
71
Flexible NC programming
1.4 Comparison and logic operations
Logic operator Meaning
AND
OR
NOT
XOR
AND OR Negation Exclusive OR
Bit-by-bit logic operator Meaning
B_AND
B_OR
B_NOT
B_XOR
Bit-by-bit AND Bit-by-bit OR Bit-by-bit negation Bit-by-bit exclusive OR
Note
In arithmetic expressions, the execution order of all the operators can be specified by parentheses, in order to override the normal priority rules.
Note
Examples
Spaces must be left between BOOLEAN operands and operators.
Note
The operator
B_NOT only refers to one operand. This is located after the operator.
Example 1: Comparison operators
IF R10>=100 GOTOF DEST
or
R11=R10>=100 IF R11 GOTOF DEST
The result of the
R10>=100 comparison is first buffered in R11.
Example 2: Logic operators
IF (R10<50) AND ($AA_IM[X]>=17.5) GOTOF DESTINATION
or
IF NOT R10 GOTOB START
NOT only refers to one operand.
Example 3: Bit-by-bit logic operators
IF $MC_RESET_MODE_MASK B_AND 'B10000' GOTOF ACT_PLANE
Job Planning
72 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.5 Precision correction on comparison errors (TRUNC)

1.5 Precision correction on comparison errors (TRUNC)

Function
The TRUNC command truncates the operand multiplied by a precision factor.
Settable precision for comparison commands
Program data of type REAL are displayed internally with 64 bits in IEEE format. This display format can cause decimal numbers to be displayed imprecisely and lead to unexpected results when compared with the ideally calculated values.
Relative equality
To prevent the imprecision caused by the display format from interfering with program flow, the comparison commands do not check for absolute equality but for relative equality.
Syntax
Precision correction on comparison errors
Significance
TRUNC (R1*1000)
TRUNC: Truncate decimal places
Relative quality of 10
-12
taken into account for
● Equality: (==)
● Inequality: (<>)
● Greater than or equal to: (>=)
● Less than or equal to: (<=)
● Greater/less than: (><) with absolute equality
● Greater than: (>)
● Less than: (<)
Compatibility
For compatibility reasons, the check for relative quality for (>) and (<) can be deactivated by setting machine data MD10280 $MN_ PROG_FUNCTION_MASK Bit0 = 1.
Note
Comparisons with data of type REAL are subject to a certain imprecision for the above reasons. If deviations are unacceptable, use INTEGER calculation by multiplying the operands by a precision factor and then truncating with TRUNC.
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
73
Flexible NC programming
1.6 Variable minimum, maximum and range (MINVAL, MAXVAL and BOUND)
Synchronized actions
The response described for the comparison commands also applies to synchronized actions.
Examples
Example 1: Precision considerations
Program code Comments
N40 R1=61.01 R2=61.02 R3=0.01 ; Assignment of initial values
N41 IF ABS(R2-R1) > R3 GOTOF ERROR ; Jump would have been executed up
until now
N42 M30 ; End of program
N43 ERROR: SETAL(66000) ;
R1=61.01 R2=61.02 R3=0.01 ; Assignment of initial values
R11=TRUNC(R1*1000) R12=TRUNC(R2*1000) R13=TRUNC(R3*1000)
IF ABS(R12-R11) > R13 GOTOF ERROR ; Jump is no longer executed
M30 ; End of program
ERROR: SETAL(66000) ;
; Accuracy correction
Example 2: Calculate and evaluate the quotient of both operands
Program code Comments
R1=61.01 R2=61.02 R3=0.01 ; Assignment of initial values
IF ABS((R2-R1)/R3)-1) > 10EX-5 GOTOF ERROR ; Jump is not executed
M30 ; End of program
ERROR: SETAL(66000) ;

1.6 Variable minimum, maximum and range (MINVAL, MAXVAL and BOUND)

Function
The MINVAL and MAXVAL commands can be used to compare the values of two variables. The smaller value (in the case of delivered as a result.
The
BOUND command can be used to test whether the value of a test variable falls within a
defined range of values.
MINVAL) or the larger value (in the case of MAXVAL) respectively is
Syntax
<smaller value>=MINVAL(<variable1>,<variable2>) <larger value>=MAXVAL(<variable1>,<variable2>) <return value>=<BOUND>(<minimum>,<maximum>,<test variable>)
Job Planning
74 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.6 Variable minimum, maximum and range (MINVAL, MAXVAL and BOUND)
Meaning
MINVAL: Obtains the smaller value of two variables (<variable1>,
<variable2>)
<smaller value>: Result variable for the MINVAL command
Set to the smaller variable value.
MAXVAL: Obtains the larger value of two variables (<variable1>,
<variable2>)
<larger value>: Result variable for the MAXVAL command
Set to the larger variable value.
BOUND: Tests whether a variable (<test variable) is within a defined range
of values.
<minimum>: Variable which defines the minimum value of the range of values. <maximum>: Variable which defines the maximum value of the range of values. <return value>: Result variable for the BOUND command
If the value of the test variable is within the defined range of values, the result variable is set to the value of the test variable.
If the value of the test variable is greater than the maximum value, the result variable is set to the maximum value of the definition range.
If the value of the test variable is less than the minimum value, the result variable is set to the minimum value of the definition range.
Note
MINVAL, MAXVAL, and BOUND can also be programmed in synchronized actions.
Note Behavior if values are equal
If the values are equal
MINVAL/MAXVAL are set to this equal value. In the case of BOUND the
value of the variable to be tested is returned again.
Example
Program code Comment
DEF REAL rVar1=10.5, rVar2=33.7, rVar3, rVar4, rVar5, rValMin, rValMax, rRetVar
rValMin=MINVAL(rVar1,rVar2) ; rValMin is set to value 10.5.
rValMax=MAXVAL(rVar1,rVar2) ; rValMax is set to value 33.7.
rVar3=19.7
rRetVar=BOUND(rVar1,rVar2,rVar3) ; rVar3 is within the limits, rRetVar is set to 19.7.
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
75
Flexible NC programming
1.7 Priority of the operations
Program code Comment
rVar3=1.8
rRetVar=BOUND(rVar1,rVar2,rVar3) ; rVar3 is below the minimum limit, rRetVar is set to
10.5.
rVar3=45.2
rRetVar=BOUND(rVar1,rVar2,rVar3) ; rVar3 is above the maximum limit, rRetVar is set to
33.7.

1.7 Priority of the operations

Function
Each operator is assigned a priority. When an expression is evaluated, the operators with the highest priority are always applied first. Where operators have the same priority, the evaluation is from left to right.
In arithmetic expressions, the execution order of all the operators can be specified by parentheses, in order to override the normal priority rules.
Order of operators
From the highest to lowest priority
1. NOT, B_NOT Negation, bit-by-bit negation
2. *, /, DIV, MOD Multiplication, division
3. +, – Addition, subtraction
4. B_AND Bit-by-bit AND
5. B_XOR Bit-by-bit exclusive OR
6. B_OR Bit-by-bit OR
7. AND AND
8. XOR Exclusive OR
9. OR OR
10. << Concatenation of strings, result type STRING
11. ==, <>, >, <, >=, <= Comparison operators
Note
The concatenation operator ":" for Frames must not be used in the same expression as other operators. A priority level is therefore not required for this operator.
Example: IF statement
If (otto==10) and (anna==20) gotof end
Job Planning
76 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.8 Possible type conversions
1.8 Possible type conversions
Function
Type conversion on assignment
The constant numeric value, the variable, or the expression assigned to a variable must be compatible with the variable type. If this is this case, the type is automatically converted when the value is assigned.

Possible type conversions

to REAL INT BOOL CHAR STRING AXIS FRAME from REAL yes yes* Yes1) yes* – INT yes yes Yes1) Yes BOOL yes yes yes yes yes – CHAR yes yes Yes STRING Yes
1)
yes yes
4)
Yes AXIS yes – FRAME yes
2)
3)
yes
Explanation
* At type conversion from REAL to INT, fractional values that are >=0.5 are rounded up,
others are rounded down (cf. ROUND function).
1)
Value <> 0 is equivalent to TRUE; value == 0 is equivalent to FALSE
2)
If the value is in the permissible range
3)
If only 1 character
4)
String length 0 = >FALSE, otherwise TRUE
Note
If conversion produces a value greater than the target range, an error message is output.
If mixed types occur in an expression, type conversion is automatic. Type conversions are also possible in synchronous actions, see Chapter "Motion-synchronous actions, implicit type conversion".
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
77
Flexible NC programming
1.9 String operations

1.9 String operations

Sting operations
In addition to the classic operations "assign" and "comparison" the following string operations are possible:
● Type conversion to STRING (AXSTRING) (Page 78)
● Type conversion from STRING (NUMBER, ISNUMBE
● Concatenation of strings (<<) (Page 81)
● Conversion to lower/upper case letters
● Determine length of string (STRLEN) (Page 83)
● Search for character/string in the s
● Selection of a substring (SUBSTR) (Page 85)
● Reading and writing of individual characters (Page 85)
● Formatting a string (SPRINT) (Page 87)
Special significance of the 0 character
Internally, the 0 character is interpreted as the end identifier of a string. If a character is replaced with the 0 character, the string is truncated.
Example:
Program code Comment
DEF STRING[20] STRG="axis . stationary"
STRG[6]="X"
MSG(STRG) ; Supplies the message "axis X
STRG[6]=0
MSG(STRG) ; Supplies the message "axis".
R, AXNAME) (Page 79)
(TOLOWER,
ring (INDEX, RINDEX, MINDEX, MATCH) (Page 83)
t
TOUPPER) (Page 82)
stationary".

1.9.1 Type conversion to STRING (AXSTRING)

Function
Using the function "type conversion to STRING" variables of different types can be used as a component of a message (MSG).
When using the << operator this is realized implicitly for data types INT, REAL, CHAR and BOOL (see "Concatenation of strings (<<) (Page 81)")..
An INT value is converted to decimal places.
Type AXIS variables can be converted to STRING using the
Job Planning
78 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
normal readable format. REAL values convert with up to 10
AXSTRING command.
Flexible NC programming
1.9 String operations
Syntax
<STRING_ERG> = << <any_type> <STRING_ERG> = AXSTRING(<axis identifier>)
Significance
Variable for the result of the type conversion <STRING_ERG>: Type: STRING
<any_type>: Variable types INT, REAL, CHAR, STRING and BOOL AXSTRING: The AXSTRING command supplies the specified axis identifier as
string.
<axis identifier>:
Note
FRAME variables cannot be converted.
Variable for axis identifier Type: AXIS
Examples
Example 1:
MSG("Position:"<<$AA_IM[X])
Example 2: AXSTRING
Program code Comments
DEF STRING[32] STRING_ERG
STRING_ERG=AXSTRING(X) ; STRING_ERG == "X"

1.9.2 Type conversion from STRING (NUMBER, ISNUMBER, AXNAME)

Function
A conversion is made from STRING to REAL using the NUMBER command. The ability to be converted can be checked using the
A string is converted into the axis data type using the
ISNUMBER command.
AXNAME command.
Syntax
<REAL_ERG>=NUMBER("<string>") <BOOL_ERG>=ISNUMBER("<string>") <AXIS_ERG>=AXNAME("<string>")
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
79
Flexible NC programming
1.9 String operations
Meaning
NUMBER: The NUMBER command returns the number represented by the <string> as
REAL value.
<string>: Type STRING variable to be converted
Variable for the result of the type conversion with Type: REAL
ISNUMBER: The ISNUMBER command can be used to check whether the <string> can
be converted into a valid number.
<BOOL_ERG>:
Variable for the result of the interrogation with Type: BOOL Value:
TRUE
ISNUMBER supplies the value TRUE, if the <string> represents a valid REAL number in
compliance with the language rules.
FALSE If
ISNUMBER supplies the value FALSE, when
calling
NUMBER with the same <string>, an alarm
is initiated.
AXNAME: The AXNAME command converts the specified <string> into an axis
identifier. Note:
<string> cannot be assigned a configured axis identifier, an alarm is
If the initiated.
Variable for the result of the type conversion with Type: AXIS
NUMBER <REAL_ERG>:
ISNUMBER
AXNAME <AXIS_ERG>:
Example
Program code Comment
DEF BOOL BOOL_ERG
DEF REAL REAL_ERG
DEF AXIS AXIS_ERG
BOOL_ERG=ISNUMBER("1234.9876Ex-7") ; BOOL_ERG == TRUE
BOOL_ERG=ISNUMBER("1234XYZ") ; BOOL_ERG == FALSE
REAL_ERG=NUMBER("1234.9876Ex-7") ; REAL_ERG == 1234.9876Ex-7
AXIS_ERG=AXNAME("X") ; AXIS_ERG == X
Job Planning
80 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.9 String operations

1.9.3 Concatenation of strings (<<)

Function
The function "concatenation strings" allows a string to be configured from individual components.
The concatenation is realized using the operator "<<". This operator has STRING as the target type for all combinations of basic types CHAR, BOOL, INT, REAL, and STRING. Any conversion that may be required is carried out according to existing rules.
Syntax
<any_type> << <any_type>
Meaning
<any_type>: Variable, type CHAR, BOOL, INT, REAL or STRING << : Operator to chain variables (<any_type>) to configure a character string
(type STRING). This operator is also available alone as a so-called "unary" variant. This can
be used for explicit type converter to STRING (not for FRAME and AXIS):
<< <any_type>
Examples
For example, such a message or a command can be configured from text lists and parameters can be inserted (for example a block name):
MSG(STRG_TAB[LOAD_IDX]<<BAUSTEIN_NAME)
Note
The intermediate results of string concatenation must not exceed the maximum string length.
Note
The FRAME and AXIS types cannot be used together with the operator "<<".
Example 1: Concatenation of strings
Program code Comment
DEF INT IDX=2
DEF REAL VALUE=9.654
DEF STRING[20] STRG="INDEX:2"
IF STRG=="Index:"<<IDX GOTOF NO_MSG
MSG("Index:"<<IDX<<"/value:"<<VALUE) ; Display:
"Index:2/value:9.654"
NO_MSG:
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
81
Flexible NC programming
1.9 String operations
Example 2: Explicit type conversion with <<
Program code Comment
DEF REAL VALUE=3.5
<<VALUE ; The specified REAL type variable is converted into a
STRING type.

1.9.4 Conversion to lower/upper case letters (TOLOWER, TOUPPER)

Function
The "conversion to lower/upper case letters" function allows all of the letters of a string to be converted into a standard representation.
Syntax
<STRING_ERG>=TOUPPER("<string>") <STRING_ERG>=TOLOWER("<string>")
Meaning
Example
TOUPPER: Using the TOUPPER command, all of the letters in a character string are
converted into upper case letters.
TOLOWER: Using the TOLOWER command, all of the letters in a character string are
converted into lower case letters.
<string>:
Character string that is to be converted Type: STRING
<STRING_ERG>:
Variable for the result of the conversion Type: STRING
Because user inputs can be initiated on the operator interface, they can be given standard capitalization (upper or lower case):
Program code
DEF STRING [29] STRG ... IF "LEARN.CNC"==TOUPPER(STRG) GOTOF LOAD_LEARN
Job Planning
82 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.9 String operations

1.9.5 Determine length of string (STRLEN)

Function
The STRLEN command can be used to determine the length of a character string.
Syntax
<INT_ERG>=STRLEN("<STRING>")
Meaning
STRLEN: The STRLEN command determines the length of the specified character
string. The number of characters that are not the 0 character, counting from the
beginning of the string is returned.
<string>:
<INT_ERG>:
Character string whose length is to be determined Type: STRING Variable for the result of the determination Type: INT
Example
In conjunction with the single character access, this function allows the end of a character string to be determined:
Program code
IF (STRLEN(BAUSTEIN_NAME)>10) GOTOF ERROR

1.9.6 Search for character/string in the string (INDEX, RINDEX, MINDEX, MATCH)

Function
This functionality searches for single characters or a string within a string. The function results specify where the character/string is positioned in the string that has been searched.
Syntax
INT_ERG=INDEX(STRING,CHAR) ; Result type: INT
INT_ERG=RINDEX(STRING,CHAR) ; Result type: INT
INT_ERG=MINDEX(STRING,STRING) ; Result type: INT
INT_ERG=MATCH(STRING,STRING) ; Result type: INT
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
83
Flexible NC programming
;
;
;
;
;
1.9 String operations
Semantics
Search functions: It supplies the position in the string (fist parameter) where the search has been successful. If the character/string cannot be found, then the value -1 is returned. The first character has position 0.
Meaning
INDEX: Searches for the character specified as second parameter (from the
beginning) in the first parameter.
RINDEX: Searches for the character specified as second parameter (from the end) in
the first parameter.
MINDEX: Corresponds to the INDEX function, except for the case that a list of
characters is transferred (as string) in which the index of the first found character is returned.
MATCH: Searches for a string in a string.
This allows strings to be broken up according to certain criteria, for example, at positions with blanks or path separators ("/").
Example
Breaking up an input into path and block names
Program code Comment
DEF INT PFADIDX, PROGIDX
DEF STRING[26] INPUT
DEF INT LISTIDX
INPUT = "/_N_MPF_DIR/_N_EXECUTE_MPF"
LISTIDX = MINDEX (INPUT, "M,N,O,P") + 1
PFADIDX = INDEX (INPUT, "/") +1
PROGIDX = RINDEX (INPUT, "/") +1
The SUBSTR function introduced in the
VARIABLE = SUBSTR (INPUT, PFADIDX, PROGIDX-PFADIDX-1)
VARIABLE = SUBSTR (INPUT, PROGIDX)
The value returned in LISTIDX is 3; because "N" is the fist character in the parameter INPUT from the selection list starting from the beginning.
Therefore the following applies: PFADIDX = 1
Therefore the following applies: PROGIDX = 12
next section can be used to break-up variable INPUT into the components "path" and "module":
Then returns "_N_MPF_DIR"
Then returns "_N_EXECUTE_MPF"
Job Planning
84 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.9 String operations

1.9.7 Selection of a substring (SUBSTR)

Function
Arbitrary parts within a string can be read with the SUBSTRING function.
Syntax
<STRING_ERG>=SUBSTR(<string>,<index>,<length>)
<STRING_ERG>=SUBSTR(<string>,<index>)
Meaning
SUBSTR: This function returns a substring from <string>, starting with <index> with the
specified <length>. If the parameter <length> is not specified, the function returns a substring
starting with <index> until the end of the string.
<index>: Start position of the substring within the string. If the start position is after the
end of the string, an empty string (" ") is returned. First character of the string: Index = 0
Range of values: 0 ... (string length - 1)
<length>: Length of the substring. If too long a length is specified, only the substring
up to the end of the string is returned. Range of values: 1 ... (string length - 1)
Example
Program code Comment
DEF STRING[29] ERG
; 1
; 0123456789012345678
ERG = SUBSTR("QUITTUNG: 10 to 99", 10, 2)
ERG = SUBSTR("QUITTUNG: 10 to 99", 10) ; ERG == "10 to 99"

1.9.8 Reading and writing of individual characters

Function
Individual characters can be read and written within a string.
The following supplementary conditions must be observed:
● Only possible with user-defined variables, not with system variables
● Individual characters of a string are only transferred "call by value" for subprogram calls
;
ERG == "10"
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
85
Flexible NC programming
1.9 String operations
Syntax
<Character>=<string>[<index>] <Character>=<string_array>[<array_index>,<index>] <String>[<index>]=<character> <String_array>[<array_index>,<index>]=<character>
Meaning
<string>: Any string <character>: Variable of type CHAR <index>: Position of the character within the string.
First character of the string: Index = 0 Range of values: 0 ... (string length - 1)
Examples
Example 1: Variable message
Program code Comment
; 0123456789
DEF STRING [50] MESSAGE = "Axis n has reached position"
MESSAGE [6] = "X"
MSG (MESSAGE) ; "Axis X has reached position"
Example 2: Evaluating a system variable
Program code Comment
DEF STRING[50] STRG ; Buffer for system variable
...
STRG = $P_MMCA ; Load system variable
IF STRG[0] == "E" GOTO ... ; Evaluating the system variable
Example 3: Parameter transfer "call by value" and "call by reference"
Program code Comment
; 0123456
DEF STRING[50] STRG = "Axis X"
DEF CHAR CHR
...
EXTERN UP_VAL(ACHSE) ; Definition of subprogram with
"call by value" parameters
Job Planning
86 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.9 String operations
Program code Comment
EXTERN UP_REF(VAR ACHSE) ; Definition of subprogram with
"call by reference" parameters
...
UP_VAL(STRG[6]) ; Parameter transfer "by value"
...
CHR = STRG[6] ; Buffer
UP_REF(CHR) ; Parameter transfer "by reference"

1.9.9 Formatting a string (SPRINT)

Function
Using the pre-defined SPRINT function, character strings can be formatted and e.g. prepared for output on external devices (also see "Process DataShare - output to an external
e/file (EXTOPEN, WRITE, EXTCLOSE) (Page 605)").
devic
Syntax
Meaning
"<Result_string>"=SPRINT("<Format_string>",<value_1>,<value_2>,..., <value_n>)
SPRINT: Identifier for a pre-defined function that supplies
a value, type STRING.
"<Format_String>": Character string that contains fixed and variable
elements. The variable elements are defined using the format control character % and a subsequent format description.
< value_1>,< value_2>,…,< value_n>: Value in the form of a constant or NC variables,
which is inserted at the location where the nth format control character % is located, corresponding to the format description in the <format_string>.
"<result_string>": Formatted character string (maximum 400 bytes)
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
87
Flexible NC programming
1.9 String operations
Format descriptions available
%B: Conversion into the "TRUE" string, if the value to be converted:
Is not equal to 0. Is not an empty string (for string values).
Conversion into the "FALSE" string, if the value to be converted:
Is equal to 0. Is an empty string.
Example:
N10 DEF BOOL BOOL_VAR=1 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF BOOL_VAR:%B", BOOL_VAR)
Result: The character string "CONTENT OF BOOL_VAR:TRUE" is written to the RESULT string variable.
%C: Conversion into an ASCII character.
Example:
N10 DEF CHAR CHAR_VAR="X" N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF CHAR_VAR:%C",CHAR_VAR)
Result: The character string "CONTENT OF CHAR_VAR:X is written to the string variable RESULT.
%D: Conversion into a string with an integer value (INTEGER).
Example:
N10 DEF INT INT_VAR=123 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF INT_VAR:%D",INT_VAR)
Result: The character string "CONTENT OF INT_VAR:123" is written to the string variable RESULT.
%<m>D: Conversion into a string with an integer value (INTEGER). The string has a
minimum length of <m> characters. The missing locations are filled with spaces, left-justified.
Example:
N10 DEF INT INT_VAR=-123 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF INT_VAR:%6D",INT_VAR)
Result: The character string "CONTENT OF INT_VAR:xx-123" is written to string variable RESULT ("x" in the example represents spaces).
%F: Conversion into a string with a decimal number with 6 decimal places. Where
relevant, the decimal places are rounded-off or filled with 0. Example:
N10 DEF REAL REAL_VAR=-1.2341234EX+03 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%F",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:-1234.123400" is written to the string variable RESULT.
Job Planning
88 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.9 String operations
%<m>F
: Conversion into a string with a decimal number with 6 decimal places and a total
length of at least <m> characters. Where relevant, the decimal places are rounded­off or filled with 0. Missing characters are filled up to the total length <m> using spaces, left-justified.
Example:
N10 DEF REAL REAL_VAR=-1.23412345678EX+03 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%15F",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR: xx-1234.123457" is written to the string variable RESULT ("x" in the example represents spaces).
%.<n>F: Conversion into a string with a decimal number with <n> decimal places. Where
relevant, the decimal places are rounded-off or filled with 0. Example:
N10 DEF REAL REAL_VAR=-1.2345678EX+03 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%.3F",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:-1234.568" is written to the string variable RESULT.
%<m>.<n>F: Conversion into a string with a decimal number with <n> decimal places and a total
length of at least <m> characters. Where relevant, the decimal places are rounded­off or filled with 0. Missing characters are filled up to the total length <m> using spaces, left-justified.
Example:
N10 DEF REAL REAL_VAR=-1.2341234567890EX+03 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%10.2F",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:xx-1234.12" is written to the string variable RESULT ("x" in the example represents spaces).
%E: Conversion into a string with a decimal number in the exponential representation.
The mantissa is saved, normalized with one pre-decimal place and 6 decimal places. Where relevant, the decimal places are rounded-off or filled with 0. The exponent starts with the keyword "EX". It is followed by the sign ("+" or "-") and a two or three-digit number.
Example:
N10 DEF REAL REAL_VAR=-1234.567890 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%E",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:-1.234568EX+03" is written to the string variable RESULT.
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
89
Flexible NC programming
1.9 String operations
%<m>E
: Conversion into a string with a decimal number in the exponential representation
and a total length of at least <m> characters. The missing characters are filled with spaces, left-justified. The mantissa is saved, normalized with one pre-decimal place and 6 decimal places. Where relevant, the decimal places are rounded-off or filled with 0. The exponent starts with the keyword "EX". It is followed by the sign ("+" or "-") and a two or three-digit number.
Example:
N10 DEF REAL REAL_VAR=-1234.5 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%20E",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:xxxxxx-1.234500EX+03" is written to the string variable RESULT ("x" in the example represents spaces).
%.<n>E: Conversion into a string with a decimal number in the exponential representation.
The mantissa is saved, normalized with one pre-decimal place and <n> decimal places. Where relevant, the decimal places are rounded-off or filled with 0. The exponent starts with the keyword "EX". It is followed by the sign ("+" or "-") and a two or three-digit number.
Example:
N10 DEF REAL REAL_VAR=-1234.5678 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%.2E",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:-1.23EX+03" is written to the string variable RESULT.
%<m>.<n>E: Conversion into a string with a decimal number in the exponential representation
and a total length of at least <m> characters. The missing characters are filled with spaces, left-justified. The mantissa is saved, normalized with one pre-decimal place and <n> decimal places. Where relevant, the decimal places are rounded-off or filled with 0. The exponent starts with the keyword "EX". It is followed by the sign ("+" or "-") and a two or three-digit number.
Example:
N10 DEF REAL REAL_VAR=-1234.5678 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%12.2E", REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:xx-1.23EX+03" is written to the string variable RESULT ("x" in the example represents spaces).
Job Planning
90 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.9 String operations
%G
: Conversion into a string with a decimal number – depending on the value range – in
a decimal or exponential representation: If the absolute value to be represented is less than 1.0EX-04 or greater than/equal to 1.0EX+06, then the exponential notation is selected, otherwise the decimal notation. A maximum of six significant places are displayed or if required, rounded-off.
Example with decimal notation:
N10 DEF REAL REAL_VAR=1.234567890123456EX-04 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%G",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:0.000123457" is written to the string variable RESULT.
Example with exponential notation:
N10 DEF REAL REAL_VAR=1.234567890123456EX+06 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%G",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:1.23457EX+06" is written to the string variable RESULT.
%<m>G: Conversion into a string with a decimal number – depending on the value range – in
a decimal or exponential notation (like %G). The string has a total length of at least <m> characters. The missing characters are filled with spaces, left-justified.
Example with decimal notation:
N10 DEF REAL REAL_VAR=1.234567890123456EX-04 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%15G",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:xxxx0.000123457" is written to the string variable RESULT ("x" in the example represents spaces).
Example with exponential notation:
N10 DEF REAL REAL_VAR=1.234567890123456EX+06 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%15G",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:xxx1.23457EX+06" is written to the string variable RESULT ("x" in the example represents spaces).
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
91
Flexible NC programming
1.9 String operations
%.<n>G
: Conversion into a string with a decimal number – depending on the value range – in
a decimal or exponential representation. A maximum of <n> significant places are displayed or if required, rounded-off. If the absolute value to be represented is less than 1.0EX-04 or greater than/equal to 1.0EX(+<n>), then the exponential notation is selected, otherwise the decimal notation.
Example with decimal notation:
N10 DEF REAL REAL_VAR=1.234567890123456EX-04 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%.3G",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:0.000123" is written to the string variable RESULT.
Example with exponential notation:
N10 DEF REAL REAL_VAR=1.234567890123456EX+03 N20 DEF STRING[80] RESULT N30 RESULT = SPRINT("CONTENT OF REAL_VAR:%.3G",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:1.23EX+03" is written to the string variable RESULT.
%<m>.<n>G: Conversion into a string with a decimal number – depending on the value range – in
a decimal or exponential notation (like %.<n>G). The string has a total length of at least <m> characters. The missing characters are filled with spaces, left-justified.
Example with decimal notation:
N10 DEF REAL REAL_VAR=1.234567890123456EX-04 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%12.4G",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:xxx0.0001235" is written to the string variable RESULT ("x" in the example represents spaces).
Example with exponential notation:
N10 DEF REAL REAL_VAR=1.234567890123456EX+04 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF REAL_VAR:%12.4G",REAL_VAR)
Result: The character string "CONTENT OF REAL_VAR:xx1.235EX+06" is written to the string variable RESULT ("x" in the example represents spaces).
Job Planning
92 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.9 String operations
%.<n>P
: Converting a REAL value into an INTEGER value taking into account <n> decimal
places. The INTEGER value is output as a 32-bit binary number. If the value to be converted cannot be represented with 32 bits, then processing is interrupted with an alarm.
As a byte sequence generated using the format instruction binary zeroes, then the total string that is generated in this way no longer corresponds to the conventions of the NC data type STRING. As a consequence, it can neither be saved in a variable, type STRING, nor be further processed using the string commands of the NC language. The only possible use is to transfer the parameter to the WRITE command with output at an appropriate external device (see the following example).
As soon as the <Format_String> contains a format description, type complete string, with the exception of the binary number generated with %.<n>P, is output corresponding to the MD10750 $MN_SPRINT_FORMAT_P_CODE in the ASCII character code, ISO (DIN6024) or EIA (RS244). If a character that cannot be converted is programmed, then processing is interrupted with an alarm.
Example:
N10 DEF REAL REAL_VAR=123.45 N20 DEF INT ERROR N30 DEF STRING[20] EXT_DEVICE="/ext/dev/1" ... N100 EXTOPEN(ERROR,EXT_DEVICE) N110 IF ERROR <> 0 ... ; error handling N200 WRITE(ERROR,EXT_DEVICE,SPRINT("INTEGER BINARY CODED:%.3P",REAL_VAR) N210 IF ERROR <> 0 … ; error handling
Result: The string "INTEGER BINARY CODED: 'H0001E23A'" is transferred to the output device /ext/dev/1. The hexadecimal value 0x0001E23A corresponds to the decimal value 123450.
%.<n>P can also contain
%P then the
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
93
Flexible NC programming
1.9 String operations
%<m>.<n>P
%S: Inserting a string.
%<m>S: Inserting a string with a minimum of <m> characters. The missing places are filled
: Conversion of a REAL value corresponding to the setting in machine data
MD10751 $MN_SPRINT_FORMAT_P_DECIMAL into a string with:
An integer of <m> + <n> places or A decimal number with a maximum of <m> pre-decimal places and precisely
<n> decimal places.
Just the same as for the format description %.<n>P, the complete string is saved in the character code defined by MD10750 $MN_SPRINT_FORMAT_P_CODE.
Conversion for MD10751 = 0: The REAL value is converted into a string with an integer number of <m> + <n>
places. If required, decimal places are rounded-off to <n> places or filled with 0. The missing pre-decimal places are filled with spaces. The minus sign is attached, left-justified; a space is entered instead of the plus sign.
Example:
N10 DEF REAL REAL_VAR=-123.45 N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("PUNCHED TAPE FORMAT:%5.3P",REAL_VAR)
Result: The character string "PUNCHED TAPE FORMAT:-xx123450" is written to the string variable RESULT ("x" in the example represents spaces).
Conversion for MD10751 = 1: The REAL value is converted into a string with a decimal number with a maximum
of <m> pre-decimal places and precisely <n> decimal places. Where necessary, the pre-decimal places are cut-off and the decimal places are rounded-off or filled with 0. If <n> is equal to 0, then the decimal point is also omitted.
Example:
N10 DEF REAL REAL_VAR1=-123.45 N20 DEF REAL REAL_VAR2=123.45 N30 DEF STRING[80] RESULT N40 RESULT=SPRINT("PUNCHED TAPE FORMAT:%5.3P VAR2:%2.0P", REAL_VAR1,REAL_VAR2)
Result: The character string "PUNCHED TAPE FORMAT:-123.450 VAR2:23" is written to the string variable RESULT.
Example:
N10 DEF STRING[16] STRING_VAR="ABCDEFG" N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF STRING_VAR:%S",STRING_VAR)
Result: The character string "CONTENT OF STRING_VAR:ABCDEFG" is written to the string variable RESULT.
with spaces. Example:
N10 DEF STRING[16] STRING_VAR="ABCDEFG" N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF STRING_VAR:%10S",STRING_VAR)
Result: The character string "CONTENT OF STRING_VAR:xxxABCDEFG" is written to the string variable RESULT ("x" in the example represents spaces).
Job Planning
94 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.9 String operations
%.<n>S
: Inserting <n> characters of a string (starting with the first character).
Example:
N10 DEF STRING[16] STRING_VAR="ABCDEFG" N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF STRING_VAR:%.3S",STRING_VAR)
Result: The character string "CONTENT OF STRING_VAR:ABC" is written to the string variable RESULT.
%<m>.<n>S: Inserting <n> characters of a string (starting with the first character). The total
length of the generated string has at least <m> characters. The missing places are filled with spaces.
Example:
N10 DEF STRING[16] STRING_VAR="ABCDEFG" N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("CONTENT OF STRING_VAR:%10.5S", STRING_VAR)
Result: The character string "CONTENT OF STRING_VAR:xxxxxABCDE" is written to the string variable RESULT ("x" in the example represents spaces).
%X: Converting an INTEGER value into a string with the hexadecimal notation.
Example:
N10 DEF INT INT_VAR='HA5B8’ N20 DEF STRING[80] RESULT N30 RESULT=SPRINT("INTEGER HEXADECIMAL:%X",INT_VAR)
Result: The character string "INTEGER HEXADECIMAL:A5B8" is written to the string variable RESULT.
Note
A property of the NC language, where a distinction is not made between upper case and lower case letters for identifiers and keywords, also applies to the format descriptions. As a consequence, you can program using either lower case or upper case letters without any functional difference.
Combination options
The following table provides information as to which NC data types can be combined with which format description. The rules regarding implicit data type conversion apply (see "Data types (Pag
%B + + + + + - - %C - + - - + - - %D + + + + - - - %F - - + + - - -
e 52)").
NC data types
BOOL CHAR INT REAL STRING AXIS FRAME
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
95
Flexible NC programming
1.10 Program jumps and branches
NC data types
%E - - + + - - - %G - - + + - - - %S - + - - + - - %X + + + - - - - %P - - + + - - -
Note
The table indicates that the NC data types AXIS and FRAME cannot be directly used in the SPRINT function. However it is possible:
To convert the AXIS data type into a string using the AXSTRING function – which can
then be processed with SPRINT.
To read the individual values of the FRAME data type per frame component access. As a
consequence, a REAL data type is obtained, which can be processed with SPRINT.

1.10 Program jumps and branches

1.10.1 Return jump to the start of the program (GOTOS)

Function
The GOTOS command can be used to jump back to the beginning of a main or sub program in order to repeat the program.
Machine data can be used to set that for every return jump to the beginning of the program:
● The program runtime is set to "0".
● Workpiece counting is incremented by the value "1".
Syntax
GOTOS
Job Planning
96 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.10 Program jumps and branches
Meaning
GOTOS:
Jump instruction where the destination is the beginning of the program. The execution is controlled via the NC/PLC interface signal: DB21, to DBX384.0 (control program branching) Value: Meaning: 0 No return jump to the beginning of the program. Program execution
is resumed with the next part program block after
GOTOS.
1 Return jump to the beginning of the program. The part program is
repeated.
Supplementary conditions
GOTOS internally initiates a STOPRE (pre-processing stop).
● For a subprogram with data definitions (LUD variables) with the
GOTOS a jump is made to
the first program block after the definition section, i.e. data definitions are not executed again. This is the reason that the defined variables retain the value reached in the block and are not reset to the standard values programmed in the definition section.
● The
GOTOS command is not available in synchronized actions and technology cycles.
Example
Program code Comment
N10 ... ; Beginning of the program
...
N90 GOTOS ; Jump to beginning of the program
...

1.10.2 Program jumps to jump markers (GOTOB, GOTOF, GOTO, GOTOC)

Function
Jump markers (labels) can be set in a program, that can be jumped to from another location within the same program using the commands execution is resumed with the instruction that immediately follows the destination marker. This means that branches can be realized within the program.
GOTOF, GOTOB, GOTO or GOTOC. Program
GOTOS
In addition to jump markers, main and sub-block numbers are possible as jump designation.
If a jump condition (
IF ...) is formulated before the jump instruction, the program jump is
only executed if the jump condition is fulfilled.
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
97
Flexible NC programming
1.10 Program jumps and branches
Syntax
GOTOB <jump destination> IF <jump condition> = TRUE GOTOB <jump destination> GOTOF <jump destination> IF <jump condition> = TRUE GOTOF <jump destination> GOTO <jump destination> IF <jump condition> = TRUE GOTO <jump destination> GOTOC <jump destination> IF <jump condition> = TRUE GOTOC <jump destination>
Meaning
GOTOB: Jump instruction with jump destination towards the beginning of the
program.
GOTOF: Jump instruction with jump destination towards the end of the program. GOTO: Jump instruction with jump destination search. The search is first made
in the direction of the end of the program, then in the direction of the beginning of the program.
GOTOC: Same effect as for GOTO with the difference that Alarm 14080 "Jump
designation not found" is suppressed. This means that program execution is not interrupted in the case that
the jump destination search is unsuccessful – but is continued with the program line following the GOTOC command.
<jump destination>:
IF: Keyword to formulate the jump condition.
Jump destination parameter Possible data include: <jump marker>: Jump destination is the jump marker (label) set
in the program with a user-defined name: <
marker>:
jump
<block number>: Jump destination is main block or sub-block
number (e.g.:
200, N300)
STRING type variable: Variable jump destination. The variable stands
for a jump marker or a block number.
The jump condition permits all comparison and logical operations (result: TRUE or FALSE). The program jump is executed if the result of this operation is TRUE.
Job Planning
98 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Flexible NC programming
1.10 Program jumps and branches
Note Jump markers (labels)
Jump markers are always located at the beginning of a block. If a program number exists, the jump marker is located immediately after the block number.
The following rules apply when naming jump markers: Number of characters:
– Minimum 2 – Maximum 32
Permissible characters are:
– Letters – Numbers – Underscores
The first two characters must be letters or underscores. The name of the jump marker is followed by a colon (":").
Supplementary conditions
● The jump destination can only be a block with jump marker or block number, that is located within the program.
● A jump instruction without jump condition must be programmed in a separate block. This restriction does not apply to jump instructions with jump conditions. In this case, several jump instructions can be formulated in a block.
● For programs with jump instructions without jump conditions, the end of the program
M2/M30 doesn't necessarily have to be be at the end of the program.
Examples
Example 1: Jumps to jump markers
Program code Comment
N10 …
N20 GOTOF Label_1 ; Jump towards the end of the program to the jump
N30 …
N40 Label_0: R1=R2+R3 ; Jump marker "Label_0" set.
N50 …
N60 Label_1: ; Jump marker "Label_1" set.
N70 …
N80 GOTOB Label_0 ; Jump in the direction of the beginning of the
N90 …
marker "Label_1".
program to the jump marker "Label_0".
Job Planning Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
99
Flexible NC programming
1.10 Program jumps and branches
Example 2: Indirect jump to the block number
Program code Comment
N5 R10=100
N10 GOTOF "N"<<R10 ; Jump to the block whose block number is located
in R10.
...
N90 ...
N100 ... ; Jump destination
N110 ...
...
Example 3: Jump to variable jump destination
Program code Comment
DEF STRING[20] DESTINATION
DESTINATION = "Marker2"
GOTOF DESTINATION ; Jump in the direction of the end of the program
to the variable jump destination DESTINATION.
Marker 1: T="Drill1"
...
Marker 2: T="Drill2" ; Jump destination
...
Example 4: Jump with jump condition
Program code Comment
N40 R1=30 R2=60 R3=10 R4=11 R5=50 R6=20 ; Assignment of the initial values.
N41 LA1: G0 X=R2*COS(R1)+R5 Y=R2*SIN(R1)+R6 ; Jump marker LA1 set.
N42 R1=R1+R3 R4=R4-1
N43 IF R4>0 GOTOB LA1 ; If the jump condition is
N44 M30 ; End of program

1.10.3 Program branch (CASE ... OF ... DEFAULT ...)

Function
The CASE function provides the possibility of checking the actual value (type: INT) of a variable or an arithmetic function and, depending on the result, to jump to different positions in the program.
fulfilled, then a jump in the direction of the beginning of the program to jump marker LA1.
Job Planning
100 Programming Manual, 03/2013, 6FC5398-2BP40-3BA1
Loading...