Anda di halaman 1dari 12

clc

cd('E:\final experiment\Vibration\chain saw\edited')


kk=dir
j=0
for i=3:length(kk)
NN=kk(i).name
if length(NN)<60
NN(length(NN):60)=32
end
Name(j+1,:)=NN
%pause
dat=xlsread(kk(i).name);
% Give the path of the directory where the data is stored
%cd('E:\final experiment\Vibration\chain saw\edited\');
%a=xlsread('chainsaw-ajay-right-wrist-X'); % Give the name of the data file (.xls file only)
a=dat;
t=a(:,2);
vib=a(:,1);
fs=1/(t(2)-t(1));
% Calclation of PDS by two methods you can use any one of these two method
%==============================================================
[Pxx,f] = pburg(vib,50,512,fs); % Calculation of PSD by Burg method
figure;
subplot(221);
plot(f,10*log10(Pxx));
xlabel('Frequency (Hz)');
ylabel('One-sided PSD (dB/rad/sample)')
hold on
[Pw fw]=pwelch(vib,600,512,[],fs,'onesided'); % Calculation of PSD by Welch method
plot(fw,10*log10(Pw),'r')
%==============================================================
band_width=20;
freq_inc=fw(2)-fw(1);
no_of_freq_samp=floor(band_width/freq_inc);
no_of_bins=length(fw)/no_of_freq_samp;
for ii=1:no_of_bins
band_power(ii)=sum(Pw((ii-1)*no_of_freq_samp+1:ii*no_of_freq_samp));
end
%plot(band_power)
%==============================================================
% Calclation of the histogram of the data
%==============================================================
[val bin]=hist(vib,200);
%figure
subplot(222)
plot(bin,val) % histogram plot

title('Histogram')
xlabel('Vibration amplitude')
ylabel('Frequency of occurance')
%==============================================================
% Calclation of the rms value of the data using a frame size of 256
%==============================================================
no_of_frames=floor(length(vib)/256);
for i=1:no_of_frames
data=vib((i-1)*256+1:i*256);
rms(i)=sqrt(mean(data.^2));
end
%figure
subplot(223)
plot(rms)
xlabel('Number of frames')
ylabel('RMS value')
%==============================================================
% Calclation of the wavelet transform and then selecting the signal in the
% frequency band of value 32-64Hz (can be further fine tuned)
%==============================================================
[c l]=wavedec(vib,4,'db4');
a = appcoef(c,l,'db4',4);
[cd1,cd2,cd3, cd4] = detcoef(c,l,[1 2 3 4]);
d4 = wrcoef('d',c,l,'db4',4);
%figure
subplot(224)
plot(t,vib)
xlabel('Time (seconds)')
ylabel('Amplitude')
hold on
plot(t,d4,'r')
legend('Original Vibration Amplitude','Vibration Amplitude of most dominant frequency (3264Hz)')
%==============================================================
% Calclation of the rms value of the data using a frame size of 61441
%==============================================================
no_of_frames=floor(length(vib)/61441);
for i=1:no_of_frames
data=vib((i-1)*61441+1:i*61441);
rms(i)=sqrt(mean(data.^2));
end
B=band_power;
m1=max(B);
l1=find(B==m1);
B(l1)=0;
m2=max(B);

l2=find(B==m2);
j=j+1;
PD(j,1)=m1;
if l1<11;
PD(j,2)=1;
elseif l1>10 && l1<21
PD(j,2)=2;
else
PD(j,2)=3;
end
PD(j,3)=m2;
if l2<11
PD(j,4)=1;
elseif l2>10 && l2<21
PD(j,4)=2;
else
PD(j,4)=3;
end
%sprintf('%f %f %f %f %s', PD(j,:), Name)
%pause
end
for i=1:length(PD)
sprintf('%f %f %f %f %s', PD(i,:), Name(i,:))
end
xlswrite('E:\final experiment\Vibration\chain saw\data', PD)

Radial Bench Drilling Machine (workshop)

Radial drilling machine (Machine shop)

Anda mungkin juga menyukai