Sunteți pe pagina 1din 98

MECH 460

Computer Aided Manufacture

Laboratory and Information Manual

This Manual was Prepared by:

Dr. G. W. Vickers

Mr. M. H. Ly

(c) University of Victoria, 1988


(c) Updated 1989
(c) Updated 1991
(c) Updated 1992
(c) Updated 1994
Reprinted December 1996
Reprinted December 1997
(c) Updated 1999
(c) Updated 2000
(c) Updated 2003
(c) Updated 2005
(c) Updated 2006
(c) Updated 2007
TABLE OF CONTENTS

Page

Demonstration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.1

Laboratory 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1

Laboratory 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1

Laboratory 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1

Laboratory 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1

APPENDICES

A Start up and Initialization Procedure for the Victor CNC Machines . . . . . . . . . . . A.1

B Manual Operation of the CNC TNS-3 Lathe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B.1

C Automatic Operation of the Victor CNC Machines . . . . . . . . . . . . . . . . . . . . . . . . C.1

D Computer Assisted Programming for the Victor CNC Machines . . . . . . . . . . . . . D.1

E Machining the First Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E.1

F Standard G-code Start and End Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F.1

G Available G-codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.1

H Postpro.c Convert cutter location file to G-code format . . . . . . . . . . . . . . . . . . H.1

Acknowledgements
SAFETY INSTRUCTIONS

1. All work on the Victor CNC TNS-3 lathe, the Victor CNC VM-5 machining centre is
to be done under supervision.

2. Familiarize yourself with all aspects of the procedure before operating equipment. If
unsure of the correct operating procedure, request assistance from your instructor.

3. Immediately report any equipment malfunctions or unusual occurrences to your


instructor.
0.1

Demonstration
OBJECTIVE

To demonstrate the basic features and operation of the Victor numerically controlled
tools.

PROCEDURE

A. Basic CNC machines operations

- Start-up and initialization procedure of the Victor CNC machines including


zero return and G92 (see Appendix A).

- Manual operation of the CNC lathe and mill including turret indexing, tail
stock motion, table motion and tool change (see Appendix B).

- Manual data input (see Appendix C).

- DNC operation (see Appendix C).

- Computer assisted programming for the CNC machines (see Appendix D).

B. Victor CNC machines features


Victor CNC VM-5 Machining Center (see Figure 1)
Specifications:
- Maximum X axis travel 40 (1020mm)
- Maximum Y axis travel 20 (510mm)
- Spindle vertical travel (Z axis) 22 (560mm)
- Spindle speed 35-3,500 rpm
- Feed rate: tape 0.04 95 inch/min (1-2400 mm/min)
Jog 0 80 inch/min (1-2000 mm/inch)
- Rapid traverse 400 inch/min (10,000mm/min)
- Maximum weight on table 1,600 lbs (700 kg)
- Weight, less controls 12,800 lbs (5,800kg)
0.2

Figure 1. Victor Machining Center with Fanuc System 6M-B

Victor CNC TNS-3 Lathe (see Figure 2)


Specifications:
- Maximum cross travel (X-axis) 6.3
- Maximum length (Z-axis) 24.0
- Spindle speed 25-5000 rpm
- Rapid feed rate X: 16.4 ft/min Z: 32.8 ft/min
- Hydraulic chuck size 10
- Turret tool positions 10
- Net weight 11,000 lbs
0.3

Figure 2. Victor CNC TNS-3 lathe with Fanuc System 10-T


1.1

Laboratory 1
CNC Lathe with Symbolic FAPT Programming

OBJECTIVES

1. To demonstrate how to program (using the computer-assisted method called


Symbolic FAPT) and machine a simple part on the Victor CNC TNS-3 lathe.

2. To program and machine an automobile stub shaft axle using Symbolic FAPT.

REPORT

A report is not required for Lab #1.

PROCEDURE (All the following operations should be done under supervision).

A) Demonstration of FAPT programming.

1. Start and initialize the Victor CNC TNS-3 lathe as shown in Appendix A.

2. Operate the lathe in manual operation mode as shown in Appendix B.

3. Execute Symbolic FAPT at the lathe console as shown in Appendix D.

4. Produce a part program for the component shown in Figure 1.1 using the
instructions given in Figure 1.2. The part is to be machined from 38 mm diameter
aluminum bar stock.

5. Execute NC data preparation and display the toolpath on the CRT screen.
1.2

B) Programming and machining an automobile stub-shaft axle.

1. Execute Symbolic FAPT at the lathe console as shown in Appendix D.

2. Produce the part program for the component shown in Figure 1.3 using the
following approach:

C TG R R

3. Execute NC mode at the lathe console and machine the part as shown in
Appendix E. The component is to be made from 52 mm diameter aluminum bar
stock.
1.3

Fig. 1.1 Demonstration Part


   


      


 

      

       

 !  "#$"#


 %    
   &
'
  (
  )**+, -)./+,  ' 0)%+   ( -

 

%  %    $1" 

   ,  )%+, -)++, 0)++, )+, -)%+

   , )+
   ,  )%+, 0)%++
   ,  )%+, -)%++

  , )!+
   ,  )%+, 0)!++
   ,  )%+, -)%!+, 0)22+, )++
  ,  )%+, -).*+, 0)*+, )++, )++, )*+
   , 0)*!

.  .  34# 4$$4

  -3)++ 03)+++
-$)++ 0$)+++
  5
'6

!  !  - $$$4 4 #3$$1

  . , $-).+, -+)++, 0+)++


   ,      
5+7+6

   ,      
5+7+6
  8 , $-).+9, -+)++, 0+)++
   ,      
5+7+6

   ,      
5+7+6

2  2   -   $4

    2+
    (&  ':    
 1$  (&    
1;'  

  &
*   #$<  41 #    

 
 

 &
2.1

Laboratory 2
2-axis CNC Mill with AutoCAD Data Input

OBJECTIVES
1. To operate a CNC milling machine and become familiar with set-up, procedures
and data flow.
2. To use AutoCAD to define a series of closed 2-D polygons that form initials, or
other artistic creations, within a 150 x 100 mm border. To run the output data file
through the AutoLISP program called digitize.lsp.
3. To run the tool offset program Offset.c to generate a cutter location file CLfile.
4. To run the G-code file Gcodehp.c to generate machine code.
5. To set-up and machine the 2-D shape in plexiglass plate with a inch (6.35 mm)
diameter ball-mill on the Victor CNC Machining Center using the program
CNC.exe.

REPORT
The report should include the AutoCAD polygon drawing and the Matlab drawing with
the cutter-offset path. Also it should include a flow chart of the program operation
sequence and a brief assessment of the limitations of the cutter offset program.
Marks for the lab will be based upon completeness of objectives and creativity of
application in the lab report. The report will be due in class at a designated date that will
be prior to the lab #2 session. Because of the interlocking lab schedule, late reports will
not be accepted for marking.
Note: While the actual machining time is not great you should use the opportunity to
investigate the CNC machine set-up and controller operations. In subsequent labs part of
the lab mark will be given for the amount of assistance required to set-up and machine
the part.

PROCEDURE

(All the program for this Lab can be found in Windows NT server
\\designsv1\courses\mech460\lab2)

A) Demonstration of the initial CP


2.2

Step 1: Create initial using AutoCAD

Start AutoCAD to create initial and then use AutoLISP program called digitize.lsp to
output points data for input to program offset.c.

1. Make the initial CP using AutoCAD.


2. Menu Format point styles select + style to display point on screen.
3. Run command DIVIDE to create points from the curve as shown in Figure 2.1.
4. Load AutoLISP program from menu Tools AutoLISP load application
Select digitize.lsp
5. Get 3 objects from AutoCAD drawing
digitize (letter C)
Start new list of objects ? (Y/N) Y (start new lists of objects)
Are you sure? (Y/N) Y
Pick points on the screen. when finish, press enter key
Add this object to the list of objects? (Y/N) Y
Save list of objects to a file? (Y/N) N (if you have another
object to digitize)
digitize (outside letter P)
Start new list of objects ? (Y/N) N
Are you sure? (Y/N) Y
Pick points on the screen. when finish, press enter key
Add this object to the list of objects? (Y/N) Y
Save list of objects to a file? (Y/N) N (if you have another
object to digitize)
digitize (inside letter P)
Start new list of objects ? (Y/N) N
Are you sure? (Y/N) Y
Pick points on the screen. when finish, press enter key
Add this object to the list of objects? (Y/N) Y
Save list of objects to a file? (Y/N) Y (When completed)
File name: cp.dat
2.3

Figure 2.1 Create initial using AutoCAD

Step 2: program offset.c

Study the tool offset program, which determines the position of an end mill cutter in
relation to a 2-D curve defined by discrete points.

1. Understand data structure of the input (CP.DAT) and output file (CP.LOC).
2. Run program offset in DOS Window to get output file. Enter 3.175 mm for tool
radius, 1 for processing curve number 1, 1 for processing curve number 2 and 0
for processing curve number 3. Compare your output with the example output
called CP.LOC.
3. Display CP.DAT and CP.LOC to make sure the tool path is correct. To get the
output Figure 2.2 using command:
D:> start up matlab from window
drawtp
Please Input the Design Data of the Part: cp.dat
Do you want to show the cutter location?(y/n): y
Please Input the offset Data of the Part: cp.loc
2.4

The Drawing of the Design Part and Its Cutter Location


90

80

70

60

50
y

40

30

20

10
0 20 40 60 80 100 120 140
x

Figure 2.2 The initial CP with cutter path

Step 3: Program gcodehp.c

Study the machining program, which converts a cutter location file to a G-code file.

1. Understand data structure of the input data (CP.LOC) and output file (CP.GCD).
2. Run program gcodehp in DOS Window to get gcode output file. Enter (0,0,100)
for home position, 200 for feed rate, 1200 for spindle speed, 20 for Z safety and
(-3.00) for depth of cut.
3. Examine the gcode output file CP.GCD.

B) Create and machine your own series of closed 2-D polygons to form initials or
other artistic creation.
2.5

List of Computer Programs for Lab #2

AutoLISP program DIGITIZE.LSP


;===============================================================
; DIGITIZE.LSP
;This AutoLISP program saves digitized AutoCAD points to a file
;To load: From within AutoCAD, enter: (load "digitize")
;To run: From within AutoCAD, enter: digitize
; Run program for each object to be digitized
; Each digitized object will be added to list of objects
; The list of objects can be saved to a file
;================================================================
(defun c:digitize()
;==================================================================
; INITIALIZE VARIABLES
;==================================================================
(setq FD nil
PtList nil
NewOb nil
NPts 0)
;===================================================================
; START NEW LIST OF OBJECTS?
;===================================================================
(setq New (getstring "Start new list of objects? (Y/N): "))
(if (or (= New "Y") (= New "y"))
(progn
(setq Sure (getstring "Are you sure? (Y/N): "))
(if (or (= Sure "Y") (= Sure "y"))
(setq ObList nil)
)
)
)
;==================================================================
; GET POINTS FOR CURRENT OBJECT
;==================================================================
(while (setq NewPt (getpoint "\nPick point: "))
;================================================================
; JUST GET X & Y COORDS FOR CURRENT POINT
;================================================================
(setq NewPt (list (car NewPt) (cadr NewPt)))

;===============================================================
; ADD CURRENT POINT TO LIST OF POINTS FOR OBJECT
;===============================================================
(setq NewOb (reverse NewOb))
(setq NewOb (cons NewPt NewOb))
(setq NewOb (reverse NewOb))
)
2.6

;===================================================================
; ADD OBJECT TO LIST OF OBJECTS?
;===================================================================
(setq AddOb (getstring "Add this object to the list of objects? (Y/N):
"))
(if (or (= AddOb "Y") (= AddOb "y"))
(prong
;==============================================================
; ADD CURRENT OBJECT TO LIST OF OBJECTS
;==============================================================
(setq ObList (reverse ObList))
(setq ObList (cons NewOb ObList))
(setq ObList (reverse ObList))
)
)
;====================================================================
; WRITE OBJECTS TO FILE?
;====================================================================
(setq SaveOb (getstring "Save list of objects to a file? (Y/N): "))
(if (or (= SaveOb "Y") (= SaveOb "y"))
(progn
;=============================================================
; GET FILE NAME FROM USER
;=============================================================
(while (= FD nil)
(setq FName (getstring "File name: "))
(setq FD (open FName "w"))
)
;=============================================================
; WRITE NUMBER OF OBJECTS TO FIRST LINE OF FILE
;=============================================================
(setq NObs (length ObList))
(write-line (itoa NObs) FD)
;=============================================================
; WRITE DATA FOR EACH OBJECT TO FILE
;=============================================================
(setq i 0)
(repeat NObs
(setq PtList (nth i ObList))
;==========================================================
; WRITE NUMBER OF POINTS IN CURRENT OBJECT TO FILE
;==========================================================
(setq NPts (length PtList))
(write-line (itoa NPts) FD)
(setq j 0)
(repeat NPts
(setq Pt (nth j PtList))
;=======================================================
; WRITE CURRENT POINT COORDINATES TO FILE
;=======================================================
2.7
(setq XCoord (car Pt))
(setq YCoord (cadr Pt))
(setq FLine (strcat (rtos XCoord)" " (rtos YCoord) " 4.0"))
(write-line FLine FD)
(setq j (+ j 1))
)
(setq i (+ i 1))
)
(close FD)
)
)
)

Offset program
/****************************************************************************/
/* Program offset.c : to calculate the tool center coordinates */
/* for a tool of radius R moving along a curve defined by discrete point. */
/* Algorithm: */
/* calculate 2 vector unit at a given point then add these vector */
/* calculate dot vector to find angle between 2 vectors */
/* calculate cross product to find direction of the normal vector */
/* Limitation: ??? */
/* Input data format ( clockwise) */
/* number lines */
/* number points of each line */
/* x y z */
/* Output data format */
/* 1 (penup) or 0 (pen down) x y z */
/* */
/****************************************************************************/

#include <stdio.h>
#include <math.h>

#define max 120

void loc_coord (); /* function calculate cutter location */

/****************************************************************************/
/* Main Program */
/****************************************************************************/

main()

{
int numpts, numobj;
char inputf[80], outputf[80];
FILE *fopen(), *fp1, *fp2;
float cutterR,radius;
float xin[max], yin[max], z;
float xout[max], yout[max];
int i, j, side;

/**************************************************************************/
/* Get input and output files and tool radius */
/**************************************************************************/
2.8

printf("Program calculates cutter offset for profiling 2D POLYGON\n");


printf("Enter the name of the input file : ");
scanf ("%s", inputf);
fp2=fopen(inputf, "r");
if (fp2 == NULL) printf("ERROR IN OPENING INPUT FILE !!\n");

printf("Enter the name of the cutter location file : ");

scanf ("%s", outputf);


fp1 = fopen(outputf, "w");
if (fp1 == NULL) printf("ERROR IN OPENING OUTPUT FILE !!\n");
printf("Enter the tool radius : ");
scanf ("%f", &radius);

/************************************************************************/
/* Process each polygon */
/************************************************************************/

fscanf(fp2,"%d\n",&numobj);
for ( j=1; j<numobj+1; ++j)
{
printf("Processing curve number #%3d \n", j);
printf("Enter 0 = machine INSIDE the curve \n");
printf(" 1 = machine OUTSIDE the curve \n");
scanf("%d",&side);
if (side == 0)
cutterR = -radius; /* change sign of the cutter */
else
cutterR = radius;

/**********************************************************************/
/* Read input data file and store into array begining with index 1 */
/**********************************************************************/
fscanf(fp2,"%d\n", &numpts);
for ( i=1; i<numpts+1; ++i)
{
fscanf(fp2,"%f %f %f\n",&xin[i], &yin[i], &z);
}
/* check to see if the date file close or open */
/* if open, close it and increased the pointer */
if (xin[1] == xin[numpts])
{
xin[0] = xin[numpts-1];
yin[0] = yin[numpts-1];
}
else /* curve points open. close it and add one more point */
{
xin[0] = xin[numpts];
yin[0] = yin[numpts];
xin[numpts+1] = xin[1];
yin[numpts+1] = yin[1];
numpts = numpts +1;
}

/***********************************************************************/
/* Calculate offset by calling subroutine loc_coord */
/***********************************************************************/
loc_coord(cutterR, xin, yin, xout, yout,numpts);
2.9

/***********************************************************************/
/* Write output to the cutter location file */
/***********************************************************************/
fprintf(fp1, "1 %9.4f %9.4f %9.4f \n",xout[1],yout[1],z);
for ( i =2; i< numpts; i++)
fprintf(fp1, "0 %9.4f %9.4f %9.4f \n",xout[i],yout[i],z);
fprintf(fp1, "0 %9.4f %9.4f %9.4f \n",xout[1],yout[1],z);
}

fclose(fp2);
fclose(fp1);
}

/*==========================================================================*/
/* Subroutine calculates cutter location for each closed polygon */
/* Given tool radius (rad), xpt, ypt and numpts */
/* Return xoff and yoff */
/*==========================================================================*/

void loc_coord(rad,xpt,ypt,xoff,yoff,numpts)
float rad;
float xpt[], ypt[], xoff[], yoff[] ;
int numpts;

{
#define x 0
#define y 1

int k;
float vec1[2], vec2[2];
float unitvec1[2], unitvec2[2];
float plus[2], normplus[2];
float crossab,scaled, theta,temp,t1,t2;

for ( k=1; k<numpts; ++k)


{
/* calculate vector 1 from Pk to Pk+1 */
vec1[x]=xpt[k+1]-xpt[k];
vec1[y]=ypt[k+1]-ypt[k];

/* calculate vector 2 from Pk to Pk-1 */


vec2[x]=xpt[k-1]-xpt[k];
vec2[y]=ypt[k-1]-ypt[k];

/* vector unit of vector 1 */


unitvec1[x]=vec1[x]/sqrt((vec1[x]*vec1[x])+(vec1[y]*vec1[y]));
unitvec1[y]=vec1[y]/sqrt((vec1[x]*vec1[x])+(vec1[y]*vec1[y]));

/* vector unit of vector 2 */


unitvec2[x]=vec2[x]/sqrt((vec2[x]*vec2[x])+(vec2[y]*vec2[y]));
unitvec2[y]=vec2[y]/sqrt((vec2[x]*vec2[x])+(vec2[y]*vec2[y]));

/* add two vector 1 and vector 2 */


plus[x] = unitvec1[x]+unitvec2[x];
plus[y] = unitvec1[y]+unitvec2[y];

/* cross product of vector 1 and vector 2 */


crossab = (unitvec1[x]*unitvec2[y] - unitvec2[x]*unitvec1[y]);
2.10

if (crossab < 0 )
{
plus[x] = -plus[x];
plus[y] = -plus[y];
}

/* vector unit of plus vector */


normplus[x]= plus[x]/sqrt((plus[x]*plus[x])+(plus[y]*plus[y]));
normplus[y]= plus[y]/sqrt((plus[x]*plus[x])+(plus[y]*plus[y]));

/* calculate the angle bewtween two unit vector 1 & 2 by dot */


/* product of these vector */
theta=0.5*acos(unitvec1[x]*unitvec2[x]+unitvec1[y]*unitvec2[y]);

/* calculate the length of the offset point */


scaled=rad/sin(theta);

/* offset point */
xoff[k]=xpt[k]+(scaled*normplus[x]);
yoff[k]=ypt[k]+(scaled*normplus[y]);

}
}
2.11

MATLAB script file drawtp.m


% This program is to draw the initial 2-D polygon and cutter offset
% location file.
clear all;
file_name = input('Please Input the Design Data of the Part: ','s');
source_file_id = fopen( file_name, 'r');
curve_number = fscanf( source_file_id, '%d',1);
hold on
grid on
xlabel('x');
ylabel('y');
zlabel('z');
title('The Drawing of the Design Part and Its Cutter Location');
for i = 1:curve_number
point_number = fscanf(source_file_id,'%d',1);
point = fscanf(source_file_id,'%f',[3,point_number]);
plot3(point(1,:),point(2,:),point(3,:));
end
fclose( source_file_id );
answer = input('Do you want to show the cutter location?(y/n): ','s');
if ((answer == 'y')|(answer == 'Y'))
file_name = input('Please Input the offset Data of the Part: ','s');
source_file_id = fopen( file_name, 'r');
[cl_point,cl_number] = fscanf(source_file_id,'%d%f%f%f',[4,inf]);
fclose( source_file_id );
cl_number = cl_number/4;
i = 1;
indicator = cl_point(1,i);
while ((indicator == 1.0)&(i <= cl_number))
j = 1;
x(j) = cl_point(2,i);
y(j) = cl_point(3,i);
z(j) = cl_point(4,i);
if (i <= cl_number-1)
i = i+1;
end
indicator = cl_point(1,i);
while ((indicator == 0.0)&(i <= cl_number))
j = j+1;
x(j) = cl_point(2,i);
y(j) = cl_point(3,i);
z(j) = cl_point(4,i);
if (i <= cl_number-1)
i = i+1;
indicator = cl_point(1,i);
elseif (i == cl_number)
indicator = 100;
end
end
plot3(x,y,z,'--');
clear x y z
end
2.12
% Output the result of evaluation in graphics.
rotate3d;
hold off;
end

Gcode program
/**************************************************************************/
/* Program gcodehp.c : to convert a cutter location file to gcode for */
/* for CNC machine */
/* Input file: cutter location with format 1 or 0 x y z */
/* Output file: G-cdoe file */
/**************************************************************************/

#include <stdio.h>

int datafrmt, up_dwn, num ;

float feedrate, spinspd;


float zsafe, zdeep;
float xx, yy, zz;
float xin, yin, zin;

char inputf[80], outputf[80];

FILE *fopen(), *fp1, *fp2;

/***********************************************/
/* Main Program Routine */
/***********************************************/

main()

{
printf("Please enter the name of the input file name : \n");
scanf ("%s", inputf);
fp2=fopen(inputf, "r");
if (fp2 == NULL) printf("ERROR IN OPENING INPUT FILE !!\n");

printf("Please enter the G-code output file name : \n");


scanf ("%s", outputf);
fp1 = fopen(outputf, "w");
if (fp1 == NULL) printf("ERROR IN OPENING OUTPUT FILE !!\n");

printf("Enter the data format : 0 = Inches \n");


printf(" : 1 = Millimeters \n");
scanf ("%d", &datafrmt);
printf("Enter the G92 home position (x y z) : \n");
scanf ("%f%f%f", &xx, &yy, &zz);
printf("Enter feedrate : \n");
scanf ("%f", &feedrate);
printf("Enter the spindle speed in rpm : \n");
scanf ("%f", &spinspd);
printf("Enter the z safety limit coordinate : \n");
scanf ("%f", &zsafe);
printf("Enter the depth of cut : \n");
scanf ("%f", &zdeep);
2.13

/***********************************************/
/* WRITE INITIAL DATA */
/***********************************************/

num = 1;
fprintf(fp1,"O23; \n");
fprintf(fp1,"N%4d G92 X%8.3f Y%8.3f Z%8.3f; \n",num, xx, yy, zz);

num = num + 1;
if (datafrmt == 0)
fprintf(fp1,"N%4d G20; \n", num);
if (datafrmt == 1)
fprintf(fp1,"N%4d G21; \n", num);
num = num +1;
fprintf(fp1,"N%4d G90; \n", num);
num = num +1;
fprintf(fp1,"N%4d G00 Z%8.3f F%5.1f; \n", num, zsafe, feedrate);
num = num +1;
fprintf(fp1,"N%4d S%5.0f M03; \n", num, spinspd);
num = num +1;
/***********************************************/
/* READ TOOL PATH DATA */
/***********************************************/

while (!feof(fp2))
{
fscanf (fp2,"%d %f %f %f", &up_dwn, &xin, &yin, &zin);

if (up_dwn == 1)
{
fprintf(fp1,"N%4d G00 Z%8.3f; \n",num, zsafe);
num = num +1;
fprintf(fp1,"N%4d G00 X%8.3f Y%8.3f; \n",num, xin, yin);
num = num +1;
fprintf(fp1,"N%4d G01 Z%8.3f F%5.1f; \n",num, zdeep, feedrate);
num = num +1;
}

if (up_dwn == 0)
{
fprintf(fp1,"N%4d G01 X%8.3f Y%8.3f; \n",num, xin, yin);
num = num +1;
}
}
fprintf(fp1,"N%4d G00 Z%8.3f; \n", num,zz);
num = num +1;
fprintf(fp1,"N%4d G00 X%8.3f Y%8.3f; \n",num, xx, yy);
num = num +1;
fprintf(fp1,"N%4d M05; \n",num);
num = num +1;
fprintf(fp1,"N%4d M30; \n",num);
fprintf(fp1,"%% \n");
fclose(fp1);
fclose(fp2);
}
2.14

Sample data input of file CP.DAT


3
39
50.0000 20.0000 4.0
45.5000 20.0000 4.0
40.5000 21.5000 4.0
36.5000 23.0000 4.0
32.0000 25.5000 4.0
28.5000 28.5000 4.0
26.0000 32.0000 4.0
23.0000 36.5000 4.0
21.0000 40.5000 4.0
20.5000 45.0000 4.0
20.0000 49.5000 4.0
20.5000 54.5000 4.0
21.5000 59.0000 4.0
23.0000 63.5000 4.0
26.0000 67.5000 4.0
29.0000 71.0000 4.0
32.5000 74.0000 4.0
36.5000 76.0000 4.0
40.5000 78.0000 4.0
45.5000 79.0000 4.0
50.0000 79.5000 4.0
50.0000 70.0000 4.0
45.5000 69.5000 4.0
42.0000 68.5000 4.0
39.0000 66.5000 4.0
36.0000 64.0000 4.0
33.5000 61.0000 4.0
31.5000 57.5000 4.0
30.5000 54.0000 4.0
30.0000 50.0000 4.0
30.5000 46.0000 4.0
31.5000 42.5000 4.0
33.5000 39.0000 4.0
36.0000 36.0000 4.0
39.0000 33.5000 4.0
42.5000 31.5000 4.0
46.0000 30.5000 4.0
50.0000 30.0000 4.0
50.0000 20.0000 4.0
18
80.0000 20.0000 4.0
80.0000 80.0000 4.0
110.5000 80.0000 4.0
113.5000 79.5000 4.0
117.0000 78.5000 4.0
120.5000 76.0000 4.0
123.0000 73.0000 4.0
124.5000 69.5000 4.0
125.0000 65.5000 4.0
124.5000 61.5000 4.0
2.15
123.0000 58.0000 4.0
121.0000 54.5000 4.0
117.5000 52.5000 4.0
114.0000 51.0000 4.0
110.0000 50.5000 4.0
90.0000 50.5000 4.0
90.0000 20.0000 4.0
80.0000 20.0000 4.0
10
90.0000 60.0000 4.0
90.0000 70.0000 4.0
110.0000 70.0000 4.0
112.5000 69.5000 4.0
114.5000 68.0000 4.0
115.0000 65.0000 4.0
114.0000 62.5000 4.0
112.5000 60.5000 4.0
110.5000 60.0000 4.0
90.0000 60.0000 4.0

Sample data output file CP.LOC with cutter radius = 3.175mm


1 53.1750 16.8250 4.0000
0 45.0340 16.8250 4.0000
0 39.4853 18.4896 4.0000
0 35.1643 20.1100 4.0000
0 30.1775 22.8804 4.0000
0 26.1407 26.3405 4.0000
0 23.3866 30.1962 4.0000
0 20.2486 34.9033 4.0000
0 17.9070 39.5866 4.0000
0 16.8074 49.4825 4.0000
0 17.3596 55.0041 4.0000
0 18.4361 59.8486 4.0000
0 20.1509 64.9928 4.0000
0 23.5221 69.4877 4.0000
0 26.7483 73.2517 4.0000
0 30.7305 76.6650 4.0000
0 39.4604 81.0300 4.0000
0 45.0124 82.1404 4.0000
0 53.1750 83.0473 4.0000
0 53.1750 67.1582 4.0000
0 46.1157 66.3739 4.0000
0 43.3488 65.5833 4.0000
0 40.9023 63.9523 4.0000
0 38.2543 61.7457 4.0000
0 36.1180 59.1821 4.0000
0 34.4473 56.2583 4.0000
0 33.6201 53.3632 4.0000
0 33.1997 50.0000 4.0000
0 33.6201 46.6368 4.0000
0 34.4473 43.7417 4.0000
0 36.1180 40.8179 4.0000
2.16
0 38.2543 38.2543 4.0000
0 40.8179 36.1180 4.0000
0 43.7417 34.4473 4.0000
0 46.6368 33.6201 4.0000
0 53.1750 32.8028 4.0000
0 53.1750 16.8250 4.0000
1 76.8250 16.8250 4.0000
0 76.8250 83.1750 4.0000
0 110.7628 83.1750 4.0000
0 114.1993 82.6022 4.0000
0 118.3993 81.4022 4.0000
0 122.6777 78.3463 4.0000
0 125.7357 74.6766 4.0000
0 127.5949 70.3386 4.0000
0 128.1997 65.5000 4.0000
0 127.5949 60.6614 4.0000
0 125.8468 56.5824 4.0000
0 123.3271 52.1729 4.0000
0 118.9176 49.6532 4.0000
0 114.8386 47.9051 4.0000
0 110.1977 47.3250 4.0000
0 93.1750 47.3250 4.0000
0 93.1750 16.8250 4.0000
0 76.8250 16.8250 4.0000
1 93.1750 63.1750 4.0000
0 93.1750 66.8250 4.0000
0 109.6856 66.8250 4.0000
0 111.1711 66.5279 4.0000
0 111.5773 66.2233 4.0000
0 111.7222 65.3543 4.0000
0 111.2080 64.0691 4.0000
0 110.6364 63.3068 4.0000
0 110.1091 63.1750 4.0000
0 93.1750 63.1750 4.0000

Sample data output file CP.GCD


O23;
N 1 G92 X 0.000 Y 0.000 Z 100.000;
N 2 G21;
N 3 G90;
N 4 G00 Z 20.000 F200.0;
N 5 S 1200 M03;
N 6 G00 Z 20.000;
N 7 G00 X 53.175 Y 16.825;
N 8 G01 Z -3.000 F200.0;
N 9 G01 X 45.034 Y 16.825;
N 10 G01 X 39.485 Y 18.490;
N 11 G01 X 35.164 Y 20.110;
N 12 G01 X 30.177 Y 22.880;
N 13 G01 X 26.141 Y 26.340;
N 14 G01 X 23.387 Y 30.196;
N 15 G01 X 20.249 Y 34.903;
2.17
N 16 G01 X 17.907 Y 39.587;
N 17 G01 X 16.807 Y 49.482;
N 18 G01 X 17.360 Y 55.004;
N 19 G01 X 18.436 Y 59.849;
N 20 G01 X 20.151 Y 64.993;
N 21 G01 X 23.522 Y 69.488;
N 22 G01 X 26.748 Y 73.252;
N 23 G01 X 30.730 Y 76.665;
N 24 G01 X 39.460 Y 81.030;
N 25 G01 X 45.012 Y 82.140;
N 26 G01 X 53.175 Y 83.047;
N 27 G01 X 53.175 Y 67.158;
N 28 G01 X 46.116 Y 66.374;
N 29 G01 X 43.349 Y 65.583;
N 30 G01 X 40.902 Y 63.952;
N 31 G01 X 38.254 Y 61.746;
N 32 G01 X 36.118 Y 59.182;
N 33 G01 X 34.447 Y 56.258;
N 34 G01 X 33.620 Y 53.363;
N 35 G01 X 33.200 Y 50.000;
N 36 G01 X 33.620 Y 46.637;
N 37 G01 X 34.447 Y 43.742;
N 38 G01 X 36.118 Y 40.818;
N 39 G01 X 38.254 Y 38.254;
N 40 G01 X 40.818 Y 36.118;
N 41 G01 X 43.742 Y 34.447;
N 42 G01 X 46.637 Y 33.620;
N 43 G01 X 53.175 Y 32.803;
N 44 G01 X 53.175 Y 16.825;
N 45 G00 Z 20.000;
N 46 G00 X 76.825 Y 16.825;
N 47 G01 Z -3.000 F200.0;
N 48 G01 X 76.825 Y 83.175;
N 49 G01 X 110.763 Y 83.175;
N 50 G01 X 114.199 Y 82.602;
N 51 G01 X 118.399 Y 81.402;
N 52 G01 X 122.678 Y 78.346;
N 53 G01 X 125.736 Y 74.677;
N 54 G01 X 127.595 Y 70.339;
N 55 G01 X 128.200 Y 65.500;
N 56 G01 X 127.595 Y 60.661;
N 57 G01 X 125.847 Y 56.582;
N 58 G01 X 123.327 Y 52.173;
N 59 G01 X 118.918 Y 49.653;
N 60 G01 X 114.839 Y 47.905;
N 61 G01 X 110.198 Y 47.325;
N 62 G01 X 93.175 Y 47.325;
N 63 G01 X 93.175 Y 16.825;
N 64 G01 X 76.825 Y 16.825;
N 65 G00 Z 20.000;
N 66 G00 X 93.175 Y 63.175;
N 67 G01 Z -3.000 F200.0;
N 68 G01 X 93.175 Y 66.825;
2.18
N 69 G01 X 109.686 Y 66.825;
N 70 G01 X 111.171 Y 66.528;
N 71 G01 X 111.577 Y 66.223;
N 72 G01 X 111.722 Y 65.354;
N 73 G01 X 111.208 Y 64.069;
N 74 G01 X 110.636 Y 63.307;
N 75 G01 X 110.109 Y 63.175;
N 76 G01 X 93.175 Y 63.175;
N 77 G01 X 93.175 Y 63.175;
N 78 G00 Z 100.000;
N 79 G00 X 0.000 Y 0.000;
N 80 M05;
N 81 M30;
%
3.1

Laboratory 3
3-axis CNC Mill with 3 & 5-axis Pro/ENGINEER Cutter Path
Planning

OBJECTIVES

1. To operate a 3-axis CNC milling machine and become familiar with set-up,
procedures and data flow.
2. To complete the Pro/ENGINEER demonstration of surface, workpiece and tool
path generation for two intersecting quarter cylinders given in Procedure A).
3. To use Pro/ENGINEER to generate a similar size and shape object, fitting within
a 65 x 65 x 50 mm size workpiece, with an intersecting quarter cylinder and
quarter cone.
4. To use Pro/ENGINEER to produce the most efficient tool paths for 3- and 5-axis
roughing and finishing operations. Use Surface Mill to create graphical tool paths
for a inch diameter end-mill cutter. The curved surface-machining programs
should not exceed an estimated time in Pro/E of 30 minutes. The actual
machining time will be significantly longer than this.
5. To output a 3-axis cutter location file for roughing and finishing operations, and
generate G-code files using the postprocessor program given in Appendix H.
6. To set-up and machine the defined shape in a block of Ren 450 model making
material on the 3-axis Victor CNC machining center.

REPORT
The report should include Pro/E drawings of the intersecting quarter cylinder and quarter
cone with at least two different tool paths for each of 3- and 5-axis finishing operations.
It should also include the reasons for selecting the final 3-axis roughing and finishing
operations as well as the Pro/E estimated machining time.
Marks for the lab will be based primarily upon completeness of objectives in the lab
report, as well as on the amount of assistance required to set-up and machine the
component. The report will be due in class at a designated date that will be prior to the
lab #3 session. Because of the interlocking lab schedule, late reports will not be accepted
for marking.
3.2

PROCEDURE
Index
A) Demonstration of the tool path generation using Pro/ENGINEER p 3.2
Step 1: Produce the surface p 3.2
Step 2: Create the workpiece p 3.8
Step 3: Perform the 3-Axis machining operation setup p 3.10
Step 4: Define the 3-Axis machining operations p 3.13
4.1 Define mill window for first cut (rough cut)
4.2 Define the second cut (finishing Cut)
Step 5: Perform 5-axis machining operation setup p 3.20
Step 6: Create the NC code p 3.24
B) Use Pro/ENGINEER to generate an intersecting quarter cylinder and quarter
cone and machine the defined shape in Ren 450 model making material on a 3-
axis CNC machine.

Procedure Start
A) Demonstration of the tool path generation using Pro/ENGINEER (Pro/E)

Step 1: Produce the surface. The surface consists of two quarter of cylinders intersected,
together form a surface (65 x 65 x 40mm) as shown in Figure 3.18.

1. Start the Pro/E program. Windows menu items, Start Programs PTC25
Pro ENGINEER Click on the icon Pro ENGINEER.
2. Set working directory. File Set Working Directory, select working
directory.
3. Create the part name. Pro/E main menu, File New, select Part in the New
window, enter part name: lab3.
4. Start of the part. The part contains some features already. The main graphics
area shows 3 datum planes and a coordinate system as shown in Figure 3.1.
3.3

Figure 3.1 Start of the Part


5. Create a quarter of cylinder with radius of 40mm and length of 65mm.
Choose INSERT EXTRUDE from the menu. You should see a new
toolbar called dashboard appear as shown in Figure 3.2.

Figure 3.2 The Dashboard

Click on Surface icon first and then click on the placement on the extrude
dashboard (Figure 3.3) and select define. The sketch dialog window
appears as shown in Figure 3.4.

Figure 3.3 The Extrude Dashboard Figure 3.4 Sketch dialog


3.4

Choose the datum place FRONT by clicking on it in the graphics window.


Accept the default on the sketch dialog window and just click on the
Sketch button. References sub-window pop up as shown in Figure 3.5 and
click close to start sketch.

Figure 3.5 References dialog Figure 3.6 The Sketcher toolbar

Choose Create Arc by picking its center and end points icon on Sketcher
Toolbar (Figure 3.6) to sketch a quarter of circle for extrusion in plane
FRONT by clicking on the center of the default origin and draw a quarter
of circle the drawing windows. Click middle mouse to finish drawing the
rectangle.
Modify the dimensions to 40mm by double clicking on the dimensions on
the arc. To end sketching choose Accept icon on Sketcher Toolbar
(Figure 3.6) and click OK in the Section dialog.
Extrude the arc to form the quarter of cylinder. Enter depth value as 65mm
into the depth field of the extrude dashboard (Figure 3.3) and click the
Accept tick to finish (Figure 3.7).
View the surface as shown in Figure 3.8. View Orientation Standard
Orientation.
3.5

Figure 3.7 Dashboard controls Figure 3.8 First surface

6. Create another quarter of cylinder with radius of 30mm and length of 65mm.
(using previous instruction 5)
Choose the datum place RIGHT as sketch plane.
Draw a quarter of circle as shown in Figure 3.9.
Extrude the arc to 65mm.
The intersected surface is given in Figure 3.10.

Figure 3.9 Draw 30mm arc. Figure 3.10 Two intersected surfaces

7. Trim two intersected surface to form a single surface.


Trim 1st surface. EDIT TRIM to cut out the first surface behind the
second surface. Pick 1st surface as trimmed quilt and 2nd surface as
trimming object shown in Figure 3.11 and Figure 3.12 and finished
surface shown in Figure 3.13.
3.6

Figure 3.11 Pick sequences Figure 3.12 Pick 1st surface as F5

Figure 3.13 Trimmed surface

Trim 2nd surface. EDIT TRIM or pick the trim icon to cut out the
surface behind 1st surface. Pick 2nd surface as trimmed quilt and edge as
trimming object shown in Figure 3.14 and Figure 3.15.

Figure 3.14 Pick sequence Figure 3.15 Pick 2nd surface as F6


3.7
The final trimmed surface as shown in Figure 3.16

Figure 3.16 Final trimmed surface

Merge two surfaces to one surface. Select 1st surface and then hold down
Ctrl key to select 2nd surface until 2 both surfaces highlighted. Select the
merge tool as shown in the Figure 3.17 to merge two surfaces to form one
surface as shown in Figure 3.18.

Figure 3.17 Merge tool Figure 3.18 The merged Surface


3.8

Save the surface. File Save and Exit.

Step 2: Create the workpiece. The workpiece represents the raw stock of material from
which the surf will be machined. Pro/E refers to this procedure as an assembly operation.

1. Start the Pro/E program. Windows menu items, Start Programs PTC25
Pro ENGINEER Click on the icon Pro ENGINEER.
2. Set working directory. File Set Working Directory, select working
directory.
3. Create the part name. Pro/E main menu, File New, select Manufacturing in
Type window and NC Assembly in Sub-type window, enter name: mfglab3 as
shown in Figure 3.19

Figure 3.19 Creating a new file Figure 3.20 Figure 3.21

4. Load the part. From MANUFACTURE menu, select Mfg Model Assemble
Ref. Model (Figure 3.20 and 3.21). Select Lab3.prt in the open window.
The component Placement window pops up. Select to place the part at
default location as shown in Figure 3.22. Click OK to close Component
Placement windows as shown in Figure 3.23.
3.9

Figure 3.22 Figure 3.23

5. Create a datum plane ADTM1. Select to create a new datum plane offset
-8.00mm of NC_ASM_FRONT plane as shown in Figure 3.24.

Figure 3.24 Create new datum plane ADTM1

6. Create a workpiece 65 x 65x 50mm. From MANUFACTURE menu, select


Mfg Model Create workpiece. Enter a name for the workpiece: wpsurf.
Select Solid Protrusion Extrude Solid Done. Select ADTM1 as
sketch plane and NC_ASM_RIGHT as reference plane in Figure 3.25. Create
a rectangle 65 x 65mm surrounding the surface and extrude it to 50mm as
shown in Figure 3.26.
3.10

Figure 3.25 Figure 3.26

Step 3: Perform the 3-Axis machining operation setup. The setup consists of defining the
type of machine to use. It also requires defining a coordinate system if one does not
already exist and a retraction plane for the cutting tool. The coordinate system must
match the mill orientation and the part zero.

1. MFG Setup Operation. Operation Setup window pops up automatically as


shown in Figure 3.27.
2. Define NC machine. Click NC machine icon in Figure 3.27, Machine Tool
Setup windows pop up as shown in Figure 3.28. Enter the parameters as shown
below
Machine name: Victor
Machine type: Mill
Number of Axis: 3
CNC control: FANUC 6MB
Location; ELW B127
3. Define Machine Zero. Click Reference Machine Zero icon in
Figure 3.27. Create MACH CSYS as Figure 3.29. Pick workpiece to create
coordinate system in. Pick 3 reference planes as Figure 3.32 (click two sides and
top planes while holding down Ctrl key) to place origin as shown in Figure 3.30.
Orient X, Y axes as shown in Figure 3.31.
4. Define retract plane. Click Retract Surface icon in Figure 3.27.
Retract Selection window pops up (Figure 3.33). Choose Along Z Axis, and in the
panel of Enter Z Depth, input 10, click OK to close the window. The retract plane
is shown in Figure 3.34.
3.11

Figure 3.27 Figure 3.28

5. Complete Operation setup. Click OK to close operation setup as Figure 3.35.


MFG Setup Done Return.

Figure 3.29 Figure 3.30 Figure 3.31


3.12

Figure 3.32 Defining the Coordinate System

Figure 3.33 Figure 3.34 Defining the Retract Surface


3.13

Figure 3.35 Completed Operation Setup

Step 4: Define the 3-Axis machining operations. The setup consists of defining the type
of tool to use and machining parameters (tools size, cutting speed, etc.), and specify the
volume of material to be removed.

4.1 Define mill window for first cut (rough cut)


1. Machining NC Sequence Machining Surface Mill 3 Axis
Done.
2. SEQ SETUP window pops up. Ensure that name, tool, parameters, window
and define cut checked and then choose DONE. (Figure 3.36).
3. Enter NC Sequence name. Type name as Rcut.
4. Tool setup table pops up. Enter the tool values as shown in Figure 3.37 and
APPLY OK.
Cutter_Diam 12.7
Length 50
Corner Radius 0.0 (Flat end mill)
3.14

Figure 3.36 Figure 3.37

5. MFG PARAMS Set. Param Tree window pops up. Input or change the
values as shown in Figure 3.38. File save parameters to file called
milprmRcut Exit and DONE.

Figure 3.38
3.15

6. Define Mill Window. To specify the volume of material to be removed. We


defined a mill windows on the top surface of our work piece that includes
the entire work piece. Think of the work piece as being transparent and the
surface as being solid. If you look down through the mill window, you will
see all the volume of the material in the work piece located around the
surface.
NC Sequence Define Wind Create Wind as shown in Figure 3.39
and enter a name for the window (MW1)
Machine Window pop up as shown in Figure 3.40 and choose Select as
shown in Figure 3.41

Figure 3.39 Figure 3.40 Figure 3.41

Pick on each of the top edges of the workpiece as shown in Figure 3.42.
Select Done and OK and mill windows was defined.

Figure 3.42
3.16

Select Tool Side and change to Tool Past as shown in Figure 3.43. Make
sure tool machine to outside of the surface.

Figure 3.43

7. Cut Direction windows pops up as shown in Figure 3.44. Click OK to accept


the default.
8. View tool path. Machining NC Sequence Play Path NC Check. The
cutting path is shown in Figure 3.45.

Figure 3.44 Figure 3.45


3.17

9. After this completes choose DONE SEQ. If you dont do this, you are
likely to lose the definition of this NC sequence.
10. Modify cutting direction. NC Sequence Select Rcut. From SEQ SETUP,
check Define Cut Done. Change Cut Angle to 90 as shown in Figure 3.46.
The cutting path is shown in Figure 3.47.

Figure 3.46 Figure 3.47

11. Cut Angle 45 as shown in Figure 3.48 and the cutting path is shown in Figure
3.49.

Figure 3.48 Figure 3.49


3.18

4.2 Define the second cut (Finishing Cut)


1. Machining NC Sequence New Sequence Machining Surface Mill
3 Axis Done.
2. SEQ SETUP window pops up. Ensure that Name, Tool, Parameters, Surface,
Define cut are checked and then close DONE.
3. Enter NC Sequence name. Type the name as FCut.
4. Tool setup table pops up. Use same tool as RCut
Cutter_Diam 12.7
Length 50
Corner Radius 0.0 (Flat end mill)
5. MFG PARAMS Set and enter the values as shown in Figure 3.50 then File
Save to file called milprmFcut Exit and DONE.

Figure 3.50

6. Create Mill Surface. NC Sequence Seq. setup Mill Surface Done.


Define Surf Create Surf. Enter surface name: surf . Surf Define Add
Copy Done. Select the 1st cylinder and hold down Ctrl key while select 2nd
cylinder. Once two cylinders have been selected click OK on Select surface
window. Click OK to close Surface Copy window. Surf Define
Done/Return. Direction (arrow indicates side of surface to be machine)
OK. Select Srfs Select all Done/Return.
7. Cut Direction window pops up. Click OK to accept the default (Figure 3.51).
8. View tool path. Machining NC Sequence Play Path NC check. The
cutting path is shown in Figure 3.52.
3.19

Figure 3.51 Figure 3.52


9. After this completes choose DONE SEQ.
10. Modify cutting direction. NC Sequence Select Fcut. From SEQ SETUP,
check Define Cut Done. Change Cut Angle to 45 and the cutting path is
shown in Figure 3.53. For Cut angle 90, the cutting path is given in Figure
3.54.

Figure 3.53 Cut Angle 45 Figure 3.54 Cut Angle 90

11. Modify Cut Type. Select From Surface Isolines. Highlight each surface as in
Figure 3.55 to make sure the cutting direction as in Figure 3.56. Run NC
Check to display tool path as shown in Figure 3.57.
3.20

Figure 3.55 Figure 3.56

Figure 3.57

Step 5: Perform 5-axis machining operation setup.

1. MFG Setup Operation. File New and Operation Setup window pops up
automatically as shown in Figure 3.58.
2. Define NC machine. Click NC machine icon in Figure 3.27, Machine
Tool Setup windows pop up as shown in Figure 3.28. Enter the parameters as
shown below:
Machine name: Hass
Machine type: Mill
Number of Axes: 5 Axis
CNC control: VMC
3.21

3. Define Machine Zero. Select NC_CSO from operation OP010.


4. Define retract plane. Select ADTM2 from operation OP010.
5. Complete Operation setup. Click OK, Done and Return.

Figure 3.58 Figure 3.59

6. Define machining operation. Machining NC Sequence Machining


Surface Mill 5 Axis Done.
7. SEQ SETUP windows pops up. Ensure that name, tool, parameters, surface
and define cut checked and then choose DONE.
8. Enter NC sequence name. Type name as Cut5X
9. Tool setup table popup. Click OK to accept the previous tool.
10. MFG PARAMS set. Param Tree window pops up. Input or change the
values as shown in Figure 3.60. File save parameters to file called
milprm5x exit and Done.

Figure 3.60
3.22

11. Define Mill surface. Surf Pick Mill Surface Done. Select the surface as
shown in Figure 3.61 and Okay. Select all and done.

Figure 3.61
12. Cut Direction window pops up. Select OK to accept the default (Figure 3.62)
13. View tool path. Machining NC Sequence Play Path NC check. The
cutting path is shown in Figure 3.63.

Figure 3.62 Figure 3.63

14. After this completes, choose DONE SEQ.


15. Modify cutting direction. NC Sequence Select Cut5X. From SEQ SETUP,
check Define Cut -> Done. The cutting paths for angle 45 and 90 are given in
Figure 3.64 and 3.65.
3.23

Figure 3.64 Cut angle 45 Figure 3.65 Cut angle 90

16. Modify Cut type. Select from the Surface Isolines as shown in Figure 3.66 and
cutting path is given in Figure 3.67.

Figure 3.66 Figure 3.67

17. Sequence information. NC sequence Seq. info Done Sel. Information


window popup. Evaluate all information to improve cutter path.
18. Manufacturing Process. MANUFACTURE Process Mgr. Manufacturing
Process Table pops up as shown in Figure 3.68.
3.24

Figure 3.68

19. Highlight two NC sequences to display cutter paths on one screen. Tools
NC check. The cutting path is given in the Figure 3.69

Figure 3.69

Step 6: Create the NC code.

1. Machining CL Data Output Select Feature NC Sequence All


Operations RCUT. PATH FILE Done. Enter name: rcut in the Save a
Copy window. Pro/E will save the file as rcut.ncl.1. Delete the file extension
.1 to rcut.ncl for working with the postprocessor program .
3.25

2. Copy postpp.exe from \\designsv1\courses\mech460\lab3 to your current


working directory.
3. Double click to open the postpp program and enter the file name as shown in
Figure 3.70.

Figure 3.70

4. The rcut.ncl and rcut.gcd file should be open with program wordpad to edit.

The rcut.ncl file is shown below:


$$* Pro/CLfile Version Wildfire 2.0 - M090
$$-> MFGNO / MFG0001
PARTNO / MFG0001
$$-> FEATNO / 34
MACHIN / UNCX01, 1
$$-> CUTCOM_GEOMETRY_TYPE / OUTPUT_ON_CENTER
UNITS / INCHES
LOADTL / 1
$$-> CUTTER / 12.700000
$$-> CSYS / 1.0000000000, 0.0000000000, 0.0000000000, 0.0000000000,
$
0.0000000000, 1.0000000000, 0.0000000000, 0.0000000000,
$
0.0000000000, 0.0000000000, 1.0000000000, 0.0000000000
SPINDL / RPM, 1200.000000, CLW
RAPID
GOTO / 71.1937467454, 66.4000000000, 10.0000000000
FEDRAT / 400.000000, IPM
GOTO / 71.1937467454, 66.4000000000, 0.0000000000
GOTO / -6.1937467454, 66.4000000000, 0.0000000000
.............
GOTO / 46.1434284767, -1.4000000000, -40.0000000000
GOTO / 46.1434284767, -1.4000000000, 10.0000000000
SPINDL / OFF
$$-> END /
FINI
3.26

The rcut.gcd is shown below:


0111;
T1; (delete this line)
G00 X 71.194 Y 66.400 Z 10.000;
F 400.000;
G01 X 71.194 Y 66.400 Z 0.000;
G01 X -6.194 Y 66.400 Z 0.000;
.......
G01 X 46.143 Y -1.400 Z -40.000;
G01 X 46.143 Y -1.400 Z 10.000;
M30;
%

Edit the beginning and the end of the gcode file so that it works on the Victor
Machining Center as shown below:
0111;
G90 G21; (Absolute, mm)
G92 X0.0 Y0.0 Z100.0; (Set home position)
S1200 M03; (Set spindle speed and switch on)
G00 X 71.194 Y 66.400 Z 10.000;
F 400.000;
G01 X 71.194 Y 66.400 Z 0.000;
G01 X -6.194 Y 66.400 Z 0.000;
.......
G01 X 46.143 Y -1.400 Z -40.000;
G01 X 46.143 Y -1.400 Z 10.000;
G00 X0.0 Y0.0 Z100.0; (Return home)
M05: (Set spindle off)
M30; (End of program and rewind)
%

B) Use Pro/ENGINEER to generate an intersecting quarter cylinder and quarter


cone and machine the defined shape in Ren 450 model making material on a 3-
axis CNC machine.
4.1

Laboratory 4
3-axis CNC Curved Surface Machining and Error
Measurement

OBJECTIVES

1. To create a minimum number of 36 (6 x 6) data points from a mathematical


surface model and input the data files into Pro/E to generate an analytical curved
surface.
2. To superimpose a 2-D engraving shape onto the analytical curved surface. The
engraving shape should be done on a fairly flat part of the surface, due to the
vertical projection and geometry of the engraving tool.
3. To produce the most efficient tool paths for 3- and 5-axis roughing and finishing
operations. Produce the appropriate G-code files for 3-axis roughing, finishing
and surface engraving in a 4 x 4 x 2 inch size workpiece. Use the 1/2 inch
diameter end-mill for roughing, the 3/8 inch diameter end-mill or ball-mill for
finishing and the engraving tool. The machining operations should not exceed an
estimated time in Pro/E of 45 minutes. The actual machining time will be
significantly longer than this.
4. To machine the finished workpiece in Ren 450 model making material on a 3-axis
CNC machine.
5. To measure the machined surface using the Coordinate Measuring Machine,
CMM, with GEOPAK software. Measurements should be taken at the control
points (to assess machining errors) and away from the control points (to assess
machining and surface fitting errors).

REPORT
The report should include the CAD drawings, with CAM drawings for at least two
different tool paths for each of 3- and 5-axis finishing operations. It should also include
the reasons for selecting the final 3-axis roughing and finishing operations, the estimated
machining time, and the error between the analytical and machined surfaces.
4.2

Marks for the lab will be based primarily upon completeness of objectives and creativity
of application as well as on the amount of assistance required to set-up and machine the
component.

PROCEDURE

Index
A) Demonstration of surface machining and engraving using Pro/ENGINEER
Step 1: Plot a mathematical surface and generate control points using Matlab p 4.2
Step 2: Produce the surface using Pro/E p 4.6
Step 3: Create the workpiece p 4.8
Step 4: Perform the manufacturing setup p 4.10
Step 5: Define the machining operations p 4.11
5.1 Define mill window for first cut (rough cut) p 4.11
5.2 Define the second cut (Finishing Cut) p 4.13
Step 6: View tool path simulation and create the NC code p 4.14
Step 7: Engrave 2-D shape on to the surface p 4.15
B) Machine the finished workpiece in Ren 450 model making material p 4.17
C) Measure the machined surface and compare with the analytical surface using a
CMM
p 4.17

Procedure Start
A) Demonstration of surface machining and engraving using Pro/ENGINEER

[( x y 2 ) 2 + y 2 ]
Step 1: Plot the surface z = xe and generate control points using Matlab.
1. Start up matlab and using the following functions to plot the surface as shown
in Figure 4.1.
>> [x,y]=meshgrid(-2:.1:2);
>> z=x.*exp(-((x-y.^2).^2+y.^2));
>> mesh(x,y,z),xlabel('X'),ylabel('Y'),zlabel('Z')
4.3

0.5

0
Z

-2
-0.5
2 -1
1
0
0
1
-1
Y
-2 2
X

Figure 4.1

2. Generate 9 control points for y = -2.0 using the following functions


>> x=[-2.0, -1.5, -1, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0];
>> y = -2.0;
>> z=x.*exp(-((x-y.^2).^2+y.^2))

z=

Columns 1 through 6

-0.0000 -0.0000 -0.0000 -0.0000 0 0.0025

Columns 7 through 9

0.0221 0.0901 0.1980

3. Generate another 9 control points for y = -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5
and 2.0.

4. Arrange 81 control points together to create a file called lab4.ibl as shown


in page 4.4.
4.4

Lab4.ibl

open Arclength
Begin section !1
Begin curve !1
1 -2.0 -2.0 0.0
2 -1.5 -2.0 0.0
3 -1.0 -2.0 0.0
4 -0.5 -2.0 0.0
5 0.0 -2.0 0.0
6 0.5 -2.0 0.0
7 1.0 -2.0 0.0
8 1.5 -2.0 0.0
9 2.0 -2.0 0.0
Begin section !2
Begin curve !1
1 -2.0 -1.5 0.0
2 -1.5 -1.5 0.0
3 -1.0 -1.5 0.0
4 -0.5 -1.5 0.0
5 0.0 -1.5 0.0
6 0.5 -1.5 0.0025
7 1.0 -1.5 0.0221
8 1.5 -1.5 0.0901
9 2.0 -1.5 0.1980
Begin section !3
Begin curve !1
1 -2.0 -1.0 -0.0001
2 -1.5 -1.0 -0.0011
3 -1.0 -1.0 -0.0067
4 -0.5 -1.0 -0.0194
5 0.0 -1.0 0.0
6 0.5 -1.0 0.1433
7 1.0 -1.0 0.3679
8 1.5 -1.0 0.4298
9 2.0 -1.0 0.2707
Begin section !4
Begin curve !1
1 -2.0 -0.5 -0.0099
2 -1.5 -0.5 -0.0546
3 -1.0 -0.5 -0.1632
4 -0.5 -0.5 -0.2219
5 0.0 -0.5 0.0
6 0.5 -0.5 0.3658
7 1.0 -0.5 0.4437
8 1.5 -0.5 0.2449
9 2.0 -0.5 0.0728
Begin section !5
Begin curve !1
1 -2.0 0.0 -0.0366
2 -1.5 0.0 -0.1581
3 -1.0 0.0 -0.3679
4 -0.5 0.0 -0.3894
4.5
5 0.0 0.0 0.0
6 0.5 0.0 0.3894
7 1.0 0.0 0.3679
8 1.5 0.0 0.1581
9 2.0 0.0 0.0366
Begin section !6
Begin curve !1
1 -2.0 0.5 -0.0099
2 -1.5 0.5 -0.0546
3 -1.0 0.5 -0.1632
4 -0.5 0.5 -0.2219
5 0.0 0.5 0.0
6 0.5 0.5 0.3658
7 1.0 0.5 0.4437
8 1.5 0.5 0.2449
9 2.0 0.5 0.0728
Begin section !7
Begin curve !1
1 -2.0 1.0 -0.0001
2 -1.5 1.0 -0.0011
3 -1.0 1.0 -0.0067
4 -0.5 1.0 -0.0194
5 0.0 1.0 0.0
6 0.5 1.0 0.1433
7 1.0 1.0 0.3679
8 1.5 1.0 0.4298
9 2.0 1.0 0.2707
Begin section !8
Begin curve !1
1 -2.0 1.5 0.0
2 -1.5 1.5 0.0
3 -1.0 1.5 0.0
4 -0.5 1.5 0.0
5 0.0 1.5 0.0
6 0.5 1.5 0.0025
7 1.0 1.5 0.0221
8 1.5 1.5 0.0901
9 2.0 1.5 0.1980
Begin section !9
Begin curve !1
1 -2.0 2.0 0.0
2 -1.5 2.0 0.0
3 -1.0 2.0 0.0
4 -0.5 2.0 0.0
5 0.0 2.0 0.0
6 0.5 2.0 0.0
7 1.0 2.0 0.0
8 1.5 2.0 0.0
9 2.0 2.0 0.0
4.6

Step 2: Produce the surface using Pro/E. The part consists of 81 control points, together
forming a surface (4 x 4 x 1) as shown in Figure 4.4.

1. Copy lab4.ibl to your working directory.


2. Start the Pro/E program. Windows menu items, Start Programs PTC25
Pro ENGINEER Click on the icon Pro ENGINEER.
3. Set working directory. File Set Working Directory, Select
workingdirectory.
4. Create the part name. Pro/E main menu, File New, select Part in the New
window, enter part name: lab4srf.

5. Create a 4 x 4 x 1 surface.
Insert menu Advanced Blend from file Surface. Select default
Coord system PRT_CSYS_DEF. Enter file Name: lab4.ibl. Choose
default arrow for Material Side. Click ok button in figure 4.2.
View Model Setup Mesh Surface Meshing spacing. Select
current surface and enter 50 for 1st direction and 2nd direction as shown in
figure 4.3. The surface will display as shown in Figure 4.4.
Save the part. File Save and Exit.

Figure 4.2 Figure 4.3


4.7

Figure 4.4
4.8

Step 3: Create the workpiece. The workpiece represents the raw stock of material from
which the part will be machined. Pro/E refers to this procedure as an assembly operation.

1. Start the Pro/E program. Windows menu items, Start Programs PTC25
Pro ENGINEER Click on the icon Pro ENGINEER.
2. Set working directory. File Set Working Directory. Select working
directory.
3. Create the part name. Pro/E main menu, File New, select Manufacturing in
New window and NC Assembly in Sub-type window, enter name: mfglab4.
4. Load the surface. From MANUFACTURE menu, select Mfg Model
Assemble Ref Model. Select lab4srf in the pop up window and place the
surface at default location.
5. Create a datum plane. Select to create a new datum plane offset 0.75 of
NC_ASM_FRONT plane as shown in Figure 4.5.

Figure 4.5
4.9

6. Create a workpiece. From MANUFACTURE menu, select Mfg Model


Create workpiece. Enter a name for the workpiece: wplab4. Select Solid
Protrusion Extrude Solid Done. Select ADTM1 as sketch plane and
NC_ASM_RIGHT as reference plane in Figure 4.6. Create a rectangle 4 x 4
x 1.5 with the surface in the center as shown in Figure 4.7.

Figure 4.6

Figure 4.7
4.10

Step 4: Perform the manufacturing setup. The setup consists of defining the type of
machine to use. It also requires defining a coordinate system if one does not already exist
and a retraction plane for the cutting tool. The coordinate system must match the mill
orientation and the part zero.

1. MFG Setup Operation. Operation Setup window pops up automatically.


2. Define NC machine. Click the machine icon , Machine Tool Setup windows
pop up. Enter the parameters as shown below
Machine name: Victor
Machine type: Mill
Number of Axis: 3
CNC control: FANUC
3. Define Machine Zero. Click Reference Machine Zero icon, Menu Manager
MACH CSYS Create. Pick workpiece and three plane of the workpiece to
define coordinate system in top left corner of the workpiece (Figure 4.8).
4. Define retract plane. Click the cursor button, Choose Along Z Axis, and in the
panel of Enter Z Depth, input 0.5, click OK to close the window (Figure 4.8).

Figure 4.8
4.11

Step 5: Define the machining operations. The setup consists of defining the type of tool
to use and machining parameters (tools size, cutting speed, etc.), and specify the volume
of material to be removed (created in the previous step).

5.1 Define mill window for the first cut (Rough Cut)
1. Machining NC Sequence Machining Surface Mill 3 Axis
Done.
2. SEQ SETUP window pops up. Ensure that Name, Tool, Parameters, Window,
Define cut are checked and then close DONE.
3. Enter NC Sequence name. Type the name as RoughCut.
4. Tool setup table pops up. Input or change the parameter to the following
values:
Cutter_Diam 0.5 (1/2 diameter end mill)
Length 3
Corner Radius 0.0 (Flat end mill)
5. MFG PARAMS Set and enter the values as shown in Figure 4.9 then File
Exit DONE.

Figure 4.9
4.12

6. Define Mill Window. NC Sequence Define Wind Create Wind and


Enter a name for the window: mwsurf . Machine Window pop up as shown in
Figure 4.10 and choose Select as shown in Figure 4.11. Pick on each of the
top edge of the workpiece and select done and ok. The mill window was
defined. Select Tool side and change to Tool past.

Figure 4.10 Figure 4.11

7. Cut Direction window pops up. Click OK to accept the default.


8. View tool path. Machining NC Sequence Play Path NC Check. The
cutting path is shown in Figure 4.12.

Figure 4.12

After this completes choose DONE SEQ. If you dont do this, you are likely
to lose the definition of this toolpath!
4.13

5.2 Define the second cut (Finishing Cut)


1. Machining NC Sequence New Sequence Machining Surface Mill
3 Axis Done.
2. SEQ SETUP window pops up. Ensure that Name, Tool, Parameters, Surface,
Define cut are checked and then close DONE.
3. Enter NC Sequence name. Type the name as FinishCut.
4. Tool setup table pops up. Input or change the parameter to the following
values:
Cutter_Diam 0.375 (3/8 diameter ball mill)
Length 3
Corner Radius 0.1875 (ball mill)
5. MFG PARAMS Set and enter the values as shown in Figure 4.13 then File
Exit DONE.

6. Create Mill Surface. NC Sequence SEQ Setup Mill Surface Done


(Figure 4.14). Define Surf Create Surf. Enter surface name: surf. Surf
Define Add Copy Done. Select the lab4surf and click OK on Select
surface window. Clip OK to close Surface Copy Window. Surf Deinfe
Done/Return. Direction (arrow indicates side of surface to be machine)
OK. Select Srfs Select all Done/Return.

7. Cut Direction window pops up. Machine in Y direction.

Figure 4.13
4.14

8. View tool path. Machining NC Sequence Play Path NC check. The


cutting path is shown in Figure 4.14.

Figure 4.14

Step 6: View combination tool path simulation and create the NC code.

1. Manufacturing Process. Manufacture Process Mgr. Manufacturing Process


table pops up as shown in Figure 4.15.

Figure 4.15

2. Highlight two NC sequences to display cutter paths on one screen. Tools


NC Check. The cutting path is given in the Figure 4.16.
4.15

Figure 4.16

3. Machining CL Data Output Select Feature NC Sequence


ROUGHCUT. PATH FILE Done. Enter name: surf in the Save a Copy
window. Pro/E will save the file as roughcut.ncl.1. Also output CL data for
FINISHCUT. Save and exit Pro/E
4. Change file name from roughcut.ncl.1 to roughcut.ncl on command window
for working with the postprocessor program
5. Copy postpp.exe from \\designsv1\courses\mech460\lab3 to your current
working directory.
6. Convert two ncl files to gcode files using postpp program.
7. Open gcode files to edit using program wordpad.

Step7: Engrave 2-D shape on to the surface.

1. Create a 2-D shape (Groove):


A groove is a projected cosmetic feature. You create a groove by making a
sketch and projecting it onto a surface. However, the groove feature cannot
cross surface boundaries. Open the surface file lab4surf.prt.

Choose Insert Cosmetic Groove. FEATURE REFS window pops


up as shown in Figure 4.17. Select the surface onto which to project the
feature.
4.16

Figure 4.17 Figure 4.18


Set up the sketching plane and reference.
Sketch the groove section as shown in Figure 4.18.
Choose Done after the section is successfully regenerated. The groove
feature is projected onto the selected surface and has no depth.
Save and close part

2. Create an Engraving NC sequence:


Start Pro/E and open mfglab4.mfg file.
Choose NC Sequence from the MACHINING menu.
Choose Engraving and Done from the MACH AUX menu.
Select Name, Tool, Parameters, Groove Feature from SEQ Setup
window to create new sequence call Esurf.
Create new grooving tool with Cutter diameter 0.1 and length of cut
2.
Choose Set from MFG Params menu and enter the values as shown
in Figure 4.19. Select Advanced button to change MACHINE
CIRC_INTERPOLATION POINTS_ONLY as shown in Figure
4.20
4.17

Figure 4.19 Figure 4.20


Choose NC Check to simulate the machining process as shown in
Figure 4.21.
Choose Done Seq or Next Seq from the NC SEQUENCE menu when
satisfied.
Choose CL Data to output Esurf sequence and convert to Gcode.

Figure 4.21
B) Machine the finished workpiece in Ren 450 model making material.

C) Measure the machined surface and compare with the analytical surface using a
CMM.
Appendix A
Start Up and Initialization Procedure
for the Victor CNC Machines
CNC TNS-3 LATHE CNC VM-5 MILLING MACHINE

1. Turn Power Supply ON 1. Turn Power Supply ON


Main wall switch - ON Main wall switch - ON

Machine switch - ON Machine switch - ON

Console power - ON Console power - ON

Reset EMERGENCY STOP - ON Reset EMERGENCY STOP - ON

Control ON button - ON READY button - ON

2. Set all OVERRIDE SWITCHES and SPIN- 2. Set all OVERRIDE SWITCHES to OFF.
DLE SPEED to OFF and close lathe door.
3. Set MODE to ZRN and select NC opera- 3. Set MODE to ZRN.
tion.
Set AXIS SELECT to Z/Y/X/A.
Shift jog lever to +X and +Z.
Hold MANUAL FEED in `+' direction un-
Hold jog lever until ZRN light is on. til ZRN light is on.
Note: Check that turret is away from the Note: Check that the table is away from
zero return position before commencing #3. the zero return position before commencing
#3.
4. Set MODE to: 4. Set MODE to:
MANUAL/MDI/TAPE/MEMORY/EDIT for MANUAL/MDI/TAPE/MEMORY/EDIT for
NC operation or otherwise select FAPT op- NC operation or EDIT for CONVERSA-
eration. TIONAL programing.
5. Turn Power Supply OFF 5. Turn Power Supply OFF.
Reverse of #1. Reverse of #1.
Appendix B
Manual Operation of the CNC TNS-3
Lathe

1. SADDLE AND TURRET MOVEMENT


 Fanuc Dial Control
{ Set MODE SELECT to HANDLE  10.
{ Select axis to X or Z.
{ Rotate dial to appropriately position the saddle and turret.
 Jog level control (JOG).
{ Set MODE SELECT to JOG.
{ Set feedrate with FEED OVERRIDE % switch to 100.
{ Shift jog lever in the X or Z direction to appropriately position the saddle
and turret.
 Jog level control (RAPID)
{ Set MODE SELECT to RPD.
{ Set feedrate with RAPID OVERRIDE % switch to F1.
{ Shift jog lever in the X or Z direction to appropriately position the saddle
and turret.
2. TURRET INDEXING
 Set MODE SELECT to MANUAL.
 Select appropriate tool number with TURRET SELECT switch.
 Ensure that the turret is free to rotate.
 Press INDEX button to rotate turret.
3. SPINDLE ROTATION
 Set MODE SELECT to MANUAL.
 Turn SPINDLE SPEED dial to fully counterclockwise (o ).
 Select spindle range, high (GH) or low (GL) with GEAR switch.
 Select spindle direction, forward (FOR) or reverse (REV) with SPINDLE
switch.
 Set rotation speed with SPINDLE SPEED dial.
4. TAILSTOCK MOVEMENT
 Set turret X axis to zero return with ZRN mode.
 Move saddle Z to align the arrows on saddle and tailstock.
 Set mode SELECT to RAPID and RAPID OVERRIDE % to 50.
 Press TAILSTOCK BODY, RETRACT switch and simultaneously the jog
lever to +Z direction.
 Release the jog lever and select ADVANCE or RETRACT on TAILSTOCK
BODY once the location pin in the saddle has engaged with the tailstock.
Appendix C
Automatic Operation of the Victor CNC
Machines
CNC TNS-3 LATHE CNC VM-5 MILLING MACHINE

1. MANUAL DATA INPUT, MDI 1. MANUAL DATA INPUT, MDI


 Zero return both axes.  Zero return all axes.
 Set MODE to MDI.  Set MODE to MDI.
 Press PROGRAM soft key to show  Press COMMAND soft key.
text.  Key in program block and INPUT.
 Key in program (max. 200 charac-  Press CYCLE START to commence
ters), INSERT and REWIND. operation.
 Press PROGRAM START to commence
operation.
2. MEMORY INPUT, MEM
2. MEMORY INPUT, MEM
 Zero return all axes.
 Zero return both axes.
 Set MODE to MEM.
 Set MODE to MEM.
 Select program by input program num-
 Select program using PROGRAM and ber and CURSOR DOWN ARROW
SEARCH soft keys. key.
 Press REWIND soft key.  Press CURSOR UP ARROW key to
 Press PROGRAM START to commence rewind.
operation.  Press CYCLE START to commence
operation.
3. COMPUTER INPUT, DNC
3. COMPUTER INPUT, DNC
 Zero return all axes.
 Zero return both axes.  Set MODE to TAPE.
 Set Panel Switch to TAPE.  Send Program from Computer using
 Set mode to EDIT with key o
. DNCMILL.
 Insert program number (same as pro-  Press CYCLE START to commence
gram number to be sent) using PRO- operation.
GRAM, INSERT, PROG #, EXEC.
 Set mode to MEM with key on.
 Send program from computer using DNCLATHE.
 Press PROGRAM START to commence
operation.
4. COMPUTER INPUT, UPLOAD AND 4. COMPUTER INPUT, UPLOAD AND
DOWNLOAD COMPLETE PROGRAMS DOWNLOAD PROGRAMS
(a) From Computer to Lathe. (a) From Computer to Mill.
 Zero return both axes.  Option not currently available.
 Set MODE to EDIT with key o
.
 Press PROGRAM soft key to
show text, OPERATION soft key
twice, READ soft key and PROG
# soft key.
 Input program number and
EXEC.
 Input program GCODE using
DNCLATHE.
(b) From Lathe to Computer. (b) From Mill to Computer.
 Zero return both axes.  Set MODE to MDI.
 Set MODE to EDIT with key o
.  Press SET soft key and set.
 Select program using PROGRAM Input DEVICE 1=0
and SEARCH soft keys. Input DEVICE 2=0
 Show program text using TEXT.  Set MODE to EDIT and select
{ Set PC computer communica- program.
tion directory DCOM. { Set PC computer communica-
{ Run batch le SRDATA. tion directory DCOM.
{ Choose communication mode { Run batch le SRDATA.
by ALT T and 4800 band { Choose communication mode
rate with 7 . by ALT T and 4800 band
{ Name the host data le by ALT rate with 7 .
F and typing lename GCODE. { Name the host data le by ALT
{ Prepare PC computer to ac- F and typing lename GCODE.
cept data le by ALT I . { Prepare PC computer to ac-
 Press PUNCH soft key to down- cept data le by ALT I .
load program.  Press PUNCH soft key to down-
{ Terminate data transfer and load program.
close host le ALT Q . { Terminate data transfer and
{ Return to PC directories close host le ALT Q .
ALT X . { Return to PC directories
ALT X .
5. PUNCHED TAPE 5. PUNCHED TAPE
(a) From Computer to Punched Tape. (a) From Computer to Punched Tape.
 Switch on the tape punch.  Switch on the tape punch.
{ Connect the tape punch to the { Connect the tape punch to the
PC serial port COM1 PC serial port COM1
with MODE COM1:600,e,7,2. with MODE COM1:600,e,7,2.
{ Run computer program TAPE { Run computer program TAPE
and send lename{GCODE. and send lename{GCODE.
(b) From Lathe to Punched Tape. (b) From Mill to Punched Tape.
 Switch on the tape punch.  Switch on the tape punch.
 Connect the tape punch to the  Connect the tape punch to the
RS232C lathe serial port. RS232C mill serial port.
 Set MODE to MDI and change  Set MODE to MDI.
NC parameter 5112 to #7 for 600  Press SET soft key and set.
band rate (the system default is INPUT DEVICE 1=0
#10 for 4800 band rate).
INPUT DEVICE 2=0
 Set MODE to EDIT with key o
.
 Set MODE to EDIT and select
 Select program using PROGRAM program.
and SEARCH soft keys.
 Press PUNCH to punch tape.
 Press PUNCH soft key to punch
tape.
(c) From Punched Tape to Lathe (c) From Punched Tape to Mill.
 Option not currently available.  Mount paper tape on the tape reader.
 Set MODE to MDI.
 Press SET soft key and set
INPUT DEVICE 1=0
INPUT DEVICE 2=0
 Set MODE to EDIT and enter pro-
gram number.
 Press READ to read tape.
Appendix D
Computer Assisted Programming for the
Victor CNC Machines
CNC TNS-3 LATHE CNC VM-5 MILLING MACHINE
`Symbolic FAPT' `Conversational Programming'

1. Select Symbolic FAPT operation.


1. Set MODE to EDIT with key o.
2. Select:
 DATA SET for setting FAPT parame- 2. Press PRGRM soft key to start the pro-
ters and MTF (material and tool
le). gram.
 FAMILY PROGRAM for listing, re-
trieval and storage of FAPT program. 3. Enter program number O0005 and INSRT.
 FAPT EXEC for interactive part pro-
gramming. EOB and INSRT.
3. To program a part select FAPT EXEC and
complete the following
ne menu selections. 4. Press MENU key.
 Select 1 BLANK and PART to
choose the material type, surface, 5. Press INITIAL SET soft key.
roughness, feedrate and blank size and  Enter 01
shape from a programmed selection. ...
 Select 2 PART FIGURE to de
ne
the part geometry. EOB and INSRT.
 Select 3 HOME POSITION to de-

ne the tool position relative to the
part axis. 6. Press FACING/SIDE CUTTING/POCK-
 Select 4 DEFINITION OF MA- ETING/NC LANGUAGE/CONTR
CHINING to de
ne the tool path.
 Select 5 NC DATA PREPARA- /HOLE PATRN/END OF CYCLE.
TION to generate G-code program. ...
EOB and INSRT.
7. Press END OF CYCLE and INSRT.

8. Press INITIAL SET soft key to end the


program.
 Enter 02

EOB and INSRT.


Appendix E
Machining the First Part
CNC TNS-3 LATHE CNC VM-5 MILLING MACHINE

 Zero return both axes.  Zero return all axes.


 Set MODE to MEM.  Set MODE to MEM.
 Select program using PROGRAM and  Select program by input program number
SEARCH soft keys. and CURSOR DOWN ARROW key.
 Press REWIND soft key.  Press CURSOR UP ARROW key to
rewind.
 Set DRN{ON (Dry run).
 Set DRY RUN{ON.
 Set SBK{ON (Single block).
 Set SINGLE BLOCK{ON.
 Set AFL{ON (Auxilliary function MST
codes).  Set Z-AXIS CANCEL{ON.
 Set G92 Home Position.  Set MST LOCK{ON.
 Set FEED/OVERRIDE to 50%.  Set MANUAL ABSOLUTE{ON.
 Press PROGRAM START.  Set G92 Home Position.
 Set JOG to 1.06 (i.e. slow).
 Press CYCLE START.
Appendix F
Standard G-code Start and End Programs
CNC TNS-3 LATHE CNC VM-5 MILLING MACHINE
N10 O0050 program number O0006 program number
N20 G91 G28 X0.
X return home N10 G91 G28 Z0. Z return home
N30 G91 G28 Z0.
Z return home N20 G91D G28 X0. X and Y return home
N40 G92 X . Z .establish home position Y0.
S2000 and maximum spindle N30 G92 X . Y . establish home position
speed Z .
N50 G00 T0808 call tool turret index 08 N40 T18 call for tool in magazine
and tool o set 08 N50 T M06 insert T18 in spindle and
N60 G96 S0200 constant surface speed, T on standby
M04 spindle speed 200 rpm, N60 G90 G21 G43 absolute, mm, tool com-
spindle start CC/W G00 Z100. H18 pensation, rapid traverse
N70 G00 Xdiame- rapid traverse to part to Z100
ter + 2mm N70 G00 X0. Y0. rapid traverse to X0. Y0.
N80 G00 Z2mm rapid traverse to part N80 S M03 set spindle speed and
:
: switch on
:
:

: your program : your program


:
:
:
:

N210 G00 X Z  return to intermediate N210 G91 G28 Z0. Z return home, spindle
position M05 o
N220 T0800 tool o set cancel N220 M30 end of program and
N230 M01 optional stop rewind
N240 M05 spindle o N230 % end of tape.
N250 M30 end of program and
rewind
N260 %: end of tape.
Appendix G
Available G-codes
a) CNC TNS-3 LATHE

G-code Table M-code Table

G code Group Function


G00 Positioning M00 Prog stop
G01 01 Linear interpolation
G02 Circular interpolation CCW view from back M01 Optional Stop
G03 Circular interpolation CW Neglected when switch o
G04 00 Dwell
G09 Exact stop M02 End of Tape, Restart
G18 02 ZpXp plane selection
G20 06 Inch input M03 Spindle Start C/W
G21 Metric input
G22 04 Safety zone check ON M04 Spindle Start CC/W
G23 Safety zone check OFF
G27 Reference point return check M05 Spindle Stop
G28 00 Reference point return
G29 Return from reference point M06 Tool Change
G30 Return to 2nd, 3rd, 4th reference point
G33 Thread cutting M07 Oil Mist On
G34 01 Variable lead thread cutting
G35 Circular thread cutting CW M08 Coolant Pump On
G40 Tool nose radius compensation cancel
G41 07 Tool nose radius compensation right M09 Coolant, Oil Unit O
G42 Tool nose radius compensation left
G52 00 Local coordinate system setting M19 Spindle Orient
G53 Machine coordinate system selection
G54 Work coordinate system 1 selection M30 End of Prog. & Rewind
G55 Work coordinate system 2 selection
G56 14 Work coordinate system 3 selection M41 Low Range
G57 Work coordinate system 4 selection
G58 Work coordinate system 5 selection M42 High Range
G59 Work coordinate system 6 selection
G61 15 Exact stop mode M50 Air Blow On
G64 Cutting Mode
G74 Peck drilling Z axis
G75 00 Grooving in X axis
G76 Threading cycle
a) CNC-TNS-3 LATHE (Cont'd)

G code Group Function


G77 Turning cycle A
G78 01 Thread cutting cycle
G79 Facing cycle B
G96 12 Constant surface speed control
G97 Constant surface speed control
G94 05 Feed per minute
G95 Feed per revolution
G90 03 Absolute command
G91 Incremental command
G92 00 Work coordinates change/maximum spindle speed
setting
b) CNC VM-5 MILLING MACHINE

G-code Table M-code Table

G code Group Function


G00 Positioning (Rapid traverse) M00 Prog stop
G01 01 Linear Interpolation (Feed)
G02 Circular Interpolation CW M01 Optional Stop
G03 Circular interpolation CCW Neglected when switch o
G04 Dwell
G07 00 Imaginary axis designation
G09 Exact stop check M02 End of Tape, Restart
G10 O set value setting
G17 XY plane selection M03 Spindle Start C/W
G18 02 ZX Plane selection
G19 YZ plane selection M04 Spindle Start CC/W
G20 06 Input in inch
G21 Input in mm M05 Spindle Stop
G22 04 Stored stroke limit ON
G23 Stored stroke limit OFF M06 Tool Change
G27 Reference point return check
G28 00 Return to reference point M07 Oil Mist On
G29 Return from reference point
G40 Cutter compensation cancel M08 Coolant Pump On
G41 07 Cutter compensation left
G42 Cutter compensation right M09 Coolant, Oil Unit O
G43 Tool length compensation + direction
G44 08 Tool length compensation ; direction M19 Spindle Orient
G49 Tool length compensation cancel
G45 Tool o set increase M30 End of Prog. & Rewind
G46 00 Tool o set decrease
G47 Tool o set double increase M41 Low Range
G48 Tool o set double decrease
G50 11 Scalling o M42 High Range
G51 Scalling on
G54 Work coordinate system 1 select M50 Air Blow On
G55 Work coordinate system 2 select
G56 Work coordinate system 3 select
G57 14 Work coordinate system 4 select
G58 Work coordinate system 5 select
G59 Work coordinate system 6 select
G61 15 Exact stop check mode
G64 Cutting mode
G65 00 Custom macro simple cell
G66 12 Custom macro modal call
G57 Custom macro modal call cancellation
b) CNC VM-5 MILLING MACHINE (Cont'd.)

G code Group Function


G73 Peck drilling cycle
G74 Counter tapping cycle
G76 Fine boring
G80 Canned cycle cancel
G81 Drilling cycle, spot boring
G82 09 Drilling cycle, counter boring
G83 Peck drilling cycle
G84 Tapping cycle
G85 Boring cycle
G86 Boring cycle
G87 Back boring cycle
G88 Boring cycle
G89 Boring cycle
G90 03 Absolute programming
G91 Incremental programming
G92 00 Programming of absolute zero point
G94 05 Per minute feed
G98 10 Return to initial point in canned cycle
G99 Return to R point in canned cycle
Appendix H
C-Program: POSTPRO.C Convert Cutter Location File to G-code format

/**********************************************************************/
/* P O S T P R O . C */
/**********************************************************************/

#include<stdio.h>
#include<math.h>

/**********************************************************************/
main()
/**********************************************************************/
{
/*-----------------------------------------------------------------*/
/* DEFINE VARIABLES USED */
/*-----------------------------------------------------------------*/

int direct,i,j;
int cir_fg,fedrate_fg,from_fg;
int intol_fg,outtol_fg,spind_fg,unit_fg;

float x,y,z;
float x_prev,y_prev,z_prev;
float xprev,yprev,zprev;
float xdumc,ydumc,zdumc;
float from_x,from_y,from_z;
float x_cir_ctr,y_cir_ctr,z_cir_ctr;
float x_cir_start,y_cir_start ;
float theta_start,cir_rad;
float feed_rate,spind_rpm,in_tol,out_tol,tool_no;
float px,py,xprod,sx,sy;

double atan(),sqrt(),fabs();
double theta1,theta2,rad1,radlow,radhigh;
double xtest,ytest,ztest;

char c,gcodefn[80],aptfn[80];
char pname[10];
char unit_type[6];
char spind_direct[3];
char cool_state[3];
char dum[4];
char cmd[4];
char previous_cmd[80];
char dummy[80];
FILE *fopen(),*fp1,*fp2;

/*-----------------------------------------------------------------*/
/* INITIALIZE APT COMMANDS */
/*-----------------------------------------------------------------*/
static char circle[] = {"SURF"};
static char coolant[] = {"COOL"};
static char spindle[] = {"SPIN"};
static char feedrate[] = {"FEDR"};
static char fini[] = {"FINI"};
static char from[] = {"FROM"};
static char gto[] = {"GOTO"};
static char intol[] = {"INTO"};
static char outtol[] = {"OUTT"};
static char rapid[] = {"RAPI"};
static char stop[] = {"STOP"};
static char toolno[] = {"LOAD"};
static char units[] = {"UNIT"};

/*-----------------------------------------------------------------*/
/* INITIALIZE CONTROL FLAGS */
/*-----------------------------------------------------------------*/
intol_fg=outtol_fg=spind_fg=from_fg=unit_fg = 0;
cir_fg = fedrate_fg = 0;
direct = 4;

/*=================================================================*/
/* DISPLAY THE INFORMATION ABOUT THE PROGRAM */
/*=================================================================*/
printf(" PROGRAM POSTPRO ***\n");
printf(" CONVERT AN APT-IV FILE TO G-CODE FROMAT\n");
printf("\nINPUT APT IV FILE NAME = ");
scanf("%s",aptfn);
fp1 = fopen(aptfn,"r");
if (fp1 == NULL)
{
printf("ERROR IN OPENING APT-IV FILE\n");
exit(1);
}
printf("\n OUTPUT G-CODE FILE NAME = ");
scanf("%s",gcodefn);
fp2 = fopen(gcodefn,"w");

/*=================================================================*/
/* READ PARTNO AND PARTNAME */
/*=================================================================*/
fscanf(fp1,"%6s %s",previous_cmd,pname);
i = compstr(previous_cmd,"PARTNO");
if (i==4)
{
fprintf(fp2,"O111;\n");
}

/*=================================================================*/
/* READ IN THE FIRST COMMAND */
/*=================================================================*/
fscanf(fp1,"\n%4s",cmd);

/*=================================================================*/
/* CHECK IF THE COMMAND "CMD" IS "FINI" THROUGH A 'DO-WHILE' LOOP */
/*=================================================================*/
j = 0;
do
{
/*==============================================================*/
/* CHECK IF THE COMMAND "CMD" IS "GOTO" */
/* AND READ THE FULL DATA LINE */
/*==============================================================*/
j = compstr(cmd,gto);
if (j == 4)
{
fscanf(fp1,"%1s%f,%f,%f",&c,&x,&y,&z);

/*===========================================================*/
/* IF THE COMMAND IS "GOTO", CHECK THE PREVIOUS COMMAND */
/*===========================================================*/
i = compstr(previous_cmd,"RAPI");

/*===========================================================*/
/* IF PREVIOUS COMMAND != RAPI */
/*===========================================================*/
if (i != 4)
{

/*===========================================================*/
/* IF PREVIOUS COMMAND = CIRCLE, */
/* CHECK IF THE POINT IS ON THE CIRCLE */
/*===========================================================*/
if(cir_fg == 1)
{
if(intol_fg==0) in_tol =0.2;
if(outtol_fg==0) out_tol = 0.2;
xtest = x_cir_ctr - x;
ytest = y_cir_ctr - y;
ztest = z_cir_ctr - z;
rad1 = sqrt(xtest*xtest + ytest*ytest + ztest*ztest);
radhigh = fabs(cir_rad) + in_tol + out_tol;
radlow = fabs(cir_rad) - in_tol - out_tol;

/*========================================================*/
/* IF THE POINT IS ON THE CIRCLE, */
/* CHECK IF THE CIRCLE IS CW OR CCW */
/*========================================================*/
if((rad1 >= radlow) && (rad1 <= radhigh) &&
((fabs(100.0*z)) == (fabs(100.0*z_prev))) )
{

/*=====================================================*/
/* AVIOD DIVIDING BY ZERO OR HAVING ONLY ONE POINT */
/*=====================================================*/
if(direct == 4 || (x == x_cir_ctr) ||
(xprev==x_cir_ctr))
{
if(direct == 4 ) direct = 3 ;
xprev = x;
yprev = y;
zprev = z;
}

/*==================================================*/
/* CALCULATE THETA1, THETA2 AND */
/* CHECK IF THE CIRCLE IS CW OR CCW */
/*==================================================*/
else
{
theta1 = atan((y-y_cir_ctr)/(x-x_cir_ctr));
theta2 = atan((yprev-y_cir_ctr)/(xprev-x_cir_ctr));
yprev = y;
xprev = x;
zprev = z;
if(theta1>theta2 && direct == 3 ) direct = 1;
if(theta1<theta2 && direct == 3 ) direct = 0;
if(theta1 == theta2 && direct == 3) direct = 3;
}
}
else

/*=====================================================*/
/* OTHERWISE THE POINT IS NOT ON THE CIRCLE, */
/* THUS THE 'CIRC'IS COMPLETE */
/*=====================================================*/
{
cir_fg = 0;
if(direct == 0)

/*==================================================*/
/* WRITE THE CW CIRCLE TO THE GCODEFN */
/*==================================================*/
{
sx = x_cir_start - x_cir_ctr;
sy = y_cir_start - y_cir_ctr;
px = xprev - x_cir_ctr ;
py = yprev - y_cir_ctr ;

/*===============================================*/
/* CROSS PRODUCT OF START AND END VECTOR */
/* TO DETERMINE IF 0 < ARC < 180 */
/*===============================================*/
xprod = (py*sx - px*sy);
if(xprod > 0 ) cir_rad = - cir_rad;
fprintf(fp2,"G02 X%8.3f Y%8.3f Z%8.3f R%8.3f;\n",
xprev,yprev,zprev,cir_rad);
fprintf(fp2,"G01 X%8.3f Y%8.3f Z%8.3f;\n",x,y,z);
x_prev = x;
y_prev = y;
z_prev = z;
direct=4;
}

/*==================================================*/
/* WRITE THE CCW CIRCLE TO GCODEFN */
/*==================================================*/
else
{
sx = x_cir_start - x_cir_ctr ;
sy = y_cir_start - y_cir_ctr ;
px = x - x_cir_ctr ;
py = y - y_cir_ctr ;
xprod = py*sx - px*sy ;
if(xprod < 0 ) cir_rad = - cir_rad;
fprintf(fp2,"G03 X%8.3f Y%8.3f Z%8.3f R%8.3f;\n",
xprev,yprev,zprev,cir_rad);
fprintf(fp2,"G01 X%8.3f Y%8.3f Z%8.3f;\n",x,y,z);
x_prev = x;
y_prev = y;
z_prev = z;
direct = 4;
}
}
}
else

/*========================================================*/
/* IF PREVIOUS COMMAND IS NOT A 'CIRCLE' */
/* WRITE G01 TO GCODEFN FILE */
/*========================================================*/
{
fprintf(fp2,"G01 X%8.3f Y%8.3f Z%8.3f;\n",x,y,z);
x_prev = x;
y_prev = y;
z_prev = z;
}
}
else

/*===========================================================*/
/* IF PREVIOUS COMMAND IS A 'RAPID' */
/* WRITE G00 TO GCODEFN FILE */
/*===========================================================*/
{
fprintf(fp2,"G00 X%8.3f Y%8.3f Z%8.3f;\n",x,y,z);
x_prev = x;
y_prev = y;
z_prev = z;
}
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'RAPID' */
/*==============================================================*/
j = 0;
j = compstr(cmd,rapid);
if ( j == 4)
{
fscanf(fp1,"%s",dummy);
strcpy(previous_cmd,"RAPI");
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'FEEDRATE' */
/*==============================================================*/
j = 0;
j = compstr(cmd,feedrate);
if ( j == 4)
{
fedrate_fg = 1;
fscanf(fp1,"%3s%f",dummy,&feed_rate);
fprintf(fp2,"F%8.3f;\n",feed_rate);
strcpy(previous_cmd,"FEDR");
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'SPINDLE SPEED' */
/*==============================================================*/
j = 0;
j = compstr(cmd,spindle);
if ( j == 4)
{
spind_fg = 1;
fscanf(fp1,"%3s%f,%s",dummy,&spind_rpm,spind_direct);
i = compstr(spind_direct,"CLW");
if ( i == 4)
{
fprintf(fp2,"M03 S%8.3f;\n",spind_rpm);
}
else
{
if ( (compstr(spind_direct,"OFF")) != 4)
{
fprintf(fp2,"M04 S%8.3f;\n",spind_rpm);
}
}
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'CIRCLE' */
/*==============================================================*/
j = 0;
j = compstr(cmd,circle);
if ( j == 4)
{
if (cir_fg == 1)
{
cir_fg = 0;
if (direct == 1)
{
sx = x_cir_start - x_cir_ctr ;
sy = y_cir_start - y_cir_ctr ;
px = x - x_cir_ctr ;
py = y - y_cir_ctr ;
xprod = py*sx - px*sy ;
if(xprod < 0 ) cir_rad = - cir_rad;
fprintf(fp2,"G03 X%8.3f Y%8.3f Z%8.3f R%8.3f;\n",
xprev,yprev,zprev,cir_rad);
x_prev = x;
y_prev = y;
z_prev = z;
direct =4;
}
else
{
sx = x_cir_start - x_cir_ctr ;
sy = y_cir_start - y_cir_ctr ;
px = x - x_cir_ctr ;
py = y - y_cir_ctr ;
xprod = py*sx - px*sy ;
if(xprod > 0 ) cir_rad = - cir_rad;
fprintf(fp2,"G02 X%8.3f Y%8.3f Z%8.3f R%8.3f;\n",
xprev,yprev,zprev,cir_rad);
x_prev = x;
y_prev = y;
z_prev = z;
direct =4;
}
}
cir_fg = 1;
fscanf(fp1,"%4s%f,%f,%f,%f,%f,%f,%f",dummy,&x,&y,&z,
&xdumc,&ydumc,&zdumc,&cir_rad);
x_cir_ctr = x;
y_cir_ctr = y;
z_cir_ctr = z;
x_cir_start = x_prev ;
y_cir_start = y_prev ;
if (x_cir_start == x_cir_ctr)
theta_start = 11.0/7.0 ;
else
theta_start = atan((y_cir_start-y_cir_ctr)/
(x_cir_start-x_cir_ctr));
if ( (theta_start < 0.0) && (y_cir_start < y_cir_ctr) )
theta_start = theta_start ;
if ( (theta_start < 0.0) && (y_cir_start > y_cir_ctr) )
theta_start = theta_start + (22.0/7.0) ;
if ( (theta_start > 0.0) && (y_cir_start < y_cir_ctr) )
theta_start = theta_start + (22.0/7.0) ;
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'STOP' */
/*==============================================================*/
j = 0;
j = compstr(cmd,stop);
if ( j == 4)
{
if(spind_fg == 1) spind_fg = 0;
fprintf(fp2,"M05;\n");
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'INTOL' */
/*==============================================================*/
j = 0;
j = compstr(cmd,intol);
if ( j == 4)
{
intol_fg = 1;
fscanf(fp1,"%2s%f",dummy,&in_tol);
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'OUTTOL' */
/*==============================================================*/
j = 0;
j = compstr(cmd,outtol);
if ( j == 4)
{
outtol_fg = 1;
fscanf(fp1,"%3s%f",dummy,&out_tol);
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'UNITS' */
/*==============================================================*/
j = 0;
j = compstr(cmd,units);
if ( j == 4)
{
unit_fg = 1;
fscanf(fp1,"%2s%s",dummy,unit_type);
i = compstr(unit_type,"MM");
if (i == 4)
fprintf(fp2,"G21;\n");
else
fprintf(fp2,"G20;\n");
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'COOLANT' */
/*==============================================================*/
j = 0;
j = compstr(cmd,coolant);
if ( j == 4)
fscanf(fp1,"%3s%3s",dummy,cool_state);

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'FROM' */
/*==============================================================*/
j = 0;
j = compstr(cmd,from);
if ( j == 4)
{
from_fg = 1;
fscanf(fp1,"%1s%f,%f,%f",dummy,&from_x,&from_y,&from_z);
fprintf(fp2,"G92 X%8.3f Y%8.3f Z%8.3f ;\n"
,from_x,from_y,from_z);
fprintf(fp2,"G90;\n");
}

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'TOOLNO' */
/*==============================================================*/
j = 0;
j = compstr(cmd,toolno);
if ( j == 4)
fscanf(fp1,"%3s%s",dummy,tool_no);

/*==============================================================*/
/* CHECK IF THE COMMAND 'CMD' IS 'FINI' */
/*==============================================================*/
j = 0;
j = compstr(cmd,fini);
if ( j == 4 ) break;

/*==============================================================*/
/* READ THE NEXT LINE OF THE APTFN FILE */
/*==============================================================*/
fscanf(fp1,"\n%4s",cmd);
j = compstr(cmd,fini);
}
/*=================================================================*/
/* END OF THE DO-WHILE LOOP WHEN THE COMMAND 'CMD' IS 'FINI' */
/*=================================================================*/
while ( j != 4) ;
fprintf(fp2,"M30;\n%%\n");
}

/**********************************************************************/
/* FUNCTION COMPSTR ( COMPARE STRING ) */
/* RETURN '4' IF TWO STRINGS 'S' AND 'T' ARE EQUAL */
/**********************************************************************/

compstr(s,t)
char s[] , t[];
{
int i ;

i = 0;
while (s[i] == t[i])
{
if ( s[i++] == '\0') return(4);
i = i+1;
}
return(i);
}
ACKNOWLEDGEMENTS

Thanks are due to previous MECH 460 and MECH 521 students for their input and
suggestion in revising this manual.

S-ar putea să vă placă și