Then I remembered that the positioning command G1 is absolute position. This implies there is a relative position command. No, but there is a modal control for relative positioning. G91 changes to relative mode; G90 goes back to absolute mode. Hence, this code that calls the O100 subroutine which moves Z down .01" on each call. Actually. 02" because the first cut is the TO cut and the second cut is the return to start position.
I was able to find a WiFI USB that lets my shop Linux PC engage in useful metworking. From 24 Kbps to 15 Mbps. Without installing new drivers, which is always the bugaboo of Linux.
%
g17 g20 g54
O100 sub
(cut Y line subroutine)
G91 (relative movement)
G1 z-0.0100 F2.0000
G90 (absolute movement)
(start point)
G1 X-0.0610 Y-0.0610 F5.0000
(cut across Y)
G1 Y3.2710 F5.0000
G91
G1 Z-0.0100 F2.0000
G90
(cut back across Y)
G1 X-0.0610 Y-0.0610 F5.0000
O100 endsub
G1 Z1 F25
G1 X-0.0610 Y-0.0610 F5.0000
G1 Z0.05 F25
G1 Z-0.3200 F2.0000
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
O100 call
G1 Z2 F25
G1 x0 Y0 F5.0000
m2
%
Some dialects of gCode let you call a subroutine with a count of calls to make; linuxCNC is not among them.
It does not make it run any faster, nor does the C program get any faster or simpler, but it is the right way to do it! The invention of the subroutine deserves more honor and praise than it usually gets.
Obscure fact: my first full time job involved programming a Univac 1219, the commercial version of, I believe the AN/UYK-7 (radar fire control). It had a sad little attempt at a subroutine call: B7IJ. You called a subroutine at X. The processor had no concept of a stack (1965), so the return address would be stored at X and execution would start at X+1. (Just to add to the weirdness, this processor used 18-bit words, usually represented as 3 bit nibbles.)
When you were ready to return to the caller, you did an indirect jump through the address stored at X. Pretty obviously, recursion was not possible. I am sure some clever engineer came up with some Rube Goldberg method of creating a stack to allow recursion.
No comments:
Post a Comment