Skip to main content

Jump

G code: G20

Function: The command executes a conditional jump.

Syntax

G20 L K

G Code Word

Description

L

. Jump target:
  • Defined line number (example: L20)

  • Jump Label

    The jump is defined by a question mark and an index (example: L?4). The command for the jump target itself is identified by an exclamation mark and the corresponding index (example: L!4). The jump target can be attached to any G code command.

    This jump is used for automatically generated CNC programs when the target line is unknown.

    Jumps with unknown targets to jump labels work in the online decoder only (not in the CNC editor).

    Requirement: The line with the jump label has to be located after the line with the jump command. "Jumping back" is not possible. If the "target line" is not defined, then commands following the jump command are not executed.

K

Condition

If K <> 0, then the jump is executed. If K is not defined, then an internal decoder variable is used.

The value of the internal decoder variable can be defined with the Changing the Values of Variables command. The default value of this internal variable is -1.

Example 25. Example: Execute jump until internal counter = 0

Ten lines are linked together by the relative mode. This results in a line movement to 100/100.

N00 G36 D10          (Setzen des Zählers auf 10)
N10 G91              (Relativer Modus)
N20 G01 X10 Y10 F100 (Bewegung um Distanz 10/10)
N30 G37 D-1          (Zähler dekrementieren)
N40 G20 L20          (Sprung, wenn Zähler != 0)


Example 26. Example: Evaluate jump condition at time of decoding

Requirement: The behavior of the variable bvar is programmed in the application. If the X-axis exceeds the position 15, then bvar FALSE is set. (bVar is initially set to TRUE.)

In the first program cycle, the X position is 10 and the program jumps to line 20. The loop is continually run because the evaluation of the condition takes place at the time of decoding and the interpolator was not started yet or is busy with the processing of objects at the beginning of the buffer. This condition fulfilled and the decoder jumps out of the loop only after enough objects are generated that the buffer is full and the interpolator begins processing.

In the second run, the X-axis is not yet at position 20. The condition is not fulfilled and bVar was not set to FALSE in the IEC code.

N0 G92 X0 Y0
N10 G91              (Relativer Modus)
N20 G01 X10 Y10 F100 (Bewegung um Distanz 10/10)
N30 G20 L20 K$bvar$  (Sprung, wenn Zähler != 0)


Example 27. Example: Insert timing synchronization

G75 executes a timing synchronization of the interpolator. G75 pauses the decoder processing until the interpolator and the mechanics reach the respective position.

N0 G92 X0 Y0
N10 G91              (Relativer Modus)
N20 G01 X10 Y10 F100 (Bewegung um Distanz 10/10)
N25 G75
N30 G20 L20 K$x$     (Sprung, wenn Zähler != 0)

For more information, see: Timing Synchronization with Interpolator



Example 28. Example: Jump to jump label

Note: Jumps to jump labels work in the online decoder only (not in the CNC editor).

N0 G16 F100 E100 E-100
N10 G20 L?4      //unconditional jump to the unknown target with index 4
N15 G20 L60
N20 G1 X1
N30 G1 X1 L!5    //resolution unknown jump target with index 5
N40 G1 Z1 L!4    //resolution unknown jump target with index 4
N50 G20 L15
N55 G1 Y1
N60 G0 X0 Y0 Z0