Created and Maintained by the Real World Software Developers and Machinists at www.KentechInc.com ... click here to check it out !!

Wednesday, February 27, 2013

Canned Cycle Drilling and R Plane Tricks

Wasting time drilling air when "drilling" holes in a part with multiple levels is not uncommon for the novice programmer. In this Making Chips post ... we would like to discuss the always important R plane and how you can easily control it in your G code program.

First ... the FACTS :

There are two planes that the programmer needs to be concerned with :

INITIAL PLANE ... this is the plane used for rapiding around the workpiece. This plane should always be set high enough to avoid the workpiece as well as any clamps or other fixture related objects that can be struck by the tool as it moves around the part.
  • On  Fanuc controlled or Haas machine ... the initial plane is defined as the last Z position before the canned cycle is called. So in the sample code below :
G00 G90 Z1.000
G98 G81 Z-.500 R.050 F1.0

  • Z1.00 would be considered the INITIAL PLANE ... because it is the last Z position prior to the the G81 canned cycle command.
  • In an Okuma machine ... the user can set the INITIAL PLANE by commanding a G71 Z--- line prior to the canned cycle command line. So ... imitating the above Fanuc line ... we would program :
G71 Z1.000
G81 Z-.500 R.050 F1.0

R PLANE : The R plane is defined as the plane at which the drilling operation begins. So basically the tool rapids from the Initial Plane to the R plane ... and then starts the drilling operation. The R plane is defined in the canned cycle command line. So in the above examples ... R.050 is defined as the R plane ... the point where the drilling operation would begin.

In the above programs ... the tool would rapid from the Z1.00 initial plane to the Z.050 R plane.

After drilling ... we can tell the tool where to return by using the G98 ( initial plane return ) or G99 ( R plane return ) ... for Fanuc / Haas ... in the canned cycle command line. Once commanded ... G98 / G99 becomes modal ... which means the machine will remember where it is supposed to return ... until told differently. When programming for Okuma ... we can use the M53 ( like G98 ) / M54  ( like G99 ) commands.

NEXT ... the TRICKS :

Did you know that you can very easily change the R plane when drilling on uneven surfaces?
Did you know that you can very easily change the return point between the INITIAL and R planes?

As mentioned above ... once G98 or G99 is set ... the control remembers where to go.
Also ... once the R plane is set in the canned cycle command ... it remembers where the R plane is.

But you can change either very easy ... just command it !! Like this :

(1) G00 G90 Z1.000
(2) G98 G81 Z-.500 R.050 F1.0
(3) X1.00 Y1.00
(4) G99 X2.00 Y2.00
(5) X3.00 Y3.00 R-.100
(6) G98 X4.00 Y4.00 R.050
(7) G80

(1) - Sets the Initial Plane as Z1.00
(2) - Sets the R plane as Z.050 ... return to the Z1.00 after drilling this hole
(3) - Drill this hole ... R plane is .050 and return to Z1.00 ... these were modal from (2)
(4) - After drilling this hole ... return to R plane ... still set to Z.050
(5) - Drill this hole but start at the new R plane of Z-.100 ... return to Z-.100 after drilling ... G99 is modal.
(6) - Drill this hole but start at the new R plane of Z.050 ... return to Z1.00 after drilling this hole G99.
(7) - Cancel the canned cycle ... all modal canned cycle information is cleared.

On an Okuma machine ... users can set and re-set the Initial Plane through the G71 command. On a Fanuc / Haas control ... this is not so easy. You would have to cancel the current canned cycle with a G80 ... move the Z axis to the desired Initial Plane ... then re-command a new canned cycle to set a new Initial Plane.

So ... as we illustrated here ... it's fairly easy to efficiently and effectively machine holes on uneven surfaces using a combination of the return plane commands G98 / G99 / M53 / M54 and R plane settings. Although the Initial Plane. So ... STOP CUTTING AIR !!!

Happy Chip Making !!

Check out our Real World World machine shop software at www.KentechInc.com
Conversational CAD/CAM
Quoting & Estimating
G Code Conversion
CNC Training
.... and MORE !!!


Monday, February 18, 2013

G28 - Do you REALLY Know What It Does?


Most programmers use the FANUC G28 command to return an axis to the ZERO RETURN or REFERENCE RETURN position for a variety of reasons. Because this position is normally the position of the axis almost at one end of the stroke, those reasons range from tool change considerations to clearance considerations to safety considerations.

On a CNC lathe, REFERENCE RETURN or ZERO RETURN is the normally the axis at the farthest position away from the chuck - used mostly for safety and clearance reasons. On a vertical machining center, the Z axis is normally required to be at this position for a tool change sequence to start - an alignment issue here.. On a horizontal machining center, both Z and Y may be required to be there for a tool change alignment.

The How's & Why's of ZERO RETURN ?
The ZERO RETURN position is a very important position to the machine tool because this position never changes, even after POWER OFF. Basically, the ZERO RETURN position is a fixed position in which the machine tool builder uses a physical limit switch to obtain. The normal mode of operation when finding ZERO RETURN is that the axis rapids in the zero return direction looking for the signal from the limit switch that the dog has made contact. At that point, the axis slows to a feedrate set within the control and feeds until the dog feeds off the switch. At this point, the axis will begin to feed at a slower rate, a set number of pulses of the motor or set number of turns of the ballscrew. This final distance is called the GRID SHIFT and is usually adjustable through the machine parameters.

This type of system assures that the ZERO RETURN position will be arrived at even after power off and will be the same position, within tenths, all the time. For this reason, the ZERO RETURN position is very important to the machine tool and the programmer. It is the only position on the machine that can be found again and again after power off - because of the use of the "hard wired" limit switch. For this reason, most work coordinate systems (G54-G59) and PART ZERO locations are measured from the ZERO RETURN position.

In the newer machines and newer controls (referencing FANUC controlled machines with "red cap" axis drive motors), the zero return position is memorized within the control. Although the "hard wired" limit switch is used to set the position initially and after a CNC failure, once the position is found it is memorized in the control. This allows for a much faster movement to ZERO RETURN either through the program or in the manual mode. This system is commonly referred to as DOGLESS ZERO RETURN.

Usually on older machines, after POWER OFF, it becomes necessary to re-establish the ZERO RETURN position before operation can begin. Therefore, the first act upon power on of the machine should be to return the machine to the ZERO RETURN either by the manual method or thru the programmed G28 command. Oftentimes, machines are set up and will not allow automatic operation until manual reference point return is completed. This type of machine set up restricts the initial reference point return to manual operation only.

The Program and Zero Return ?
As mentioned above, it often becomes necessary in a program to send one or all of the axis to the ZERO RETURN position for any of the reasons outlined above. This can be accomplished in the program through the G28 - Return to Reference Point command. Although most programmers use this command, I have encountered many instances when I ask them why and how they use it, they simply say, "I don't know, that's the way we do it and it works?"

Like all movement commands, G28 can be made in either the ABSOLUTE mode (G90) or INCREMENTAL mode (G91). In either case, the movement is always made through an INTERMEDIATE POINT in the G28 command. The intermediate point is a point the tool will go through before proceeding to the ZERO RETURN position.

If G28 is commanded in the ABSOLUTE mode, that is with an absolute dimension after the G28, this absolute dimension is regarded as the INTERMEDIATE POINT and the machine tool will first go to this point before moving to reference return. For example, used in a machining center, one might command :

Machining Center Ref. : G00 G90 G28 X4.00 Y2.00 ;
Lathe Ref. : G00 G28 X4.00 Z2.00 ;

The above command would move the tool from the current position to the absolute position of X4.00 and Y2.00, then to the X and Y axis reference point return position. This is movement through an absolute INTERMEDIATE POINT. This can be used for safety or clearance reasons and eliminates the need for a seperate move to the clearance point than another command to the zero return position.

When used in the INCREMENTAL mode, the G28 can produce a move directly to the zero return position. For example, the machining center command of :

Machining Center Ref. :G00 G91 G28 X0 Y0 ;
Lathe Ref. : G00 G28 U0 W0 ;

The above command actually establishes an intermediate point of with an incremental distance in X and Y of 0. Therefore the tool moves to the intermediate point (no movement) then to the reference point. The end result is a direct move to the reference point. This is commonly used in programming.

As stated in the above examples, the Return to Reference Point is performed using the modal G movement command (G00 or G01) if not commanded in the same line as the G28 command. Therefore, good programming practice is to include the G00 or G01 on the same line as the G28 command.

Happy Chip Making !!



Check out our Real World World machine shop software at www.KentechInc.com
Conversational CAD/CAM
Quoting & Estimating
G Code Conversion
CNC Training
.... and MORE !!!

Monday, February 11, 2013

The How's and Why's of Sub Programming

If you have done any manual G code program creation, you know you are always looking for some shortcuts  that can not only help cut down the data input ... but would also help eliminate errors. Whether they be typing errors or movement errors ... the less chance to create one the better.

One of the more powerful tools available to a programmer is the use of SUB PROGRAMMING. In this Making Chips post ... we would like to touch on some of the basic ideas, concepts and uses for sub programming. This post will illustrate the Fanuc / Haas coding format ... but check out the end of the post for Okuma explanations as well.

What is a Sub Program?
Basically, a sub program is a G code program that is called from another G code program. The contents of the sub program is not limited and can contain tool calls, spindle calls ... just about anything any other G code program can contain. The sub program itself resides in memory under it's own program number ... and is separate from the "main program".

Why Would I Use a Sub Program?
As mentioned above ... the less data entry means less chance for a mistake. let's take this example scenario where we have to let's say spot drilling then drill then chamfer then tap a series of holes. The less times we have to re-type those hole locations, the less chance we will have a typo and / or put a hole in the wrong place. If we can store the X / Y coordinates of the hole locations in one location and call them out as needed ... that saves data input and reduces our chances for errors. This is a good example of how a sub program ( in this case it would be the program that stores the hole locations ) can be a big help.

How Do I Program and Call a Sub Program?
A sub program scenario consists of a main program and the sub program. The main program consists of all the code that doesn't repeat itself ... the sub program consists of all the data that will be repeated. In our above example ... the tool calls, spindle calls, drilling cycles will all be different for each hole ... so we will store that in the main program ... but the hole locations will be the same so we will store them in the sub program.

When you create a sub program ... it is done just like you would create any other program. On Fanuc / Hass controls you start out with an O number ... and type the program as normal. Let's take our above example of hole locations ... the sub program might look like this :

O1234
X1.1 Y1.1
X2.2 Y2.2
X3.3 Y3.3
X4.4 Y5.5
M99
%

Notice that we have an M99 at the end ... not an M30 or M02 like a normal program. This indicates that this is a sub program ... we'll explain the M99 command a little later.

This program is entered in the control as any other program ... and resides in it's own memory space.

When a Fanuc / Haas control wants to call a sub program to run ... the programmer issues an M98 command in the Main Program. The M98 command is also followed by a P address ... which is the "O" number of the external program to run. Our above sample sub program would be called with the command :
M98 P1234

When the main program reads the M98 command ... it jumps out of the main program and starts to execute the sub program ... in this case program O1234.

When it reads the M99 command at the end of the sub program ... it jumps back to the main program to the line after the one through which it left. In other words, it jumps back to the line after the M98 command.

The Complete Story
Let's take a look at the full program and the sub program calls ... see if you can follow the path.

Main Program
O0001
G00G91G28Z0
G28X0Y0
M01
N0001
(SPOT DRILL)
G00G91G28Z0
T01M06
G90S3500M03
G00X1.100Y1.100
G43Z.500H01M08
G99G81Z-.130R.050F20.0L0
M98P1234
G80
G00G91G28Z0
M01
N0002
(DRILL)
G00G91G28Z0
T02M06
G90S3000M03
G00X1.100Y1.100
G43Z.500H02M08
G99G73Z-875R.050Q.125F20.0L0
M98P1234
G80
G00G91G28Z0
M01

ETC.    ETC.    ETC.

M30
%

Sub Program
O1234
X1.1 Y1.1
X2.2 Y2.2
X3.3 Y3.3
X4.4 Y5.5
M99
%

Can you follow the path as the program jumps to the sub program?
Here is an in-depth explanation.

N0001 
(SPOT DRILL)
G00G91G28Z0
T01M06
G90S3500M03
G00X1.100Y1.100 --------------------- Position to our first hole.
G43Z.500H01M08 --------------------- Bring the Z axis to the clearance plane.
G99G81Z-.130R.050F20.0L0 ---------- Call our canned cycle ... but use L0 which means 
                                                                the control will hold the data ... but will not
                                                                execute the cycle.
M98P1234 ----------------------------- Jump to our sub program O1234 which will cause a
                                                                hole to be spotted at each X / Y location in the sub.
G80 -------------------------------------When the M99 is read ... the program will jump 
                                                                back to here.
G00G91G28Z0
M01


N0002 ---------------------------------- This sequence basically does the same thing ...
                                                                except we are establishing a different
                                                                canned cycle before we jump to the sub program.
(DRILL)
G00G91G28Z0
T02M06
G90S3000M03
G00X.100Y.100
G43Z.500H02M08
G99G73Z-875R.050Q.125F20.0L0
M98P1234
G80
G00G91G28Z0
M01

Another Example ...
Once you are able to follow the above ... here is another scenario.

You can also call a sub program and have it executed a set number of times. Let's take the example where we want to execute a program on our lathe to make a washer (3) times. We will enter the main program and sub program as below.

Main Program :
O0001
M98 P1234 L3
M30
%

Sub Program :
O1234
*********
between here is the complete machining program that includes
tool calls ... spindle calls
the feeding of the stock
the machining of the part
the cut-off of the part
*********
M99
%

The cycle start is executed with program O0001 ... which calls the sub program O1234 and executes that program (3) times ... the L in the M98 line. This feature is different for the various Fanuc controls but is usually commanded either :

M98 P ---- L
or
M98 P****$$$$ where **** is the program number and $$$$ is the number of times to repeat.

Differences Between Fanuc / Haas and Okuma OSP
The basic ideas of calling and executing a sub program is the same between these controls ... the G code commands are a bit different. Those differences are outlined below.

Sub Program Call
Fanuc / Haas : M98
Okuma : CALL
Example : CALL O1234 will call sub program O1234

Sub Program End
Fanuc / Haas : M99
Okuma : RTS

Sub Program Call with Repeat
Fanuc / Haas : M98 P1234 L5 or M98 P12345
Okuma : CALL O1234 Q5 with the Q value being the number of repeats.

That's basically it ... just some G code differences but the basic idea and execution is the same.

**************************************

Sub programming is a powerful tool ... even if you are not trying to avoid re-typing and repeated data entry. Hopefully this Making Chips post will get you thinking and exploring all the ways sub programs can make you a better programmer.

Happy Chip Making !!

Check out our Real World World machine shop software at www.KentechInc.com
Conversational CAD/CAM
Quoting & Estimating
G Code Conversion
CNC Training
.... and MORE !!!