A Labelled Loop

Repeat work with a label and a conditional jump instead of copying blocks.

A label and a conditional jump turn a list of blocks into a loop. LBL 1 marks a spot; FN 12: IF … GOTO LBL 1 jumps back to it while a condition holds. This is where a program stops being a list of moves and starts being software.

Read firstHeidenhain TNC 640: Klartext & Q-ParametersWriting macros on the Heidenhain TNC 640: Klartext program structure, labels and subprograms, Q/QL/QR/QS parameter types and ranges, FN functions for math and jumps, string processing, FN 14 error output, and DIN/ISO D-function equivalents.

Your turn

Your macro is called with a hole count in Q1. Using a label and a conditional jump, count from 0 up to that number in Q2, adding each step into a running total in Q10. (With 5 holes the total is 0+1+2+3+4 = 10.)

The machine gives you

5 holes:Q1 = 5
8 holes:Q1 = 8

Your program is run once for each set of conditions. It has to work for all of them.

Loading...

This is a learning simulation — always prove out a program on the actual control before you cut metal.