CNC Code -- Causing a Line to Be Ignored

Code which will exclude a line from the program. June 4, 2004

Question
Is there a character that can be placed at the beginning of a line of code that will cause that line to be ignored/skipped?

I currently have four programs to route essentially the same piece. I need different versions because, depending on the methods of joinery and manufacture, certain paths are sometimes added or omitted. If I had a way to make the machine ignore certain lines, I would only need one program to produce these four slightly different products.

Forum Responses
(CNC Forum)
From contributor C:
Yes, there should be a character that causes a line to be ignored. For instance, Biesse uses the semi colon ; character. Check your programming manual - I believe this will be different for each machine code.



From contributor S:
Some examples are the good old "/" and even a ";" for good measure. Each machine is different, so you have to try and find out which one works with yours.


From contributor B:
What machine do you have? That might help narrow it down.



From contributor T:
There are two ways to do this.

1) For ISO/EIA Standard G Code CNC controls, the "/" character indicates a Block Skip command.

Not all CNC controls support block skip. On Fanuc compatible controls, this character can be placed anywhere within a line of code for specific results.

2) Another method is to modify the line so that the CNC control treats it as a man readable comment rather than a line of code to be executed.

For ISO/EIA Standard G Code CNC controls, placing characters between parentheses "()" indicates a man-readable comment. Other controls use the semi-colon ";" Consult you CNC control manual for the proper method for your control.



From contributor D:
What's wrong with having the four different programs? Are you out of disk space? There is less chance of error by having the four different programs with four different names than modifying the same program over and over. Why chance a possible program error because someone was sleepy at the wheel?

By eliminating a line or two you may also have to add a line or two depending on what the router is doing at the time, such as rapid moves, Z height moves, etc. The use of computer programs to generate the g code for you was to help speed things up and to help eliminate errors. Sounds to me you're taking a step backwards.



From contributor M:
As others pointed out, it depends what controls you have. Each control has vocabulary it uses to run. I suggest referring to the user manual or post here what control you have. Also, I'd like you to consider a little different approach if (and it is a big if) your control understands GOTO instruction.

First, for each machine operation or path, create label with . (dot) instruction in front of each operation/path, for example .TOEKICK .HOLE .DADO, etc.

At the end of those operations put GOTO END and at the end of the program create label .END

Now, at the begin of the program use GOTO instruction and in the next field type the name of the operation you want to do. Example: GOTO TOEKICK.

Program execution is going to look like this: Computer reads first line and jumps to the label you specified with GOTO instruction, machine executes code until GOTO END and jumps to .END label, end of program. If you need two or three operations, just type that operation's name/label in the GOTO field instead .END. Example:
GOTO TOEKICK
GXX...
GXX...
GOTO DADO

Your control might have different vocabulary, but the logic is the same, and I see where you could use this if, for example, you have long programs and it is time consuming to delete all the lines of code you don't need and copy all the programs, etc.



From contributor J:
I fully agree with the last post. Parametric programming can be a very powerful tool. It's especially nice if your controller does not store a lot of programs and/or you have a capable operator.

Find out if your controller accepts commands such as the GOTO statement and the always important IF THEN. I'd then set that same program up with 2-5 lines at the beginning that look something like this:

VARA=1 (toe kick 1=yes 0=no)
VARB=0 (shelfpin holes 1=yes 0=no)
VARC=1 (back dado 1=yes 0=no)

Once your code is written for all your cut paths/operations, you can have the machine skip what you don't want by adding IF THEN's something like:

IF VARA=0 GOTO X Line

*toe kick cut path*

Line X

(if the operator switches VARA to 1 you get a toe kick)

That's a basic explanation, but I hope you get the idea. Again, this depends if your controller will support that style of programming (I think most do).

Now your operator can edit only a few values at the start and the body of the program remains unaltered, which minimizes the risk of errors mentioned earlier.

This is also an extremely powerful tool once you learn it for things like circles, simple shapes, machining operations.

We have a tiny memory in our controller (FANUC), but we keep at all times programs like:

ANYCIRCLE
ANYDOORLITE
ANYSQUARECUTOUT
ANYGROMMET
etc.

Guys on the bench love it because they can ask the operator to quickly cut a shape or make a cutout in 30 seconds with a few numbers. They don't have to bug the programmer (me) and wait for when I have time. Very powerful tool. You can really do some pretty sophisticated parts this way if you have the patience to write the code. Sometimes a little hard to debug at first, but once they work, it's very satisfying. Obviously more sophisticated programs don't just use 0 and 1 for yes or no, but can actually be values for length and widths, etc. You could also make the program perform a certain operation series by entering only 1 variable equal to say 1 through 4 (personally I never liked that method, but it does work).



From contributor J:
I'll go one step further since I really feel the more you know programming, the more power you can extract from your machine. Try to read through this and follow the logic. This program uses a few operator inputs to drill any shelf pin holes in a gable (on 32 mm centers). It uses a few key concepts that you should learn. Both the IF GOTO and the "loop" (for repeating). Read it through slowly. Don't get caught up in the specific machine codes or the actual drilling. Have a pad and paper and keep track of what the variables values are as you read. It's quite neat how this stuff works. Some machines use letters/words for variables. This control uses them in the format "#123". Remember, these are variables, not numbers.

%
O6008 (ANYSHELFPINS)
#120=100 (DIST FROM RIGHT STOP)
#121=130 (FRONT STOP TO FIRST ROW)
#122=400 (FRONT STOP TO SECOND ROW)
#123=15 (NUMBER OF HOLES)
G17 G90 G21 G40 G80
#133=#123-1
M68
G08 P1
M06
'(OP 1 DRILL HOLES TOOL 6100000 T6 100000)
'(TOOL DIAMETER 7, HOLE DIAMETERS 7)
G91 G28 Z0
M21


M23
#130=0
#120=[#120-160]

N1 (LINE BORING - TOP ROW OF DRILLS)
(USING DRILL 1)
G52 X-[#130*32]

M88 T1
G90 G0 G55 X-[#120+111] Y-[1489-#121] Z75.
G98 G81 Z5. R30. F2000.
X-[#120+111] Y-[1489-#122]
G80 T0
IF [#130EQ#133] GOTO 5
#130=[#130+1]
GOTO 1
N5 G17 G91 G28 M95
G52 X0Y0Z0
M92
G08 P0
\M07
M69
G91 G28 Z0
G28 X0 Y0
M30
%

(Worthy of noting that on this FANUC controller anything in () is just an operator note and is ignored as well as lines that begin with the ' symbol.)



From contributor O:
Our Fanuc controller supports the / and I use it often. Remember that this usually works in conjunction with the BDT switch on your controller. If the switch is on, the line will be skipped. If the switch is off, the line will be run.

It gets fun when you realize you can make ten programs into one or a thousand line program into a 40 line program. We are limited to eight characters in our program names. I think I've come to the mathematical limited number of programs (and imagination).



From contributor O:
Point of clarification regarding Fanuc. The line will only be skipped if the block skip code is at the beginning of the line. A block skip code can be used anywhere within a block for discreet code execution.


From contributor E:
We use the GOTO quite often. For a simple example, we may have a program that includes drilling holes at the beginning of the program for screwing the part down directly to the LDF tables. (We do a lot of one-off stuff.) Then there will be a table move and M0 pause so the operator can get to the part easily to screw it down. Then some machining on the part. We may stop the program after some of the machining to check to see if we need to do any tweaking. When we restart the program from the beginning, we don’t want the drilling for the holes because the part is already screwed down. We put a GOTO (line number) in right before the drilling operation where (line number) is the line just after the drilling. Here is part of a sample program.

O2081
N5 (PROGRAM#: 2081)
N10 (PROGRAMMED BY:)
N15 (CREATED ON 02/25/04 AT 14:02:46)
N20 (ROUTER SPINDLE #3 12.7 DN 38 LONG)
N25 M98 P8000 (START)
N30 G52 Z19.0
N35 M98 P8201 (Y TABLE)
N40 G90
GOTO N125
N45 #500=12
N50 #501=2048
N55 M98 P8104 (DRILL)
N60 G0 G90 X-713.0 Y-1114.0
N65 Z25.0
N70 G1 X-713.0 Y-1114.0 Z-19.5 F5000.0
N75 G0 X-713.0 Y-1114.0 Z25.0
N80 G0 X-713.0 Y-1464.0 Z25.0
N85 G1 X-713.0 Y-1464.0 Z-19.5 F5000.0
N90 G0 X-713.0 Y-1464.0 Z25.0
M75
M27
G0 X-2500 Y-250
M0 (PAUSE)
N125 (CONTOUR: 20040225.14014753)
N130 T13
N135 M98 P8101 (ROUTER#3)
N140 S16000
N145 G0 X-586.57 Y-1323.96 Z25.0
N150 G1 X-586.57 Y-1323.96 Z6.0 F4500.0
Etc.
Etc.

You could put the GOTO in anywhere. And you could use more than one in a program.

I agree about the power of using variables. I created a passage door hinge mortising program that has variables for the size of door, size of hinge, including thickness of the leaves, and also variables for the placement of the hinges based off of the distance from the top and bottom of the door, and the number of hinges. One program, many combinations. The operator just needs to enter in the variables.



From contributor M:
If you really want to go wild, you can create parametric macros or fixed cycles. Depends on what controller you use. Basically, this way you have just one instruction, one line of code that does complex machine paths/operations. It works similar to Auto Cad Lisp function.

I'll give you an example. At the university we had Weeke PTP with nice boring operation that references middle position of the row of holes. If you had 7 holes, number 4 would be position you need to input. This is helpful if you want to have row of adjustable shelf holes centered between two dados or just centered on the panel so there is same distance from the lower hole to the edge and same for the opposite side.

I don't have that option for Morbidelli machines - at least I could not find one. So I have created something like this:

H DX=0 DY=0 DZ=0 C=0 T=0 R=1 *MM /"3z,ZAHDJYGINxy,185,cyc.msg"
;Created by Mirko M.
PAR pY "Y Coordinate"
PAR pZ "Boring Depth"
PAR pH "Number of Holes"
PAR pD "Diameter"
PAR pJ "Second Reference Point"
PAR pG "Steps Number"
PAR pI "First Reference Point"
PAR pN "Boring Bit Type"
PAR px "X step"
PAR py "Y step"
PAR pA "Angle"
;
L FIRST =pI
L SECOND =pJ
L LX =SECOND-FIRST
L HX =pH
L POLA =LX/2
L XRAZ =px
L B =((HX-1)*XRAZ)/2
L BOR =((LX/2)-B)+FIRST
;
BO X=BOR Y=pY Z=pZ D=pD N=pN R=HX x=px y=py G=pG V=pV L=pL

The last line of code is actual execution of code. When I run this macro all I have to do is input positions of my upper and lower reference points and how many holes I want between those.

Example:

H DX=800 DY=415 DZ=22 -AB C=0 T=0 R=1 *MM /"DEF"
MIRBOR Y=38.1 Z=10.5 H=7 I=100 J=700 x=64 y=0 D=6.35 N="P"
C

Row of 7 holes is going to be centered between I=100 and J=700.
Little math at the begin saves a lot of math down the road.

P.S. If some of you Xilog users want to use this, you can. You might have to modify your CYC.msg file after you compile this macro because I have added a couple of lines of code in mine.



From contributor J:
Anyone have much experience with writing macros in AlphaCAM? I've been toying with my own full cabinet macro but I don't have much literature on commands, etc. Up to 2000+ lines of code and it works for the most part, but the one thing I have yet to figure out is how (if it's even possible) to have the parts "self dimension." I've got them labeling themselves already.


From contributor T:

Contributor J, you should contact AlphaCAM about getting the VBA for AlphaCAM training materials. They are a wealth of information. You can also use the AlphaCAM API help file. AlphaCAM doesn't support the legacy parametric macros any longer, so if you are going that route now, you'd be wise to reconsider. Some things will simply be impossible to do with AlphaCAM's old parametric macro language. It's only left in the product for limited legacy use.



From contributor I:
Contributor M, I use Xilog for my AUTH.504 R7. I appreciate your post - very handy.