5/17/07

第十一章 齒輪(2)-齒輪曲線



11.2 齒輪曲線之形成

由前面齒列之程式可以瞭解齒輪雖然僅有齒牙相接觸,但其曲線之形成仍然必須依據特定的曲線規則。漸開線是最常用的曲線,為此可以使用齒列作為切刀,修正曲線之外廓。程式gear_curve.m除可產生齒輪之基本曲線外,可以依所需之齒數建立一個完整的齒輪,並且使其作適當的迴轉運動。程式中另呼叫onegear.m、rotate2xy.m。前者是將一個完整的齒輪的外形座標組合,後者則是座標旋轉的程式。程式gear_curve.m之呼叫格式如下:

  function [rack,gear]=gear_curve(Dp,N,phi,ar,br,rt,rf,ag,ptregion)


Dp      = 節矩
ar      = 齒列之齒冠
br      = 齒列之齒根
phi     = 壓力角, degrees
rt      = 頂部圓角半徑
rf      = 根部圓角半徑
r       = 齒輪之節圓半徑
ag      = 齒輪之齒冠
bg      = 齒輪之齒根
ptregion= 齒形之五區點數,列矩陣,例如:[5 15 5 15  5]
N       = 齒輪之齒數


function [rack,gear]=gear_curve(Dp,N,phi,ar,br,rt,rf,ag,ptregion)
%
% Matlab program to draw a gear generated by a straight flanked hob.
%
%Some of the important variables used are:
%
% Example  gear_curve(10,10,20,1.25,1,0.02,0.04,1.0,[30 30 40 30 30],10)
%          gear_curve(10,10)
%
%Dp      = Diametral pitch
%ar      = Addendum constant for rack
%br      = Dedendum constant for rack
%phi     = pressure angle in degrees
%rt      = tip radius of rack
%rf      = fillet radius of rack
%r       = pitch radius of gear
%ag      = Addendum constant for gear
%bg      = Dedendum constant for gear
%ptregion= No. of points for five regions, row matrix
%N       = Number of gear teeth
if nargin<4,
ar=1.25;br=1;rt=0.02;rf=0.04;ag=1;
%ptregion=[10 15 20 15 15];
ptregion=[10 15 10 15 10];
end
th=linspace(0,2*pi,50);
if nargin<3,phi=20;end ans="'y';" d2r="pi/180;" ansp="'y';" pc="pi/Dp;" r="pc*N/(pi*2);%" ro="r+ag/Dp;" phir="phi*d2r;" rackline="line('xdata'," rackpitchline="line('xdata'," xmax="max(rack(1,:));xmin="min(rack(1,:));xrange="xmax-xmin;" ymax="max(rack(2,:));ymin="min(rack(2,:));yrange="ymax-ymin;" ymin="ymin-0.05*yrange;" ymax="ymax+0.05*yrange;" dtheta="2*pi/N/d2r;" gear0="gear;" i="1:N-1," gear="[gear," gearline="line('xdata'," gearpitchline="line('xdata'," xtemp="gear(1,:);ytemp="gear(2,:);" xmax="max(xtemp);xmin="min(xtemp);xr="xmax-xmin;" ymax="max(ytemp);ymin="min(ytemp);yr="ymax-ymin;" s="0.1;" xgear="xtemp';ygear="ytemp';" ainc="1;" theta="0;i="0;">360,theta=theta-360;i=i+1; end
set(gearline, 'xdata', xgear, 'ydata', ygear);
[xgear,ygear]=rotate2xy(xgear,ygear,ainc);
theta=theta+ainc;
drawnow;
pause(0.01);
end

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

function [rack,n]=rackm(phir,Dp,A,B,rt,rf,ptregion)
%
%Calculate a rack profile, with ptregion specifies 5-region points
% phir:pressure angle in radian
% Dp:diametral pitch
% ar: addendium
% br: bottom reference,dedendum of rack
% rt  = tip radius of rack
% rf  = fillet radius of rack
gamma=pi/2-phir;
lt=pi/(2*Dp)-2*A*tan(phir)-2*rt*tan(gamma/2);
lb=pi/(2*Dp)-2*B*tan(phir)-2*rf*tan(gamma/2);
if lt < 0
lt=0;
rt=(pi/(2*Dp)-2*A*tan(phir))/(2*tan(gamma/2));
end
if lb <0
lb=0;
rf=(pi/(2*Dp)-2*B*tan(phir))/(2*tan(gamma/2));
end
i=0;
for k=1:length(ptregion) %for 5 regions
beta=0.0;nx=ptregion(k);dbeta=1/nx;
for j=1:nx
i=i+1; 
beta=beta+dbeta;
switch k
case 1
rack(:,i)=[beta*lt/2;A];n(:,i)=[0;1.0];
case 2
rack(:,i)=[lt/2+rt*sin(beta*gamma);...
A-rt*(1-cos(beta*gamma))];
n(:,i)=[sin(beta*gamma);cos(beta*gamma)];
case 3
sg=sin(gamma);cg=cos(gamma);
rack(:,i)=[(1-beta)*(lt/2+rt*sg)+beta*(pi/(2*Dp)-lb/2-rf*sg);...
(1-beta)*(A-rt*(1-cg))+beta*(-B+rf*(1-cg))];
n(:,i)=[cos(phir);sin(phir)];
case 4
sb=sin((1-beta)*gamma); cb=cos((1-beta)*gamma);
rack(:,i)=[pi/(2*Dp)-lb/2-rf*sb;-B+rf*(1-cb)];
n(:,i)=[sb;cb];
case 5
rack(:,i)=[pi/(2*Dp)-lb/2*(1-beta);-B];
n(:,i)=[0;1];
end
end
end

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

function [gear,plx,ply]=onegear(rack,n,r,ro,N)
%
%find coordinates of one gear
% rack:coordinates of a rack
% n: normal vector of each point on the rack
% r: pictch radius
% ro:outside radius
% N: no. of teeth
d2r=pi/180;
ang=(rack(1,:).*n(2,:)-rack(2,:).*n(1,:))./(r*n(2,:));
geart(1,:)=-cos(ang).*(rack(1,:)-r*ang)+sin(ang).*(rack(2,:)-r);
geart(2,:)=-sin(ang).*(rack(1,:)-r*ang)-cos(ang).*(rack(2,:)-r);

% Define the pitch circle arc

maxang=max(ang);
minang=min(ang);
dk=(maxang-minang)/20;
i=0;
for k=minang:dk:maxang
i=i+1;
plx(i)=r*sin(k);
ply(i)=r*cos(k);
end 

% Rotate the coordinate system by -pi/N so that the y axis is along the
% centerline of the gear tooth instead of the centerline of the gap.

[xx,yy]=rotate2xy(geart(1,:)',geart(2,:)',-pi/N/d2r);
xx=xx';yy=yy';
% Test for the undercut points which cannot be on the gear
itotal=length(rack(1,:));
jstop=itotal+1;
istop=itotal+1;
for i = 1:itotal-2
for j=i+1:itotal-1
if istop==itotal+1 & jstop==itotal+1
ra=[xx(i) yy(i)];
rb=[xx(i+1) yy(i+1)];
rc=[xx(j) yy(j)];
rd=[xx(j+1) yy(j+1)];
rba=rb-ra;rca=rc-ra;
rac=ra-rc;rda=rd-ra;
rdc=rd-rc;rbc=rb-rc;
rbd=rb-rd;
Aabc=rba(1)*rca(2)-rba(2)*rca(1);
Aabd=rba(1)*rda(2)-rba(2)*rda(1);
Acda=rdc(1)*rac(2)-rdc(2)*rac(1);
Aadb=rda(1)*rba(2)-rda(2)*rba(1);
Acdb=rdc(1)*rbc(2)-rdc(2)*rbc(1);
test1=Aabc*Aabd;
test2=Acda*Acdb;   

% Check for the intersection of two line segments

if test1<0 & test2<0
istop=i;
jstop=j+1;
alpha=abs(Acdb)/(abs(Acda)+abs(Acdb));
re(1)=alpha*ra(1)+(1-alpha)*rb(1);
re(2)=alpha*ra(2)+(1-alpha)*rb(2);
j=itotal;
i=itotal;
end 
end  
end
end

% If two lines intersect, delete the points in the undercut region.

j=0;
for i=1:itotal
if i<=istop | i >= jstop
j=j+1;
geart(:,j)=[xx(i);yy(i)];
if i==istop
j=j+1;
geart(1,j)=re(1);
geart(2,j)=re(2);
end
end
end
itotal=j;

% Check that the points do not extend beyond the addendum circle (ro).

j=0;
rtest1=0;
istop='n';
i=0;
for i=1:itotal
if istop=='n'
rtest2=sqrt(geart(1,i)^2+geart(2,i)^2);
if rtest2<=ro
j=j+1;
gear(:,j)=geart(:,i);
xx(j)=gear(1,j);
yy(j)=gear(2,j);
end

% If the points extend beyond the addendum circle, discard the
% points beyond ro and find the intersection of the gear with the
% ro circle.

if rtest2>ro
alpha=(ro-rtest1)/(rtest2-rtest1);
j=j+1;
gear(:,j)=geart(:,i-1)+alpha*(geart(:,i)-geart(:,i-1));
xx(j)=gear(1,j);
yy(j)=gear(2,j);
istop='y';
end
rtest1=rtest2;
end
end

% if the addendum is reached replace the points beyond the
% addendum with points on a circle arc.

if j<itotal
beta = atan2(gear(1,j), gear(2,j));
dbeta=beta/5;
betak=beta;
for k=1:5
j=j+1;
betak=betak-dbeta;
sbetak=sin(betak);
cbetak=cos(betak);
gear(1,j)=ro*sbetak;
gear(2,j)=ro*cbetak;
end
end
jtotal=j;

% Reflect the points to draw the rest of the gear tooth

for i=1:jtotal-1
j=j+1;
gear(1,j)=-gear(1,jtotal-i);
gear(2,j)=gear(2,jtotal-i);
end 
itotal=j;

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

function [x,y]=rotate2xy(x,y,theta,x0,y0)
if nargin<4, x0=0;y0=0;end;
th=theta*pi/180;
c=cos(th);s=sin(th);fact=[c s;-s c];
coords=[x y]*fact;
x=coords(:,1)+x0;y=coords(:,2)+y0;


執行例:
>>gear_curve(10,10);



2 comments:

  1. Nice answer back in return of this issue with genuine arguments and telling the
    whole thing concerning that.

    Review my blog post mazda rx8 engine for sale

    ReplyDelete
  2. certainly like your website however you need to take a look at the spelling on several
    of your posts. A number of them are rife with spelling problems and I find it very troublesome to inform the
    truth however I will certainly come again again.


    My web site; mazda rx 8 r3

    ReplyDelete