*********************************************** function [x]=isinterf(phi,N1,N2) % % Test if the gear set exists an interference % phi:pressure angle, in degrees % N1,N2:teeth of both gears % x=0:no interference; x=1 interence exists x=0; sinx=sin(phi*pi/180); if N2if N1*(N1+2*N2)*sinx*sinx<4*(1+N2), x=1;end ************************************************ phi為壓力角 N1為齒輪一齒數 N2為齒輪二齒數 x=1表示產生干涉 x=0表示不產生干涉
主程式 ==> function [x]=isinterf(20,30,48)
ans=0 所以是不產生干涉,與計算結果符合的!
4. function [coords]=draw_gear(Dp,N,phi,range,x0,y0)
************************************************* function [coords]=draw_gear(Dp,N,phi,range,x0,y0) % [coords]=draw_gear(Dp,N,phi,range,x0,y0) % To draw a whole gear % Inputs: % Dp: Diametrical pitch % N: no of teeth in a gear % phi: pressure angle, degrees % range: the section range to be drawn % x0,y0: the location of the gear center % Example [coords]=draw_gear(10,15,20,360,0,0) [coord,theta,rp,rb]=tooth(Dp,N,phi); coords=[];i=0; while i coord1=rotate2D(coord,-i,x0,y0); coords=[coords;coord1]; i=i+theta; end plot(coords(:,1),coords(:,2));hold on; [coord]=bushing(rp/8,x0,y0); plot(coord(:,1),coord(:,2),'b-'); [coord]=bushing(-rp,x0,y0); plot(coord(:,1),coord(:,2),'r:'); [coord]=bushing(-rb,x0,y0); plot(coord(:,1),coord(:,2),'b:'); axis equal; *************************************************
*************************************************** function move2_gear(Dpitch,nn1,nn2,phi,omega1) % move2_gear(Dpitch,nn1,nn2,phi,omega1) % To draw a whole gear % Inputs: % Inputs: % Dpitch:dimetral pitch % nn1,nn2: no. of teeth for both gears % phi:pressure angle, degrees % omega1: angular velocity of gear 1 % Example move2_gear(10,15,20,20,10) clf; d2r=pi/180;delt=0.01; [coord1,r1,rb1]=one_tooth(Dpitch,nn1,phi,360,0,0); [coord2,r2,rb2]=one_tooth(Dpitch,nn2,phi,360,0,0); st=180/nn2;if nn1+nn2>2*fix((nn1+nn2)/2),st=0;end coord2=rotate2D(coord2,180+st,0,0); xc1=coord1(:,1);yc1=coord1(:,2); xc2=coord2(:,1);yc2=coord2(:,2); height=max(r1,r2)*1.2; ar=min(abs(r1),abs(r2)); coord=bushing(ar/5,0,0); % Get the coordinates of 1st bushing xb1=coord(:,1)-r1;yb1=coord(:,2); xb2=coord(:,1)+r2;yb2=coord(:,2); coord=bushing(-r1,-r1,0);%Get the 1st pitch circle xp1=coord(:,1);yp1=coord(:,2); coord=bushing(-r2,r2,0);% Get the 2nd pitch circle xp2=coord(:,1);yp2=coord(:,2); plot(xb1,yb1,'r-');hold on; plot(xb2,yb2,'k-'); plot(xp1,yp1,'r:'); plot(xp2,yp2,'k:'); plot([-r1,r2]',[0,0]','r:'); xx1=min([r1,r2])/2;phir=(90-phi)*d2r; plot([0,0]',[-xx1*2,xx1*2]','b:'); plot([-xx1 xx1]',[-xx1*tan(phir), xx1*tan(phir)]','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'); lx1=[0 -r1]';ly1=[0,0]'; lx2=[r2,0]';ly2=[0,0]'; axis([-2.5*r1 2.5*r2 -height height]); axis equal; title('Press Ctl-C to stop'); theta1=180;theta2=180;s1=omega1*delt/d2r; while 1, z1=rotate2D([xc1,yc1],theta1,-r1,0); z2=rotate2D([xc2,yc2],theta2,r2,0); L1=rotate2D([lx1,ly1],theta1,-r1,0); L2=rotate2D([lx2,ly2],theta2,r2,0); set(cir1,'xdata',z1(:,1),'ydata',z1(:,2)); % For 1st circle moving set(cir2,'xdata',z2(:,1),'ydata',z2(:,2)); % For 2nd circle moving set(line1,'xdata',L1(:,1),'ydata',L1(:,2)); % For 1st line set(line2,'xdata',L2(:,1),'ydata',L2(:,2)); % For 2nd line drawnow; pause(1/s1); %Stop for a while so we can see the graph theta1=theta1+s1; theta2=theta2-s1*r1/r2; if theta1>360, theta1=theta1-360;end; %Reverse the direction at bondary line if theta2>360,theta2=theta2-360;end; end ****************************************** Dpitch:節矩 nn1,nn2:兩齒輪之齒數 phi:壓力角,degrees omega1: 齒輪1之角速度,rad/s
******************************************************************************* 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 *********************************************************************************
****************************************************************** 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 ********************************************************************