iTNC 530 Klartext Macros & Q-Parameters
If you know Fanuc Macro B, the Heidenhain iTNC 530 does everything #-variables and G65 do — it just calls variables Q parameters and macros subprograms (LBL/CALL LBL) or called programs (PGM CALL). Instead of cryptic variable numbers, Klartext gives you typed parameter families (Q, QL, QR, QS), plain-infix formulas, and named labels. This reference covers the iTNC 530 (final 606 42x firmware) — numbers and syntax differ on newer TNC controls, so verify against your series.
Klartext Program Structure
A conversational program is a .H file (DIN/ISO programs are .I). Every program is bracketed by BEGIN PGM and END PGM blocks carrying the program name and unit of measure, and usually opens with a BLK FORM workpiece-blank definition for graphics:
0 BEGIN PGM ELLIPSE MM
1 BLK FORM 0.1 Z X+0 Y+0 Z-20 ; blank: min corner
2 BLK FORM 0.2 X+100 Y+100 Z+0 ; blank: max corner
...
47 END PGM ELLIPSE MM
Reusable blocks of code are marked with labels and called like macros:
| Mechanism | Syntax | Rules from the manual |
|---|---|---|
| Label | LBL 1 … LBL 999 or LBL "NAME" | Each number/name may be set only once per program; LBL 0 marks a subprogram end and may repeat freely |
| Subprogram call | CALL LBL 10 (answer REP with NO ENT) | Runs from LBL 10 to the next LBL 0, then returns; a subprogram cannot call itself; CALL LBL 0 is not permitted |
| Program section repeat | CALL LBL 1 REP 2 | Repeats the section between LBL 1 and the call; up to 65 534 repeats; total executions = repeats + 1 |
| External program as subprogram | CALL PGM TNC:\ZW35\SCHRUPP\PGM1.H | No labels needed; the called program must not contain M2/M30 (use FN 9: IF +0 EQU +0 GOTO LBL 99 to jump to the end instead) and must not call back into the caller |
Write subprograms after the M2/M30 block — anything before it executes at least once even uncalled. Nesting depth: 8 levels for subprograms, 30 for program calls (a CYCL CALL counts as a program call). Two collision-relevant warnings straight from the manual: Q parameters are global across PGM CALL, so a called program can change your Q values; and coordinate transformations defined in a called program stay active in the caller unless you reset them.
Q-Parameter Types and Ranges
The iTNC 530 has four parameter families: Q (numeric, global to all programs in TNC memory), QL (numeric, local to one program), QR (numeric, nonvolatile — survives power-off, like Fanuc #500s), and QS (string). Numeric values may be ±999 999 999 (nine digits plus sign, decimal point anywhere); QS parameters hold up to 254 characters.
| Range | Who owns it |
|---|---|
| Q — global numeric | |
Q0–Q99 | Freely applicable (as long as no overlap with SL cycles; Q60–Q99 may be claimed by encoded OEM cycles — MP7251 decides local vs. global) |
Q100–Q199 | Reserved — special TNC functions (preassigned values, see below). Do not use as calculation parameters |
Q200–Q1199 | Primarily used by Heidenhain cycles (cycle transfer parameters live here) |
Q1200–Q1399 | Primarily OEM cycles |
Q1400–Q1499 / Q1500–Q1599 | Call-active / Def-active OEM cycles |
Q1600–Q1999 | Freely applicable |
| QL / QR / QS | |
QL0–QL499 | Free, local to the program (define via Q key then L) |
QR0–QR499 | Free, nonvolatile across power interruption (Q key then R) |
QS0–QS1999 | Strings; same range layout as Q, and QS100–QS199 is reserved for internal texts |
Two machine parameters change macro behavior between machines: MP7300 decides whether Q parameters reset at program end or persist, and MP7251 scopes Q60–Q99 for OEM cycles. The manual also warns that values are stored IEEE 754 binary — some decimals have round-off error, so be careful comparing calculated Q values in jump conditions.
Assignments & Arithmetic — FN 0–5 and Formulas
Press the Q key to reach the function soft keys. The classic single-operation functions:
| Function | Example | Does |
|---|---|---|
| Basic arithmetic | ||
FN 0 ASSIGN | FN 0: Q5 = +60 | Assign a value |
FN 1 ADDITION | FN 1: Q1 = -Q2 + -5 | Sum of two values |
FN 2 SUBTRACTION | FN 2: Q1 = +10 - +5 | Difference |
FN 3 MULTIPLICATION | FN 3: Q2 = +3 * +3 | Product |
FN 4 DIVISION | FN 4: Q4 = +8 DIV +Q2 | Quotient (divide by 0 not permitted) |
FN 5 SQUARE ROOT | FN 5: Q20 = SQRT 4 | Root (negative operand not permitted) |
| Trigonometry & geometry | ||
FN 6 SINE | FN 6: Q20 = SIN-Q5 | Sine of an angle in degrees |
FN 7 COSINE | FN 7: Q21 = COS-Q5 | Cosine |
FN 8 ROOT SUM OF SQUARES | FN 8: Q10 = +5 LEN +4 | Length from two values (hypotenuse) |
FN 13 ANGLE | FN 13: Q20 = +25 ANG-Q1 | Angle from arc tangent of two sides (0–360°) |
| Circle calculation | ||
FN 23 CIRCLE from 3 points | FN 23: Q20 = CDATA Q30 | Coordinate pairs in Q30–Q35 → center in Q20/Q21, radius in Q22 |
FN 24 CIRCLE from 4 points | FN 24: Q20 = CDATA Q30 | Coordinate pairs in Q30–Q37 → same result parameters (they overwrite the result parameter and the two following ones) |
The FORMULA soft key lets you skip FN numbers entirely and write whole expressions with normal precedence and parentheses. Available operators/functions: + - * /, ( ), SQ, SQRT, SIN, COS, TAN, ASIN, ACOS, ATAN, ^ (power), PI, LN, LOG, EXP, NEG, INT (truncate decimals), ABS, FRAC, SGN, and % (modulo):
16 FN 0: Q5 = +10 ; classic single-step style
17 FN 3: Q12 = +Q5 * +7
37 Q25 = ATAN (Q12/Q13) ; formula style - one block
12 Q1 = 5 * 3 + 2 * 10 ; = 35 (normal precedence)
13 Q2 = SQ 10 - 3^3 ; = 73
14 Q12 = 400 % 360 ; = 40 (modulo)
You can mix Q parameters and fixed numbers anywhere — L X+Q10 in a positioning block behaves exactly like L X+25 when Q10 = 25. Check or edit live values any time with the Q INFO soft key (all four families via SHOW PARAMETERS Q QL QR QS).
Jumps & Conditions — FN 9–12 (IF/GOTO)
If-then decisions compare a Q parameter with another parameter or a number; when true, execution jumps to a label. The jump target can be a label number, a label name in quotes, or a QS string parameter holding the name:
| Function | Example | Condition |
|---|---|---|
FN 9 IF EQUAL, JUMP | FN 9: IF +Q1 EQU +Q3 GOTO LBL "SPCAN25" | Equal (EQU) |
FN 10 IF UNEQUAL, JUMP | FN 10: IF +10 NE -Q5 GOTO LBL 10 | Not equal (NE) |
FN 11 IF GREATER, JUMP | FN 11: IF +Q1 GT +10 GOTO LBL QS5 | Greater than (GT) |
FN 12 IF LESS, JUMP | FN 12: IF +Q5 LT +0 GOTO LBL "ANYNAME" | Less than (LT) |
There is no dedicated unconditional jump — the manual’s idiom is a condition that is always true: FN 9: IF+10 EQU+10 GOTO LBL1. Note there is no GE/LE on this control; restructure the comparison instead.
String Processing with QS Parameters
QS parameters feed variable text into FN 16 logs and label jumps. Assign with DECLARE STRING; process with the STRING FORMULA functions (result is a string) or inside FORMULA (result is a number):
| Function | Example | Does |
|---|---|---|
| Assign | 37 DECLARE STRING QS10 = "WORKPIECE" | Initialize a string parameter |
| Concatenate | 37 QS10 = QS12 || QS13 || QS14 | Chain-link strings |
TOCHAR | 37 QS11 = TOCHAR ( DAT+Q50 DECIMALS3 ) | Number → string with 3 decimals |
SUBSTR | 37 QS13 = SUBSTR ( SRC_QS10 BEG2 LEN4 ) | Copy 4 chars from the 3rd position (index starts at 0) |
SYSSTR | 37 QS13 = SYSSTR ( ID321 NR0 ) | System time as text (NR0 = DD.MM.YYYY hh:mm:ss; formats 0–15) |
TONUMB | 37 Q82 = TONUMB ( SRC_QS11 ) | String → number (string must be purely numeric) |
INSTR | 37 Q50 = INSTR ( SRC_QS10 SEA_QS13 BEG2 ) | Search — returns position of first hit; returns total length if not found |
STRLEN | 37 Q52 = STRLEN ( SRC_QS15 ) | Length of a string |
STRCOMP | 37 Q52 = STRCOMP ( SRC_QS12 SEA_QS14 ) | Alphabetic compare: 0 identical, −1 / +1 ordering |
Error Output & the Other FN Functions
FN 14: ERROR interrupts program run and displays a predefined message — the Klartext equivalent of Fanuc #3000 alarms, except the texts are canned: error numbers 0–299 show “FN 14: Error code n”, 300–999 are machine-builder dialogs, and 1000–1099 are Heidenhain-defined texts (1000 “Spindle?”, 1002 “Tool radius too small”, 1014 “Touch point inaccessible”, 1025 “Excessive nesting”…). For free-form operator messages use FN 16 output to SCREEN: instead.
180 FN 14: ERROR = 254 ; display text stored under error 254
| Function | Purpose |
|---|---|
FN 15: PRINT | Unformatted output of texts or Q values through the data interface |
FN 16: F-PRINT | Formatted log output using a mask file — see the companion article iTNC 530 Tables & System Data |
FN 18: SYSREAD | Read system data (positions, tool data, transformations…) into a Q parameter — also in the companion article |
FN 19: PLC | Transfer up to two values to the PLC, e.g. 56 FN 19: PLC=+10/+Q3 (units 0.1 μm / 0.0001°) — only with the machine builder’s blessing |
FN 20: WAIT FOR | NC↔PLC sync, e.g. 32 FN 20: WAIT FOR M4095==1; the variant FN 20: WAIT FOR SYNC stops look-ahead so a following FN 18 read reflects real time |
FN 26/27/28 | Open / write / read freely definable .TAB tables — companion article |
Preassigned Q Parameters (Q100–Q199)
The TNC fills these for you — read them, never write them:
| Parameter | Contents |
|---|---|
Q100–Q107 | Values handed over from the PLC |
QS100 | Workpiece material from the WMAT block |
Q108 | Active tool radius (R + DR from table + DR from TOOL CALL) — survives power-off |
Q109 | Tool axis: −1 none, 0 X, 1 Y, 2 Z, 6 U, 7 V, 8 W |
Q110 | Spindle status: −1 undefined, 0 M3, 1 M4, 2 M5 after M3, 3 M5 after M4 |
Q111 | Coolant: 1 = M8 on, 0 = M9 off |
Q112 | Overlap factor for pocket milling (MP7430) |
Q113 | Unit of measure of the main program: 0 mm, 1 inch |
Q114 | Active tool length — survives power-off |
Q115–Q119 | Spindle position at probe contact (X, Y, Z, 4th, 5th axis) — stylus length/ball radius NOT compensated. After TT tool measurement, Q115/Q116 hold the length/radius deviation instead |
Q120–Q122 | Rotary-axis coordinates the TNC calculated for tilting with mathematical angles (A, B, C) |
Q150–Q160 / Q161–Q167 / Q170–Q172 / Q180–Q182 | Touch-probe cycle results: actual values / deviations / space angles / good-rework-scrap class — see the probing article for the full table |
Q199 | TT tool-measurement status: 0.0 in tolerance, 1.0 worn (LTOL/RTOL), 2.0 broken (LBREAK/RBREAK) |
Worked Example — Parametric Ellipse (from the manual)
The manual’s ellipse program shows the whole toolkit at once: a header of named Q assignments (part-family style), a subprogram for the machining, trig in formulas, a loop counter, and an FN 12 conditional jump:
0 BEGIN PGM ELLIPSE MM
1 Q1 = +50 ; center X
2 Q2 = +50 ; center Y
3 Q3 = +50 ; semiaxis X
4 Q4 = +30 ; semiaxis Y
5 Q5 = +0 ; start angle
6 Q6 = +360 ; end angle
7 Q7 = +40 ; number of calculation steps
...
17 CALL LBL 10 ; call machining
18 L Z+100 R0 FMAX M2
19 LBL 10 ; subprogram: machining
20 CYCL DEF 7.0 DATUM SHIFT ; shift datum to ellipse center
21 CYCL DEF 7.1 X+Q1
22 CYCL DEF 7.2 Y+Q2
25 Q35 = (Q6 - Q5) / Q7 ; angle increment
26 Q36 = Q5 ; copy start angle
27 Q37 = 0 ; loop counter
28 Q21 = Q3 * COS Q36 ; X of start point
29 Q22 = Q4 * SIN Q36 ; Y of start point
30 L X+Q21 Y+Q22 R0 FMAX M3
33 LBL 1 ; --- loop ---
34 Q36 = Q36 + Q35 ; update angle
35 Q37 = Q37 + 1 ; update counter
36 Q21 = Q3 * COS Q36
37 Q22 = Q4 * SIN Q36
38 L X+Q21 Y+Q22 R0 FQ11
39 FN 12: IF +Q37 LT +Q7 GOTO LBL 1 ; not done? loop
...
46 LBL 0 ; end of subprogram
47 END PGM ELLIPSE MM
DIN/ISO Equivalents — the D Functions
In a .I DIN/ISO program on the same control, every FN function becomes a D function with positional P01/P02/P03 operands: D00–D05 arithmetic, D09–D12 jumps (P03 = label), D14 error. Same numbers, different dress:
; Klartext ; DIN/ISO
FN 0: Q10 = +25 N150 D00 Q10 P01 +25 *
FN 1: Q1 = -Q2 + -5 D01 Q1 P01 -Q2 P02 -5 *
FN 9: IF +Q1 EQU +Q3 GOTO LBL "SPCAN25" D09 P01 +Q1 P02 +Q3 P03 "SPCAN25" *
FN 14: ERROR = 254 N180 D14 P01 254 *
References
- HEIDENHAIN, iTNC 530 Conversational Programming User's Manual, NC software 606 42x-04, 737759-24.
- HEIDENHAIN, iTNC 530 DIN/ISO Programming User's Manual, NC software 606 42x-04, 737760-24.
Have a question or want to contribute?
Contact us with corrections, additions, or topics you'd like covered.
Get in Touch