凸轮设计.docx
- 文档编号:9289829
- 上传时间:2023-02-04
- 格式:DOCX
- 页数:29
- 大小:41.40KB
凸轮设计.docx
《凸轮设计.docx》由会员分享,可在线阅读,更多相关《凸轮设计.docx(29页珍藏版)》请在冰豆网上搜索。
凸轮设计
机械原理
——凸轮机构解析法
程序源代码如下
#include"math.h"
#include"stdio.h"
#definePI3.14159265358979
doubleshuchu_x[361],shuchu_y[361],sd[2][361],x_dao[361],y_dao[361],x_[361],y_[361],x_2[361],y_2[361];
externdoubleabs1(doublex);
externintquzheng(doublex);
voidmain()
{
//变量定义区
FILE*fp;
charname[30];
inti;
doublefai=0.0,h,r_b,r_c=0,r_r,a,a1,pn,w,c_tui,c_hui,c_ting,r_bian,s,ar,p;
doublex_dao2,y_dao2;//x的二次导,y的二次导
doubleds_dfai,ds_dfai2;//s的导,s的二次导
double*dz1=&fai,*dz2=&h,*dz3=&r_b,*dz4=&r_r,*dz5=&a,*dz6=&a1,*dz7=&pn,*dz8=&w,*dz9=&c_tui,*dz10=&c_hui,*dz11=&c_ting,*dz12=&r_bian;
//数据输入区
{
do
{
puts("\a**********************************************\n**************本器由西陵剑魂所铸**************\n**********************************************");
puts("请选择输入方式\n1\t读取文件;\n2\t直接输入。
");
scanf("%d",&i);
if(i==1)
{
puts("\a请输入数据文件名(文件名应小于30字节):
");
scanf("%s",name);
if((fp=fopen(name,"rt"))==NULL)
{
printf("不能打开输入文件!
\n\a\a\a\a");
return;
}
fscanf(fp,"%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",dz2,dz3,dz4,dz5,dz6,dz7,dz8,dz9,dz10,dz11,dz12,&r_c);
fclose(fp);
}
else
if(i==2)
{
puts("\a请依次输入1-上升高度、2-基圆半径、3-滚子半径、4-许用推程压力角、5-许用回程压力角、6-许用曲率半径、7-转速、8-推程运动角、9-回程运动角、10-停歇角、11-半径变量、12-刀具半径:
\n\a");
scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",dz2,dz3,dz4,dz5,dz6,dz7,dz8,dz9,dz10,dz11,dz12,&r_c);
}
else
puts("输入有误,请重试\a\a");
getchar();
}while(i!
=1&&i!
=2);
c_tui=PI/180.0*c_tui,c_hui=PI/180.0*c_hui,c_ting=PI/180.0*c_ting,a=PI/180.0*a,a1=PI/180.0*a1;
}
{
/*运算区*/
loop1:
fai=0.000000000000000,i=0;
loop2:
if((fai)<=c_tui)//如果fai小于推程运动角
{
s=h*(fai/c_tui-1.0/2.0*sin(2.0*PI*fai/c_tui)/PI);
shuchu_x[i]=(r_b+s)*sin(fai);
shuchu_y[i]=(r_b+s)*cos(fai);
x_dao[i]=h*(1.0/c_tui-cos(2.0*PI*fai/c_tui)/c_tui)*sin(fai)+(r_b+h*(fai/c_tui-1.0/2.0*sin(2.0*PI*fai/c_tui)/PI))*cos(fai);
y_dao[i]=h*(1.0/c_tui-cos(2.0*PI*fai/c_tui)/c_tui)*cos(fai)-(r_b+h*(fai/c_tui-1.0/2.0*sin(2.0*PI*fai/c_tui)/PI))*sin(fai);
x_dao2=2.0*h*sin(2.0*PI*fai/c_tui)*PI/(c_tui*c_tui)*sin(fai)+2.0*h*(1.0/c_tui-cos(2.0*PI*fai/c_tui)/c_tui)*cos(fai)-(r_b+h*(fai/c_tui-1.0/2.0*sin(2.0*PI*fai/c_tui)/PI))*sin(fai);
y_dao2=2.0*h*sin(2.0*PI*fai/c_tui)*PI/(c_tui*c_tui)*cos(fai)-2.0*h*(1.0/c_tui-cos(2.0*PI*fai/c_tui)/c_tui)*sin(fai)-(r_b+h*(fai/c_tui-1.0/2.0*sin(2.0*PI*fai/c_tui)/PI))*cos(fai);
ds_dfai=h*(1.0/c_tui-cos(2.0*PI*fai/c_tui)/c_tui);
ds_dfai2=2.0*h*sin(2.0*PI*fai/c_tui)*PI/(c_tui*c_tui);
}
else
{
if(fai<=((c_tui)+(c_ting)))//如果fai小于推程+回程
{
s=h;
x_dao[i]=(r_b+h)*cos(fai);
y_dao[i]=-(r_b+h)*sin(fai);
x_dao2=-(r_b+h)*sin(fai);
y_dao2=-(r_b+h)*cos(fai);
ds_dfai=0.0;
ds_dfai2=0.0;
}
else
if(fai<=((c_tui)+(c_ting)+(c_hui)))
{
//
s=h*(1.0-(fai-c_tui-c_ting)/c_hui+1.0/2.0*sin(2.0*PI*(fai-c_tui-c_ting)/c_hui)/PI);x_dao[i]=h*(-1.0/c_hui+cos(2.0*PI*(fai-c_tui-c_ting)/c_hui)/c_hui)*sin(fai)+(r_b+h*(1.0-(fai-c_tui-c_ting)/c_hui+1.0/2.0*sin(2.0*PI*(fai-c_tui-c_ting)/c_hui)/PI))*cos(fai);
y_dao[i]=h*(-1.0/c_hui+cos(2.0*PI*(fai-c_tui-c_ting)/c_hui)/c_hui)*cos(fai)-(r_b+h*(1.0-(fai-c_tui-c_ting)/c_hui+1.0/2.0*sin(2.0*PI*(fai-c_tui-c_ting)/c_hui)/PI))*sin(fai);
x_dao2=-2.0*h*sin(2.0*PI*(fai-c_tui-c_ting)/c_hui)*PI/(c_hui*c_hui)*sin(fai)+2.0*h*(-1.0/c_hui+cos(2.0*PI*(fai-c_tui-c_ting)/c_hui)/c_hui)*cos(fai)-(r_b+h*(1.0-(fai-c_tui-c_ting)/c_hui+1.0/2.0*sin(2.0*PI*(fai-c_tui-c_ting)/c_hui)/PI))*sin(fai);
y_dao2=-2.0*h*sin(2.0*PI*(fai-c_tui-c_ting)/c_hui)*PI/(c_hui*c_hui)*cos(fai)-2.0*h*(-1.0/c_hui+cos(2.0*PI*(fai-c_tui-c_ting)/c_hui)/c_hui)*sin(fai)-(r_b+h*(1.0-(fai-c_tui-c_ting)/c_hui+1.0/2.0*sin(2.0*PI*(fai-c_tui-c_ting)/c_hui)/PI))*cos(fai);
ds_dfai=h*(-1.0/c_hui+cos(2.0*PI*(fai-c_tui-c_ting)/c_hui)/c_hui);
ds_dfai2=-2.0*h*sin(2.0*PI*(fai-c_tui-c_ting)/c_hui)*PI/(c_hui*c_hui);
}
else
{
s=0.0;
x_dao[i]=(r_b)*cos(fai);
y_dao[i]=-(r_b)*sin(fai);
x_dao2=-(r_b+s)*sin(fai);
y_dao2=-(r_b+s)*cos(fai);
ds_dfai=0.0;
ds_dfai2=0.0;
}
}
//计算压力角ar
ar=atan(abs1((ds_dfai)/(s+r_b)));
//
if(!
(((fai<=((c_tui)+(c_ting)))&&(ar<=(a)))||(((fai)>((c_tui)+(c_ting))&&(ar<=(a1))))))
{
loop3:
r_b=(r_b)+(r_bian);
gotoloop1;
;
}
else
//按式14计算曲率半径p
p=-sqrt((x_dao[i]*x_dao[i]+y_dao[i]*y_dao[i])*(x_dao[i]*x_dao[i]+y_dao[i]*y_dao[i])*(x_dao[i]*x_dao[i]+y_dao[i]*y_dao[i]))/(x_dao[i]*y_dao2-x_dao2*y_dao[i]);
//p=10;
;
;
if((p>=0)&&((p)<((pn)+r_r)))
gotoloop3;
//
shuchu_x[i]=(r_b+s)*sin(fai);
shuchu_y[i]=(r_b+s)*cos(fai);
//计算式5
//
x_[i]=shuchu_x[i]+r_r*y_dao[i]/sqrt(x_dao[i]*x_dao[i]+y_dao[i]*y_dao[i]);
y_[i]=shuchu_y[i]-r_r*x_dao[i]/sqrt(x_dao[i]*x_dao[i]+y_dao[i]*y_dao[i]);
//
if(r_c>=r_r)
{
x_2[i]=shuchu_x[i]-abs1(r_c-r_r)*y_dao[i]/sqrt(x_dao[i]*x_dao[i]+y_dao[i]*y_dao[i]);
y_2[i]=shuchu_y[i]+abs1(r_c-r_r)*(x_dao[i])/sqrt(x_dao[i]*x_dao[i]+y_dao[i]*y_dao[i]);
}
else
{
x_2[i]=shuchu_x[i]+abs1(r_c-r_r)*y_dao[i]/sqrt(pow(x_dao[i],2)+pow(y_dao[i],2));
y_2[i]=shuchu_y[i]-abs1(r_c-r_r)*x_dao[i]/sqrt(pow(x_dao[i],2)+pow(y_dao[i],2));
}
if(fai<2.0*PI)
{
//输出,
(fai)+=PI/180.0;
i=quzheng(fai*180.0/PI);
gotoloop2;
}
}
//数据输出区
printf("该凸轮各项设计数据为:
\n基圆半径rb为:
%3.2f\n转角\t理论x坐标\ty坐标\t实际x坐标\t实际y坐标\t刀具x坐标\t刀具y坐标\n\a",r_b);
for(i=0;i<=360;i++)
printf("%d\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t\n",i,shuchu_x[i],shuchu_y[i],x_[i],y_[i],x_2[i],y_2[i]);
puts("请选择输出方式:
\n1\t默认文件名\n2\t自定义文件名\a");
scanf("%d",&i);
do
{
if(i==2)
{
puts("请输入文件路径:
\a");
scanf("%s",name);
if((fp=fopen(name,"wt"))==NULL)
{
printf("不能创建输出文件!
\n\a\a\a\a");
return;
}
}
else
if(i==1)
{
if((fp=fopen("d:
\\outputfile.txt","wt"))==NULL)
{
printf("不能创建输出文件!
\n\a\a\a\a");
return;
}
}
else
puts("输入有误,请重试");
getchar();
}while(i!
=1&&i!
=2);
fprintf(fp,"该凸轮各项设计数据为:
\n基圆半径rb为:
%3.2f\n转角\t理论x坐标\ty坐标\t实际x坐标\t实际y坐标\t刀具x坐标\t刀具y坐标\r\n\a",r_b);
for(i=0;i<=360;i++)
fprintf(fp,"%d\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t\n",i,shuchu_x[i],shuchu_y[i],x_[i],y_[i],x_2[i],y_2[i]);
fclose(fp);
puts("****感谢使用,按回车退出****");
getchar();
getchar();
该凸轮各项设计数据为:
基圆半径rb为:
55.00
转角理论x坐标y坐标实际x坐标实际y坐标刀具x坐标刀具y坐标
00.00000055.0000000.00000045.0000000.00000045.150000
10.95988554.9917950.79071444.9932260.79325245.143204
21.91952054.9678651.59191344.9732321.59682745.123152
32.87871954.9292392.40339144.9405422.41052145.090372
43.83736954.8769383.22496944.8957083.23415545.045426
54.79542654.8119724.05648844.8393114.06757244.988901
65.75291554.7353314.89781144.7719594.91063844.921409
76.70992854.6479825.74882144.6942755.76323744.843581
87.66662454.5508616.60941644.6069026.62527444.756062
98.62322054.4448707.47950944.5104897.49666544.659505
109.57999954.3308728.35902344.4056918.37733844.554569
1110.53729554.2096849.24788944.2931619.26723044.441909
1211.49549954.08207310.14603944.17354310.16628144.322171
1312.45505153.94875111.05340944.04746811.07443444.195987
1413.41643353.81037411.96993043.91554611.99162844.063968
1514.38017353.66753512.89553043.77835712.91780043.926695
1615.34683153.52076113.83012943.63644913.85288043.784714
1716.31700253.37051014.77364343.49032514.79679343.638528
1817.29130653.21716915.72597643.34044115.74945643.488592
1918.27038553.06105116.68703043.18719716.71078043.335305
2019.25489652.90239217.65669843.03093017.68067143.179002
2120.24550852.74135318.63487142.87191318.65903143.019954
2221.24289652.57801219.62143942.71034419.64576142.858359
2322.24773152.41237120.61629342.54634820.64076542.694338
2423.26068352.24434921.61932842.37997121.64394842.527936
2524.28240552.07378622.63044742.21117822.65522642.359118
2625.31353851.90044323.64955942.03985623.67451842.187765
2726.35469551.72400124.67658641.86580924.70175842.013682
2827.40646451.54406325.71146141.68876125.73688641.836591
2928.46939951.36015626.75412641.50836226.77985541.656139
3029.54401451.17173327.80453441.32418427.83062741.471898
3130.63077850.97817628.86264841.13573228.88917041.283368
3231.73011450.77879829.92843340.94243929.95545841.089985
3332.84238950.57284431.00185840.74368231.02946540.891119
3433.96791250.35950132.08288640.53877432.11116140.686085
3535.10693150.13789333.17147540.32698033.20050740.474144
3636.25962549.90709334.26756840.10751634.29744940.254510
3737.42610849.66612235.37109039.87955535.40191640.026353
3838.60641549.41395836.48194039.64223336.51380739.788809
3939.80051049.14953637.59998639.39465637.63299339.540979
4041.00827548.87175938.72505939.13590138.75930839.281939
4142.22951248.57949739.85695238.86502539.89254039.010742
4243.46394248.27159840.99540738.58107041.03243538.726428
4344.71120047.94689242.14011838.28306642.17868438.428023
4445.97083647.60419443.29072237.97003643.33092438.114549
4547.24231447.24231444.44680037.64100644.48873337.785026
4648.52501246.86005945.60787037.29500445.65162737.438480
4749.81822346.45624546.77339036.93106846.81906237.073946
4851.12115446.02969447.94275036.54825247.99042636.690473
4952.43292845.57924949.11528036.14562749.16504536.287131
5053.75258345.10377350.29024135.72229250.34217635.863014
5155.07908044.60215951.46683135.27737251.52101435.417244
5256.41129744.07333552.64418534.81002852.70069234.948977
5357.74803943.51626953.82137734.31945853.88027734.457410
5459.08803642.9
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 凸轮 设计
![提示](https://static.bdocx.com/images/bang_tan.gif)