Siemens Sinumerik 840D sl,Sinumerik 840DE sl,Sinumerik 828D Programming Manual

Preface
SINUMERIK
SINUMERIK 840D sl/828D Job planning
Programming Manual
Flexible NC programming
File and Program Management
Protection zones
Special Motion Commands Coordinate transformation
(FRAMES)
Transformations
Tool offsets
Path traversing behavior
Axis couplings
Motion synchronous actions
1 2 3 4 5 6 7 8 9
10
Validfor
Controlsystem SINUMERIK840Dsl/840DEsl SINUMERIK828D
SoftwareVersion CNC-Software2.7CNCsoftwareversion2.7
Oscillation
Punching and nibbling
Grinding
Additional functions
User stock removal programs
Programming cycles externally
Tables
Appendix
11 12 13 14 15 16 17
A
02/2011
6FC5398-2BP40-1BA0
Legal information- Warning notice system
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
with a safety alert symbol, indicates that minor personal injury can result if proper precautions are not taken.
CAUTION
without a safety alert symbol, indicates that property damage can result if proper precautions are not taken.
NOTICE
indicates that an unintended result or situation can occur if the corresponding information is not taken into account.
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 for the specific task, 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 adhered to. The information in the relevant documentation must be observed.
Trademarks
All names identified by ® are registered trademarks of the 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-1BA0 Ⓟ 12.2010
Copyright © SiemensAG2011. Technical data subject to change

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
FAQs
You can find Frequently Asked Questions in the Service&Support pages under Product Support. http://support.automation.siemens.com
Job planning Programming Manual 02/2011, 6FC5398-2BP40-1BA0
3
Preface
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
Technical Support
This Programming Guide 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.
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, 02/2011, 6FC5398-2BP40-1BA0
Information on structure and contents
"Fundamentals" and "Advanced" Programming Manual
The description of the NC programming is divided into two manuals:
1. Fundamentals
This "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
The Programming Manual "Advanced" 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.
Preface
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 SINUMERIK 828D [Page 877]" of the "".
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
5
Preface
Job planning
6 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0

Table of contents

Preface.........................................................................................................................................................3
1 Flexible NC programming .........................................................................................................................17
1.1 Variables.................................................................................................................................... 17
1.1.1 General information about variables .......................................................................................... 17
1.1.2 System variables ....................................................................................................................... 18
1.1.3 Predefined user variables: Arithmetic parameters (R) ............................................................... 21
1.1.4 Predefined user variables: Link variables .................................................................................. 23
1.1.5 Definition of user variables (DEF) .............................................................................................. 25
1.1.6 Redefinition of system variables, user variables, and NC language commands (REDEF) ....... 31
1.1.7 Attribute: Initialization value ....................................................................................................... 34
1.1.8 Attribute: Limit values (LLI, ULI) ................................................................................................ 37
1.1.9 Attribute: Physical unit (PHU) .................................................................................................... 39
1.1.10 Attribute: Access rights (APR, APW, APRP, APWP, APRB, APWB) ........................................ 41
1.1.11 Overview of definable and redefinable attributes ...................................................................... 46
1.1.12 Definition and initialization of array variables (DEF, SET, REP) ............................................... 47
1.1.13 Definition and initialization of array variables (DEF, SET, REP): Further Information .............. 52
1.1.14 Data types ................................................................................................................................. 55
1.2 Indirect programming................................................................................................................. 56
1.2.1 Indirectly programming addresses ............................................................................................ 56
1.2.2 Indirectly programming G codes ................................................................................................ 59
1.2.3 Indirectly programming position attributes (BP) ......................................................................... 60
1.2.4 Indirectly programming part program lines (EXECSTRING) ..................................................... 63
1.3 Arithmetic functions ................................................................................................................... 64
1.4 Comparison and logic operations .............................................................................................. 67
1.5 Precision correction on comparison errors (TRUNC) ................................................................ 69
1.6 Variable minimum, maximum and range (MINVAL, MAXVAL and BOUND)............................. 71
1.7 Priority of the operations............................................................................................................ 73
1.8 Possible type conversions ......................................................................................................... 74
1.9 String operations ....................................................................................................................... 75
1.9.1 Type conversion to STRING (AXSTRING) ................................................................................ 76
1.9.2 Type conversion from STRING (NUMBER, ISNUMBER, AXNAME) ...
1.9.3
1.9.4 Conversion to lower/upper case letters (TOLOWER, TOUPPER) ............................................ 79
1.9.5 Determine length of string (STRLEN) ........................................................................................ 80
1.9.6 Search for character/string in the string (INDEX, RINDEX, MINDEX, MATCH) ........................ 81
1.9.7 Selection of a substring (SUBSTR) ........................................................................................... 82
1.9.8 Selection of a single character (STRINGVAR, STRINGFELD) ................................................. 83
1.9.9 Formatting a string (SPRINT) .................................................................................................... 84
1.10 Program jumps and branches ................................................................................................... 93
1.10.1 Return jump to the start of the program (GOTOS) .................................................................... 93
1.10.2 Program jumps to jump markers (GOTOB, GOTOF, GOTO, GOTOC) .................................... 94
1.10.3 Program branch (CASE ... OF ... DEFAULT ...) ........................................................................ 97
Concatenation of strings (<<) .................................................................................................... 78
..................................... 77
Job planning Programming Manual 02/2011, 6FC5398-2BP40-1BA0
7
Table of contents
1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)............................................... 99
1.12 Check structures...................................................................................................................... 106
1.12.1 Program loop with alternative (IF, ELSE, ENDIF) .................................................................... 107
1.12.2 Continuous program loop (LOOP, ENDLOOP) ....................................................................... 109
1.12.3 Count loop (FOR ... TO ..., ENDFOR) .....................................................................................110
1.12.4 Program loop with condition at start of loop (WHILE, ENDWHILE) ......................................... 112
1.12.5 Program loop with condition at the end of the loop (REPEAT, UNTIL) ................................... 113
1.12.6 Program example with nested check structures ...................................................................... 114
1.13 Program coordination (INIT, START, WAITM, WAITMC, WAITE, SETM, CLEARM) ............. 115
1.14 Interrupt routine (ASUB) .......................................................................................................... 120
1.14.1 Function of an interrupt routine ................................................................................................ 120
1.14.2 Creating an interrupt routine .................................................................................................... 121
1.14.3 Assign and start interrupt routine (SETINT, PRIO, BLSYNC) ................................................. 122
1.14.4 Deactivating/reactivating the assignment of an interrupt routine (DISABLE, ENABLE) .......... 124
1.14.5 Delete assignment of interrupt routine (CLRINT) .................................................................... 125
1.14.6 Fast retraction from the contour (SETINT LIFTFAST, ALF) .................................................... 126
1.14.7 Traversing direction for fast retraction from the contour .......................................................... 128
1.14.8 Motion sequence for interrupt routines .................................................................................... 131
1.15 Axis replacement, spindle replacement (RELEASE, GET, GETD).......................................... 132
1.16 Transfer axis to another channel (AXTOCHAN)...................................................................... 137
1.17 Activate machine data (NEWCONF) ....................................................................................... 139
1.18 Write file (WRITE).................................................................................................................... 140
1.19 Delete file (DELETE) ............................................................................................................... 146
1.20 Read lines in the file (READ) ................................................................................................... 148
1.21 Check for presence of file (ISFILE).......................................................................................... 152
1.22 Read out file information (FILEDATE, FILETIME, FILESIZE, FILESTAT, FILEINFO) ............ 154
1.23 Checksum calculation using an array (CHECKSUM) .............................................................. 158
1.24 Roundup (ROUNDUP)............................................................................................................. 160
1.25 Subprogram technique ............................................................................................................ 161
1.25.1 General information ................................................................................................................. 161
1.25.1.1 Subprogram ............................................................................................................................. 161
1.25.1.2 Subprogram names ................................................................................................................. 162
1.25.1.3 Nesting of subprograms ................................
.................................................................
.......... 163
1.25.1.4 Search path ............................................................................................................................. 164
1.25.1.5 Formal and actual parameters ................................................................................................. 165
1.25.1.6 Parameter transfer ................................................................................................................... 166
1.25.2 Definition of a subprogram ....................................................................................................... 168
1.25.2.1 Subprogram without parameter transfer .................................................................................. 168
1.25.2.2 Subprogram with call-by-value parameter transfer (PROC) .................................................... 169
1.25.2.3 Subprogram with call-by-reference parameter transfer (PROC, VAR) .................................... 170
1.25.2.4 Save modal G functions (SAVE) .............................................................................................. 172
1.25.2.5 Suppress single block execution (SBLOF, SBLON) ................................................................ 173
1.25.2.6 Suppress current block display (DISPLOF, DISPLON, ACTBLOCNO) ................................... 179
1.25.2.7 Identifying subprograms with preparation (PREPRO) ............................................................. 183
1.25.2.8 Subprogram return M17 ........................................................................................................... 184
Job planning
8
Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Table of contents
1.25.2.9 RET subprogram return ........................................................................................................... 185
1.25.2.10Parameterizable subprogram return jump (RET ...) ................................................................ 186
1.25.3 Subprogram call ...................................................................................................................... 193
1.25.3.1 Subprogram call without parameter transfer ........................................................................... 193
1.25.3.2 Subprogram call with parameter transfer (EXTERN) .............................................................. 195
1.25.3.3 Number of program repetitions (P) .......................................................................................... 197
1.25.3.4 Modal subprogram call (MCALL) ............................................................................................. 199
1.25.3.5 Indirect subprogram call (CALL) .............................................................................................. 201
1.25.3.6 Indirect subprogram call with specification of the calling program part
(CALL BLOCK ... TO ...) .......................................................................................................... 202
1.25.3.7 Indirect call of a program programmed in ISO language (ISOCALL) ...................................... 203
1.25.3.8 Calling subroutine with path specification and parameters (PCALL) ....................................... 205
1.25.3.9 Extend search path for subprogram calls (CALLPATH) .......................................................... 206
1.25.3.10Execute external subroutine (EXTCALL) ................................................................................. 208
1.25.4 Cycles ...................................................................................................................................... 212
1.25.4.1 Parameterizing user cycles ..................................................................................................... 212
1.26 Macro technique (DEFINE ... AS)............................................................................................ 216
2 File and Program Management ...............................................................................................................219
2.1 Program memory..................................................................................................................... 219
2.2 Working memory (CHANDATA, COMPLETE, INITIAL) .......................................................... 224
2.3 Structuring instruction in step editor (SEFORM) ..................................................................... 227
3 Protection zones .....................................................................................................................................229
3.1 Definition of the protection zones (CPROTDEF, NPROTDEF) ............................................... 229
3.2 Activating/deactivating protection zones (CPROT, NPROT)................................................... 233
3.3 Checking for protection zone violation, working area limitation and software limits
(CALCPOSI) ............................................................................................................................ 237
4 Special Motion Commands .....................................................................................................................245
4.1 Approaching coded positions (CAC, CIC, CDC, CACP, CACN) ............................................. 245
4.2 Spline interpolation (ASPLINE, BSPLINE, CSPLINE, BAUTO, BNAT, BTAN, EAUTO, ENAT,
ETAN, PW, SD, PL)................................................................................................................. 246
4.3 Spline grouping (SPLINEPATH).............................................................................................. 257
4.4 NC block compression (COMPON, COMPCURV, COMPCAD, COMPOF) .....
....................... 259
4.5 Polynomial interpolation (POLY, POLYPATH, PO, PL)........................................................... 262
4.6 Settable path reference (SPATH, UPATH).............................................................................. 268
4.7 Measurements with touch trigger probe (MEAS, MEAW) ....................................................... 271
4.8 Extended measuring function (MEASA, MEAWA, MEAC) (option)......................................... 274
4.9 Special functions for OEM users (OMA1 ... OMA5, OEMIPO1, OEMIPO2, G810 ... G829) ... 283
4.10 Feed reduction with corner deceleration (FENDNORM, G62, G621)...................................... 284
4.11 Programmed end-of-motion criterion (FINEA, COARSEA, IPOENDA, IPOBRKA,
ADISPOSA) ............................................................................................................................. 285
4.12 Programmable servo parameter set (SCPARA)...................................................................... 288
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
9
Table of contents
5 Coordinate transformation (FRAMES) ....................................................................................................289
5.1 Coordinate transformation via frame variables ........................................................................ 289
5.1.1 Predefined frame variable ($P_BFRAME, $P_IFRAME, $P_PFRAME, $P_ACTFRAME) ...... 291
5.2 Frame variables / assigning values to frames ......................................................................... 297
5.2.1 Assigning direct values (axis value, angle, scale) ................................................................... 297
5.2.2 Reading and changing frame components (TR, FI, RT, SC, MI) ............................................. 300
5.2.3 Linking complete frames .......................................................................................................... 301
5.2.4 Defining new frames (DEF FRAME) ........................................................................................ 303
5.3 Coarse and fine offsets (CFINE, CTRANS)............................................................................. 304
5.4 External zero offset.................................................................................................................. 306
5.5 Preset offset (PRESETON) ..................................................................................................... 307
5.6 Frame calculation from three measuring points in space (MEAFRAME) ................................ 309
5.7 NCU global frames ................................................................................................................. 313
5.7.1 Channel-specific frames ($P_CHBFR, $P_UBFR) .................................................................. 314
5.7.2 Frames active in the channel ................................................................................................... 315
6 Transformations ......................................................................................................................................321
6.1 General programming of transformation types ........................................................................ 321
6.1.1 Orientation movements for transformations ............................................................................. 324
6.1.2 Overview of orientation transformation TRAORI ..................................................................... 327
6.2 Three, four and five axis transformation (TRAORI) ................................................................. 329
6.2.1 General relationships of universal tool head ............................................................................ 329
6.2.2 Three, four and five axis transformation (TRAORI) ................................................................. 332
6.2.3 Variants of orientation programming and initial setting (ORIRESET) ...................................... 334
6.2.4 Programming of the tool orientation (A..., B..., C..., LEAD, TILT) ............................................ 335
6.2.5 Face milling (3D-milling A4, B4, C4, A5, B5, C5) .................................................................... 342
6.2.6 Orientation axis reference (ORIWKS, ORIMKS) ..................................................................... 344
6.2.7 Programming orientation axes (ORIAXES, ORIVECT, ORIEULER, ORIRPY, ORIRPY2,
ORIVIRT1, ORIVIRT2) ............................................................................................................ 346
6.2.8 Orientation programming along the peripheral surface of a taper (ORIPLANE, ORICONCW,
ORICONCCW, ORICONTO, ORICONIO) ............................................................................... 348
6.2.9 Specification of orientation for two contact points (ORICURVE, PO[XH]=, PO[YH]=,
PO[ZH]=) ................................................................................................................................. 352
6.3 Orientation polynomials (PO[angle], PO[coordinate]).........
6.4
Rotations of the tool orientation (ORIROTA, ORIROTR, ORIROTT, ORIROTC, THETA) ...... 356
..................................................... 354
6.5 Orientations relative to the path............................................................................................... 359
6.5.1 Orientation types relative to the path ....................................................................................... 359
6.5.2 Rotation of the tool orientation relative to the path (ORIPATH, ORIPATHS,
angle of rotation) ...................................................................................................................... 361
6.5.3 Interpolation of the tool rotation relative to the path (ORIROTC, THETA) ............................... 362
6.5.4 Smoothing of orientation characteristic (ORIPATHS A8=, B8=, C8=) ..................................... 364
6.6 Compression of the orientation (COMPON, COMPCURV, COMPCAD)................................. 366
6.7 Smoothing the orientation characteristic (ORISON, ORISOF) ................................................ 369
6.8 Kinematic transformation ......................................................................................................... 371
6.8.1 Milling on turned parts (TRANSMIT) ........................................................................................ 371
10
Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Job planning
Table of contents
6.8.2 Cylinder surface transformation (TRACYL) ............................................................................. 375
6.8.3 Inclined axis (TRAANG) .......................................................................................................... 383
6.8.4 Inclined axis programming (G05, G07) .................................................................................... 386
6.9 Cartesian PTP travel ............................................................................................................... 388
6.9.1 PTP for TRANSMIT ................................................................................................................. 393
6.10 Constraints when selecting a transformation........................................................................... 397
6.11 Deselect transformation (TRAFOOF) ...................................................................................... 398
6.12 Chained transformations (TRACON, TRAFOOF).................................................................... 399
7 Tool offsets .............................................................................................................................................401
7.1 Offset memory ......................................................................................................................... 401
7.2 Additive offsets ........................................................................................................................ 404
7.2.1 Selecting additive offsets (DL) ................................................................................................. 404
7.2.2 Specify wear and setup values ($TC_SCPxy[t,d], $TC_ECPxy[t,d]) ....................................... 406
7.2.3 Delete additive offsets (DELDL) .............................................................................................. 407
7.3 Special handling of tool offsets................................................................................................ 408
7.3.1 Mirroring of tool lengths ........................................................................................................... 410
7.3.2 Wear sign evaluation ............................................................................................................... 411
7.3.3 Coordinate system of the active machining operation (TOWSTD, TOWMCS, TOWWCS,
TOWBCS, TOWTCS, TOWKCS) ............................................................................................ 412
7.3.4 Tool length and plane change ................................................................................................. 415
7.4 Online tool offset (PUTFTOCF, FCTDEF, PUTFTOC, FTOCON, FTOCOF) .......................... 416
7.5 Activate 3D tool offsets (CUT3DC..., CUT3DF...).................................................................... 421
7.5.1 Activating 3D tool offsets (CUT3DC, CUT3DF, CUT3DFS, CUT3DFF, ISD) .......................... 421
7.5.2 3D tool offset peripheral milling, face milling ........................................................................... 423
7.5.3 3D tool offset Tool shapes and tool data for face milling ......................................................... 425
7.5.4 3D tool offset Compensation on the path, path curvature, insertion depth (CUT3DC, ISD) .... 426
7.5.5 3D tool offset Inside/outside corners and intersection procedure (G450/G451) ...................... 429
7.5.6 3D tool offset 3D circumferential milling with limitation surfaces ............................................. 430
7.5.7 3D tool offset Taking into consideration a limitation surface (CUT3DCC, CUT3DCCD) ......... 431
7.6 Tool orientation (ORIC, ORID, OSOF, OSC, OSS, OSSE, ORIS, OSD, OST)....................... 435
7.7 Free assignment of D numbers, cutting edge numbers........................................................... 441
7.7.1 Free assignment of D numbers, cutting edge numbers (CE address) .................................... 441
7.7.2 Free assignment of D numbers: Checking D numbers (CHKDNO)
7.7.3
Free assignment of D numbers: Rename D numbers (GETDNO, SETDNO) ......................... 442
......................................... 441
7.7.4 Free assignment of D numbers: Determine T number to the specified D number
(GETACTTD) ........................................................................................................................... 443
7.7.5 Free assignment of D numbers: Invalidate D numbers (DZERO) ........................................... 444
7.8 Tool holder kinematics............................................................................................................. 445
7.9 Tool length compensation for orientable toolholders (TCARR, TCOABS, TCOFR, TCOFRX,
TCOFRY, TCOFRZ) ................................................................................................................ 451
7.10 Online tool length compensation (TOFFON, TOFFOF)........................................................... 454
7.11 Cutting data modification for tools that can be rotated (CUTMOD) ......................................... 457
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
11
Table of contents
8 Path traversing behavior .........................................................................................................................463
8.1 Tangential control (TANG, TANGON, TANGOF, TLIFT, TANGDEL)...................................... 463
8.2 Feedrate response (FNORM, FLIN, FCUB, FPO) ................................................................... 470
8.3 Program sequence with preprocessing memory (STOPFIFO, STARTFIFO, FIFOCTRL,
STOPRE)................................................................................................................................. 475
8.4 Conditionally interruptible program sections (DELAYFSTON, DELAYFSTOF)....................... 478
8.5 Preventing program position for SERUPRO (IPTRLOCK, IPTRUNLOCK) ............................. 483
8.6 Repositioning to a contour (REPOSA, REPOSL, REPOSQ, REPOSQA, REPOSH,
REPOSHA, DISR, DISPR, RMI, RMB, RME, RMN)................................................................ 486
8.7 Influencing the motion control.................................................................................................. 495
8.7.1 Percentage jerk correction (JERKLIM) .................................................................................... 495
8.7.2 Percentage velocity correction (VELOLIM) .............................................................................. 496
8.7.3 Program example for JERKLIM and VELOLIM ....................................................................... 499
8.8 Programmable contour/orientation tolerance (CTOL, OTOL, ATOL) ...................................... 500
8.9 Tolerance for G0 motion (STOLF) ........................................................................................... 504
9 Axis couplings .........................................................................................................................................507
9.1 Coupled motion (TRAILON, TRAILOF) ................................................................................... 507
9.2 Curve tables (CTAB)................................................................................................................ 511
9.2.1 Define curve tables (CTABDEF, CATBEND) ........................................................................... 512
9.2.2 Check for presence of curve table (CTABEXISTS) ................................................................. 518
9.2.3 Delete curve tables (CTABDEL) .............................................................................................. 519
9.2.4 Locking curve tables to prevent deletion and overwriting (CTABLOCK, CTABUNLOCK) ....... 520
9.2.5 Curve tables: Determine table properties (CTABID, CTABISLOCK, CTABMEMTYP,
CTABPERIOD) ........................................................................................................................ 521
9.2.6 Read curve table values (CTABTSV, CTABTEV, CTABTSP, CTABTEP, CTABSSV, CTABSEV,
CTAB, CTABINV, CTABTMIN, CTABTMAX) .......................................................................... 523
9.2.7 Curve tables: Check use of resources (CTABNO, CTABNOMEM, CTABFNO, CTABSEGID, CTABSEG, CTABFSEG, CTABMSEG, CTABPOLID, CTABPOL, CTABFPOL, CTABMPOL) 528
9.3 Axial leading value coupling (LEADON, LEADOF).................................................................. 530
9.4 Electronic gear (EG) ................................................................................................................ 536
9.4.1 Defining an electronic gear (EGDEF) ......................................................................................536
9.4.2 Switch-in the electronic gearbox (EGON, EGONSYN, EGONSYNE)
3 Switching-in the electronic gearbox (EGOFS, EGOFC) .......................................................... 541
9.4.
..................................... 538
9.4.4 Deleting the definition of an electronic gear (EGDEL) ............................................................. 542
9.4.5 Rotational feedrate (G95) / electronic gear (FPR) ................................................................... 542
9.5 Synchronous spindle ............................................................................................................... 543
9.5.1 Synchronous spindle: Programming (COUPDEF, COUPDEL, COUPON, COUPONC,
COUPOF, COUPOFS, COUPRES, WAITC) ........................................................................... 544
9.6 Master/slave group (MASLDEF, MASLDEL, MASLON, MASLOF, MASLOFS)...................... 555
10 Motion synchronous actions ....................................................................................................................559
10.1 Basics ...................................................................................................................................... 559
10.1.1 Area of validity and machining sequence (ID, IDS) ................................................................. 561
10.1.2 Cyclically checking the condition (WHEN, WHENEVER, FROM, EVERY) ............................. 563
Job planning
12
Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Table of contents
10.1.3 Actions (DO) ............................................................................................................................ 565
10.2 Operators for conditions and actions ....................................................................................... 566
10.3 Main run variables for synchronized actions ........................................................................... 568
10.3.1 System variables ..................................................................................................................... 568
10.3.2 Implicit type conversion ........................................................................................................... 570
10.3.3 GUD variables ......................................................................................................................... 571
10.3.4 Default axis identifier (NO_AXIS) ............................................................................................ 573
10.3.5 Synchronized action marker ($AC_MARKER[n]) .................................................................... 574
10.3.6 Synchronized action parameters ($AC_PARAM[n]) ................................................................ 575
10.3.7 Arithmetic parameter ($R[n]) ................................................................................................... 575
10.3.8 Read and write NC machine and NC setting data ................................................................... 576
10.3.9 Timer variable ($AC_Timer[n]) ................................................................................................ 578
10.3.10 FIFO variables ($AC_FIFO1[n] ... $AC_FIFO10[n]) ................................................................. 579
10.3.11 Information about block types in the interpolator ($AC_BLOCKTYPE,
$AC_BLOCKTYPEINFO, $AC_SPLITBLOCK) ....................................................................... 581
10.4 Actions in synchronized actions .............................................................................................. 584
10.4.1 Overview of possible actions in synchronized actions ............................................................. 584
10.4.2 Output of auxiliary functions .................................................................................................... 586
10.4.3 Set read-in disable (RDISABLE) ............................................................................................. 587
10.4.4 Cancel preprocessing stop (STOPREOF) ............................................................................... 588
10.4.5 Delete distance-to-go (DELDTG) ............................................................................................ 589
10.4.6 Polynomial definition (FCTDEF) .............................................................................................. 591
10.4.7 Synchronized function (SYNFCT) ........................................................................................... 594
10.4.8 Closed-loop clearance control with limited correction ($AA_OFF_MODE) .............................. 597
10.4.9 Online tool offset (FTOC) ........................................................................................................ 600
10.4.10 Online tool length compensation ($AA_TOFF) ........................................................................ 603
10.4.11 Positioning movements ........................................................................................................... 605
10.4.12 Position axis (POS) ................................................................................................................. 606
10.4.13 Position in specified reference range (POSRANGE) ............................................................... 608
10.4.14 Start/stop axis (MOV) .............................................................................................................. 609
10.4.15 Axis replacement (RELEASE, GET) ........................................................................................610
10.4.16 Axial feed (FA) ........................................
..................................................................
............... 614
10.4.17 Software limit switch ................................................................................................................ 614
10.4.18 Axis coordination ..................................................................................................................... 615
10.4.19 Set actual values (PRESETON) .............................................................................................. 616
10.4.20 Withdrawing the enable for the axis container rotation (AXCTSWEC) .................................... 617
10.4.21 Spindle motions ....................................................................................................................... 620
10.4.22 Coupled motion (TRAILON, TRAILOF) ................................................................................... 621
10.4.23 Leading value coupling (LEADON, LEADOF) ......................................................................... 623
10.4.24 Measuring (MEAWA, MEAC) .................................................................................................. 626
10.4.25 Initialization of array variables (SET, REP) ............................................................................. 627
10.4.26 Set/delete wait markers (SETM, CLEARM) ............................................................................. 628
10.4.27 Fault responses (SETAL) ........................................................................................................ 629
10.4.28 Travel to fixed stop (FXS, FXST, FXSW, FOCON, FOCOF) ................................................... 630
10.4.29 Determining the path tangent in synchronized actions ............................................................ 632
10.4.30 Determining the current override ............................................................................................. 633
10.4.31 Time use evaluation of synchronized actions .......................................................................... 634
10.5 Technology cycles ................................................................................................................... 636
10.5.1 Context variable ($P_TECCYCLE) ..........................................................................................639
10.5.2 Call-by-value parameters ........................................................................................................ 640
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
13
Table of contents
10.5.3 Default parameter initialization ................................................................................................ 640
10.5.4 Control processing of technology cycles (ICYCOF, ICYCON) ................................................ 641
10.5.5 Cascading technology cycles .................................................................................................. 642
10.5.6 Technology cycles in non-modal synchronized actions ........................................................... 642
10.5.7 Check structures (IF) ............................................................................................................... 643
10.5.8 Jump instructions (GOTO, GOTOF, GOTOB) ......................................................................... 643
10.5.9 Lock, unlock, reset (LOCK, UNLOCK, RESET) ....................................................................... 644
10.6 Delete synchronized action (CANCEL).................................................................................... 646
10.7 Control behavior in specific operating states ........................................................................... 647
11 Oscillation ................................................................................................................................................651
11.1 Asynchronous oscillation (OS, OSP1, OSP2, OST1, OST2, OSCTRL, OSNSC, OSE, OSB) 651
11.2 Oscillation controlled by synchronized actions (OSCILL) ........................................................ 657
12 Punching and nibbling .............................................................................................................................665
12.1 Activation, deactivation ............................................................................................................ 665
12.1.1 Punching and nibbling on or off (SPOF, SON, PON, SONS, PONS, PDELAYON,
PDELAYOF, PUNCHACC) ...................................................................................................... 665
12.2 Automatic path segmentation .................................................................................................. 670
12.2.1 Path segmentation for path axes ............................................................................................. 673
12.2.2 Path segmentation for single axes ........................................................................................... 675
13 Grinding ...................................................................................................................................................677
13.1 Grinding-specific tool monitoring in the part program (TMON, TMOF).................................... 677
14 Additional functions .................................................................................................................................679
14.1 Axis functions (AXNAME, AX, SPI, AXTOSPI, ISAXIS, AXSTRING, MODAXVAL)................ 679
14.2 Replaceable geometry axes (GEOAX) .................................................................................... 682
14.3 Axis container (AXCTSWE, AXCTSWED, AXCTSWEC) ........................................................ 687
14.4 Wait for valid axis position (WAITENC) ................................................................................... 693
14.5 Check scope of NC language present (STRINGIS)................................................................. 695
14.6 Function call ISVAR and read machine data array index ........................................................ 699
14.7 Learn compensation characteristics (QECLRNON, QECLRNOF) .......................................... 701
14.8 Interactively call the window from the part program (MMC) .................................................... 703
14.9 Program runtime/part counter..................................
................................................................ 704
14.9.1 Program runtime/part counter (overview) ................................................................................ 704
14.9.2 Program runtime ...................................................................................................................... 705
14.9.3 Workpiece counter ................................................................................................................... 709
14.10 Output to an external device/file (EXTOPEN, WRITE, EXTCLOSE)....................................... 710
14.11 Alarms (SETAL)....................................................................................................................... 719
14.12 Drive-integrated extended stop and retract (ESR)................................................................... 721
14.12.1 Configuring drive-integrated stopping (ESRS) ......................................................................... 721
14.12.2 Configuring drive-integrated retraction (ESRS) ....................................................................... 722
14
Job planning
Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Table of contents
15 User stock removal programs .................................................................................................................725
15.1 Supporting functions for stock removal ................................................................................... 725
15.2 Generate contour table (CONTPRON).................................................................................... 726
15.3 Generate coded contour table (CONTDCON)......................................................................... 732
15.4 Determine point of intersection between two contour elements (INTERSEC) ........................ 736
15.5 Execute the contour elements of a table block-by-block (EXECTAB) ..................................... 738
15.6 Calculate circle data (CALCDAT) ............................................................................................ 739
15.7 Deactivate contour preparation (EXECUTE) ........................................................................... 741
16 Programming cycles externally ...............................................................................................................743
16.1 Technology cycles ................................................................................................................... 743
16.1.1 Introduction .............................................................................................................................. 743
16.1.2 Drilling, centering - CYCLE81 .................................................................................................. 745
16.1.3 Drilling, counterboring - CYCLE82 .......................................................................................... 746
16.1.4 Reaming - CYCLE85 ............................................................................................................... 747
16.1.5 Deep-hole drilling - CYCLE83 ................................................................................................. 748
16.1.6 Boring - CYCLE86 ................................................................................................................... 750
16.1.7 Tapping without compensating chuck - CYCLE84 .................................................................. 751
16.1.8 Tapping with compensating chuck - CYCLE840 ..................................................................... 754
16.1.9 Thread milling - CYCLE78 ....................................................................................................... 756
16.1.10 Freely programmable positions - CYCLE802 .......................................................................... 758
16.1.11 Row of holes - HOLES1 .......................................................................................................... 760
16.1.12 Grid or frame - CYCLE801 ...................................................................................................... 761
16.1.13 Circle of holes - HOLES2 ........................................................................................................ 762
16.1.14 Face milling - CYCLE61 .......................................................................................................... 763
16.1.15 Milling a rectangular pocket - POCKET3 .................................................................................765
16.1.16 Milling a circular pocket - POCKET4 ....................................................................................... 768
16.1.17 Rectangular spigot milling - CYCLE76 .................................................................................... 770
16.1.18 Circular spigot milling - CYCLE77 ........................................................................................... 772
16.1.19 Multiple-edge - CYCLE79 ........................................................................................................ 774
16.1.20 Longitudinal slot - SLOT1 ........................................................................................................ 776
16.1.21 Circumferential slot - SLOT2 ................................................................................................... 779
16.1.22 Mill open slot - CYCLE899 ...................................................................................................... 781
16.1.23 Elongated hole - LONGHOLE ................................................................................................. 783
16.1.24 Thread milling - CYCLE70 ....................................................................................................... 785
16.1.25 Engraving cycle - CYCLE60 ..............................
.................................................................
..... 787
16.1.26 Contour call - CYCLE62 .......................................................................................................... 790
16.1.27 Path milling - CYCLE72 ........................................................................................................... 791
16.1.28 Predrilling a contour pocket - CYCLE64 .................................................................................. 794
16.1.29 Milling a contour pocket - CYCLE63 ........................................................................................ 796
16.1.30 Stock removal - CYCLE951 ..................................................................................................... 798
16.1.31 Groove - CYCLE930 ................................................................................................................ 801
16.1.32 Undercut forms - CYCLE940 ................................................................................................... 804
16.1.33 Thread turning - CYCLE99 ...................................................................................................... 807
16.1.34 Thread chain - CYCLE98 ........................................................................................................ 810
16.1.35 Cut-off - CYCLE92 ................................................................................................................... 813
16.1.36 Contour grooving - CYCLE952 ................................................................................................ 815
16.1.37 Swiveling - CYCLE800 ............................................................................................................ 819
16.1.38 High Speed Settings - CYCLE832 ........................................................................................... 822
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
15
16.1.39 High speed cutting (HSC) - CYCLE_HSC ............................................................................... 823
17 Tables .....................................................................................................................................................825
17.1 Operations ............................................................................................................................... 825
17.2 Operations: Availability for SINUMERIK 828D ........................................................................ 877
17.3 Currently set language in the HMI ........................................................................................... 899
A Appendix .................................................................................................................................................901
A.1 List of abbreviations................................................................................................................. 901
A.2 Overview.................................................................................................................................. 906
Glossary...................................................................................................................................................909
16
Job planning
Programming Manual, 02/2011, 6FC5398-2BP40-1BA0

Flexible NC programming

1.1 Variables

1.1.1 General information about 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. For this purpose the system makes three different types of variable available.
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, to a large extent, predefined by the system and its properties are fixed. 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 commands (REDEF) [Page 31]".
User variables
1
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:
- 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 commands (REDEF) [Page 31]".
- User-defined variables
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 25]".
Job planning Programming Manual 02/2011, 6FC5398-2BP40-1BA0
17
Flexible NC programming
1.1 Variables
See also
System variables System variables [Page 18]
Predefined user variables: Arithmetic parameters (R) Predefined user variables: Arithmetic parameters (R) [Page 21]
Predefined user variables: Link variables Predefined user variables: Link variables [Page 23]
Attribute: Initialization value Attribute: Initialization value [Page 34]
Attribute: Limit values (LLI, ULI) Attribute: Limit values (LLI, ULI) [Page 37]
Attribute: Physical unit (PHU) Attribute: Physical unit (PHU) [Page 39]
Attribute: Access rights (APR, APW, APRP, APWP, APRB, APWB) Attribute: Access rights (APR, APW, APRP, APWP, APRB, APWB) [Page 41]
Overview of definable and redefinable attributes Overview of definable and redefinable attributes [Page 46]
Definition and initialization of array variables (DEF, SET, REP) Definition and initialization of array variables (DEF, SET, REP) [Page 47]
Data types Data types [Page 55]

1.1.2 System variables

System variables are variables which are predefined in the system and provide access to the actual parameter settings associated with the control, as well as machine, control, and process statuses, in part programs and cycles.
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)
Job planning
18 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Prefix system
Flexible NC programming
1.1 Variables
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.
$ + 1. Letter Significance: Data type System variables which are read/written during preprocessing $M
$S
Machine data
Setting data, protection zones $T Tool management data $P Programmed values $C Cycle variables of ISO envelope cycles $O Option data R
R-parameters (arithmetic parameters) System variables which are read/written during the main run $$M
$$S
Machine data
Setting data $A Up-to-date main run data $V Servo data $R
1)
When machine and setting data are used in the part program/cycle as preprocessing variables, the
R-parameters (arithmetic parameters)
prefix is written with one $ sign. When they are used in synchronized actions as main run variables, the prefix is written with two $ signs.
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.
1)
1)
2)
1)
1)
2)
2. Letter Significance: Visibility N NCK-global variable (NCK) C Channel-specific variable (Channel) A Axis-specific variable (Axis)
General 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
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
19
Flexible NC programming
1.1 Variables
Use of machine and setting data in synchronized actions
When machine and setting data are 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.
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:
Program code
ID=1 WHENEVER G710 $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:
Program code
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.
References
See also
A list of the properties of all system variables appears in:
List Manual, system variable
General information about variables General information about variables [Page 17]
Job planning
20 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0

1.1.3 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.
When using synchronized actions, the $ sign must be included as a prefix, e.g. $R10.
Syntax
When used as a preprocessing variable:
R<n> R[<expression>]
When used as a main run variable:
$R<n> $R[<expression>]
Flexible NC programming
1.1 Variables
Significance
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 to 9999 9999) Note:
A maximum of 8 decimal places are permitted. For an exponential notation: ± (1*10
-300
to 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.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
21
Flexible NC programming
1.1 Variables
<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 into the INT data type (INT, REAL, BOOL, CHAR).
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
See also
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)
General information about variables General information about variables [Page 17]
Job planning
22 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0

1.1.4 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 control as additional global user variables alongside global user variables (GUD).
Syntax
$A_DLB[<index>] $A_DLW[<index>] $A_DLD[<index>] $A_DLR[<index>]
Flexible NC programming
1.1 Variables
Significance
$A_DLB: Link variable for BYTE data format (1 byte)
Data type: UINT Range of values: 0 to 255
$A_DLW: Link variable for WORD data format (2 bytes)
Data type: INT Range of values: -32768 to 32767
$A_DLD: Link variable for DWORD data format (4 bytes)
Data type: INT Range of values: -2147483648 to 2147483647
$A_DLR: Link variable for REAL data format (8 bytes)
Data type: REAL Range of values:
±(2,2*10
-308
… 1,8*10
+308
)
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
23
Flexible NC programming
1.1 Variables
<index>: 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, etc. – $A_DLW[i]: i = 0, 2, 4, etc. – $A_DLD[i]: i = 0, 4, 8, etc. – $A_DLR[i]: i = 0, 8, 16, etc.
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.
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]
Job planning
24 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
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
General information about variables General information about variables [Page 17]

1.1.5 Definition of user variables (DEF)

Function
Flexible NC programming
1.1 Variables
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 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.
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.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
25
Flexible NC programming
1.1 Variables
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.
A number of variables of the same data type can be defined for each data definition.
Syntax
DEF <range> <type> <PP_stop> <init_time> <phys_unit> <limit_values> <access_rights> <name>[<value_1>,<value_2>,<value_3>]=<init_value>
Significance
DEF: Command for defining GUD, PUD, LUD user variables <range>: Range of validity, only relevant for GUD:
NCK: NC-global user variable CHAN: Channel-global user variable
<type>: 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 55]"
<PP_stop>: Preprocessing stop, only relevant for GUD (optional)
SYNR: Preprocessing stop while reading SYNW: Preprocessing stop while writing SYNRW: Preprocessing stop while reading/writing
Job planning
26 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.1 Variables
<init_time>: Point in time at which the variable is reinitialized (optional)
INIPO:PowerOn 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 34]"
<phys_unit>: Physical unit (optional)
PHU <unit>:
See "Attribute: Physical unit (PHU) [Page 39]"
<limit values>: Lower and upper limit value (optional)
LLI <limit value>: Lower limit value (lower limit) ULI <limit value>: Upper limit value (upper limit)
See "Attribute: Limit values (LLI, ULI) [Page 37]"
<access rights>: Access rights 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
See "Attribute: Access rights (APR, APW, APRP, APWP, APRB, APWB) [Page 41]"
<name>: Name of variable
Note
A maximum of 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>,
Specification of array sizes for 1- to max. 3-dimensional array variables (optional)
<value_3>]: <init_value>: Initialization value (optional)
See "Attribute: Initialization value [Page 34]" For the initialization of array variables: See "Definition and initialization of array variables (DEF, SET, REP)
[Page 47]"
Protection level Range of values: 0 ... 7
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
27
Flexible NC programming
1.1 Variables
Examples
Example 1: Definition of user variables in the data block for machine manufacturers
Program code
%_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
; 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
Job planning
28 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
Example 2: Program-global and program-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 and write PUD
VAR2=1 ; Write LUD
ENDIF
SUB3 ; Subprogram call
...
M17
1.1 Variables
Program code Comment
PROC SUB3 ; Subprogram SUB3
...
IF (VAR1==1) ; Read PUD
VAR1=VAR1+1 ; Read and 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 ; 1. geometry axis
DEF AXIS SPINDLE ; Spindle
...
IF ISAXIS(1) == FALSE GOTOF CONTINUE
ABSCISSA = $P_AXN1
CONTINUE:
...
SPINDLE=(S1) 1. spindle
OVRA[SPINDLE]=80 ; Spindle override = 80%
SPINDLE=(S3) 3. spindle
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
29
Flexible NC programming
1.1 Variables
General 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_ Significance 11140 GUD_AREA_ SAVE_TAB Additional save for GUD blocks
1)
18118
18120
18130
18140
18150
18660
18661
18662
18663
18664
18665
MM_NUM_GUD_MODULES Number of GUD files in the active file system
1)
MM_NUM_GUD_NAMES_NCK Number of global GUD names
1)
MM_NUM_GUD_NAMES_CHAN Number of channel-spec. GUD names
1)
MM_NUM_GUD_NAMES_AXIS Number of axis-spec. GUD names
1)
MM_GUD_VALUES_MEM Memory location for global GUD values
1)
MM_NUM_SYNACT_GUD_REAL Number of configurable GUD of the REAL data
type
1)
MM_NUM_SYNACT_GUD_INT Number of configurable GUD of the INT data
type
1)
MM_NUM_SYNACT_GUD_BOOL Number of configurable GUD of the BOOL data
type
1)
MM_NUM_SYNACT_GUD_AXIS Number of configurable GUD of the AXIS data
type
1)
MM_NUM_SYNACT_GUD_CHAR Number of configurable GUD of the CHAR data
type
1)
MM_NUM_SYNACT_GUD_STRING Number of configurable GUD of the STRING
data type
1)
For SINUMERIK 828D, MD can only be read!
Program-global user variables (PUD)
NOTICE Visibility of program-local user variables (PUD) Program-local 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-local 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.
Job planning
30 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.1 Variables
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 (see "") 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
See also
General information about variables General information about variables [Page 17]

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

Function
Syntax
The REDEF command can be used to change system variable, user variable and NC language command attributes. 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 REDEF operation 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.
Redefinable attributes
See "Overview of definable and redefinable attributes [Page 46]".
Local user variables (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>
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
31
Flexible NC programming
1.1 Variables
Significance
REDEF: Command for the redefinition of a specific system variable, user
variable, and NC language command attribute
<name>: Name of a predefined variable or an NC language command <PP stop>: Preprocessing stop
SYNR: Preprocessing stop while reading SYNW: Preprocessing stop while writing SYNRW: Preprocessing stop while reading/writing
<phys_unit>: Physical unit
PHU <unit>:
See "Attribute: Physical unit (PHU) [Page 39]" Note
Cannot be redefined for:
System variables
Global user data (GUD)
Data types: BOOL, AXIS, STRING, FRAME
<limit values>: Lower and/or upper limit value
LLI <limit value>: Lower limit value (lower limit) ULI <limit value>: Upper limit value (upper limit)
See "Attribute: Limit values (LLI, ULI) [Page 37]" Note
Cannot be redefined for:
System variables
Global user data (GUD)
Data types: BOOL, AXIS, STRING, 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
See "Attribute: Access rights (APR, APW, APRP, APWP, APRB, APWB) [Page 41]"
Range of values: 0 to 7
Job planning
32 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
<init_time>: Point in time at which the variable is reinitialized
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 34]"
<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 34]" For the initialization of array variables: See "Definition and initialization of array variables (DEF, SET, REP)
[Page 47]" Note
Cannot be redefined for:
System variables, with the exception of setting data
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
$PATH=/_N_DEF_DIR
REDEF $TC_DPC1 APWB 2 APWP 3
REDEF $TC_DPC1 PHU 21
REDEF $TC_DPC1 LLI 0 ULI 200
REDEF $TC_DPC1 INIPO (100, 101, 102, 103)
; Description
Write access right: 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.
;
; Physical unit = [ % ]
; Limit values: lower = 0, upper = 200
; The array variable is initialized with the 4 values at POWER ON.
M30
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
33
Flexible NC programming
1.1 Variables
General 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.
See also
General information about variables General information about variables [Page 17]

1.1.7 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)
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)
Job planning
34 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.1 Variables
Reinitialization time During redefinition a 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
Number Identifier
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 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
G command
SF
PDELAYON
SETMS
G25
G26
LIMS
FPRAON
G26
G25
FXST
FXSW
OSP1
OSP2
OST1
OST2
FA
OSNSC
OSE
OSCTRL
OS
1)
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
35
Flexible NC programming
1.1 Variables
Table 1-1 Programmable setting data
General conditions
Number Identifier
43790 $SA_OSCILL_START_POS
1) This G command is used to address the setting data.
G command
OSB
1)
Initialization value: Global user variables (GUD)
•Only INIPO (POWER ON) can be defined as the initialization time for global user variables (GUD) with the NCK range of validity.
In addition to INIPO (POWER ON), INIRE (reset) or INICF (NewConfig) can be defined as the initialization time for global user variables (GUD) with the CHAN range of validity.
In the case of global user variables (GUD) with the CHAN range of validity and INIRE (reset) or INICF (NewConfig) initialization time, for an NC reset, mode group reset and 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 FRAME data type. Variables of the FRAME data type are initialized implicitly and always with the default frame.
Initialization value: CHAR data type
For variables of the CHAR data type, instead of the ASCII code (0...255), the corresponding ASCII character can be programmed in quotation marks, e.g. "A".
Initialization value: STRING data type
In the case of variables of the STRING data type, the character string must be enclosed in
quotation marks, e.g. ...= "MACHINE_1"
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).
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.
Job planning
36 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.1 Variables
Implicit initialization value: AXIS data type
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
NOTICE 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.
See also
General information about variables General information about variables [Page 17]

1.1.8 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, 02/2011, 6FC5398-2BP40-1BA0
37
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
General information about variables General information about variables [Page 17]
Job planning
38 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0

1.1.9 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
2
3 Angular position [ degree ] 4
5
6 Angular velocity [ rpm ] 7
8
9 Angular acceleration
10
11
12 Angular jerk
13 Time [ s ] 14 Position controller gain [ 16.667/s ] 15
16
18 Force [ N ] 19 Mass [ kg ] 20
21 Percent [ % ] 22 Frequency [ Hz ] 23 Voltage [ V ] 24 Current [ A ] 25 Temperature [ °C ] 26 Angle [ degree ] 27 KV [ 1000/min ] 28
29
Linear or angular position
Linear position
2)
Linear or angular velocity
Linear velocity
2)
Linear or angular acceleration
Linear acceleration
Linear or angular jerk
Linear jerk
2)
Revolutional feedrate
Temperature compensation
Moment of inertia
Linear or angular position
Cutting rate
2)
Flexible NC programming
1.1 Variables
1)2)
1)2)
1)2)
2)
1)2)
2)
1)2)
3)
3)
[ mm ], [ inch ], [ degree ]
[ mm ], [ inch ]
[ mm/min ], [ inch/min ], [ rpm ]
[ mm/min ]
[ m/s2 ], [ inch/s2 ], [ rev/s2 ]
[ m/s2 ], [ inch/s2 ]
2
]
[ rev/s
[ m/s3 ], [ inch/s3 ], [ rev/s3 ]
[ m/s3 ], [ inch/s3 ]
3
]
[ rev/s
[ mm/rev ], [ inch/rev ]
[ mm ], [ inch ]
[ kgm2 ]
[ mm ], [ inch ], [ degree ]
[ m/min ], [ feet/min ]
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
39
Flexible NC programming
1.1 Variables
<unit> Meaning Physical unit
30
Peripheral speed 31 Resistance [ ohm ] 32 Inductance [ mH ] 33
34
Torque
Torque constant
3)
35 Current controller gain [ V/A ] 36
Speed controller gain 37 Speed [ rpm ] 42 Power [ kW ] 43 Current, low [ μA ] 46
Torque, low 48 Per mil ­49 - [ Hz/s ] 65 Flow rate [ l/min ] 66 Pressure [ bar ] 67
68
Volume
Controlled-system gain
3)
69 Force controller controlled-system gain [ N/V ]
155
156
Thread lead
Change in thread lead
1) The physical unit is dependent 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.
2)
[ m/s], [ feet/s ]
[ Nm ]
3)
3)
3)
[ Nm/A ]
[ Nm/(rad*s) ]
[ μNm ]
[ cm3 ]
3)
3)
3)
[ mm/(V*min) ]
[ mm/rev ], [ inch/rev ]
[ mm/rev / rev ], [ inch/rev / rev ]
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
40 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
NOTICE 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
General information about variables General information about variables [Page 17]

1.1.10 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
1.1 Variables
Definition (DEF) of user variables
Access rights (APR.../APW...) can be defined for the following variables:
Global user data (GUD)
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
41
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
42 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
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:
/PG/ Programming Manual, Fundamentals; Chapter: G functions/Preparatory functions
Predefined functions
References:
/PG/ Programming Manual, Fundamentals; Chapter: Predefined functions
Predefined subprogram calls
References:
/PG/ Programming Manual, Fundamentals; Chapter: Predefined subprogram calls
DO operation with synchronized actions
Cycles program identifier
Flexible NC programming
1.1 Variables
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, 02/2011, 6FC5398-2BP40-1BA0
43
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.).
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.
APR/APW access attributes
For compatibility reasons, attributes APR and APW are implicitly mapped to the attributes APRP / APRB and APWP / APWB:
APR xAPRP x APRB x
APW yAPWP y APWB y
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.
Job planning
44 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.1 Variables
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
/BAD/ Operating Manual, HMI Advanced,
Chapter: Services operating area > Data administration > Modify properties
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
General information about variables General information about variables [Page 17]
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
45
Flexible NC programming
1.1 Variables

1.1.11 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 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
REDEF
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
General information about variables General information about variables [Page 17]
Job planning
46 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming

1.1.12 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: DEF <data type> <variable name>[<n>]
2dimensional: DEF <data type> <variable name>[<n>,<m>]
3dimensional: DEF <data type> <variable name>[<n>,<m>,<o>]
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
1.1 Variables
Syntax (DEF)
Values can be assigned to array elements at the following points in time:
During array definition (initialization values)
During program execution
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 (REP)
Note FRAME data type user variables cannot be assigned initialization values.
DEF <data type> <variable name>[<n>,<m>,<o>] DEF STRING[<string length>] <variable name>[<n>,<m>]
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
47
Flexible NC programming
1.1 Variables
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...)
Significance
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>)
DEF: Command to define variables <data type>: 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
<string length>: Maximum number of characters for a STRING data
type
Job planning
48 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.1 Variables
<variable name>: Variable name. [<n>,<m>,<o>]: Array sizes or array indices <n>: 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
<m>: 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
<o>: 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
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 initializing with REP.
<number_array_elements>: Number of array elements to be written with the
specified <value>. The following apply to the remaining array elements, dependent on the point in
time:
initialization when defining the array:
→ Zero is written to the remaining array elements.
Assignment during program execution:
→ 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:
initializing when defining the array:
→ All elements are pre-assigned zero
Assignment during program execution:
→ The actual values of the array elements remain
unchanged.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
49
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
FELD[n,m,o] = 1
ENDFOR
ENDFOR
ENDFOR
Job planning
50 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
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)
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 Definition and initialization of array variables (DEF, SET, REP): Further Information [Page 52]
General information about variables General information about variables [Page 17]
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
51
Flexible NC programming
1.1 Variables

1.1.13 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.
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
FELD[0,0]=SET(1,2, , ,5) ; Value assignment with gap to the first 5
ARRAY[2,3]=SET(VARIABLE,4*5.6) ; Value assignment with variable and
elements [0,0] - [0,4]
array elements [0,0] - [0,4], array elements[0,2] and [0,3] = 0
expression starting at array index [2,3]: [2,3] = VARIABLE [2,4] = 4 * 5.6 = 22.4
Job planning
52 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
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.
Flexible NC programming
1.1 Variables
elements [0] to [3] with value 3.5.
Examples:
Program code Comments
DEF REAL varName[10] ; Array definition
varName[5]=REP(4.5,3) ; Array elements [5] to [7] = 4.5
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 AXIS data type. In the case of value assignments to an axial item of machine data using 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
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
53
Flexible NC programming
1.1 Variables
NOTICE 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) Definition and initialization of array variables (DEF, SET, REP) [Page 47]
Job planning
54 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.1 Variables

1.1.14 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)
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)
±( ∼ 2,2*10
---
-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 xxx 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
General information about variables General information about variables [Page 17]
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
55
Flexible NC programming

1.2 Indirect programming

1.2 Indirect programming

1.2.1 Indirectly programming addresses

Function
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)
Syntax
Significance
Examples
<ADDRESS>[<Index>]
<ADDRESS>[...]: Fixed address with extension (index)
<index>: Index variable, e.g., spindle number, axis, ....
Example 1: Indirectly programming a spindle number
Direct programming:
Program code Comments
S1=300 ; Speed in rpm for the spindle number 1.
Indirect programming:
Program code Comments
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).
Job planning
56 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.2 Indirect programming
Example 2: Indirectly programming an axis
Direct programming:
Program code Comments
FA[U]=300 ; Feed rate 300 for axis "U".
Indirect programming:
Program code Comments
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:
Programming Comments
$AA_MM[X] ; Read probe measured value (MCS) of axis "X".
Indirect programming:
Program code Comments
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.
Example 4: Indirectly programming an axis
Direct programming:
Program code
X1=100 X2=200
Indirect programming:
Program code Comments
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
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
57
Flexible NC programming
1.2 Indirect programming
Example 5: Indirectly programming an axis
Direct programming:
Program code
G2 X100 I20
Indirect programming:
Program code Comments
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 Comments
DEF INT ARRAY1[4,5] ; Defining array 1
Indirect programming:
Program code Comments
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
Example 7: Indirect subprogram call
Program code Comments
CALL "L" << R10 ; Call the program, whose number is located in R10
(string cascading).
Job planning
58 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0

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
Flexible NC programming
1.2 Indirect programming
Examples
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.
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
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
59
Flexible NC programming
1.2 Indirect programming
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, refer to: Programming Manual, Fundamentals; Chapter "G function groups"

1.2.3 Indirectly programming position attributes (BP)

Function
Application
Syntax
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 BP.
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 CASE instruction is required, which would otherwise branch for all possible position attributes.
<POSITIONING COMMAND>[<axis/spindle>]= BP(<position>,<position attribute) <axis/spindle>=BP(<position>,<position attribute)
Job planning
60 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Significance
Flexible NC programming
1.2 Indirect programming
<POSITIONING COMMAND>[]: The following positioning commands can be
programmed together with the key word BP: POS, POSA,SPOS, SPOSA
Also possible:
All axis and spindle identifiers present in the channel:
<axis/spindle>
Variable axis/spindle identifier AX <axis/spindle>: Axis/spindle that is to be positioned BP(): 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, ...)
The values supplied from the variables have the following significance:
Value Significance Permissible for: 0 No change to the position attribute 1AC POS, POSA,SPOS, SPOSA,AX, axis address
2IC POS, POSA,SPOS, SPOSA,AX, axis address
3DC POS, POSA,SPOS, SPOSA,AX, axis address
4ACP POS, POSA,SPOS, SPOSA,AX, axis address
5ACN POS, POSA,SPOS, SPOSA,AX, axis address
6OC ­7PC ­8DAC POS, POSA,AX, axis address
9DIC 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 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
61
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 the SPOS
command in the main program.
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 Comments
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 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), Chapter: Replacement of NC functions by subprograms
Job planning
62 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0

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
Flexible NC programming
1.2 Indirect programming
Example
Note 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 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
63
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 Arcsine Arccosine Arctangent2 Square root Absolute value
2. power (square) Truncate to integer
The accuracy for comparison commands can be set using TRUNC (see "Precision correction on comparison errors (TRUNC) [Page 69]")
Round to integer Natural logarithm Exponential function Lower value of two variables
(see "Variable minimum, maximum and range (MINVAL, MAXVAL and BOUND) [Page 71]")
Larger value of two variables (see "Variable minimum, maximum and range (MINVAL,
MAXVAL and BOUND) [Page 71]")
Job planning
64 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming

5 $7$1
5 $7$1



QGYHFWRU
QGYHFWRU
$QJOH r
$QJOH r
VWYHFWRU
VWYHFWRU
1.3 Arithmetic functions
Programming
Examples
BOUND ()
Variable value within the defined value range (see "Variable minimum, maximum and range (MINVAL,
MAXVAL and BOUND) [Page 71]")
CTRANS() CROT ()
CSCALE()
CMIRROR()
Translation Rotation Change of scale Mirroring
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 of the total vector from two mutually perpendicular vectors.
The result is in one of four quadrants (-180° < 0 < +180°).
The angular reference is always based on the 2nd value in the positive direction.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
65
Flexible NC programming
1.3 Arithmetic functions
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.
R14=(R1+R2)*R3 ; Parentheses are calculated first.
R15=SQRT(POT(R1)+POT(R2)) ; Inner parentheses are resolved first:
RESFRAME=FRAME1:FRAME2 FRAME3=CTRANS(…):CROT(…)
R15 = square root of (R1+R2)
; The concatenation operator links frames
to form a resulting frame or assigns values to frame components.
Job planning
66 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
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.
The comparison operations are applicable to variables of type CHAR, INT, REAL and BOOL. The code value is compared with the CHAR type. For types STRING, AXIS and FRAME, the following are possible: == and <>, which can be used for STRING type operations, even in synchronous actions.
The result of comparison operations is always of BOOL type.
Logic operators are used to link truth values.
The logical operations can only be applied to type BOOL variables. However, they can also be applied to the CHAR, INT and REAL data types via internal type conversion.
For the logic (Boolean) operations, the following applies to theBOOL, CHAR,INT and REAL data types:
Flexible NC programming

1.4 Comparison and logic operations

Programming
0 corresponds to: FALSE
not equal to 0 means: TRUE
Bit logic operators
Logic operations can also be applied to single bits of types CHAR and INT. Type conversion is automatic.
Relational operator Significance
==
<>
> <
>=
<=
equal to not equal to greater than less than greater than or equal to less than or equal to
Logic operator Significance
AND
OR
NOT
XOR
AND OR Negation Exclusive OR
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
67
Flexible NC programming
1.4 Comparison and logic operations
Bit-by-bit logic operator Significance
B_AND
B_OR
B_NOT
B_XOR
Bit-serial AND Bit-serial OR Bit-serial negation Bit-serial 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 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.
Examples
Example 1: Relational 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
68 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0

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
TRUNC (R1*1000)
Flexible NC programming
Significance
TRUNC: Truncate decimal places
Relative quality of 10
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.
-12
taken into account for
Synchronized actions
The response described for the comparison commands also applies to synchronized actions.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
69
Flexible NC programming
1.5 Precision correction on comparison errors (TRUNC)
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) ;
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) ;
; Accuracy correction
Job planning
70 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming

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

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 MINVAL) or the larger value (in the case of MAXVAL) respectively is 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.
Syntax
<smaller value>=MINVAL(<variable1>,<variable2>) <larger value>=MAXVAL(<variable1>,<variable2>) <return value>=<BOUND>(<minimum>,<maximum>,<test variable>)
Significance
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.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
71
Flexible NC programming
1.6 Variable minimum, maximum and range (MINVAL, MAXVAL and BOUND)
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 Comments
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.
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.
Job planning
72 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
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-serial negation
2. *, /, DIV, MOD Multiplication, division
3. +, – Addition, subtraction
4. B_AND Bit AND
5. B_XOR Bit-serial exclusive OR
6. B_OR Bit-serial OR
7. AND AND
8. XOR Exclusive OR
9. OR OR
10. << Concatenation of strings, result type STRING
11. ==, <>, >, <, >=, <= Comparison operators
Flexible NC programming

1.7 Priority of the operations

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 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
73
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*
INT yes yes
BOOL yes yes yes yes yes – CHAR yes yes
STRING
AXIS–––––yes– FRAME ––––––yes
1
)
Yes
1
)Yes
Yes
1)
Yes
4)
Yes
yes*
2)
yes yes
3)
Yes
–––
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
74 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
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 76]
Type conversion from STRING (NUMBER, ISNUMBER, AXNAME) [Page 77]
Concatenation of strings (<<) [Page 78]
Conversion to lower/upper case letters (TOLOWER, TOUPPER) [Page 79]
Determine length of string (STRLEN) [Page 80]
Search for character/string in the string (INDEX, RINDEX, MINDEX, MATCH) [Page 81]
Selection of a substring (SUBSTR) [Page 82]
Selection of a single character (STRINGVAR, STRINGFELD) [Page 83]
Formatting a string (SPRINT) [Page 84]
Flexible NC programming

1.9 String operations

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".
stationary".
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
75
Flexible NC programming
1.9 String operations

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 78]")..
An INT value is converted to normal readable format. REAL values convert with up to 10 decimal places.
Type AXIS variables can be converted to STRING using the AXSTRING command.
Syntax
<STRING_ERG> = << <any_type> <STRING_ERG> = AXSTRING(<axis identifier>)
Significance
Examples
<STRING_ERG>: Variable for the result of the type conversion
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>: Variable for axis identifier
Type: AXIS
Note FRAME variables cannot be converted.
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"
Job planning
76 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.9 String operations

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 ISNUMBER command.
A string is converted into the axis data type using the AXNAME command.
Syntax
<REAL_ERG>=NUMBER("<string>") <BOOL_ERG>=ISNUMBER("<string>") <AXIS_ERG>=AXNAME("<string>")
Significance
NUMBER:The NUMBER command returns the number represented by the
<string> as REAL value. <string>: Type STRING variable to be converted <REAL_ERG>: Variable for the result of the type conversion with NUMBER
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 ISNUMBER
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:
If the <string> cannot be assigned a configured axis identifier, an
alarm is initiated. <AXIS_ERG>: Variable for the result of the type conversion with AXNAME
Type: AXIS
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
77
Flexible NC programming
1.9 String operations
Example
Program code Comments
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

1.9.3 Concatenation of strings (<<)

Function
The function "concatenation strings" allows a string to be configured from individual components.
Syntax
Significance
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.
<any_type> << <any_type>
<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>
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)
CAUTION 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 "<<".
Job planning
78 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Examples
Flexible NC programming
1.9 String operations
Example 1: Concatenation of strings
Program code Comments
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) ; Didplay:
"Index:2/value:9.654"
NO_MSG:
Example 2: Explicit type conversion with <<
Program code Comments
DEF REAL VALUE=3.5
<<VALUE ; The specified type REAL 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>")
Significance
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
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
79
Flexible NC programming
1.9 String operations
Example
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

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>")
Significance
Example
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>: Character string whose length is to be determined
Type: STRING
<INT_ERG>: Variable for the result of the determination
Type: INT
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
Job planning
80 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.9 String operations

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
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.
Significance
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 Comments
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 ; 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.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
81
Flexible NC programming
1.9 String operations
Program code Comments
PFADIDX = INDEX (INPUT, "/") +1 ; Therefore the following applies:
PFADIDX = 1
PROGIDX = RINDEX (INPUT, "/") +1 ; Therefore the following applies:
PROGIDX = 12
The SUBSTR function introduced in the next section can be used to break-up variable INPUT in the components "path" and "module":
VARIABLE = SUBSTR (INPUT, PFADIDX, PROGIDX-PFADIDX-1) ; Then returns "_N_MPF_DIR"
VARIABLE = SUBSTR (INPUT, PROGIDX) ; Then returns "_N_EXECUTE_MPF"

1.9.7 Selection of a substring (SUBSTR)

Function
This functionality extracts a substring from a string. For this purpose, the index of the first character and the desired string length (if applicable) are specified. If no length information is specified, then the string data refers to the remaining string.
Syntax
Example
STRING_ERG = SUBSTR (STRING,INT) ; Result type: INT
STRING_ERG = SUBSTR(STRING,INT, INT) ; Result type: INT
Semantics
In the first case, the substring from the position specified by the second parameter is returned up to the end of the string.
In the second case, the result string is limited to the maximum length, specified by the third parameter.
If the initial position is after the end of the string, the empty string (" ") will be returned.
If the initial position or the length is negative, an alarm is output.
Program code Comments
DEF STRING[29] ERG
ERG = SUBSTR ("ACK:10 to 99", 10, 2) ; Therefore the following
applies: ERG == "10"
Job planning
82 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.9 String operations

1.9.8 Selection of a single character (STRINGVAR, STRINGFELD)

Function
This functionality selects a single character from a string. This applies both to read access and write access operations.
Syntax
CHAR_ERG = STRINGVAR [IDX] ; Result type: CHAR
CHAR_ERG = STRINGFELD [IDX_FELD, IDX_CHAR] ; Result type: CHAR
Semantics
The character at the specified position is read/written within the string. If the position parameter is negative or greater than the string, then an alarm is output.
Example messages:
Insertion of an axis identifier into a prepared string.
Program code Comments
DEF STRING [50] MESSAGE = "Axis n has reached position"
MESSAGE [6] = "X"
MSG (MESSAGE) ; Returns the message "axis X has
reached position"
Parameters
Examples
Single character access is possible only to user-defined variables (LUD, GUD, and PUD data).
This type of access is also possible only for "call-by-value" type parameters in subprogram calls.
Example 1: Single character access to system data, machine data, etc.
Program code Comments
DEF STRING [50] STRG
DEF CHAR ACK
STRG = $P_MMCA
ACK = STRG [0] ; Evaluating the acknowledgement
components
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
83
Flexible NC programming
1.9 String operations
Example 2: Single character access with call-by-reference parameter
Program code Comments
DEF STRING [50] STRG
DEF CHAR CHR1
EXTERN UP_CALL (VAR CHAR1) ; Call-by-reference parameters!
CHR1 = STRG [5]
UP_CALL (CHR1) ; Call-by-reference
STRG [5] = CHR1

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 "Output to an external device/file (EXTOPEN, WRITE, EXTCLOSE) [Page 710]").
Syntax
Significance
"<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
84 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Format descriptions available
%B: Conversion into the "TRUE" string, if the value to be converted:
%C: Conversion into an ASCII character.
%D: Conversion into a string with an integer value (INTEGER).
%<m>D: Conversion into a string with an integer value (INTEGER). The string has a
%F: Conversion into a string with a decimal number with 6 decimal places. Where
Flexible NC programming
1.9 String operations
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.
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.
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.
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).
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 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
85
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.
%<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).
Job planning
86 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.9 String operations
%.<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).
%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.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
87
Flexible NC programming
1.9 String operations
%<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).
%.<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
88 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
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 %.<n>P can also contain 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 %P then the
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.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
89
Flexible NC programming
1.9 String operations
%<m>.<n>P: Conversion of a REAL value corresponding to the setting in machine data
MD10751$MN_SPRINT_FORMAT_P_DECIMAL into a string with:
an integer number 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.
%S: Inserting a string.
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.
%<m>S: Inserting a string with a minimum of <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:%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).
%.<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.
Job planning
90 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.9 String operations
%<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 [Page 55]").
NC data types
BOOL CHAR INT REAL STRING AXIS FRAME
%B +++++- ­%C -+- -+- ­%D ++++- - ­%F --++--­%E --++--­%G --++--­%S -+- -+- ­%X +++---­%P --++---
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
91
Flexible NC programming
1.9 String operations
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.
Job planning
92 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
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
Flexible NC programming

1.10 Program jumps and branches

Significance
GOTOS: Jump instruction where the destination is the beginning of the program.
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 GOTOS 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.
The execution is controlled via the NC/PLC interface signal: DB21, to DBX384.0 (control program branching)
Value: Significance: 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.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
93
Flexible NC programming
1.10 Program jumps and branches
Example
Program code Comments
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 GOTOF, GOTOB, GOTO or GOTOC. Program
execution is resumed with the instruction that immediately follows the destination marker. This means that branches can be realized within the program.
In addition to jump markers, main and sub-block numbers are possible as jump designation.
Syntax
Significance
If a jump condition (IF ...) is formulated before the jump instruction, the program jump is only executed if the jump condition is fulfilled.
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>
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.
Job planning
94 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming
1.10 Program jumps and branches
<jump destination>:
Jump destination parameter Possible data include:
<jump marker>: Jump destination is the jump marker (label) set
in the program with a user-defined name: <jump marker>:
<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.
IF: Keyword to formulate the jump condition.
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.
Note Jump markers (labels)
Jump markers (labels) 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: – At least 2 – A maximum of 32
Permitted characters include: –Letters – Numbers – Underscore symbols
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.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
95
Flexible NC programming
1.10 Program jumps and branches
Examples
Example 1: Jumps to jump markers
Program code Comments
N10 …
N20 GOTOF Label_1 ; Jump towards the end of the program to the jump
marker "Label_1".
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
program to the jump marker "Label_0".
N90 …
Example 2: Indirect jump to the block number
Program code Comments
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 Comments
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
...
Job planning
96 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Example 4: Jump with jump condition
Program code Comments
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.
Flexible NC programming
1.10 Program jumps and branches
fulfilled, then a jump in the direction of the beginning of the program to jump marker LA1.
Syntax
Significance
CASE(<expression>) OF <constant_1> GOTOF <jump destination_1> <constant_2> GOTOF <jump destination_2> ... DEFAULT GOTOF <jump destination_n>
CASE: Jump statement <expression>: Variable or arithmetic function OF: Keyword to formulate conditional program branches. <constant_1>: First specify constant value for the variable or arithmetic function
Type: INT
<constant_2>: Second specified constant value for the variable or arithmetic
function Type: INT
DEFAULT: For the cases where the variable or arithmetic function does not
assume any of the specified constant values, the DEFAULT instruction can be used to determine the branch destination.
Note: If the DEFAULT instruction is not programmed, then in these cases, the block following the CASE instruction is the jump destination.
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
97
Flexible NC programming
1.10 Program jumps and branches
GOTOF: Jump instruction with jump destination towards the end of the
program. Instead ofGOTOF all other GOTO commands can be programmed (refer to the subject "Program jumps to jump markers").
<jump destination_1>:
A branch is made to this jump destination if the value of the variable or arithmetic function corresponds to the first specific constant.
The jump destination can be specified as follows: <jump marker>: Jump destination is the jump marker (label)
set in the program with a user-defined name: <jump marker>:
<block number>: Jump destination is main block or sub-block
number (e.g.: 200, N300)
<jump destination_2>:
STRING type variable:
A branch is made to this jump destination if the value of the variable or arithmetic function corresponds to the second specified
Variable jump destination. The variable stands for a jump marker or a block number.
constant.
<jump destination_n>:
A branch is made to this jump destination if the value of the variable does not assume the specified constant value.
Example
Program code
...
N20 DEF INT VAR1 VAR2 VAR3
N30 CASE(VAR1+VAR2-VAR3) OF 7 GOTOF Label_1 9 GOTOF Label_2 DEFAULT GOTOF Label_3
N40 Label_1: G0 X1 Y1
N50 Label_2: G0 X2 Y2
N60 Label_3: G0 X3 Y3
...
The CASE instruction from N30 defines the following program branch possibilities:
1. If the value of the arithmetic function VAR1+VAR2-VAR3=7, then jump to the block with the jump marker definition "Label_1" ( → N40).
2. If the value of the arithmetic function VAR1+VAR2-VAR3=9, then jump to the block with the jump marker definition "Label_2" ( → N50).
3. If the value of the arithmetic function VAR1+VAR2-VAR3 is neither 7 nor 9, then jump to the block with the jump marker definition "Label_3" ( → N60).
Job planning
98 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Flexible NC programming

1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)

1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
Function
Program section repetition allows you to repeat existing program sections within a program in any order.
The program lines or program sections to be repeated are identified by jump markers (labels).
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
The following characters are permitted: –Letters – Numbers – Underscores
The first two characters must be letters or underscores.
The name of the jump marker is followed by a colon (":").
Syntax
1. Repeat individual program line:
<jump marker>: ...
...
REPEATB <jump marker> P=<n>
...
2. Repeat program section between jump marker and REPEAT statement:
<jump marker>: ...
...
REPEAT <jump marker> P=<n>
...
3. Repeat section between two jump markers:
<start jump marker>: ...
...
<end jump marker>: ...
...
REPEAT <start jump marker> <end jump marker> P=<n>
...
Job planning Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
99
Flexible NC programming
1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
Note It is not possible to nest the REPEAT statement with the two jump markers in parentheses. If
the <start jump marker> appears before the REPEAT statement and the <end jump
marker> is not reached before the REPEAT statement, the section between the <start jump marker> and the REPEAT statement will be repeated.
4. Repeat section between jump marker and ENDLABEL:
<jump marker>: ...
...
ENDLABEL: ...
...
REPEAT <jump marker> P=<n>
...
Note It is not possible to nest the REPEAT statement with the <jump marker> and the ENDLABEL
in parentheses. If the <jump marker> appears before the REPEAT statement and the
ENDLABEL is not reached before the REPEAT statement, the section between the <jump marker> and the REPEAT statement will be repeated.
Job planning
100 Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Loading...