Peter Smid

CNC Control Setup for Milling and Turning:


Скачать книгу

program structure flaws can be quite large. Poor program structure will increase lead time and also can make a life of the operator a bit unpleasant or even difficult. These flaws of structure belong to the logical program features and mainly relate to G-codes and M-functions, particularly to their application within a program.

      One very common break of logical structure is using the right G-codes in the wrong place. Typical example are G-codes used before tool change, for example:

      N1 G21 G17 G40 G80 G90 G54 G00 G49

      N2 T01 M06

      N3 . . .

      Although technically correct, this structure has several potential problems. One is having G21 (or G20) in the same block with other G-codes, which is not allowed on some controls, especially those that can convert metric and imperial mode between each other. That may not be important for one machine, but for another, it may be very important. Placing G20/G21 in a block by itself will make the program available to more similar machines and prevents problems on those machines that require it.

       Is G20/G21 Really Needed ?

      Some programmers do not use G20 or G21 unit selection in the program at all. They often based their reasoning on the fact that only metric jobs or only jobs in imperial units are ever done on that machine. While that may be true today, it may not be true tomorrow. Programmers who do not use the proper G-code for units selection count on the following control feature:

       Units set before machine shut-off remain in effect after machine power-on

      In absolute terms, command G20 or G21 is not needed in the program, providing the units are set at the control. However, including the units selection in the program will guarantee that that only those units will be in effect - now or in the future. There is no practical difference between units set through the program and units set at the control.

      This observation slightly changes the earlier example:

      N1 G21

      N2 G17 G40 G80 G90 G54 G00 G49

      N3 T01 M06

      N4 . . .

      By isolating the G20 or G21 command, the program is one step closer to being portable between machines with similar control systems.

       G17 is Good for ...?

      Preparatory command G17 is often part of the program initial blocks, and surprisingly many CNC programmers (and operators) have no idea why it is there in the first place or what it is for.

      By definition, G17 is the first of three similar preparatory commands - each define a unique working plane:

       ▪G17 - XY plane

       ▪G18 - ZX plane

       ▪G19 - YZ plane

      Plane selection is important only in two major areas:

Circular interpolation... G02 and G03
Cutter radius offset... G41 and G42

       In circular interpolation, it supplies the MISSING AXIS:

      Consider this simple example ...

image

      ... and a section of the part program:

N1 G21
N2 G17 G40 G80 G90 G54 G00 G49
...
N21 G01 X0 Y25.0 F200.0(P1)
N22 G02 X20.0 I20.0 J0(P2)
N23 G03 X36.0 I8.0 J0(P3)
N24 G01 ...

      Note that in block N21, the linear motion ends and arc motion begins (P1). Both X and Y axes are programmed in this block. The following two blocks are both circular motions. As per drawing, the Y-axis is identical for both start points P1 and P2. Since axis commands are modal, they do not have to be repeated in every block. That accounts for only X being programmed for both arcs.

      Considering that arcs always require two axes, and also considering that they can be machined in ZX and YZ planes, the control system has to replace the axis that is not included. This is where the plane selection command comes in. In the example, G17 in block N2 provides the missing axis as the Y-axis. Control system will interpret the program as:

      N1 G21

      N2 G17 G40 G80 G90 G54 G00 G49

      ...

      N21 G01 X0 Y25.0 F200.0 (P1)

      N22 G02 X20.0 Y25.0 I20.0 J0 (P2)

      N23 G03 X36.0 Y25.0 I8.0 J0 (P3)

      N24 G01 ...

       In cutter radius offset mode, it supplies the DIRECTION:

      Cutter radius offset is programmed by two preparatory commands:

▪G41 ... cutter radius offset to the LEFT
▪G42 ... cutter radius offset to the RIGHT

      The left and right descriptions indicate position of the cutter when viewed into the cutting direction. As this direction is always relative to the three available planes, the correct plane selection command has to be included in the program.

       Initial Settings

      In addition to the plane selection command, such as G17, the initial block N2 contains several other G-codes:

       N2 G17 G40 G80 G90 G54 G00 G49

      Note that all are included before tool change, which is an important consideration.

      Many CNC programmers include these G-codes at the program beginning, mainly for two reasons:

       ▪Cancellation of commands that may be in effect

       ▪Initialization of the program mode

      The block that contains these codes is often called the safety block. Although well meant, it also presents a sense of false security. There is no guarantee that the program will run smoothly, regardless of this block.

      There are three common cancellations in block N2:

▪G40 ... Cancel cutter radius offset
▪G80 ... Cancel fixed cycle
▪G49 ... Cancel tool length offset

      Are these cancellations necessary? In one word - no. They are mainly a leftover from early days of NC and even CNC and have gained a permanency of their own. What do they represent at the program beginning?

      The answer uses three words ‘just in case’. Just in case the cutter radius is active when cutting was interrupted; just in case the fixed cycle has not been canceled; just in case the tool length offset is still active. Are these situations possible? They may be in some very extreme cases, but practically, they are not likely. The main reason is that when you press the