Software Features

$PUSHSTATE_$POPSTATE

Program $PUSHSTATE to save certain system states, typically at the start of a subroutine; then program $POPSTATE at the end of the subroutine to restore those states. This relieves you from having to worry about whether those states were changed after you returned from a subroutine. The states are nested, like subroutines, so you can use the commands in every subroutine if desired.

The following states are saved:

  • G0/G1/G2 (rapid traverse, linear interpolation, or circular interpolation)
  • G2/G3 (clockwise/counterclockwise)
  • G5/G7 (exact/continuous motion)
  • G90/G91 (absolute/incremental)
  • Feedrate

Here is an example:

M5S1
$PUSHSTATE ; save feedrate, G90 state, etc.
G91 F200 X-1
$POPSTATE ; restore feedrate, G90 state, etc.
M6
; MAIN PROGRAM
G90 F100 X-20 Y-20
Q1
X-21 Y-21

In the main program, the first block is an absolute move (G90). Even though the subroutine changes the feedrate and calls for an incremental move (G91), the subroutine call can be followed by another absolute move, without having to worry about whether the subroutine changed the feedrate or changed to G91.