CNC Code -- Causing a Line to Be Ignored
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.
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:
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)
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*
(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:
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.
N1 (LINE BORING - TOP ROW OF DRILLS)
(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.
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"
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.
H DX=800 DY=415 DZ=22 -AB C=0 T=0 R=1 *MM /"DEF"
Row of 7 holes is going to be centered between I=100 and J=700.
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.
Would you like to add information to this article?
Interested in writing or submitting an article?
Have a question about this article?
Have you reviewed the related Knowledge Base areas below?