An Artificial Neural Network Approach to Surface Waviness Prediction in Surface Finishing Process

Chi Ngo

ECE/ME 539 Final Project

May 18, 2000


Table of contents

I. Introduction …………………………………………… page 3

II. Work performed …………………………………….. page 4

1. Data collection ……………………………… page 4

2. Neural network design ………………………. page 6

3.  Selection of network parameters …………. page 11

4.  Network usage ……………………………… page 11

III. Results …………………………………………… page 12

1. Base line study ……………………………… page 14

IV. Discussions …………………………………………… page 14

References …………………………………………… page 15
I. Introduction:

In the highly competitive manufacturing industry, high volume production methods such as die casting, injection molding and forming have played important roles in producing products efficiently and economically. These methods require dies and molds to be manufactured before products are produced. CNC machines (e.g. milling machines) are used to machine out the desired shape of the dies molds surface. After a workpiece is machined to a die/mold on a CNC mill, some surface errors like waviness, scallops, and roughness are presented on the surface. Thus the final step is to remove these surface errors, and this can be done by different methods. In this project, conventional mechanical method such as CNC machine or industrial robot is used. This method should be efficient so that the machining time and cost can be kept low while having the surface topography meet requirements. And this can only be achieved by properly selecting cutting parameters such as cutting speed, cross feed, feed rate and tool displacement for a specific surface finish requirement.

In the past, many people have tried to predict and control the surface finish results. They have tried to develop mathematical finishing process models that included depth of cut, waviness and roughness as function of cutting parameters. By using these models, proper values of cutting parameters then can be determined according to desired surface topography and consideration of efficiency. [Chen 94] used two-level factorial experimental design to determine surface roughness from other model constants and coefficients:

Ry = CwCg()e1(ae)e2()e3 (1)

Model constant such as Cw, Cg and coefficients such as e1, e2, and e3 are determined from data collected from experiment. So with given qe, de, and ae, surface roughness can be determined. [Hsu 98] used central composite design to predict depth of cut (DOC) and surface waviness (WAV) from cutting parameters such as feed rate (F), cross feed (f), spindle speed (w), and tool displacement (a):

DOC = C1Fk1fk2wk3ak4 (2)

W = C2Fh1fh2wh3ah4 (3)

C1, C2, k1, k2, k3, k4, h1, h2, h3, and h4 are determined from data collected from experiment. Same as before, with given F, f, w, and a, DOC and WAV can be determined. Each one of these models has its own advantages and disadvantages.

In this project, I built a multi-layer perceptron with back propagation to predict surface waviness and depth of cut from cutting parameters such as feed rate, cross feed, spindle speed, and tool displacement. During the building process, the number of hidden layers and the number of perceptrons are determined such that optimal output can be obtained. Because this is approximation problem, therefore multi-layer perceptron with application to approximation is used in this project.

II. Work performed:

1. Data collection:

Twenty-eight sets of data are collected from real workpieces and on a CNC machine. The CNC machine center used in this project is a Cincinnati Milacron 5VC-750 Precision Machining Center with a Cincinnati Milacron Acrmatic 900 V2 Control. The workpieces used in this project are P-20 mold steel blocks and they were rough milled using a 6.35mm diameter ball end mill. It took a long time to collect one set of data, because of time constraint, only twenty-eight sets of data are used in this project.

Feed rate
(mm/min) / Cross feed
(mm) / Spindle speed
(rpm) / Tool displacement
(mm) / Depth of cut
(mm) / Waviness
(mm)
225 / 0.4 / 17,400 / 360 / 0.096 / 15.5
400 / 0.4 / 17,400 / 360 / 0.087 / 15.5
225 / 0.9 / 17,400 / 360 / 0.071 / 21.1
400 / 0.9 / 17,400 / 360 / 0.046 / 21.3
225 / 0.4 / 23,000 / 360 / 0.173 / 16.0
400 / 0.4 / 23,000 / 360 / 0.136 / 17.3
225 / 0.9 / 23,000 / 360 / 0.092 / 24.4
400 / 0.9 / 23,000 / 360 / 0.071 / 21.9
225 / 0.4 / 17,400 / 1000 / 0.138 / 15.0
400 / 0.4 / 17,400 / 1000 / 0.095 / 16.5
225 / 0.9 / 17,400 / 1000 / 0.089 / 23.3
400 / 0.9 / 17,400 / 1000 / 0.056 / 21.9
225 / 0.4 / 23,000 / 1000 / 0.168 / 16.7
400 / 0.4 / 23,000 / 1000 / 0.120 / 15.2
225 / 0.9 / 23,000 / 1000 / 0.092 / 23.8
400 / 0.9 / 23,000 / 1000 / 0.075 / 26.5
300 / 0.6 / 20,000 / 600 / 0.108 / 20.8
300 / 0.6 / 20,000 / 600 / 0.094 / 20.0
300 / 0.6 / 20,000 / 600 / 0.083 / 18.9
300 / 0.6 / 20,000 / 600 / 0.084 / 19.1
200 / 0.6 / 20,000 / 600 / 0.130 / 21.0
450 / 0.6 / 20,000 / 600 / 0.089 / 20.6
300 / 0.34 / 20,000 / 600 / 0.113 / 17.2
300 / 1.06 / 20,000 / 600 / 0.058 / 26.8
300 / 0.6 / 16,400 / 600 / 0.087 / 18.9
300 / 0.6 / 24,400 / 600 / 0.119 / 17.2
300 / 0.6 / 20,000 / 291 / 0.072 / 19.9
300 / 0.6 / 20,000 / 1236 / 0.090 / 18.9

For my multi-layer perceptron in this project, at first I used the first four columns as my feature vectors and the last two columns as my target vectors. But then the results didn’t look good, even with the best learning rate, momentum, number of neurons, and number of epochs, and even when I scaled the input and output vectors. So I decided to redo everything over again but this time I used the first four columns as my feature vectors and only one column (either column four or five) as the target vector. I had to run the program two times. First I trained my multi-layer perceptron network with the first four columns as my feature vectors and the fourth column (depth of cut) as my target vector to get the weight matrix. Later on I can use this weight matrix to predict the depth of cut with a given set of feed rate, cross feed, spindle speed, and tool displacement. Then I trained my multi-layer perceptron network again this time with the first four columns as my feature vectors and the last column (waviness) as the target vector to get another weight matrix. Same as before, I later on can use this weight matrix to predict waviness with a given set of feed rate, cross feed, spindle speed, and tool displacement.

Because of small amount of data, I had to use re-sampling strategy to prepare the training and testing data. I repeat model fitting many times using the same data set. Each time, I random partition the data set into training and testing data sets.

2. Neural Network Design:

Over the course of the ECE/ME 539 semester, I had had exposure to many artificial neural network learning algorithms, including simple perceptron learning, back-propagation perceptron learning, auto-regressive models, and time-delayed neural networks. Based on the results I saw during the semester for the various learning experiments conducted, I determined that back-propagation perceptron learning with application to approximation would work the best for my project. As we can see from the picture below, targets are real numbers instead of binary class membership as in classification problem.

I used a multi-layer perceptron neural network back-propagation algorithm with one hidden layer implemented in my Matlab file bpappro.m. It is based on Professor Yu Hen Hu’s bpappro.m and uses bpfun.m and bptesta.m also written by Professor Hu. It uses a training file and testing file with each row specifying cutting condition and the last column specifying depth of cut or waviness. Pbappro.m let user specify the number of hidden neurons to use, the learning rate, the momentum constant, and the maximum number of epoch to run. Below is the Matlab file bpappro.m:

% bpappro.m - backpropagation driver program for approximation problems

% copyright (c) 1996 by Yu Hen Hu

% Created: 9/21/96

%

% call bpfun.m to perform backpropagation training

% call bptesta.m to test training data results.

% call randomize.m to reorder training data

%

% Steps:

% 1. load data file, input network dimensions M-H-N

% 2. decide alpha (learning rate), mom (momentum), #epoch, & K (epock size)

% 3. initialize weight matrices

% 4. sample the next K samples from training file

% 5. call bpfun.m to get new update of weight matrices

% 6. test for convergence. If not, go to 4, 3, or 2.

%

% Modify: 9/21/96, scale.m

% convert input range to -0.5 to 0.5

% output range to 0.2 to 0.8

% modified from bp.m on 9/22/96

% 1. remove bptest.m since goal is not classification

% 2. write bptesta.m to test the network

% 3. Note, in the test files, the feature vectors are scaled

% but not target vectors remain unchanged

% Modified 9/20/97 to add more informative interface

clear all;clf;figure(1)

load data.txt

% it is assumed that the training file is an ascii array

% of numbers in a K by MN matrix. There are K lines, each

% corresponding to a 1xM feature vector and an 1xN target vector

% rename this file to a standard name: train

[Ntrain,MN]=size(data);

disp(['There are ' num2str(Ntrain) ' training samples. ']);

disp(['Input dimension + Output dimension = ' num2str(MN)]);

%M=input(' # of MLP inputs (feature space dimension) M = ');

M=4;

N=MN-M; %disp([' so output dimension (# of classes) = ' num2str(N)]);

%disp('Only one hidden layer is used in this program!')

H=15; %input(' # of hidden neurons H = ');

%scalein=input('If want to scale input to range of -5 to 5, type 1: ');

%if isempty(scalein), scalein=0; end

%if scalein==1,

[feature,fmin,fmax]=scale(data(:,1:M),-5,5); % scale input

%else

% feature=data(:,1:M);

%end

%scaleout=input('If want to scale output to range of .2 to .8, type 1: ');

%if isempty(scaleout),scaleout=0; end

%if scaleout==1,

[target,tmin,tmax]=scale(data(:,M+1:MN),0.2,0.8);% scale output

%else

% target=data(:,M+1:MN);

%end

% step 2. input learning rate (alpha), momentum const (mom), epoch size (K)

%echo on

% Next we will select input learning rate (step size), momentum term,

% and number of epochs. During each epoch, one or more input samples

% will be fed-forward to calculate the error. But he weights are

% updated only once per epoch.

%echo off

alpha=0.3; %input('learning rate (between 0 and 1) alpha = ');

mom=0.8; %input(' momentum constant (between 0 and 1) mom = ');

nepoch=1000; %input('maximum number of epochs to run, nepoch = ');

K=25; %input([' epoch size (# of samples) < ' num2str(Ntrain+1) '; K = ']);

ne=floor(Ntrain/K);

% step 3. initialize weight matrices

randn('seed',sum(100*clock));

Wh=randn(H,M+1)*0.005; Wo=randn(N,H+1)*0.005;

dWh=zeros(H,M+1); dWo=zeros(N,H+1);

% step 4. Prepare training data for an epoch

error=zeros(1,nepoch); check=0; converged=0;

train=randomize([feature target]);

%train=[feature target];

for nn=1:nepoch,

% since there are Ntrain samples, with K samples per epoch, it takes

% ne+1 epochs to go throught entire training samples once. In fact,

% only ne epochs are executed. After that, the order of the Ntrain

% samples are re-suffled (randomized), and the next K*ne samples will

% be used in the next round. Each time K*ne samples have been trained,

% we will perform convergence test.

ns=rem(nn,ne)*K; %nn modulo ne: 1, 2, .., ne-1, 0 1, 2, ..., ne-1, 0,

if ns == 0,

ns=ne*K;

check=1; % to check for convergence once later

train=randomize([feature target]); % randomize once each run of entire training file

%train=[feature target];

end

train_ep=train(ns-K+1:ns,:);

% step 5. call bpfun.m

% Usage: [err,Wh,Wo,dWh,dWo]=bpfun(M,H,N,Wh,Wo,dWh,dWo,train,alpha,mom)

[err,Wh,Wo,dWh,dWo]=bpfun(M,H,N,Wh,Wo,dWh,dWo,train_ep,alpha,mom);

error(nn)=err; % training error is computed using scaled output

if rem(nn,20)==0,

plot([max(1,nn-1000):nn],error(max(1,nn-1000):nn));

title('training error, last 1000 iterations'); drawnow

end

if check == 1,

% compute training error over the entire training file!

[ems,emax]=bptesta(Wh,Wo,[feature target]);

% if scaleout==1, %if output is scaled, scale back the error

ems=ems*(tmax-tmin)/(0.8-0.2);

emax=emax*(tmax-tmin)/(0.8-0.2);

% end

% training approximation error: ems - mean square error,

% emax - maximum absolute error

if ems < 1e-3,

converged=1;

disp(['DATA CONVERGE AT ' num2str(nn) ' epoch']);

disp(['with mean square error = ' num2str(ems)]);

plot([1:nn],error(1:nn));

title('training error, all iterations'); drawnow

break

else

check=0;

end

end

end

% summarize training data results

[ems,emax,out]=bptesta(Wh,Wo,[feature,target]);

%if scaleout==1, %if output is scaled, scale back the error

ems=ems*(tmax-tmin)/(0.8-0.2);

emax=emax*(tmax-tmin)/(0.8-0.2);

out=scale(out,tmin,tmax);

%end

disp('Training data set results')

disp([' Mean square error = ' num2str(ems)]);

disp([' Maximum absolute error = ' num2str(emax)]);

% get testing data set statistics

Testdata=data; %Testdata=eval(test_name);

[Ntest,MN1]=size(Testdata);

if MN1~=MN,

error('testing data set dimension does not match training data set!');

end

%if scalein==1,

[testin,tinmin,tinmax]=scale(Testdata(:,1:M),-5,5);

%else

% testin=Testdata(:,1:M);

%end

%if scaleout==1,

[testout,toutmin,toutmax]=scale(Testdata(:,M+1:MN),0.2,0.8);

%else

% testout=Testdata(:,M+1:MN);

%end

[ems,emax,out]=bptesta(Wh,Wo,[testin,testout]);

%if scaleout==1, %if output is scaled, scale back the error

ems=ems*(toutmax-toutmin)/(0.8-0.2);

emax=emax*(toutmax-toutmin)/(0.8-0.2);

out=scale(out,toutmin,toutmax);

%end

if N==1, % if output dimension =1, plot output figure(3),plot([1:Ntest],Testdata(:,MN),'o',[1:Ntest],out,'+',[1:Ntest],Testdata(:,MN))

legend('original data','approximated values')

ylabel('Waviness prediction [um]')

end

%if N==2,

% figure(3),plot(Testdata(:,MN-1),Testdata(:,MN),'o',out(:,1),out(:,2),'+')

% title('Test Result-- true data: o versus ANN output +')

%end

%disp('Testing data set results')

%disp([' Mean square error = ' num2str(ems)]);

%disp([' Maximum absolute error = ' num2str(emax)]);

3. Selection of network parameters:

As I have mentioned before, I had to run the program two times. The first time I used the first four columns as the feature vectors and the fourth column as the target vector to get the weight matrix so that later on I can used it to predict the depth of cut. The second time, I used the first four columns as the feature vectors and the last column as the target vector to get the weight matrix so I can used it later on to predict the waviness.