内容发布更新时间 : 2024/11/15 7:18:08星期一 下面是文章的全部内容请认真阅读。
凸轮机构的设计源程序
#include
void tulun(double [N][2],double [N][2],double [N],double [N],double [N],int ); void max(double [N],double [2]); void min(double [N],double [2]); //定义全局变量 double
r0=40,r0t=100,lo4d=125,lo24=125,rt=15,swaymax=15*PI/180,xupreang1=45*PI/180,xupreang2=65*PI/180,xup=0.3;
25
double
ang1=200*PI/180,ang2=60*PI/180,ang3=10*PI/180,ang4=90*PI/180,ang41=10*PI/180,t=0; int fangan; void main() {
FILE *fp;
for(fangan=0;fangan<4;fangan++) { switch(fangan) { case 0:ang1=195*PI/180;ang2=90*PI/180;ang3=15*PI/180;ang4=60*PI/180; if((fp=fopen(\ { printf(\ exit(0); }break; default:printf(\请重新启动,输入正确选择。\\n\ } //主程序 int i,j; double shuju[N][4]={0}; double lz[N][2]={0},sz[N][2]={0},a1[N]={0},a2[N]={0},p[N]={0}; double a1max[2]={0},a2max[2]={0},pmin[2]={0}; r0=50; r0t=100; lo24=125; tulun(lz,sz,a1,a2,p,fangan);//初次调用tulun max(a1,a1max);max(a2,a2max);min(p,pmin); while(((a1max[1]>xupreang1) || (a2max[1]>xupreang2) || (pmin[1]<(1+xup)*rt)) && (r0<(lo4d+lo24))) { r0+=1; tulun(lz,sz,a1,a2,p,fangan);//循环调用tulun max(a1,a1max);max(a2,a2max);min(p,pmin); } while(r0t>r0) { lo24-=5;r0t=r0;r0=40; tulun(lz,sz,a1,a2,p,fangan);//初次调用tulun max(a1,a1max);max(a2,a2max);min(p,pmin); while(((a1max[1]>xupreang1) || (a2max[1]>xupreang2) || (pmin[1]<(1+xup)*rt)) && (r0<(lo4d+lo24))) {
26
r0+=1; tulun(lz,sz,a1,a2,p,fangan);//循环调用tulun max(a1,a1max);max(a2,a2max);min(p,pmin); } } printf(\case 0 %d:\\nlo24=%6.3f,ang1=%6.3f,ang2=%6.3f,ang3=%6.3f,ang4=%6.3f\\n\g3,ang4); //写入文件 fprintf(fp,\方案\\t%d:\\nlo24\\t%f\\nang1\\t %6.3f\\t ang2\\t %6.3f\\n ang3\\t %6.3f\\t ang4\\t %6.3f\\n\ fprintf(fp,\ for(i=0;i //求最大压力角 void max(double a[N],double amax[2]) { int i; amax[0]=0;amax[1]=a[0]; for(i=1;i 27 { if(a[i]>amax[1]) {amax[0]=i;amax[1]=a[i];} } } //求最小曲率半径 void min(double p[N],double pmin[2]) { int i; pmin[0]=0;pmin[1]=p[0]; for(i=1;i //求解凸轮理论实际轮廓曲线,压力角,曲率半径 void tulun(double lz[N][2],double sz[N][2],double a1[N],double a2[N],double p[N],int fangan1) { int i,c; double ang; double csway,sway,dsway,ddsway,dx,dy,ddx,ddy,sn,csn; for(i=0;i 28 break;//多项式推程 }break; case 2:sway=swaymax;dsway=0;ddsway=0;break;//远休 case 3: double swaymax1; ang-=ang1+ang2+ang3; swaymax1=ang41*swaymax/(2*ang4-2*ang41); if(ang<=ang41) { sway=swaymax+swaymax1*(-ang/ang41+sin(PI*ang/ang41)/PI); dsway=swaymax1*(cos(PI*ang/ang41)-1)/ang41; ddsway=-PI*swaymax1*sin(PI*ang/ang41)/(ang41*ang41); } else if(ang4-ang<=ang41) { sway=swaymax1*((ang4-ang)/ang41-sin(PI*(ang4-ang)/ang41)/PI); dsway=swaymax1*(cos(PI*(ang4-ang)/ang41)-1)/ang41; ddsway=PI*swaymax1*sin(PI*(ang4-ang)/ang41)/(ang41*ang41); } else { sway=swaymax-swaymax1-(swaymax-2*swaymax1)*(ang-ang41)/(ang4-2*ang41); dsway=-(swaymax-2*swaymax1)/(ang4-2*ang41); ddsway=0; } ang+=ang1+ang2+ang3; a2[i]=atan(fabs((lo24*fabs(dsway)+pow(-1,(ang>(ang1+ang2)))*(lo4d*cos(csway+sway)-lo24))/(lo4d*sin(csway+sway)))); break;//修正等速回程 } lz[i][0]=lo4d*sin(ang)-lo24*sin(ang+sway+csway); lz[i][1]=lo4d*cos(ang)-lo24*cos(ang+sway+csway); dx=lo4d*cos(ang)-lo24*cos(ang+sway+csway)*(1+dsway); dy=-lo4d*sin(ang)+lo24*sin(ang+sway+csway)*(1+dsway); sn=dx/sqrt(dx*dx+dy*dy); csn=-dy/sqrt(dx*dx+dy*dy); sz[i][0]=lz[i][0]-rt*csn; sz[i][1]=lz[i][1]-rt*sn; ddx=-lo4d*sin(ang)+lo24*sin(ang+sway+csway)*pow(1+dsway,2)-lo24*cos(ang+sway+csway)*ddsway; 29