|
function worm3
0 X; ?1 ^2 B7 A$ Z' h5 J6 ~clear
& F! V! D# r4 Z* Jclc+ |+ Y, P& e* D' l
a=240.65;%中心距" Q3 z0 |" |5 ]* g
z1=1;%蜗杆头数& ^( F/ o u, F, t% X% ^% R V
z2=40;%齿轮齿数6 E7 e' `( D/ s
i12=z2/z1;%传动比
- S" J/ s/ o2 k0 _( Vzc=4;%蜗杆包围蜗轮齿数
( ?. C i! E- [: H4 dd1=80;%蜗杆分度圆直径$ J7 ]) Y, n3 @' I8 ?5 C2 b0 b8 A
d2=2*a-d1;%蜗轮分度圆直径
0 H6 V. b+ M$ Z% V% N" imt=d2/z2;%蜗轮端面模数
8 N5 u$ J9 b. oda2=417.36;%蜗轮齿顶圆直径
# x# X) c0 r* f- Wdf2=381.24;%蜗轮齿根圆直径& K8 C/ m8 [) s
ha=(da2-d2)/2;%齿顶高
/ n5 ~ e n6 K3 i5 ?hf=(d2-df2)/2;%齿根高4 U5 O6 S. `, G7 I
da1=d1+2*ha;%蜗杆顶圆直径4 g0 W+ q: ]! _9 D
df1=d1-2*hf;%蜗杆根圆直径4 u- m0 X) w' _4 L5 u0 t2 I
Rf1=a-df1/2;%蜗杆齿根圆弧半径
- D" [' b1 S' X$ l7 }" p, e- |5 @2 xRa1=a-da1/2;%蜗杆齿顶圆弧半径+ E2 G1 Y" ?. C$ q4 W
gama=atan(d2/d1/i12);%蜗杆喉部分度圆导程角+ D f5 k, w {9 O
tau=2*pi/z2;%齿距角
9 \" y' Y& W& P, F& B; }# wdb=153;%主基圆直径
, v( i. `2 [ I3 Q$ B& w; v4 [alpha=asin(db/d2);%蜗轮分度圆压力角" d* R: V$ R1 D
phi_w=0.5*tau*(zc-0.45);%蜗杆包围蜗轮的工作半角
1 v) T* O$ k& i% Z' t; bphi_0=alpha-phi_w;%工作起始角6 [* [- n0 p6 a( l7 Q) f1 w0 S
Lw=d2*sin(phi_w);%蜗杆工作部分长度8 M) e! ~: d2 F( y7 I
beta=11/180*pi;%母平面倾斜角
5 l4 }6 r0 W. ~phi0min=phi_0;6 Y- D* r2 c+ J; O# o, l
phi0max=phi_0+2*phi_w;
9 }8 `% Q' o b- A, S8 v5 d6 w1 ru0=((d2/2)^2-(db/2)^2)^0.5;
7 ^1 c1 M4 J+ Hphi0=linspace(phi0min,phi0max,300);
/ j+ f5 Z$ T( Y, @1 BR=linspace(Ra1,Rf1,10);
6 Q- @( z2 t6 gphi1=phi0.*i12;- W( ]9 b) ~4 D$ k) U7 r. P
cath=2*alpha+162/z2/180*pi;$ }* w& d3 y( F9 {1 C( @, ^8 V/ a
0 g9 K4 }4 `& T' \" {/ E
%预设矩阵
# [7 h1 x: b/ O) v( x5 Y3 h4 |2 I) yu1=zeros(length(phi0),length(R));v1=zeros(length(phi0),length(R));%甲面参数
, F0 V' ?- c b% t2 ix01=zeros(length(phi0),length(R));y01=zeros(length(phi0),length(R));z01=zeros(length(phi0),length(R));%甲面的平面
- T1 Y+ U% h* ~% O {x11=zeros(length(phi0),length(R));y11=zeros(length(phi0),length(R));z11=zeros(length(phi0),length(R));%蜗杆甲面
/ d0 q) u& F: j( h1 k% _5 mx13=zeros(length(R),length(phi0));y13=zeros(length(R),length(phi0));z13=zeros(length(R),length(phi0));%甲面的螺旋线形式( R3 N9 E+ s+ s* ?( z# R7 ?, o
theta1=zeros(length(R),length(phi0));R1=zeros(length(R),length(phi0));Z1=zeros(length(R),length(phi0));%甲面的加工参数% F; d, p& I5 c1 D3 Q' m7 `
3 I0 [& X, [/ x# @
u2=zeros(length(phi0),length(R));v2=zeros(length(phi0),length(R));%乙面参数
/ _# e( t4 d3 u6 M# ?! H6 sx03=zeros(length(phi0),length(R));y03=zeros(length(phi0),length(R));z03=zeros(length(phi0),length(R));%乙面的平面' S( k: t# Y% H0 @+ q/ M
x02=zeros(length(phi0),length(R));y02=zeros(length(phi0),length(R));z02=zeros(length(phi0),length(R));%乙面的平面( @7 b6 W7 X9 b, l J, F
x12=zeros(length(phi0),length(R));y12=zeros(length(phi0),length(R));z12=zeros(length(phi0),length(R));%蜗杆乙面
! _: W4 t. a7 m5 k( s- mx14=zeros(length(R),length(phi0));y14=zeros(length(R),length(phi0));z14=zeros(length(R),length(phi0));%甲面的螺旋线形式
6 i) ^9 c( I J5 [, |1 ltheta2=zeros(length(R),length(phi0));R2=zeros(length(R),length(phi0));Z2=zeros(length(R),length(phi0));%甲面的加工参数/ G, V2 t, D: H) O+ N
0 y3 ^8 t. l4 y4 {1 n- [5 F; V* bfigure(1)
/ d0 v+ p W9 R( ~7 G1 t6 E/ yfor i=1:length(phi0)
/ p; J; ] ~. C+ D; G for j=1:length(R) M. N5 w& G; Q( N) d: |
f1=@(x)[(a-((x(1)*cos(phi0(i))-(x(2)*sin(beta)-db/2)*sin(phi0(i))-a)^2+(x(2)*cos(beta))^2)^0.5)^2+(x(1)*sin(phi0(i))+(x(2)*sin(beta)-db/2)*cos(phi0(i)))^2-R(j)^2;(x(1)*(cos(beta)/i12+sin(beta)*cos(phi0(i)))+(db/2*sin(phi0(i))-a)*sin(beta))/sin(phi0(i))-x(2)];4 r- U0 ?+ l" t: U) q
options=optimset('Display','off','TolFun',1e-7);" z. t/ P* r1 t7 v5 C
x0=[u0 0];
/ G. a$ b/ V T x=fsolve(f1,x0,options);
* ~2 D D% Z5 O5 H u1(i,j)=x(1);6 ]6 `; }# G" Y, H1 E
v1(i,j)=x(2);* H+ K' R- n: i
x01(i,j)=u1(i,j);+ H2 {* U h; @/ S
y01(i,j)=v1(i,j).*sin(beta)-db/2;! n4 b, J9 y# h9 e* ]! ]
z01(i,j)=v1(i,j).*cos(beta);
# b3 J/ W2 w) _3 M x11(i,j)=-cos(phi1(i)).*cos(phi0(i)).*x01(i,j)+cos(phi1(i)).*sin(phi0(i)).*y01(i,j)-sin(phi1(i)).*z01(i,j)+a.*cos(phi1(i));
! L/ x2 _% K& Q# Q9 T$ f1 ~/ N+ \, f y11(i,j)=sin(phi1(i)).*cos(phi0(i)).*x01(i,j)-sin(phi1(i)).*sin(phi0(i)).*y01(i,j)-cos(phi1(i)).*z01(i,j)-a.*sin(phi1(i));
" b, \. D- S! u! i8 [+ ?% R* |: V z11(i,j)=-sin(phi0(i)).*x01(i,j)-cos(phi0(i)).*y01(i,j);- C1 n) _; t6 v N G- _+ O
end9 v/ C9 J6 m/ g3 x! e
plot3(x11(i,,y11(i,,z11(i,,'r')
' C% ^# R! ~# _4 {; [7 X$ Z hold on( _2 C. R# X; J& F$ T
end
6 ?% r4 K) F8 d4 m5 x5 d% u( Qaxis equal& o9 F! W4 j. q! c- e
3 \3 N) ]; A9 b% s
figure(1)- d, I2 `; f$ O# L
for i=1:length(phi0) ]" u. h$ ?& J8 x6 i" k
for j=1:length(R)
) j7 ^) @+ e! T3 Y0 P! S' e9 m f2=@(x)[(a-(((x(1)*cos(cath)+(x(2)*sin(beta)+db/2)*sin(cath))*cos(phi0(i))-(-x(1)*sin(cath)+(x(2)*sin(beta)+db/2)*cos(cath))*sin(phi0(i))-a)^2+(x(2)*cos(beta))^2)^0.5)^2+((x(1)*cos(cath)+(x(2)*sin(beta)+db/2)*sin(cath))*sin(phi0(i))+(-x(1)*sin(cath)+(x(2)*sin(beta)+db/2)*cos(cath))*cos(phi0(i)))^2-R(j)^2;(x(1)*(cos(beta)/i12+sin(beta)*cos(phi0(i)-cath))+(-db/2*sin(phi0(i)-cath)-a)*sin(beta))/sin(phi0(i)-cath)-x(2)];+ C ?% ]1 Z7 N* o; X5 S5 Y" {* Y
options=optimset('Display','off','TolFun',1e-7);4 M: v7 x) k( c- K% B
x0=[u0 0];
- B, `: Q8 ?/ S x=fsolve(f2,x0,options);
0 X0 f: n& s& p, ~5 c+ a u2(i,j)=x(1);8 b7 r1 x$ f4 w# T0 U6 b
v2(i,j)=x(2);
' j0 P9 @7 j+ Y% I x03(i,j)=u2(i,j);) y3 \( h" K+ g7 @/ T
y03(i,j)=v2(i,j).*sin(beta)+db/2;
1 K3 E9 X: I" j) W) O3 Z" L z03(i,j)=v2(i,j).*cos(beta);7 M' \$ k1 Z0 |7 Q. _
x02(i,j)=x03(i,j).*cos(cath)+y03(i,j).*sin(cath);
) h; w' E3 X" i8 }% m# O' B y02(i,j)=-x03(i,j).*sin(cath)+y03(i,j).*cos(cath);
" D- S# d$ x# T m$ M( |" k8 L z02(i,j)=z03(i,j);
, W7 z: R3 r- U: X6 Y4 U& G- J9 ? x12(i,j)=-cos(phi1(i)).*cos(phi0(i)).*x02(i,j)+cos(phi1(i)).*sin(phi0(i)).*y02(i,j)-sin(phi1(i)).*z02(i,j)+a.*cos(phi1(i));
- o6 e2 R+ q+ H: C. g y12(i,j)=sin(phi1(i)).*cos(phi0(i)).*x02(i,j)-sin(phi1(i)).*sin(phi0(i)).*y02(i,j)-cos(phi1(i)).*z02(i,j)-a.*sin(phi1(i));
8 Z, g* q$ b, Y( J. l) K z12(i,j)=-sin(phi0(i)).*x02(i,j)-cos(phi0(i)).*y02(i,j);
. N2 ~6 P* ?; L6 I. A end
5 |$ K# e6 |! L' e, q2 Y/ A$ y plot3(x12(i,:),y12(i,:),z12(i,:))' }2 ^* k& ~! c6 f1 e# p3 m
hold on
3 M8 S% I% e' U* Q! H- j3 T8 L9 nend
, e' o k# `) T& u5 m/ Yaxis equal5 Z: X$ _* ? W; P* {5 Y
+ Z& i, l" @' N9 t Y( S. S& Q
figure(2)6 P. B* J( s% z# a
for j=1:length(R)
! V3 Y3 C. c% n# Q# @2 h plot3(x11(:,j),y11(:,j),z11(:,j),'r'); H9 ]& ]1 A1 i! F3 P( k/ m* n! I& L
hold on
& l. |- p( P) Z8 g0 q' oend
2 N; C& F, t, }3 }; M! M4 Faxis equal, o, I$ m; w$ L
figure(2)/ Z% Q8 c# D) R- l; v1 z
for j=1:length(R) % l1 b4 v( w6 _6 |; ]3 p6 W
plot3(x12(:,j),y12(:,j),z12(:,j))- b) r9 G( G8 |6 ~' H
hold on* v/ |4 R6 a' V' u: O5 b |
end
0 B( s; d- j+ o& naxis equal
7 d2 D( B3 r+ R) g
, I6 ^; h' F1 L( _0 `x13=x11';%转换为螺旋线的格式
* Q# I( L0 y! I. ]: k8 U% ]: w) yy13=y11';
) @; u/ |0 ?! [. O( f$ q$ ez13=z11';$ z; ]( F: W# p3 S
x14=x12';
/ I# o' s" h2 J5 v& O8 uy14=y12';* G& F- j+ m: r0 M2 p( |& h
z14=z12';
( |( b& s; a5 T1 D+ v
, R% K2 s+ M, ~; l) Tfor i=1:length(R)2 l4 K3 l( O$ j! Z
for j=1:length(phi0)! D/ b- D5 b( ]5 n; ^) J5 F6 A
theta1(i,j)=cal_theta(x13(i,j),y13(i,j))/pi*180;
' {; A% Z, E2 ?, s; a R1(i,j)=(x13(i,j)^2+y13(i,j)^2)^0.5;%车床X方向为直径值6 L; ?& y: F* N4 P r: o
Z1(i,j)=z13(i,j);$ f' t% m2 h/ x- B; I1 w+ Y
theta2(i,j)=cal_theta(x14(i,j),y14(i,j))/pi*180;
' S, t3 H; g7 \2 o* \ R2(i,j)=(x14(i,j)^2+y14(i,j)^2)^0.5;
' u4 z8 X* V9 {6 l, k C1 L* D) T Z2(i,j)=z14(i,j);7 o7 N2 M) ]; z" Q) t
end. Z# ] q& x, S7 l
end$ H3 s) J+ P( e% e; L, F+ \
1 N: ^/ _, o, _8 D2 e4 \%角度转换为绝对式+ C2 ~+ D" d! k6 l5 E }' j
for i=1:length(R)
+ V8 a3 o$ D! \$ Z% d% S8 A: O for j=1length(phi0)-1)
6 \) t v7 ~( @; P8 z if theta1(i,j+1)<theta1(i,j)# R. m( }7 K; m& Q/ W8 k" f0 F0 }! j, C
for k=(j+1):length(phi0): @, V5 ]7 ~/ l9 d
theta1(i,k)=theta1(i,k)+360;) F) A, @7 q( U. D( H
end
/ F' s7 a- {0 S1 E4 s! ` end& f% f3 }9 s- T5 b5 d2 w, @- z
if theta2(i,j+1)<theta2(i,j)% X2 e8 `6 R+ M6 W
for k=(j+1):length(phi0)
M% o1 y7 a$ [6 {; N4 s theta2(i,k)=theta2(i,k)+360;; J& n* @; u- U$ u+ `3 [3 K
end
?5 |9 ?7 }, z1 K end$ S4 l, ^. Y7 w$ e( r3 m
end$ P" C& H* b& K! o
end c6 t2 x! e2 T; O3 K0 u
( s* B/ V" u7 T4 p, v5 J7 X' \assignin('base','X1',R1)) H: s, }% k. D: P3 C1 l' o) g
assignin('base','Z1',Z1)( e. c; o6 }/ N3 k/ ?
assignin('base','C1',theta1)0 {; D0 |0 Q1 v% g- A3 o
assignin('base','X2',R2)
" g5 o7 B) E' kassignin('base','Z2',Z2)
5 m$ s0 F" Z# C0 ]% uassignin('base','C2',theta2)! e7 L7 c& e( Z/ s1 ]: | T
( {( W# T, A4 q" h%G代码的输出* l; Q" ?9 G' W# {) g1 l7 d
% fid=fopen('turncode.txt','wt');
# J/ L# u7 h ~" E0 y% fprintf(fid,'O0001\n');
/ D& K/ U4 ?3 l% q9 `% d+ _. l. A% for i=1:length(R)- h7 x; Z0 ], q6 {6 X3 P `* |& u5 v( l
% for j=1:length(phi0)! d6 y, W7 y0 {- j5 o( |: ]
% fprintf(fid,'X=%0.4f\t',R1(i,j))0 C4 r! ^3 b( q6 s
% fprintf(fid,'Z=%0.4f\t',Z1(i,j))8 o0 B1 `& {4 h" V+ V8 n
% fprintf(fid,'C=%0.4f\n',theta1(i,j))9 \2 k: @3 J8 v) c8 W C m; r' z
% end# R @1 N7 s }
% end
3 h* H. t' `5 V& G; b6 X
, [& S+ i" s6 z! m) V' P
6 C1 {1 B+ v3 x( E5 P+ x
) P+ v' w" U! A' n$ O, C- j& V
& k3 i n/ a6 s$ J3 K2 d( efunction theta=cal_theta(x1,y1)
! U0 }/ z6 s: R0 J8 d# ]* {if (x1>0)&&(y1<0)
2 Y* B1 X( _- O; u( j theta=acos(x1./(x1^2+y1^2)^0.5);%电机转是角度还是弧度?
; m# {; m+ D$ A7 ?elseif (x1<0)&&(y1<0);% a% k8 Q, U g- |$ f. J0 G
theta=acos(x1./(x1^2+y1^2)^0.5);
4 e R& O/ z9 c. E4 }. _$ yelseif (x1<0)&&(y1>0);
% R0 E$ j! {/ Z% ^! K theta=2*pi-acos(x1./(x1^2+y1^2)^0.5);
, y4 M( X& |3 C! H+ Q! |elseif (x1>0)&&(y1>0);! i% ~* C9 l: {2 t
theta=2*pi-acos(x1./(x1^2+y1^2)^0.5);; F) y& `, F/ z& G, S
elseif (x1>0)&&(y1>0);7 R/ Q, z7 m X$ P$ }
theta=2*pi-acos(x1./(x1^2+y1^2)^0.5);
2 y7 m+ p+ o; jelseif (x1>0)&&(y1==0);; b7 a' A% y; L# @' j2 d+ {
theta=0;
% o5 |$ b$ e- y/ zelseif (x1<0)&&(y1==0);
' X, g0 ^4 ^& d- l' I4 D theta=pi;( |- _+ D5 M+ z& [4 T6 s
elseif (x1==0)&&(y1<0);3 j j' i K, N
theta=pi/2;
; ]: V- o2 y9 e& Q* g" Lelseif (x1==0)&&(y1>0);
1 z. S1 L$ m# ?! N' b/ J" z theta=3*pi/2;) u9 p% K) o% ~- j; z) D( H* W
end |
|