《机构设计凸轮曲线程序》由会员分享,可在线阅读,更多相关《机构设计凸轮曲线程序(7页珍藏版)》请在金锄头文库上搜索。
1、Cls Dim t(7) as double Dim p(7) as double Dim f(7) as double Dim c(7) as double Dim b(7) as double Dim jsd(7) as double Dim yd(7) as double Dim sd(7) as double Dim wy(7) as double Dim pi as double Dim a1 as double Dim a2 as double Dim m as double Dim i as double Dim j as double Dim mc as double Dim
2、ss as double J=0 Dim tt as double Dim aa as double Star: Pi=3.1415926 ss=”请选择通用间歇体形曲线的名称:”& chr(10)+chr(13)&”1、 修正等速“& chr(10)+chr(13)&” 2、修正梯形”& chr(10)+chr(13) &” 3、修正正弦” mc=inputbox(ss) if mc=1 then t(0)=0 t(1)=1/16 t(2)=1/16 t(3)=1/4 t(4)=3/4 t(5)=15/16 t(6)=15/16 t(7)=1 if mc=2 then t(0)=0 t(1)
3、=1/8 t(2)=3/8 t(3)=1/2 t(4)=1/2 t(5)=5/8 t(6)=7/8 t(7)=1 elseif mc=3 then t(0)=0 t(1)=1/8 t(2)=1/8 t(3)=1/2 t(4)=1/2 t(5)=7/8 t(6)=7/8 t(7)=1 else msgbox(“请输入 1-3 的数”) goto start end if for i= 1 to7 f(i)=2*(t(i)-f(i-1)/pi next i m=(f(1)+f(2)*pi/2+f(3)/(f(5)+f(6)*pi/2+f(7) a1=(f(3)2+0.5*(t(2)-t(1)2)-
4、f(1)2+f(3)*(1-t(3)+(t(2)-t(1)*(1-t(2)+f(1)-m*(f(7)2+0.5*(t(6)-t(5)2)- f(5)2+f(5)*(1-t(4)+(t(6)-t(5)*(1-t(6)(-1) a2=m*a1 c(1)=f(1)*a1 c(2)=-t(1)*a1+c(1) c(3)= t(2)*a1+c(2) c(4)= f(3)*a1+c(3) c(5)=-f(5)*a2+c(4) c(6)=t(5)*a2+c(5) c(7)=- t(6)*a2+c(6) b(1)=0 b(2)=-a1*(f(1)2+0.5*t(1)2)+t(1)*(c(1)-c(2)+b(1
5、) b(3)= a1*(f(3)2+0.5*t(2)2)+t(2)* (c(2)-c(3)+b(2) b(4)=t(3)*(c(3)-c(4)+b(3) b(5)=t(4)*(c(4)-c(5)+b(4) b(6)=a(2)*(f(5)2+0.5*t(5)2)+t(5)*(c(5)-c(6)+b(5) b(7)=-a(2)*(f(7)2+0.5*t(6)2)+t(6)*(c(6)-c(7)+b(6) for tt=0 to 1 step 0.01 for i=1 to 7 select case i case 1 and (tt=t(0) and ttt(1)and ttt(2)and ttt
6、(3)and ttt(4)and ttt(5)and ttt(6)and tt=t(7) p(i)=(tt-t(i-1)/f(i)+(i-1)*pi/4 j=j+1 jsd(j)=a2*sin(p(i) yd(j)=a2*cos(p(i)/f(i) sd(j)=-a2*f(i)*cos(p(i)+c(i) wy(j)= -a2*(f(i)2)*sin(p(i)+c(i)*tt+b(i) open “d:加速度.txt”for append as #1 print #1,jsd(j) close open “d:跃度.txt”for append as #1 print #1,yd(j) clo
7、se open “d:速度.txt”for append as #1 print #1,sd(j) close open “d:位移.txt”for append as #1 print #1,wy(j) close end select next i next ii msgbox (“计算完毕”&chr(10)+chr(13)&”位移数据在 d:位移.txt” &chr(10)+chr(13)& ”速度数据在 d:速度.txt” &chr(10)+chr(13)&”加速度数据在 d:加速度.txt” &chr(10)+chr(13)& ” 跃度数据在 d:位移.txt”) msbox(“输出
8、图形“) for i=1 to 1200 step 2 form1.currentx=i*5+100 form1.currenty=1500 print”.” Next for i=1 to 101 currentx=i*20+1500 currenty=-wy(i)*600+1500 print”.” Next currentx=1500 currenty=2500 print”位移曲线” for i=1500 to 3000 step 2 form1.currentx=i*5+100 form1.currenty=1500 print”.” Next for i=1 to 101 curr
9、entx=i*20+8500 currenty=-sd(i)*200+1500 print”.” Next currentx=9500 currenty=2500 print”速度曲线” for i=1 to 1200 step 2 form1.currentx=i*5+100 form1.currenty=5500 print”.” Next for i=1 to 1000 step 2 form1.currentx=i*2+5000 form1.currenty=1500 print”.” Next for i=1 to 101 currentx=i*20+1500 currenty=-j
10、sd(i)*50+5500 print”.” Next currentx=2000 currenty=7000 print”加速度曲线” for i=1500 to 3000 step 2 form1.currentx=i*5+100 form1.currenty=5500 print”.” Next for i=1 to 1000 step 2 form1.currentx=i*2+5000 form1.currenty=8500 print”.” Next for i=1 to 101 step 0.8 currentx=i*20+8500 currenty=-yd(i)*6+5500 p
11、rint”.” Next currentx=9000 currenty=7000 print”跃度曲线” print print select case mc case 1 currentx=6000 currenty=12000 print “修正等速”;”的四个曲线” case 2 currentx=6000 currenty=12000 print “修正梯形”;”的四个曲线” case 3 currentx=6000 currenty=12000 print “修正正弦”;”的四个曲线” end select end sub private sub command2_click() end end sub end sub