128
APPENDIX – A
CASESTUDY - 1
The sample part given below, is used to demonstrate the working of
the proposed methodology for the integration of feature recognition and
CNC code generation. The component shown in Figure A-1 is composed of
various line and arc features. It has 14 design features in total each of
which is a separate turning surface. In addition to the plain and inclined
turning surfaces, this component also consists of a curved surface
(convex) and a different type of groove surface as discussed earlier. The
component is drawn in AutoCAD with the units expressed in inches.
129
Figure A-1 Profile of the component with arc and groove feature (FCD)
Figure A-2 3D view of the component
130
Figure A-3 Output of feature extraction module
Figure A-4 Various pattern primitives in the component
Based on the Output file (DRAWIOUT) all the design features are
rearranged as per the syntactic pattern recognition methodology. The
given component has only external features and Figure A-4 illustrates all
the design features arranged in an order, starting from the right most
feature (D) to the leftmost feature (B). The arc feature (represented by
pattern I) is shown with its starting and ending coordinates, but the
details like radius and the starting angle and ending angles are stored in
the database for downstream applications of manufacturing. Thus the
final string pattern for the given component is- “BCBCFCIDCFCGCD”.
131
Figure A-5 Manufacturing features of the component
From the final string pattern “BCBCFCIDCFCGCD”, various
manufacturing features are extracted, using the string reduction
algorithm. The string is reduced in to 8 predefined manufacturing
features as shown in the Figure A-5.
132
Figure A-6 Rule-based sequence of operations
The manufacturing features are converted into their corresponding
operations by feature mapping algorithm. And the operations are
sequenced as per the rule-based sequencing discussed earlier. The first
operation is plain turning operation (CD) and the last operation to be
performed is the profile (arc (I)) turning.
133
Figure A-7 Excerpt of the CNC code generated for the component.
The CNC code generated by the proposed methodology accommodates
all the operations as given in the Figure A-6. The first line in the above
program provides the billet size as given by the user. The values of the
process parameters speed, feed and depth of cut are provided by the user.
The number of steps in each operation depends on the depth of cut. The
part program is saved as a text file which may be given as an input to the
simulation package for the simulation runs, to validate the proposed
novel methodology.
134
CASESTUDY - 2
The second component consists of 15 design features which include
an arc profile (concave) and a vivid groove element. A combination of
polyline command, line command and arc commands are used to
generate the profile of the component.
Figure A-8 Profile of the component with arc and groove feature (FBCDG)
135
Figure A-8 3D view of the TEST2 component
Figure A-9 Output of feature extraction module
136
Figure A-10 Various pattern primitives in the component
Based on the Output file (TEST2OUT) all the design features are
rearranged as per the syntactic pattern recognition methodology. The
given component has only external features and Figure A-10 provides all
the design features with their patterns. The arc feature (represented by
pattern V) is shown with its starting and ending coordinates, but the
details like radius and the starting angle and ending angles are stored in
the database for downstream applications of manufacturing.
137
Figure A-11 Manufacturing features of the component
138
From the final string pattern various manufacturing features are
extracted and the string is reduced in to 10 predefined manufacturing
features viz. one profile turning, two outer grooves and four turning
surfaces on as shown in the Figure A-11.
Figure A-12 Rule-based sequence of operations
139
Figure A-13 Excerpt of the CNC code generated for TEST2 component.
140
Appendix-B
Group Codes
Table B-1 List of various Group Codes and their Values
141
Table B-2 List of various Group Codes and their Values
142
/* Program for Integration of feature recognition and CNC code generation*/ #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<math.h> FILE *fp1,*fp2,*fp3; float cm,cn,cr,ia,fa,doc,feed,refx,refy,ad,al,ud,ul; int i=0,j,count,end,speed; char word[200],cnc[50]; int detect(int); void polyline(); void line(); void circle(); void arc(); void order(); void swap(int); void swaps(int,int); float mode(float); void feaext(); void outergrooves(); void profileturning(); void turninga();
void turningb(); void bmcnd(); void bcd(); void fcg(); void fcd(); void bcg(); void mcn(); void v(); void m(); void n(); void J(); void I(); void g(); void cd(); void f(); void bc(); void processchart(); void search(char []); void searchk(char []); void turningapro(); void turningbpro(); void outergroovespro(); void profileturningp(); void cnccode(); void cdcnc(); void gcnc(); void bccnc(); void fcnc(); void bccnc(); void fcnc(); void bcgcnc(); void fcgcnc(); void bcdcnc(); void fcdcnc(); void vcnc();
Table B-3 Excerpts of C-Program showing various subprograms
143
fp1=fopen(cad,"r"); if(fp1==NULL) { printf("the file not found"); getch(); exit(0); } fp2=fopen(det,"w"); fprintf(fp2,"type x1 y1 x2 y2 type representation\n"); fprintf(fp2,"----------------------------------------------------------------------------------------\n"); while((fscanf(fp1,"%s",word))!=EOF) { if(!strcmp("ENTITIES",word)) { while((fscanf(fp1,"%s",word)!=EOF)) { if(!strcmp("ENDSEC",word)) break; if(!strcmp("LINE",word)) line(); if(!strcmp("LWPOLYLINE",word)) { while(fscanf(fp1,"%s",word)!=EOF) { if(!strcmp(word,"0.0"))
{ polyline(); break; } } } if(!strcmp("ARC",word)) arc(); } break; } } count=i; if(k[0].x2<k[0].x1) swap(0); order(); fclose(fp1); fclose(fp2); for(i=0;i<count;i++) { if(k[i].t>64&&k[i].t<73) { if(k[i].y1==k[i].y2&&k[i].x2>k[i].x1) k[i].t='A'; if(k[i].x1==k[i].x2&&k[i].y2<k[i].y1) k[i].t='B'; if(k[i].y1==k[i].y2&&k[i].x2<k[i].x1) k[i].t='C'; if(k[i].x1==k[i].x2&&k[i].y2>k[i].y1) k[i].t='D'; if(k[i].x2>k[i].x1&&k[i].y2<k[i].y1) k[i].t='E'; if(k[i].y2<k[i].y1&&k[i].x2<k[i].x1) k[i].t='F'; if(k[i].y2>k[i].y1&&k[i].x2<k[i].x1) k[i].t='G'; if(k[i].y2>k[i].y1&&k[i].x2>k[i].x1) k[i].t='H'; } else { if((k[i].ia>=0.0&&k[i].fa<=90.0)&&k[i].x2<k[i].x1&&k[i].y2>k[i].y1) k[i].t='I'; else if(k[i].ia>=90.0&&k[i].fa<=180.0&&k[i].x2<k[i].x1&&k[i].y2<k[i].y1) k[i].t='J';
Table B-4 Excerpts of C-Program for extracting Polyline, line & Arc Entities
144
void line()
{
fprintf(fp2,"line ");
while(fscanf(fp1,"%s",word)!=EOF)
{
if(!strcmp("10",word))
{
fscanf(fp1,"%f",&k[i].x1);
fprintf(fp2,"%9.4f ",k[i].x1);
fscanf(fp1,"%s",word);
fscanf(fp1,"%f",&k[i].y1);
fprintf(fp2,"%9.4f ",k[i].y1);
fscanf(fp1,"%s",word);
fscanf(fp1,"%s",word);
fscanf(fp1,"%s",word);
fscanf(fp1,"%f",&k[i].x2);
fprintf(fp2,"%9.4f ",k[i].x2);
fscanf(fp1,"%s",word);
fscanf(fp1,"%f",&k[i].y2);
fprintf(fp2,"%9.4f ",k[i].y2);
k[i].ia=0;
k[i].fa=0;
k[i].r=0;
if(k[i].x1==k[i].x2&&k[i].y2!=k[i].y1) fprintf(fp2,"vrtl line ");
else if(k[i].x2!=k[i].x1&&k[i].y2==k[i].y1) fprintf(fp2,"hztl line ");
else if(k[i].x2!=k[i].x1&&k[i].y2!=k[i].y1) fprintf(fp2,"incl line ");
if(k[i].y2==k[i].y1&&k[i].x2>k[i].x1) { fprintf(fp2," A\n"); k[i].t='A'; }
if(k[i].y2<k[i].y1&&k[i].x2==k[i].x1) { fprintf(fp2," B\n"); k[i].t='B'; }
if(k[i].y2==k[i].y1&&k[i].x2<k[i].x1) { fprintf(fp2," C\n"); k[i].t='C'; }
if(k[i].y2>k[i].y1&&k[i].x2==k[i].x1) { fprintf(fp2," D\n"); k[i].t='D'; }
break;
}
}
i++;
}
void arc()
{
fprintf(fp2,"\narc ");
while(fscanf(fp1,"%s",word)!=EOF)
{
if(!strcmp("10",word))
{
fscanf(fp1,"%f",&cm);
fprintf(fp2," %.4f ",cm);
}
else if(!strcmp("20",word))
{
fscanf(fp1,"%f",&cn);
fprintf(fp2,"%.4f ",cn);
}
else if(!strcmp("40",word))
{
fscanf(fp1,"%f",&cr);
fprintf(fp2," %f \n\n",cr);
}
else if(!strcmp("50",word))
{
fscanf(fp1,"%f",&ia);
fprintf(fp2,"\t Intial Angle :%.4f \n ",ia);
}
else if(!strcmp("51",word))
{
fscanf(fp1,"%f",&fa);
fprintf(fp2,"\t end Angle :%.4f\n",fa);
break;
}
Table B-5 Excerpts of C-Program for extracting line & Arc features
145
void cdcnc()
{
int n;
float x1,y1,x2,y2,x3,y3,c;
fscanf(fp2,"%s %f %f %f %f\n",word,&x1,&y1,&x2,&y2);
fscanf(fp2,"%s %f %f %f %f\n",word,&x2,&y2,&x3,&y3);
n=(y3-y1)/doc;
c=(y3-y1)-n*doc;
fprintf(fp1,"N%02d G00 X%f Z%f\n",count++,(y3-refy)*2+1,x1-refx+1);
if(c!=0.0)
{
fprintf(fp1,"N%02d G90 X%f Z%f F%f\n",count++,(y3-refy)*2,x3-refx,feed);
fprintf(fp1,"N%02d X%f\n",count++,(y1-refy)*2+n*doc*2);
}
else
{
fprintf(fp1,"N%02d G90 X%f Z%f F%f\n",count++,(y3-refy)*2,x3-refx,feed);
}
for(i=0;i<n;i++)
fprintf(fp1,"N%02d X%f\n",count++,2*(y1-refy)+(n-1-i)*2*doc);
}
void gcnc()
{
int n;
float x1,y1,x2,y2,c;
fscanf(fp2,"%s %f %f %f %f\n",word,&x1,&y1,&x2,&y2);
n=(y2-y1)/doc;
c=(y2-y1)-n*doc;
fprintf(fp1,"N%02d G00 X%f Z%f\n",count++,(y2-refy)*2+1,x1-refx+1);
if(c!=0.0)
{
fprintf(fp1,"N%02d G90 X%f Z%f R-%f F%f\n",count++,(y2-refy)*2,x2-refx,c,feed);
fprintf(fp1,"N%02d X%f R-%f\n",count++,(y2-refy)*2-(c+doc-1),c+doc);
}
else
{
fprintf(fp1,"N%02d G90 X%f Z%f R-%f F%f\n",count++,(y2-refy)*2,x2-refx,doc+c,feed);
}
for(i=1;i<n;i++)
fprintf(fp1,"N%02d X%f R-%f\n",count++,2*(y2-refy)-c-i*doc,c+(i+1)*doc);
}
void bccnc()
{
int n;
float x1,y1,x2,y2,x3,y3,c;
fscanf(fp2,"%s %f %f %f %f\n",word,&x1,&y1,&x2,&y2);
fscanf(fp2,"%s %f %f %f %f\n",word,&x2,&y2,&x3,&y3);
n=(y1-y2)/doc;
c=(y1-y2)-n*doc;
fprintf(fp1,"N%02d G00 X%f Z%f\n",count++,(y1-refy)*2+1,x1-refx);
if(c!=0.0)
{
fprintf(fp1,"N%02d G90 X%f Z%f F%f\n",count++,(y1-refy)*2,x3-refx,feed);
fprintf(fp1,"N%02d X%f\n",count++,(y3-refy)*2+n*doc*2);
}
else
{
fprintf(fp1,"N%02d G90 X%f Z%f F%f\n",count++,(y1-refy)*2,x3-refx,feed);
}
for(i=0;i<n;i++)
fprintf(fp1,"N%02d X%f\n",count++,2*(y2-refy)+(n-1-i)*2*doc);
}
Table B-6 Excerpts of C-Program for generation of Part program