10.1抛物線曲面之計算
利用MATLAB程式可以計算抛物線之運動參數,其程式內容如下,呼叫之名稱與參數分別為:
function [y, yy, yyy]=parabol_cam(phi, phi_in, beta_range, direct, travel,rpm)
8-4.3.2 MATLAB計算程式
function [y, yy, yyy]=parabol_cam(phi,phi_in,beta_range,direct,travel,rpm)
% code = 2
% [y, yy, yyy]=parabol_cam(phi,phi_in,beta_range,direct,travel,rpm)
% phi=cam angle, degrees
% phi_in=starting cam angle, degrees
% beta_range=motion range, degrees
% direct=motion type; +1 for upward, -1 for downward
% travel=the follower travels(=1 for a unit of travel)
% rpm=cam rotation speed, rpm(=0 for not effective)
% Example: [y, yy, yyy]=parabol_cam(10,180,120,1,1,0)
d2r=pi/180;
th=phi*d2r; thinit=phi_in*d2r; beta=beta_range*d2r;
speed=rpm*2*pi/60;if rpm==0, speed=1;end;
theta=th-thinit;
thmed=thinit+beta/2;
thx=theta/beta;
if direct==1,
if th<thmed
y=2*thx^2;
yyy=4/beta/beta;
yy=yyy*th;
else
y=1-2*(1-thx)^2;
yy=4/beta*(1-thx);
yyy=-4/beta/beta;
end
else
if th<thmed
y=1-2*thx^2;
yyy=-4/beta/beta;
yy=yyy*th;
else
y=2*(1-thx)^2;
yy=-4/beta*(1-thx);
yyy=4/beta/beta;
end
end
y=y*travel;
yy=yy*speed*travel;
yyy=yyy*speed*speed*travel;
執行例:
1. 升程起始點120∘,β=60∘,h=0.8cm,角度為150∘時之位移、速度及加速度:
>> [y, yy, yyy]=parabol_cam(150,120,60,1,0.8,0)
y = 0.4 (cm)
yy = 1.5279 (cm/s)
yyy = -2.9181 (cm/s2)
2. 返程起始點210∘,β=150∘,h=0.8,角度為250∘時之位移、速度及加速度:
>> [y, yy, yyy]=parabol_cam(250,210,150,-1,0.8,0)
y = 0.68622(cm)
yy = -0.3259(cm/s)
yyy = -0.46689(cm/s2)
範例8.1
某凸輪開始時先在0-120∘區間滯留,其高度為零。升程落於120-180∘,並於180-210∘滯留,其總升程為8公分。設刻度區間為10∘,凸輪則以等角速度旋轉,且其升程與返程均採用等加速度運動。求其變化曲線。
[解]:
1. 設ψ凸輪之迴轉角度,ψ=120-180∘為升程,轉折點為150∘,起點120∘,令θ = ψ-120,β = 60及h = 8代入公式8.9,可得升程之第一段(θ=120-150∘):
y(θ)=2h(θ/β)²=2(8)[(ψ-120)/60]²
2. 而升程之第二段(θ=150-180∘)則仍以ψ-120=θ,β=60及h=8代入公式8.10,得:
y(θ)=h[1-2(1-θ/β)²]=(8)[1-2(1-{ψ-120}/60]²
3. 返程之區間為210∘至360∘,轉折點為(210+360)/2=285∘,而β=360-210=150∘。設ψ-210=θ,代入返程一段的位移公式8.11,得第一區段(θ=210-285∘):
y(θ)=h[1-2(θ/β)²]=(8)[1-2({ψ-210}/150]²
4. 返程第二段之區間為285至360度,其轉折點與β均與第3項同,代入返程二段的位移公式,可以得到:
y(θ)=2h[1-(θ/β)²]=2(8)[1-({ψ-210}/150]²
由上面所得之函數可以利用電腦程式運算。針對升程(Demo8.1)與返程( Demo8.2)計算結果如下:
% Demo8_1
% 計算升程對應點之資料:位移,速度及加速度
theta=120:10:180;
for i=1:length(theta)
[ss(i), vv(i), aa(i)]=parabol_cam(theta(i),120,60,1,8,0);
end;
%(theta:對應角度; ss:位移, vv:速度, aa:加速度)
[theta' ss' vv' aa']
>> demo8_1
ans =
120.0000 0 0 29.1805
130.0000 0.4444 5.0930 29.1805
140.0000 1.7778 10.1859 29.1805
150.0000 4.0000 15.2789 -29.1805
160.0000 6.2222 10.1859 -29.1805
170.0000 7.5556 5.0930 -29.1805
180.0000 8.0000 -0.0000 -29.1805
%----------------------------------------
% Demo8_2
% 計算返程對應點之資料:位移,速度及加速度
theta=210:10:360;
for i=1:length(theta)
[ss(i), vv(i), aa(i)]=parabol_cam(theta(i),210,150,-1,8,0);
end;
%(theta:對應角度; ss:位移, vv:速度, aa:加速度)
[theta' ss' vv' aa']
%------------------------------------------
>> demo8_2
ans =
210.0000 8.0000 0 -4.6689
220.0000 7.9289 -0.8149 -4.6689
230.0000 7.7156 -1.6297 -4.6689
240.0000 7.3600 -2.4446 -4.6689
250.0000 6.8622 -3.2595 -4.6689
260.0000 6.2222 -4.0744 -4.6689
270.0000 5.4400 -4.8892 -4.6689
280.0000 4.5156 -5.7041 -4.6689
290.0000 3.4844 -5.7041 4.6689
300.0000 2.5600 -4.8892 4.6689
310.0000 1.7778 -4.0744 4.6689
320.0000 1.1378 -3.2595 4.6689
330.0000 0.6400 -2.4446 4.6689
340.0000 0.2844 -1.6297 4.6689
350.0000 0.0711 -0.8149 4.6689
360.0000 0.0000 -0.0000 4.6689
若就從動件之位移,利用電腦之資料或依10度為區間實際計算,可以得出其運動圖如圖8.19。
10.2 擺線曲線之函數
撰寫一套程式,仿抛物線之parabol_cam(phi, phi_in, beta_range, direct, travel,rpm),作一產生擺線曲線之函數。並計算下面之情況:總升程為50mm,升程以擺線運動經歷180度,其後滯留90度,再以擺線返程。凸輪之最小半徑為25mm。輸出資料除位移、速度及加速度外,並計算對應點之曲率半徑ρ、壓力角Φ。
[解]
function [y, yy, yyy, rho, alpha]=cycloidal_cam(r0,theta,theta_in,beta_range,direct,travel,rpm)
% code = 2
% [y, yy, yyy,rho,phi]=cycloidal_cam(r0,theta,theta_in,beta_range,direct,travel,rpm)
% r0:min. radius of the pitch surface.
% theta=cam angle, degrees
% theta_in=starting cam angle, degrees
% beta_range=motion range, degrees
% direct=motion type; +1 for upward, -1 for downward
% travel=the follower travels(=1 for a unit of travel)
% rpm=cam rotation speed, rpm(=0 for not effective)
% rho: radius of curvature
% alpha: pressure angle, in degrees.
% Example: [y, yy, yyy,rho,alpha]=cycloidal_cam(25,10,180,120,50,1,0)
d2r=pi/180;
th=theta*d2r; thinit=theta_in*d2r; beta=beta_range*d2r;
speed=rpm*2*pi/60;if rpm==0, speed=1;end;
theta=th-thinit;
thmed=thinit+beta/2;
thx=theta/beta;pi2=pi*2;
if direct==1,
y=thx-(1/pi2)*sin(pi2*thx);
yy=(1/beta)*(1-cos(pi2*thx));
yyy=(pi2/beta/beta)*sin(pi2*thx);
else
y=1-thx+(1/pi2)*sin(pi2*thx);
yy=-(1/beta)*(1-cos(pi2*thx));
yyy=-(pi2/beta/beta)*sin(pi2*thx);
end
y=y*travel;
yy=yy*speed*travel;
yyy=yyy*speed*speed*travel;
r=r0+y;
rho=(r.*r+yy.*yy).^1.5./(r.*r+2*yy.*yy-r.*yyy);
alpha=atan2(yy,r)/d2r;
執行例:
>> [y, yy, yyy,rho,alpha]=cycloidal_cam(25,[0:30:180],0,180,1,50,0)
y = 0 1.4417 9.7751 25 40.225 48.558 50
yy = 0 7.9577 23.873 31.831 23.873 7.9577 0
yyy = 0 27.566 27.566 3.8982e-015 -27.566 -27.566 -7.7963e-015
rho = 25 217.26 53.972 46.005 46.589 53.537 75
alpha = 0 16.749 34.47 32.482 20.103 6.1744 0
10.3 簡諧曲線之函數
8.5 撰寫一套程式,仿抛物線之parabol_cam(phi, phi_in, beta_range, direct, travel,rpm),作一產生簡諧曲線之函數。並計算下面之情況:總升程為50mm,升程以擺線運動經歷90度,其後滯留90度,再以擺線返程。凸輪之最小半徑為25mm。輸出資料除位移、速度及加速度外,並計算對應點之曲率半徑ρ、壓力角Φ。
[解]
function [y, yy, yyy, rho, alpha]=harmonic_cam(r0,theta,theta_in,beta_range,direct,travel,rpm)
% code = 2
% [y, yy, yyy,rho,phi]=harmonic_cam(r0,theta,theta_in,beta_range,direct,travel,rpm)
% r0:min. radius of the pitch surface.
% theta=cam angle, degrees
% theta_in=starting cam angle, degrees
% beta_range=motion range, degrees
% direct=motion type; +1 for upward, -1 for downward
% travel=the follower travels(=1 for a unit of travel)
% rpm=cam rotation speed, rpm(=0 for not effective)
% rho: radius of curvature
% alpha: pressure angle, in degrees.
% Example: [y, yy, yyy,rho,alpha]=harmonic_cam(25,10,180,120,50,1,0)
d2r=pi/180;
th=theta*d2r; thinit=theta_in*d2r; beta=beta_range*d2r;
speed=rpm*2*pi/60;if rpm==0, speed=1;end;
theta=th-thinit;
thmed=thinit+beta/2;
thx=theta/beta;
if direct==1,
y=0.5*(1-cos(pi*thx));
yy=(pi/2/beta)*sin(pi*thx);
yyy=(pi/beta)^2/2*cos(pi*thx);
else
y=0.5*(1+cos(pi*thx));
yy=-(pi/2/beta)*sin(pi*thx);
yyy=-(pi/beta)^2/2*cos(pi*thx);
end
y=y*travel;
yy=yy*speed*travel;
yyy=yyy*speed*speed*travel;
r=r0+y;
rho=(r.*r+yy.*yy).^1.5./(r.*r+2*yy.*yy-r.*yyy);
alpha=atan2(yy,r)/d2r;
執行例:
>> [y, yy, yyy,rho,alpha]=harmonic_cam(25,10,180,120,50,1,0)
y = 0.37059
yy = -0.72444
yyy = 0.29117
rho = 25.654
alpha = -1.6356
範例8.11
某凸輪開始在0-90∘區間在零高度滯留,然後提升後在150至180∘區間滯留,時高度為10公分,其餘則為返程。設刻度區間為10∘繪出其高度圖。凸輪則以等角速度旋轉,其升程與返程均採用等加速度運動。
[解]
1. 設ψ凸輪之迴轉角度,ψ=90-150∘為升程,轉折點為120∘,起點90∘,令θ = ψ-90,β = 60及h = 10代入公式8.9,可得升程之第一段(θ =90-120):
y(θ)=2h(θ/β)²=2(10)[(ψ-90)/60]²
2. 而升程之第二段(θ =120-150),則以ψ-90=θ,β=60及h=10代入公式8.10,得:
y(θ)=h[1-2(1-θ/β)²]=(10)[1-2{1-(ψ-90)/60}²]
3. 返程之區間為180∘至360∘,轉折點為(180+360)/2=270∘,β=360-180=180∘。設ψ-180=θ,代入返程一段的位移公式8.11,第一區段(θ =180-270)得:
y(θ)=h[1-2(1-θ/β)²]=(10)[1-2{1-(ψ-180)/180}²]
4. 返程第二段之區間θ =270-360度,代入返程一段的位移公式,可以得到:
y(θ)=2h(1-θ/β)²=2(10)[1-(ψ-180)/180]²
利用MATLAB程式可撰寫如下:
function [theta,y]=P8_11(theta,limit0,s)
% ex P8.11
% Inputs: theta: angles in row matrix
% limit0: mark angles [(dwell) t0 (rise) t1 (dwell) t2(return)t3]
% s:stroke
% Example: [theta,y]=P8_11([0:10:360],[90 150 180 360],30)
d2r=pi/180;
h=s;lm=limit0*d2r;
lm=[lm(1) (lm(1)+lm(2))/2 lm(2) lm(3) (lm(3)+lm(4))/2 lm(4)]/d2r;
LM=lm*d2r;
th=theta*d2r;
y=ones(size(th));
y(th<LM(1))=0;
y(th>=LM(3))=h;
y(th>=LM(1)&th<LM(2))=2*h*((th(th>=LM(1)&th<LM(2))-LM(1))/(LM(3)-LM(1))).^2;
y(th>=LM(2)&th<LM(3))=h*(1-2*(1-(th(th>=LM(2)&th<LM(3))-LM(1))/(LM(3)-LM(1))).^2);
y(th>=LM(4)&th<LM(5))=h*(1-2*((th(th>=LM(4)&th<LM(5))-LM(4))/(LM(6)-LM(4))).^2);
y(th>=LM(5)&th<=LM(6))=2*h*(1-(th(th>=LM(5)&th<=LM(6))-LM(4))/(LM(6)-LM(4))).^2;
plot(th/d2r,y);
xlabel('Theta in degrees');
ylabel('Follower displacement');
grid on;
執行結果:
>> [theta,y]=P8_11([0:10:360],[90 150 180 360],30)
theta = 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360
y = 0 0 0 0 0 0 0 0 0 0 1.6667 6.6667 15 23.333 28.333 30 30 30 30 29.815 29.259 28.333 27.037 25.37
23.333 20.926 18.148 15 11.852 9.0741 6.6667 4.6296 2.963 1.6667 0.74074 0.18519 0
10.4 DWELL函數簡介
上述各函數作為從動件運動件運動包括其上升下降之位移、速度、加速度等均可以利用程式表示。為求統一,可歸納到dwell.m這個函數之中。其呼叫法為:
function [y,yy,yyy]=dwell(ctheta,range,pattern)
其中參數定義如下:
ctheta = 需要計算之凸輪角度,單位為度數。可以使用矩陣輸入之型式。
pattern = 運動的型式,二元素之列矩陣,其代碼如下:
1:等速運動uniform 2:抛物線parabolic 3:簡諧simple harmonic
4:擺線cycloidal 5:多項式polynomial motion
e.g. [4 3]:升程為擺線運動cycloidal;返程為簡諧運動harmonic motion
range =升程及返程之範圍,三元素列矩陣 e.g.[90 180 240]升程始於90 度,止於180度;
返程始於240 度,止於360。
輸出: y:位移(其最大值為1,故得到對應值後應與從動件之衝程相乘,才是真正的位移,其第一及第二導數相同);yy 對於凸輪角ctheta之第一導數; yyy 對於凸輪角ctheta之第二導數。
程式內容:
function [y,yy,yyy]=dwell(ctheta,range,pattern)
%
% This function determines the follower displacement and derivatives
% for a full rotation cam. The routine is set up for the displacement
% schedule in Examples 6.7 and 6.8
% The input values are:
%ctheta = individual cam angles (deg)--can be a matrix to be processed
%pattern = denote the types of motion used(a 2 element-row matrix). types
% are:
% 1:uniform 2:parabolic 3:simple harmonic 4: cycloidal
% 5:polynomial motion
% e.g. [4 3]:cycloidal motion for rise and harmonic motion for
% return
%range =the degrees the specific motion starts(array of 3 elements), e.g.
% [90 180 240] starts to rise at 90 deg. and ends at 180 deg.
% starts to return at 240 deg. and ends at 360 deg.
% Output: y is for displacement, yy is the derivative of the displacement with
% respect to theta, and yyy the second derivative with respect to theta.
% Example dwell(60,[90 180 240],[4 3]);
% Author:DSFon, BIME, NTU Revise Date:May 18, 2007
d2r=pi/180;
theta=ctheta*d2r;range=range*d2r;
dim=length(ctheta);
y=zeros(size(ctheta));yy=y;yyy=y;
for i=1:dim
if theta(i)>=range(3) %for the last motion(downward)
mode=pattern(2);betax=2*pi-range(3);
switch mode,
case 1, [y(i),yy(i),yyy(i)]=uniform(theta(i), range(3),betax,-1);
case 2, [y(i),yy(i),yyy(i)]=parabolicm(theta(i), range(3),betax,-1);
case 3, [y(i),yy(i),yyy(i)]=harmonicm(theta(i), range(3),betax,-1);
case 4, [y(i),yy(i),yyy(i)]=cycloidm(theta(i), range(3),betax,-1);
case 5, [y(i),yy(i),yyy(i)]=polynorm(theta(i), range(3),betax,-1);
end;
elseif theta(i)>=range(2) % dewell on the top
y(i)=1;
elseif theta(i)>=range(1) % for the 1st motion(upward)
mode=pattern(1);betax=range(2)-range(1);
switch mode,
case 1, [y(i), yy(i), yyy(i)]=uniform(theta(i), range(1),betax,+1);
case 2, [y(i), yy(i), yyy(i)]=parabolicm(theta(i), range(1),betax,+1);
case 3, [y(i), yy(i), yyy(i)]=harmonicm(theta(i), range(1),betax,+1);
case 4, [y(i), yy(i), yyy(i)]=cycloidm(theta(i), range(1),betax,+1);
case 5, [y(i), yy(i), yyy(i)]=polynorm(theta(i), range(1),betax,+1);
end
end
end
%*********************************************
function [t1, t2, t3]=uniform(th, thinit,beta,direct)
% code = 1 for uniform motion
%th=cam angle, radians
%beta=motion range, radians
%thinit=starting cam angle, radians
%beta=motion range, radians
%direct=motion type; +1 for upward, -1 for downward
theta=th-thinit;
t1=theta/beta;
if direct==-1,
t1=1-t1;
end;
t2=direct*1/beta;
t3=0;
%*********************************************
function [t1, t2, t3]=parabolicm(th,thinit,beta,direct)
% code = 2 for parabolic motion
%th=cam angle, radians
%beta=motion range, radians
%thinit=starting cam angle, radians
%beta=motion range, radians
%direct=motion type; +1 for upward, -1 for downward
theta=th-thinit;
thmed=thinit+beta/2;thx=theta/beta;
if direct==1,
if th<thmed
t1=2*thx^2;
t3=4/beta/beta;
t2=t3*th;
else
t1=1-2*(1-thx)^2;
t2=4/beta*(1-thx);
t3=-4/beta/beta;
end
else
if th<thmed
t1=1-2*thx^2;
t3=-4/beta/beta;
t2=t3*th;
else
t1=2*(1-thx)^2;
t2=-4/beta*(1-th/beta);
t3=4/beta/beta;
end
end
%*********************************************
function [t1, t2, t3]=harmonicm(th,thinit,beta,direct)
% code = 3 for harmonic motion
%th=cam angle, radians
%beta=motion range, radians
%thinit=starting cam angle, radians
%beta=motion range, radians
%direct=motion type; +1 for upward, -1 for downward
theta=th-thinit;
t1=0.5*(1-cos(pi*theta/beta));
if direct==-1, t1=1-t1;end;
t2=direct*(0.5*pi/beta)*sin(pi*theta/beta);
t3=direct*0.5*(pi/beta)^2*cos(pi*theta/beta);
%*********************************************
function [t1, t2, t3]=cycloidm(th,thinit,beta,direct)
%
% code = 4 for cycloidal motion
%th=cam angle, radians
%thinit=starting cam angle, radians
%beta=motion range, radians
%direct=motion type; +1 for upward, -1 for downward
theta=th-thinit;
t1=theta/beta-(0.5/pi)*sin(2*pi*theta/beta);
if direct==-1,t1=1-t1;end;
t2=direct*(1-cos(2*pi*theta/beta));
t3=direct*2*pi/beta/beta*sin(2*pi*theta/beta);
%*********************************************
function [t1, t2, t3]=polynorm(th,thinit,beta,direct)
%
% code = 5 for polynormial motion
%th=cam angle, radians
%thinit=starting cam angle, radians
%beta=motion range, radians
%direct=motion type; +1 for upward, -1 for downward
theta=th-thinit;
thx=theta/beta;
t1=thx*thx*thx*(10+thx*(-15+thx*6));
if direct==-1, t1=1-t1;end;
t2=direct*(30/beta)*thx*thx*(1+thx*(-2+thx));
t3=direct*(60/beta/beta)*thx*(1+thx*(-3 +2*thx));
本程式將配合其他凸輪繪製時呼叫使用。
Dwell執行範例8.10
下面plot_dwell.m為一執行Dwell函數之範例。其指令如下:
function plot_dwell(ctheta,s,pattern,range)
相關參數請參照後節之程式介紹。
function plot_dwell(ctheta,s,pattern,range)
%ctheta = cam angle (deg)--can be a matrix
%pattern = denote the type of motion used(a 3 element-row matrix)
% 1:uniform 2:parabolic 3:simple harmonic 4: cycloidal
% 5:polynomial motion
% example [4 3]
%range =the degrees the specific motion starts
% Output: y is for displacement, yy is the derivative of the displacement with
% respect to theta, and yyy the second derivative with respect % to theta.
% Example plot_dwell(0:10:360,2,[4 3],[90 180 240]);
figure(1);clf;
[y,yy,yyy]=dwell(ctheta,range,pattern)
h1=plot(ctheta,y*s,'b-',ctheta,yy*s,'k-',ctheta,yyy*s,'r-')
legend('Displacement','Velocity','Acceleration',3)
xlabel('Elapsed Angle, degrees')
grid
執行例
>>plot_dwell(0:10:360,2,[4 3],[90 180 240]);
範例8.10
就梢從動件之凸輪通常可利用課本圖8.26及公式8.26之轉軸進行模擬各角度之位置,假設一從動件之梢長為L,其偏置量為e,凸輪之基圓半徑為r0,衝程為s。可以利用dwell函數求各角度對應衝程,然後依公式8.26進行轉軸。設此程式名稱為pincam,其呼叫方式如下:
function [x,y]=pincam(cth,r0,s,e,L,range,pattern,cw)
其中,各參數定義如下:
輸入參數:
cth:凸輪角度,度數
r0:凸輪基圓半徑
e:偏置量
s:從動件衝程
L:從動件長度
cw:凸輪轉動方向(反時鐘為正,順時鐘為負)
pattern = 運動的型式,二元素之列矩陣,其代碼如下:
1:等速運動uniform 2:抛物線parabolic 3:簡諧simple harmonic
4:擺線cycloidal 5:多項式polynomial motion
e.g. [4 3]:升程為擺線運動cycloidal;返程為簡諧運動harmonic motion
range =升程及返程之範圍,三元素列矩陣 e.g.[90 180 240]升程始於90 度,
止於180度;返程始於240 度,止於360。
程式內容
function [x,y]=pincam(cth,r0,s,e,L,range,pattern,cw)
%Find the pin type cam with an offsect e
%Inputs:
% cth:angle of cam, degrees
% r0:radius of base circle
% e:offset
% s:stroke
% L:length of pin
% cw:rotation direction of cam(-counterclockwise,+clockwise
%pattern = denote the type of motion used(a 3 element-row matrix)
% 1:uniform 2:parabolic 3:simple harmonic 4: cycloidal
% 5:polynomial motion
% example [4 3]
%range =the degrees the specific motion starts, eg.[90 180 240]
% Example: [x y]=pincam([10 60],5,2,1,10,[90 180 240],[4 3],-1)
figure(1);
clf;
th=cth*pi/180;
s0=sqrt(r0*r0-e*e);
for i=1:length(cth)
t=th(i)*cw;
A=[cos(t) -sin(t);sin(t) cos(t)];
[ym,yy,yyy]=dwell(cth(i),range,pattern);
x0=s0+ym*s;
Sx=[0 x0 x0+L;e e e];
X=A\Sx;
x(i)=X(1,2);y(i)=X(2,2);
line(X(1,1:2),X(2,1:2));
line(X(1,2:3),X(2,2:3),'linewidth',3,'color','red')
end
hold on;
plot([0 x],[0 y],'ro',x,y,'k-')
axis equal
執行例一:偏置量為零時
>> [x y]=pincam([0:10:360],6,5,0,10,[90 180 240],[4 3],-1)
執行例二:偏置量不為零時
>> [x y]=pincam([0:10:360],6,5,4,10,[90 180 240],[4 3],-1);
範例8.12
試就問題8.11所得從動子之抛物線運動之位移量,繪製一凸輪,設從動子屬刀緣接觸型,其基圓半徑為35mm,順時鐘方向旋轉。
[解]請參考圖8.6
繪圖程式撰寫如下:
function [rp,rb]=drawcam(r0,y,direct)
% To draw a cam profile with base radius of r0 and rise in y
% The program may work with P8_11
% Input: direct: +1 for clockwise; -1 for counterclockwise
%
% Example: [s,T]=drawcam(35,y)
d2r=pi/180;
nn=length(y);
LM=max(y+r0);
figure(2);
line([-LM LM]',[0 0]');line([0 0]',[-LM LM]');
if direct==1,
theta=linspace(0,360,nn)'*d2r;
else
theta=linspace(360,0,nn)'*d2r;
end
theta=theta+pi/2;
rb=[r0*cos(theta) r0*sin(theta)];
rp=[(r0+y').*cos(theta) (r0+y').*sin(theta)];
line(rb(:,1),rb(:,2),'color','r')
line(rp(:,1),rp(:,2));
axis equal;
執行結果:
>> [s]=drawcam(35,y,1)
s =
35 0
34.468 6.0777
32.889 11.971
30.311 17.5
26.812 22.498
22.498 26.812
17.5 30.311
11.971 32.889
6.0777 34.468
2.1431e-015 35
-6.3671 36.11
-14.251 39.154
-25 43.301
-37.496 44.686
-48.516 40.71
-56.292 32.5
-61.08 22.231
-64.013 11.287
-65 7.9602e-015
-63.83 -11.255
-60.384 -21.978
-54.848 -31.667
-47.523 -39.877
-38.805 -46.246
-29.167 -50.518
-19.128 -52.553
-9.2291 -52.341
-9.1849e-015 -50
8.1357 -46.14
15.074 -41.416
20.833 -36.084
25.473 -30.358
29.081 -24.402
31.754 -18.333
33.585 -12.224
34.651 -6.1098
35 -8.5725e-015
範例8.13
試就問題8.11所得從動子之抛物線運動之位移量,繪製一凸輪,設從動子屬滾子型,其半徑為8mm,基圓半徑為40mm,順時鐘方向旋轉。
[解]請參考圖8.29
繪圖程式撰寫如下:
function [rp,rb]=draw_roller_cam(r0,r,y,direct)
% To draw a cam profile with base radius of r0 and rise in y
% The program may work with P8_11
% Input: direct: +1 for clockwise; -1 for counterclockwise
%
% Example: [rp,rb]=draw_roller_cam(40,6,y,1)
d2r=pi/180;
nn=length(y);
LM=max(y+r0);
figure(2);
line([-LM LM]',[0 0]');line([0 0]',[-LM LM]');
if direct==1,
theta=linspace(0,360,nn)'*d2r;
else
theta=linspace(360,0,nn)'*d2r;
end
theta=theta+pi/2;
rb=[r0*cos(theta) r0*sin(theta)];
rp=[(r0+y').*cos(theta) (r0+y').*sin(theta)];
line(rb(:,1),rb(:,2),'color','r');
line(rp(:,1),rp(:,2));
th=linspace(0,2*pi,50)';
for i=1:nn,
line(rp(i,1)+r*cos(th),rp(i,2)+r*sin(th));
end
axis equal;
執行結果:
>> [rp,rb]=draw_roller_cam(40,8,y,1)
rp =
2.4493e-015 40
-6.9459 39.392
-13.681 37.588
-20 34.641
-25.712 30.642
------------------------------------------
57.265 -10.097
55 -1.3471e-014
51.064 9.004
46.115 16.784
40.415 23.333
34.188 28.687
27.616 32.912
20.833 36.084
13.934 38.284
6.9781 39.575
1.2246e-014 40
rb =
2.4493e-015 40
-6.9459 39.392
-13.681 37.588
-20 34.641
-25.712 30.642
------------------------------------
25.712 30.642
20 34.641
13.681 37.588
6.9459 39.392
1.2246e-014 40
圖P8.1所得之結果作一切線切於各滾子內圈之弧即可得其工作曲線,而所採用的點數愈多,其內、外包絡線愈為顯明。
範例8.14
試就問題8.11所得從動子之抛物線運動之位移量,繪製一凸輪,設從動子屬平板型,基圓半徑為100mm,順時鐘方向旋轉。
[解]請參考圖8.32
繪圖程式撰寫如下:
function [rp,rb]=draw_plat_cam(nn,r0,s,d,range,pattern,cw)
% The program work with dewell.m
%Inputs:
% nn:number of points in process
% r0:radius of base circle
% re:radius of the roller
% a:distance between two axes of cam and roller
% s:stroke
% d:length of plate follower
% cw:rotation direction of cam(-counterclockwise,+clockwise
%pattern = denote the type of motion used(a 3 element-row matrix)
% 1:uniform 2:parabolic 3:simple harmonic 4: cycloidal
% 5:polynomial motion
% example [4 3]
%range =the degrees the specific motion starts, eg.[90 180 240]
% Example: draw_plat_cam(36,5,2,2,[90 180 240],[4 3],-1)
figure(1);clf;d2r=pi/180;
th=linspace(0,360,nn);
[y,ff]=dwell(th,range,pattern);
theta=(th+90)*d2r;%The follower is in upright position
if cw==-1,theta=pi-theta;end
rb=[r0*cos(theta);r0*sin(theta)];
%
%rp=[(r0+y*s).*cos(theta)+cw*ff*s.*sin(theta);...
% (r0+y*s).*sin(theta)-cw*ff*s.*cos(theta)];
%line(rp(1,:),rp(2,:));%Draw working circle
for i=1:nn,
rr=r0+y(i);
xx=rr*cos(theta(i));yy=rr*sin(theta(i));
line([0 xx], [0 yy]);
dx=d*sin(theta(i));dy=d*cos(theta(i));
line([xx+dx xx-dx],[yy-dy yy+dy],'linewidth',2,'color','red');
end
line(rb(1,:),rb(2,:),'color','r');%draw base circle
axis equal;
執行結果:
>> draw_plat_cam(36,5,2,2,[90 180 240],[4 3],1)
圖P8.14 平板從動子之凸輪軌跡
10.5 凸輪運動之進階分析
如何繪製凸輪之外緣曲線,是探討凸輪的主題。下面程式為針對板式從動件所產生之凸輪外緣曲線,並且依所需之運動型式進行設計。
平板從動件之凸輪
camwork程式為一平板式從動件對凸輪運動時之相對軌跡曲線之繪製,其法與前面之drawcam大致上相同。通常係讓凸輪固定,然後由從動件依設定之角度進行繪製。本程式之呼叫法如下:
function camwork(rb,rise,range,pattern,platdim,direction,ainc)
參數說明:
pattern = 運動的型式,二元素之列矩陣,其代碼如下:
1:等速運動uniform 2:抛物線parabolic 3:簡諧simple harmonic
4:擺線cycloidal 5:多項式polynomial motion
e.g. [4 3]:升程為擺線運動cycloidal;返程為簡諧運動harmonic motion
range =升程及返程之範圍,三元素列矩陣 e.g.[90 180 240]升程始於90 度,
止於180度;返程始於240 度,止於360。
rb:基圓半徑
rise:從動件升程
platdim:從動件平板尺寸,其型式如 [Ll,Lr,t], 其中,L1,Lr分別為從動件中心線前與後之板面 長度,t:從動件之厚度
direction:凸輪轉動方向, +1 為逆時鐘;-1 為順時鐘。
ainc: 迴轉角度分量,度
本程式呼叫 dwell.m, bush.m, camfollow.m及 frame.m等函數,若需要板面傾斜某一角度,則需另呼叫trans4.m程式,此函數在第二章中有關轉動座標之函數中已經介紹過,可以引用。
function camwork(rb,rise,range,pattern,platdim,direction,ainc)
%Draw a plate cam in diferent positions
% Call dwell.m, bush.m, camfollow.m, frame.m
%Inputs:
% rb:radius of the cam base circle
% rise:rise of the follower
%range =the degrees the specific motion starts(array of 3 elements), e.g.
% [90 180 240] starts to rise at 90 deg. and ends at 180 deg.
% starts to return at 240 deg. and ends at 360 deg.
%pattern = denote the types of motion used(a 2 element-row matrix). types
% are:
% 1:uniform 2:parabolic 3:simple harmonic 4: cycloidal
% 5:polynomial motion
% e.g. [4 3]:cycloidal motion for rise and harmonic motion for
% return
%platdim:the plate dimension, in forms of [Ll,Lr,t], in which
% L1,Lr:length of plage in front of and behind the centerline,
% t:thickness of the axle of the plate follower.
% direction:cam direction, +1 for counterclockwise; -1 for clockwise
% ainc: angular increment, degrees
%Examples: camwork(5,2,[100 180 270],[3 3],[2 3 1],1,60)
platdim(find(platdim<=0.2))=0.2;
d2r=pi/180;
camangle=0:1:360;
th=camangle*d2r;
[s,ss,sss]=dwell(camangle,range,pattern);
s=s*rise;ss=ss*rise;
xcam=(rb+s).*cos(th)-ss.*sin(th);
ycam=(rb+s).*sin(th)+ss.*cos(th);
ycam=ycam*direction;
[coords]=bushing(-rb,0,0);
xb=coords(:,1);yb=coords(:,2);
[coords]=bushing(rb/7,0,0);
xbush=coords(:,1);ybush=coords(:,2);
figure(1);
clf;
axis equal;
thi=[0:ainc:360]';
nx=length(thi);
bush=line('xdata',[],'ydata',[],'linewidth',1.5,'color','r','erasemode','none');
base=line('xdata',[],'ydata',[],'linewidth',1,'color','b','erasemode','none');
cam=line('xdata',[],'ydata',[],'linewidth',2,'color','k','erasemode','none');
frame1=line('xdata',[],'ydata',[],'linewidth',1,'color','r','erasemode','none');
frame2=line('xdata',[],'ydata',[],'linewidth',1,'color','r','erasemode','none');
for k=1:nx-1,
follow(k)=line('xdata',[],'ydata',[],'linewidth',1,'color','k','erasemode','none');
end
line1=line('xdata',[],'ydata',[],'linewidth',1,'color','k','erasemode','none');
bead=line('xdata', [], 'ydata', [],'marker','o','markersize', 6, 'erasemode',...
'xor');
set(bush,'xdata',xbush,'ydata',ybush);
set(base,'xdata',xb,'ydata',yb);
set(cam,'xdata',xcam,'ydata',ycam);
%set(bush,'xdata',xbush,'ydata',ybush);
thr=thi*d2r;
tho=thi;if direction==-1,tho=360-thi;end;
[coordf]=camfollow(platdim(1),platdim(2),platdim(3),rise);
coords=coordf;
linest=[];
[frame0]=frame(platdim(3),rise,1,0);
set(frame1,'xdata',frame0(:,1)+rb,'ydata',frame0(:,2))
[frame0]=frame(platdim(3),rise,-1,0);
set(frame2,'xdata',frame0(:,1)+rb,'ydata',frame0(:,2))
for i=1:length(thr)-1
[s,ss,sss]=dwell(thi(i),range,pattern);
s=s*rise;ss=ss*rise;
xx=(rb+s)*cos(thr(i))-ss*sin(thr(i));
yy=((rb+s)*sin(thr(i))+ss*cos(thr(i)))*direction;
coords=coordf;
coords(:,1)=coordf(:,1)+rb+s;
xf=rb+s;yf=0;
[coords]=trans4(coords,tho(i),5);
[linef]=trans4([0 0;xf yf],tho(i),5);
text(linef(2,1),linef(2,2),num2str(tho(i)));
linest=[linest;0 0;linef];
set(bead,'xdata',xx,'ydata',yy);
set(follow(i),'xdata',coords(:,1),'ydata',coords(:,2));
end
set(line1,'xdata',linest(:,1),'ydata',linest(:,2));
axis equal;
function [coords] = bushing(rr,x0,y0)
% Determine the coordinates of the anchor seat
% rr: radius of the shaft
% x0,y0: center coordinates of the shaft
d2r=pi/180;
theta=[360:-10:0]*d2r;
r=abs(rr);
rx=r*cos(theta);ry=r*sin(theta);
if rr<0,
rx=rx+x0;
ry=ry+y0;
coords=[rx' ry'];
return;
end;
rx1=rx/2;rx2=-rx1;
ry1=ry/2;ry2=-ry1;
r4=r+r/4;r3=r/3;
bx=[ 0 0 0 -r -r -r4 -r4 r4 r4 -r r r];
by=[r3 -r3 0 0 -r -r -r4 -r4 -r -r -r 0];
coords(:,1)=[bx rx rx1 rx2]'+x0;
coords(:,2)=[by ry ry1 ry2]'+y0;
hold off;
function [coords]=camfollow(tl,tr,thickness,stroke,theta)
%Detemine the coordinates of the plate follower
%Inputs:
% tl:length of plate in front of center line
% tr:length of plate behind the cneter line
% thickness:thichness of the plate
% stroke:rise of the follower
% theta:the slant angle(degrees) of plate
%Outputs:coords:coordinates of the plate
%coordinates for bock and outside form
t=thickness;s=stroke*1.5;tm=t/2;
coords=[0 0;0 tl; tm tl; t tm;t+s tm;t+s -tm;t -tm;tm -tr;0 -tr;0 0];
if nargin==5 % draw a slant follower
coords=trans4(coords,theta,5);
end
function [coords]=frame(thickness,stroke,mode,theta)
% determine the coordinate of follower seat
% Inputs:
% thickness:the thckness of the follower shaft
% stroke:rise of the follower
% theta:slant angle of the follower, degrees
% mode:+1 for one side, -1 for another side
t=thickness*1.05;s=stroke*1.2;
t0=thickness+stroke;tx=t/2;tm=t/3;
if mode==1
coords=[t0 -tx];
tt=t0+tm;
while 1
coords=[coords;tt -tx;tt-tm -tx-tm;tt -tx];
tt=tt+tm;
if tt-t0>s, break;end
end
end
if mode==-1
coords=[t0 tx];
tt=t0+tm;
while 1
coords=[coords;tt tx;tt-tm tx+tm;tt tx];
tt=tt+tm;
if tt-t0>s, break;end
end
end
if nargin==4,
coords=trans4(coords,theta,5);
end
執行範例:
基圓半徑5公分,升程2公分,分佈範圍為[100 180 270]度,升程與返程均使用簡諧運動型式,從動件為平板,左2公分,右3公分,板軸厚度為1公分,試將圓周以60均分繪出其從動件位置及對應之凸輪曲線。
>>camwork(5,2,[100 180 270],[3 3],[2 3 1],1,60)
10.6 滾輪從動件之凸輪
以滾子從動件運轉之凸輪可以利用camwork2.m進行繪製,其呼叫法如下:
function camwork2(rb,ro,rise,offset,range,pattern,direction,ainc)
參數說明:
pattern = 運動的型式,二元素之列矩陣,其代碼如下:
1:等速運動uniform 2:抛物線parabolic 3:簡諧simple harmonic
4:擺線cycloidal 5:多項式polynomial motion
e.g. [4 3]:升程為擺線運動cycloidal;返程為簡諧運動harmonic motion
range =升程及返程之範圍,三元素列矩陣 e.g.[90 180 240]升程始於90 度,
止於180度;返程始於240 度,止於360。
rb:基圓半徑
ro:滾子從動件半徑
rise:從動件升程
offset:從動件之中心線偏置量
direction:凸輪轉動方向, +1 為逆時鐘;-1 為順時鐘。
ainc: 迴轉角度分量,度
camwork2程式呼叫 dwell.m, bush.m, camfollow2.m及 frame.m等函數。同camwork,若滾子軸需要板面傾斜某一角度,則需另呼叫trans4.m程式,此函數在第二章中有關轉動座標之函數中已經介紹過,可以引用。
function camwork2(rb,ro,rise,offset,range,pattern,direction,ainc)
%
%function camwork2(rb,ro,rise,offset,range,pattern,direction,ainc)
%find roller cam curve using envelop technique
% Call dwell.m, bush.m, camfollow.m, frame.m
%Inputs:
% rb:radius of the cam base circle
% ro:radius of the roller follower
% rise:rise of the follower
% offset:the offset of centerline of follower
% range =the degrees the specific motion starts(array of 3 elements), e.g.
% [90 180 240] starts to rise at 90 deg. and ends at 180 deg.
% starts to return at 240 deg. and ends at 360 deg.
% pattern= denote the types of motion used(a 2 element-row matrix). types
% are:
% 1:uniform 2:parabolic 3:simple harmonic 4: cycloidal
% 5:polynomial motion
% e.g. [4 3]:cycloidal motion for rise and harmonic motion for
% return
% direction:cam direction, +1 for counterclockwise; -1 for clockwise
% ainc: angular increment, degrees
%Examples: camwork2(5,2,1.5,1,[100 180 270],[3 3],1,60)
%Designed by D S Fon, BIME, NYU. Dated June 10, 2002
d2r=pi/180;
camangle=0:1:360;
th=camangle*d2r;
[s,ss,sss]=dwell(camangle,range,pattern);
s=s*rise;ss=ss*rise;
rho=rb+ro+s;
alpha=atan((rho./(offset*offset+rho.*rho)-offset).*ss);
phi=alpha-atan(offset./rho)/d2r;
offset0=abs(offset);
dd=sqrt((rb+ro)^2-offset*offset);%distance from center of roller to x-axis
ct=cos(th);st=sin(th);
UU=(dd+s).*st-(offset+ss).*ct;
VV=(dd+s).*ct+(offset+ss).*st;
xcam=offset*st+(dd+s).*ct-sign(ct)*ro./sqrt(1+(UU./VV).^2);
ycam=(xcam.*UU+(dd+s).*ss)./VV;
ycam=ycam*direction;
xf=offset*st+(dd+s).*ct;
yf=(-offset*ct+(dd+s).*st)*direction;
arg=ycam.^2+xcam.^2-(yf.^2+xf.^2);
ycam(arg>0)=[];
xcam(arg>0)=[];
[coords]=bushing(-rb,0,0);
xb=coords(:,1);yb=coords(:,2);
[coords]=bushing(-abs(offset),0,0);
xoff=coords(:,1);yoff=coords(:,2);
figure(1);
clf;
thi=[0:ainc:360]';
nx=length(thi);
base=line('xdata',[],'ydata',[],'linewidth',1,'color','b','erasemode','none');
offcircle=line('xdata',[],'ydata',[],'linewidth',1,'color','r','erasemode','none');
pitch=line('xdata',[],'ydata',[],'linewidth',1,'color','r','erasemode','none');
cam=line('xdata',[],'ydata',[],'linewidth',2,'color','k','erasemode','none');
frame1=line('xdata',[],'ydata',[],'linewidth',1,'color','r','erasemode','none');
frame2=line('xdata',[],'ydata',[],'linewidth',1,'color','r','erasemode','none');
for k=1:nx-1,
follow(k)=line('xdata',[],'ydata',[],'linewidth',1,'color','k',...
'erasemode','none');
linex(k)=line('xdata',[],'ydata',[],'linewidth',1,'color','k',...
'erasemode','none');
end
set(base,'xdata',xb,'ydata',yb);
set(cam,'xdata',xcam,'ydata',ycam);
set(offcircle,'xdata',xoff,'ydata',yoff);
set(pitch,'xdata',xf,'ydata',yf);
thr=thi*d2r;
tho=thi;if direction==-1,tho=360-thi;end;
[coordf]=camfollow2(ro,ro/2,rise);
coordf(:,2)=coordf(:,2);
coords=coordf;
maxline=rb+ro*2+rise;
offset0=-offset*direction;
[frame0]=frame(ro/2,rise,1,0);
set(frame1,'xdata',frame0(:,1)+rb+ro,'ydata',frame0(:,2)+offset0);
[frame0]=frame(ro/2,rise,-1,0);
set(frame2,'xdata',frame0(:,1)+rb+ro,'ydata',frame0(:,2)+offset0);
for i=1:length(thr)-1
[s,ss,sss]=dwell(thi(i),range,pattern);
s=s*rise;ss=ss*rise;
ct=cos(thr(i));st=sin(thr(i));
xf=offset*st+(dd+s)*ct;
yf=(-offset*ct+(dd+s)*st)*direction;
[coords]=trans4(coordf,tho(i),5);
coords=trans4(coords,[xf yf],1);
linef=[maxline 0;0 0;0 offset0];
[linef]=trans4(linef,tho(i),5);
linef=[linef;xf yf];
text(xf,yf,num2str(tho(i)));
set(linex(i),'xdata',linef(:,1),'ydata',linef(:,2));
set(follow(i),'xdata',coords(:,1),'ydata',coords(:,2));
end
axis equal;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [coords] = bushing(rr,x0,y0)
% Determine the coordinates of the anchor seat
% rr: radius of the shaft
% x0,y0: center coordinates of the shaft
d2r=pi/180;
theta=[360:-10:0]*d2r;
r=abs(rr);
rx=r*cos(theta);ry=r*sin(theta);
if rr<0,
rx=rx+x0;
ry=ry+y0;
coords=[rx' ry'];
return;
end;
rx1=rx/2;rx2=-rx1;
ry1=ry/2;ry2=-ry1;
r4=r+r/4;r3=r/3;
bx=[ 0 0 0 -r -r -r4 -r4 r4 r4 -r r r];
by=[r3 -r3 0 0 -r -r -r4 -r4 -r -r -r 0];
coords(:,1)=[bx rx rx1 rx2]'+x0;
coords(:,2)=[by ry ry1 ry2]'+y0;
hold off;
function [coords]=camfollow2(r,thickness,stroke,theta,npts)
%[coords]=camfollow2(r,thickness,stroke,theta,npts)
%This program gives coordinates for different type of cam followers
% Inputs:
% r : radius of roller if any
% thickness: thickness of rod
% stroke : the maximum stroke movement
% theta : angle that foller inclines
% npts : No. of points to draw the roller, default=30, npts=3 for point follower
% if thickness >2r, the orign will be transfered to the edge of circle or the point,
% otherwise, it is located at the center of the circle.
%Designed by D.S.Fon, BIME, NTU, dated June 6, 2002
t=thickness;tm=t/2;
s=stroke;
if stroke>0,s=stroke*1.5;end
th1=0;th2=2*pi;
loc=0;
if t<2*r,
th1=asin(abs(tm)/r);
th2=th2-th1;
else
t=2*r,th1=pi/2;th2=th2-th1;
loc=1;
end
nn=30;if nargin==5,nn=npts;end;
th=linspace(th1,th2,nn);
rx=r*cos(th);ry=r*sin(th);
coords=[rx' ry';s+r -tm;s+r tm;rx(1) ry(1)];
if loc,coords=trans4(coords,[r 0],1);end
if nargin==4 % draw a slant follower
coords=trans4(coords,theta,5);
end
function [coords]=frame(thickness,stroke,mode,theta)
% determine the coordinate of follower seat
% Inputs:
% thickness:the thckness of the follower shaft
% stroke:rise of the follower
% theta:slant angle of the follower, degrees
% mode:+1 for one side, -1 for another side
t=thickness*1.05;s=stroke*1.2;
t0=thickness+stroke;tx=t/2;tm=t/3;
if mode==1
coords=[t0 -tx];
tt=t0+tm;
while 1
coords=[coords;tt -tx;tt-tm -tx-tm;tt -tx];
tt=tt+tm;
if tt-t0>s, break;end
end
end
if mode==-1
coords=[t0 tx];
tt=t0+tm;
while 1
coords=[coords;tt tx;tt-tm tx+tm;tt tx];
tt=tt+tm;
if tt-t0>s, break;end
end
end
if nargin==4,
coords=trans4(coords,theta,5);
end
執行範例:
基圓半徑5公分之凸輪,其從動件為滾子,直徑為2公分。設此組凸輪之升程1.5公分,從動件之偏置量為1公分。分佈範圍為[100 180 270]度,升程與返程均使用簡諧運動型式,從動件為平板,左2公分,右3公分,板軸厚度為1公分,試將圓周以60均分繪出其從動件位置及對應之凸輪曲線。
將上述資訊化為指令參數,執行結果如下:
>> camwork2(5,2,1.5,1,[100 180 270],[3 3],1,60)
其他凸輪動畫
Interactive Cam Mechanism Design