5/17/07

第十一章 齒輪(5)-齒列與齒輪



11.5 齒列與齒輪間之互動關係

本節將示範一齒列與一齒輪間之運動情形,程式是動態的變化,但可依參數輸入值決定其間之關係。其程式名稱為move2_rack.m,呼叫格式如下:
function move2_rack(Dpitch,nn1,phi,omega1)



輸入參數定義如下:

Dpitch:節矩
 nn1:齒輪數目
 phi:壓力角,degrees
 omega1: 齒輪角速度,rad/s

程式內容:

function move2_rack(Dpitch,nn1,phi,omega1)
%  move2_gear(Dpitch,nn1,nn2,phi,omega1)
% To draw a whole gear
% Inputs:
%  Inputs:
%    Dpitch:dimetral pitch
%    nn1: no. of teeth for both gears
%    phi:pressure angle, degrees
%    omega1: angular velocity of gear 1
% Example move2_rack(10,15,20,10)
clf;
d2r=pi/180;delt=0.01;
phir=phi*d2r;
pc=pi/Dpitch;
[coord1,r1,rb1]=one_tooth(Dpitch,nn1,phi,360,0,0);
[coord2]=rack(Dpitch,phi,nn1,0,0,-r1);
xc1=coord1(:,1);yc1=coord1(:,2);
xc2=coord2(:,1);yc2=coord2(:,2);
coord=bushing(r1/8,0,0); % Get the coordinates of  1st bushing
xb1=coord(:,1);yb1=coord(:,2);
coord=bushing(-r1,0,0);%Get the 1st pitch circle
xp1=coord(:,1);yp1=coord(:,2);
xp2=[0 0]';yp2=[0 -r1]';
plot(xb1,yb1,'r-');hold on;
plot(xp1,yp1,'r:');
plot(xp2,yp2,'k:');
xx=nn1*pc/2;xx1=xx/2;
plot([-xx xx]',[-r1 -r1]','r:');
plot([-xx1  xx1]',[xx1*tan(phir)-r1, -xx1*tan(phir)-r1]','b-');
cir1=line('xdata',[],'ydata',[],'erasemode','xor','linewidth',1,'color','r');
cir2=line('xdata',[],'ydata',[],'erasemode','xor','linewidth',1,'color','k');
line1=line('xdata',[],'ydata',[],'erasemode','xor','linewidth',2,'color','r');
line2=line('xdata',[],'ydata',[],'erasemode','xor','linewidth',2,'color','k');
rm=r1+1/Dpitch;
axis([-1.2*rm 1.2*rm -1.3*rm 1.3*rm]);
axis equal;
title('Press Ctl-C to stop');
delta=0;delx=0;dels=omega1*delt;
while 1,
z1=rotate2D([xc1,yc1],delta,0,0);
z2=[xc2-delx,yc2];
L1=rotate2D([xp2,yp2],delta,0,0);
set(cir1,'xdata',z1(:,1),'ydata',z1(:,2)); % For 1st circle moving
set(cir2,'xdata',z2(:,1),'ydata',z2(:,2)); % For the rack moving
set(line1,'xdata',L1(:,1),'ydata',L1(:,2)); % For 1st line
drawnow;
pause(1/omega1);      %Stop for a while so we can see the graph
delta=delta+dels;
delx=delx-dels*r1*d2r;
if delta>360, delta=delta-360;end;   %Reverse the direction at bondary line
if delx<pc,delx=delx+pc;end;
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [coords,rp,rb]=one_tooth(Dp,N,phi,range,x0,y0)
% [coords]=draw_gear(Dp,N,phi,range,x0,y0)
% To draw a whole gear
% Inputs:
%     Dp: Diametrial pitch
%     N: no of teeth in a gear
%     phi: pressure angle, degrees
%     range: the section range to be drawn
% Example one_tooth(10,10,20,360)
nn=10;
d2r=pi/180;
phir=phi*d2r;
rp=N/Dp/2;
pc=pi/Dp;
ra=rp+1/Dp;
rb=rp*cos(phir);
rd=rp-1.25/Dp;
thpb=pc/rp;% angle respect to one pitch
tp=pc/2;
rr=linspace(rb,ra,nn)';
invphi=tan(phir)-phir;
for i=1:nn
beta=acos(rp/rr(i)*cos(phir));
tt(i)=(tp/rp/2+invphi-tan(beta)+beta);
end
coord1=[rr.*cos(tt') rr.*sin(tt')];
coord3=reverse(coord1);
th1=linspace(thpb/2,thpb/2-tt(nn),nn)';
coord0=[cos(th1) sin(th1)]*rd;
th2=linspace(tt(nn),-tt(nn),nn)';
coord2=[cos(th2) sin(th2)]*ra;
coord4=reverse(coord0);
coord=[coord0;coord1;coord2;coord3;coord4];
theta=thpb/d2r;
coords=[];i=0;
while i<range
coord1=rotate2D(coord,-i,x0,y0);
coords=[coords;coord1];
i=i+theta;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function [coords]=rack(Dp,phi,nn,theta,x0,y0)
d2r=pi/180;
phir=phi*d2r;
h=2/Dp;
pc=pi/Dp;
sl=h/cos(phir);
m=sl*sin(phir);
m1=(pc/2-m)/2;
coord=[-pc/2 0;-m1-m 0;-m1,h;m1 h;m1+m 0;pc/2 0];
coords=coord;
for i=1:nn-1
coord1=[coord(:,1)+i*pc coord(:,2)];
coords=[coords;coord1];
end
nd=fix(nn/2)-mod(nn+2,4)*.25;
coords=rotate2D(coords,theta,x0-nd*pc,y0-h/2);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [B]=reverse(A,m)
if nargin==1,m=1;end
nn=length(A); B=A;
for i=1:nn,B(i,:)=A(nn-i+1,:);end
if m==1,  B=[B(:,1) -B(:,2)];end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [coords] = bushing(rr,x0,y0)
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;

%%%%%%%%%%%%%%%%%%%%%%%%

function [coords]=rotate2D(coord,theta,x0,y0)
th=theta*pi/180;
c=cos(th);s=sin(th);fact=[c s;-s c];
coords=coord*fact;
coords(:,1)=coords(:,1)+x0;
coords(:,2)=coords(:,2)+y0;


執行例

>> move2_rack(10,15,20,10)


齒列與齒輪的互動