Tuesday, April 14, 2015

Utilizing macro statements in G code programs


CNC engineering

Standard G code programs work very well so why ever use or learn macro programming. After all, G codes call macros and any operation can be done in the form of a G code program, right? Well that’s not a hundred percent true but for all practical applications you can do everything necessary without ever calling a macro variable.  
Compared to your personal computer, machine controls have very little memory. When long repeated tool paths are necessary very lengthy programs are produced. Sometimes it is necessary to “drip feed” programs from a PC because of memory restrictions. Repeated processes lend themselves well to macro programming through branch and loop NC statements. The code repeats itself over and over until a condition is met. Four lines of code can be used to replace thousands of G code commands.  
In all types of programs readability is important for ease of understanding and organization. Macro variables can be set to any name you wish and held constant throughout a program unless the value is explicitly changed by the program or operator. Imagine the simplicity of use for finish OD diameter in a program that is written FINISHOD instead of 27.759. This is done with the macro command SETVN and written: SETVN 539[FINISHOD]; where 539 is an unused common variable and its value has been set previously. Now code can be executed in the form:
G01 X [#FINISHOD] F0.01;
Macros variables also allow you to pass values to other programs for execution. You can think of this similarly to the R, Q’s and P’s after a G81 command but you can use the data anyway you wish. One macro method causes execution to stop in one program and start another then, return exactly where the initiating program left off. This allows programs to be called that match situations changing from time to time.
Many more options are available. All it takes is a little reading in your programming manual and then a little testing during the learning curve.

manufacturing engineering

No comments:

Post a Comment