forked from LinuxCNC/linuxcnc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
save-restore: add examples for usage for M70,M72,M73 in nc_files
- Loading branch information
Michael Haberler
committed
Mar 29, 2011
1 parent
82d3bb3
commit b659a75
Showing
5 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
; | ||
|
||
O<g20sub> sub | ||
M70 (save in current call context) | ||
|
||
g20 (imperial) | ||
g90 (absolute mode) | ||
f4 (much faster feed) | ||
G0 X1.0 Y1.0 (move absolute to 1in/1in) | ||
|
||
M71 (restore to caller context) | ||
O<g20sub> endsub | ||
|
||
m2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
; Demonstrate saving and explicitely restoring the global state around | ||
; a subroutine call using M70 - save state and M72 - restore state | ||
; | ||
; note that the subroutine itself is not aware of the M7x features | ||
|
||
O<showstate> sub | ||
(DEBUG, imperial=#<_imperial> absolute=#<_absolute> feed=#<_feed> rpm=#<_rpm>) | ||
O<showstate> endsub | ||
|
||
O<imperialsub> sub | ||
; | ||
g20 (imperial) | ||
g91 (relative mode) | ||
F5 (low feed) | ||
S300 (low rpm) | ||
; | ||
(debug, in subroutine, state now:) | ||
o<showstate> call | ||
; | ||
O<imperialsub> endsub | ||
|
||
|
||
; main program | ||
g21 (metric) | ||
g90 (absolute) | ||
f200 (fast speed) | ||
S2500 (high rpm) | ||
; | ||
(debug, in main, state now:) | ||
o<showstate> call | ||
;; | ||
M70 (save caller state in at global level) | ||
; | ||
O<imperialsub> call | ||
; | ||
M72 (explicitely restore state) | ||
; | ||
(debug, back in main, state now:) | ||
o<showstate> call | ||
; | ||
m2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
; Demonstrate saving the global state within a subroutine | ||
; using the M73 autorestore feature | ||
; | ||
|
||
O<showstate> sub | ||
(DEBUG, imperial=#<_imperial> absolute=#<_absolute> feed=#<_feed> rpm=#<_rpm>) | ||
O<showstate> endsub | ||
|
||
|
||
O<imperialsub> sub | ||
M73 (save caller state in current call context, restore on return or endsub) | ||
; | ||
g20 (imperial) | ||
g91 (relative mode) | ||
F5 (low feed) | ||
S300 (low rpm) | ||
; | ||
(debug, in subroutine, state now:) | ||
o<showstate> call | ||
(debug, arg=#1) | ||
o<test_return> if [[#1] GT 0] | ||
; if called with param #1 > 0, demonstrate restore-on-return | ||
(debug, executing return) | ||
o<test_return> return | ||
o<test_return> endif | ||
|
||
; note - no exit M7x code needed - the following endsub or an | ||
; explicit 'return' will restore caller state | ||
(debug, executing endsub) | ||
O<imperialsub> endsub | ||
|
||
|
||
; main program | ||
g21 (metric) | ||
g90 (absolute) | ||
f200 (fast speed) | ||
S2500 (high rpm) | ||
; | ||
(debug, in main after endsub, state now:) | ||
o<showstate> call | ||
; | ||
; show restore-on-endsub: | ||
o<imperialsub> call [0] | ||
; | ||
(debug, back in main after return, state now:) | ||
o<showstate> call | ||
; now show restore-on-return: | ||
o<imperialsub> call [1] | ||
; | ||
(debug, back in main, state now:) | ||
o<showstate> call | ||
; | ||
m2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
|
||
G21 (metric) | ||
F100 (note slow feed) | ||
|
||
G91 (relative mode) | ||
G1 X10 | ||
|
||
; this sub switches to G20 (inch) and G90 but protects the caller by M70/M71 | ||
; it also switches to a much higher feed | ||
O<g20sub> callsub | ||
|
||
G1 X10 (this move still relative and in metric units, note slow feed restored) | ||
m2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
; using M70/M71/M72 at the top level | ||
; note that the 'Active G-codes' window in Axis isnt properly updated | ||
; when single stepping | ||
|
||
F200 | ||
S1200 | ||
G90 (absolute mode) | ||
|
||
M70 (save state) | ||
|
||
f50 | ||
s120 | ||
g91 (relative motion) | ||
g1 x5 | ||
|
||
M72 (restore without invalidating - multiple use possible) | ||
(DEBUG, feed and speed back at f200 s1200 plus G90 restored) | ||
f100 | ||
|
||
M71 (restore and invalidate) | ||
(DEBUG, another M71 or M72 here should fail with an error message) | ||
|
||
; M71 | ||
|
||
M2 |