用C语言编程求解的凸轮运动规律

  • 格式:doc
  • 大小:151.00 KB
  • 文档页数:12

凸轮大作业

利用计算机辅助设计完成下列偏置式直动滚子推杆盘形构件(推杆的移动副导路位于凸轮盘回转中心右侧)或摆动滚子推杆盘形凸轮机构的设计,设计已知数据如下表所示,机构中凸轮沿着逆时针方向作匀速转动。

凸轮机构的推杆在近休、推程、远休及回程阶段的凸轮转角

近修凸轮转角 推程凸轮转角 远修凸轮转角 回程凸轮转角

0°~60° 60°~210° 210°~270° 270°~360°

偏置直动滚子推杆盘形凸轮机构的已知参数

二、动规律及凸轮廓线方程

推程 等加速

202/2hs

等减速

2020/)(2hhs

回程 初选基圆半径

R0/mm 偏距

e/mm 滚子半径

Rt/mm 推杆行程

h/mm 许用压力角

许用最小曲率半径

[P amin] [a1] [a2]

15 +10 12 30 30° 75° 0.3Rt 理论轮廓廓线方程

x=(s0+s)sinδ+ecosδ

y= (s0+s)cosδ-esinδ

工作廓线方程

x'=x-trcosδ

y'=y-trsinδ

实际廓线方程:

22/)/(/)/(sinddyddxddx

22/)/(/)/(cosddyddxddy

cos'rrxx

sin'rryy

三、原始程序

#include

#include

using namespace std;

#define N 120

#define pi 3.1415926

double oro=0.5;

double rt=12,h=30,e=10,a_max1=30*pi/180,a_max2=75*pi/180,p_min=3.6;

double change_angel(int d)

{

return d*pi/180;

}

double f_s0(double r0,double e)

{

return pow(pow(r0,2)-pow(e,2),0.5);

}

double f_s(double a)

{ double s;

if(a>=0&&a<=60)

s=0;

else if(a<=135) s=2*h*pow(a-60,2)/pow(135,2);

else if(a<=210)s=h-2*h*pow(210-a,2)/pow(135,2);

else if(a<=270)s=h;

else s=h*(4-a/90+sin(change_angel(4*a-3*360))/2/pi);

return s;

}

double f_x(double s,double s0,double a)

{

double x;

x=(s0+s)*sin(change_angel(a))+e*cos(change_angel(a));

return x;

}

double f_y(double s,double s0,double a)

{

double y;

y=(s0+s)*cos(change_angel(a))-e*sin(change_angel(a));

return y;

}

double f_s1(double a)

{

double s1;

if(a>=0&&a<=60) s1=0;

else if(a<=135) s1=64*h*(change_angel(a)-(pi/4))/9/pow(pi,2);

else if(a<=210) s1=64*h*(pi-change_angel(a))/9/pow(pi,2);

else if(a<=270) s1=0;

else s1=h*(-2/pi+2*cos(change_angel(4*a-3*360))/pi);

return s1;

}

double f_x1(double s0,double a,double s,double s1)

{

double x1;

x1=(s0+s)*cos(change_angel(a))+s1*sin(change_angel(a))-e*sin(change_angel(a));

return x1;

}

double f_y1(double s0,double a,double s,double s1)

{

double y1;

y1=-(s0+s)*sin(change_angel(a))+s1*cos(change_angel(a))-e*cos(change_angel(a));

return y1; }

double f_xx(double x,double x1,double y1)

{

double xx;

xx=x+rt*y1/pow(pow(x1,2)+pow(y1,2),0.5);

return xx;

}

double f_yy(double y,double x1,double y1)

{

double yy;

yy=y-rt*x1/pow(pow(x1,2)+pow(y1,2),0.5);

return yy;

}

double f_aa(double r0,double s,double s1)

{ double aa;

aa=atan(fabs(s1/(r0+s)));

return aa;

}

double f_s2(double a)

{

double s2;

if(a>=0&&a<=60)

s2=0;

else if(a<=135) s2=64*h/9/pow(pi,2);

else if(a<=210) s2=-64*h/9/pow(pi,2);

else if(a<=270) s2=0;

else s2=-8*h*sin(change_angel(4*a-3*360))/pi;

return s2;

}

double f_x2(double s,double s1,double a,double s2,double s0)

{

double x2;

x2=s2*sin(change_angel(a))+2*s1*cos(change_angel(a))-(s0+s)*sin(change_angel(a))-e*cos(change_angel(a));

return x2;

}

double f_y2(double s,double s1,double a,double s2,double s0)

{

double y2;

y2=s2*cos(change_angel(a))-2*s1*sin(change_angel(a))-(s0+s)*cos(change_angel(a))-e*cos(change_angel(a)); return y2;

}

double f_p(double x1,double y1,double x2,double y2)

{

double p;

p=pow(pow(x1,2)+pow(y1,2),1.5)/(x1*y2-x2*y1);

return p;

}

void main()

{

double

y1,x2,r0=15,s0,a,s,s1,x1,s2,y2,x[N],y[N],xx[N],yy[N],aa,p,pa,temp_aa1=0,temp_aa2=0,temp_a1=0,temp_a2=0,temp_p=0,temp_ap=0;

s0=f_s0(r0,e);

FILE*fp=fopen("d://he.txt","w");

for(int i=0;i

{

a=3*i;

s=f_s(a);

x[i]=f_x(s,s0,a);

y[i]=f_y(s,s0,a);

s1=f_s1(a);

x1=f_x1(s0,a,s,s1);

y1=f_y1(s0,a,s,s1);

xx[i]=f_xx(x[i],x1,y1);

yy[i]=f_yy(y[i],x1,y1);

aa=f_aa(r0,s,s1);

/*cout<<"s0是:"<

cout<<"a是:"<

cout<<"s是:"<

cout<<"x[]是:"<

cout<<"y[]是:"<

cout<<"s[]是:"<

cout<<"x1是:"<

cout<<"y1是:"<

cout<<"xx[]是:"<

cout<<"yy[]是:"<

cout<<"aa是:"<

*/

if(a>=270&&a<=360)

{

if(aa>a_max2)

{