Vous êtes sur la page 1sur 12

SHAFT DESIGN

//program for finding shaft dia having 2 pulley, 2 gear or 1 gear and 1 pulley
#include<math.h>
#include<conio.h>
#include<stdio.h>
#define PI 3.14159265
#define absol(x) ((x)<0 ? -(x) : (x))
void pulleysX2();
void gearx2();
void gearandpulley();
void pulleyx2power(float,float,float,float,float,float,float,float);
void pulleyx2tension(float,float,float,float,float,float,float,float);
int main()
{
int ch;
printf("\nWelcome user!\nThe following design is according to ASME code... \nPress 1 for 2
pulleys\nPress 2 for 2 gears\nPress 3 for gear and pulley\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
pulleysX2();
break;
case 2:
gearx2();
break;
case 3:
gearandpulley();
break;
default:
printf("\nInvalid choice\n");
}
getch();
return 1;
}
void pulleysX2()
{
int ch,key;
float d1,d2,x1,x2,x3,x4,su,sy,sall,incl1,incl2;
x4=0;
printf("\nIs the pulley keyed? \n Press 1 if Yes\n Else press 2 \n");
scanf("%d",&key);
printf("\nEnter two dia\n");
scanf("%f %f", &d1,&d2);
printf("\nEnter ultimate and yield stress\n");

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

scanf("%f %f",&su,&sy);
sall=((0.18*su)<(0.3*sy)?(0.18*su):(0.3*sy));
switch(key)
{
case 1:
sall*=0.75;
break;
case 2:
break;
default:
printf("\nInvalid Input\n");
}
printf("\nAllowable stress is %3.2f\n",sall);
printf("\nInput inclination of belt of pulley 1 >> and >> pulley 2(in Degrees)(with respect to
vertically downward pointing vector)\n");
scanf("%f %f",&incl1,&incl2);
printf("\nPress 1 if data known is Power and RPM\n Press 2 if tension is known\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
pulleyx2power(d1,d2,x1,x2,x3,sall,incl1,incl2);
break;
case 2:
pulleyx2tension(d1,d2,x1,x2,x3,sall,incl1,incl2);
break;
default:
printf("\nInvalid choice\n");
}
}
void pulleyx2power(float d1,float d2,float x1,float x2,float x3,float sall,float incl1,float incl2)
{
float
P,N,T,T1,T2,T3,T4,mu,n,theta,L1,L2,R1,R2,bm,bm1,bm2,kb,kt,d,w1,w2,x4,loc[4],vload[4],hload[4],sw
ap,hbm1,hbm2,vbm1,vbm2,VT1,VT2,VT3,VT4,HT1,HT2,HT3,HT4,h1,h2,VR1,VR2,HR1,HR2;
int ch,c,da;
x4=0.0;
printf("\n Input power(in Watt) and speed(in RPM)\n");
scanf("%f %f",&P,&N);
T=(60*P)/(2*3.14*N);
printf("\n Press 1 if tension ratio is known\n Press 2 if MU and Theta are known\n");
scanf("%d",&ch);
switch(ch)
{

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

case 1:
printf("\nInput tension ratio\n");
scanf("%f",&n);
break;
case 2:
printf("\nInput mu, theta(in Radians)\n");
scanf("%f %f",&mu,&theta);
n=exp(mu*theta);
break;
default:
printf("\nInvalid choice\n");
}
T2=(2*T)/((n-1)*d1);
T1=T2*n;
T3=(2*T)/((n-1)*d2);
T4=T3*n;
T1*=1000;
T2*=1000;
T3*=1000;
T4*=1000;
VT1=T1*cos(incl1);
VT2=T2*cos(incl1);
VT3=T3*cos(incl2);
VT4=T4*cos(incl2);
HT1=T1*sin(incl1);
HT2=T2*sin(incl1);
HT3=T3*sin(incl2);
HT4=T4*sin(incl2);
printf("\nT1=%3.2f \nT2=%3.2f \nT3=%3.2f \nT4=%3.2f",T1,T2,T3,T4);
//Reactions
printf("\nEnter weights of pulleys,w1,w2 and distances x1,x2,x3\n");
printf("\n(For the values of 'x' take 1st support as origin and give value of 1st wt, w1 and
distace x1 and so on)\n");
scanf("%f %f %f %f %f",&w1,&w2,&x1,&x2,&x3);
w1=w1+VT1+VT2;
w2=w2+VT3+VT4;
h1=HT1+HT2;
h2=HT3+HT4;
VR2=((w1*x1)+(w2*x2))/(x3);
VR1=(w1+w2)-VR2;
HR2=((h1*x1)+(h2*x2))/(x3);
HR1=(h1+h2)-HR2;
printf("\nHR1 is %3.2f \nHR2 is %3.2f\nVR1 is %3.2f \nVR2 is %3.2f\n",HR1,HR2,VR1,VR2);
//bending moment

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

loc[0]=x1;
loc[1]=x2;
loc[2]=x3;
loc[3]=x4;
vload[0]=w1;
vload[1]=w2;
vload[2]=VR1;
vload[3]=VR2;
hload[0]=h1;
hload[1]=h2;
hload[2]=HR1;
hload[3]=HR2;
for (c = 0 ; c < 4; c++)
{
for (da = 0 ; da < 4 - c - 1; da++)
{
if (loc[da] > loc[da+1])
{
swap=loc[da];
loc[da]= loc[da+1];
loc[da+1]= swap;
swap= vload[da];
vload[da]= vload[da+1];
vload[da+1]= swap;
swap= hload[da];
hload[da]= hload[da+1];
hload[da+1]= swap;
}
}
}
for(c=0;c<4;c++)
printf("\n LOCATION : %f \t V.LOAD: %f\t H.LOAD: %f\n",loc[c],vload[c],hload[c]);
vbm1=vload[0]*(loc[1]-loc[0]);
vbm2=vload[3]*(loc[3]-loc[2]);
hbm1=hload[0]*(loc[1]-loc[0]);
hbm2=hload[3]*(loc[3]-loc[2]);
bm1=pow((vbm1*vbm1)+(hbm1*hbm1),0.5);
bm2=pow((vbm2*vbm2)+(hbm2*hbm2),0.5);
bm=(bm1>bm2)?bm1:bm2;
printf("\nMax bending moment is %3.2f",bm);
printf("\nInput Kb and Kt\n");
scanf("%f %f",&kb,&kt);
bm=kb*bm;
T=kt*T*1000;
printf("\nT= %f B= %f",T,bm);

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

T=pow(((T*T)+(bm*bm)),0.5);
d=(16*T)/(3.14*sall);
d=pow(d,0.33333);
printf("\nThe diameter of the shaft is %3.2f\n",d);
getch();
}
void pulleyx2tension(float d1,float d2,float x1,float x2,float x3,float sall,float incl1,float incl2)
{
float
P,N,T,T1,T2,T3,T4,mu,n,theta,L1,L2,R1,R2,bm,bm1,bm2,kb,kt,d,w1,w2,x4,loc[4],vload[4],hload[4],sw
ap,hbm1,hbm2,vbm1,vbm2,VT1,VT2,VT3,VT4,HT1,HT2,HT3,HT4,h1,h2,VR1,VR2,HR1,HR2;
int ch,c,da;
x4=0.0;
printf("\n Input maximum Tension in smaller pulley\n");
scanf("%f %f",&T1);
printf("\n Press 1 if tension ratio is known\n Press 2 if MU and Theta are known\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\nInput tension ratio\n");
scanf("%f",&n);
break;
case 2:
printf("\nInput mu, theta(in Radian)\n");
scanf("%f %f",&mu,&theta);
n=exp(mu*theta);
break;
default:
printf("\nInvalid choice");
}
T2=T1/n;
T=(T1-T2)*d1/2;
T3=(2*T)/((n-1)*d2);
T4=T3*n;
T1*=1000;
T2*=1000;
T3*=1000;
T4*=1000;
VT1=T1*cos(incl1);
VT2=T2*cos(incl1);
VT3=T3*cos(incl2);
VT4=T4*cos(incl2);
HT1=T1*sin(incl1);

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

HT2=T2*sin(incl1);
HT3=T3*sin(incl2);
HT4=T4*sin(incl2);
printf("\nT1=%3.2f \nT2=%3.2f \nT3=%3.2f \nT4=%3.2f",T1,T2,T3,T4);
//Reactions
printf("\nEnter weights of pulleys,w1,w2 and distances x1,x2,x3\n");
printf("\n(For the values of 'x' take 1st support as origin and give value of 1st wt, w1 and
distace x1 and so on)\n");
scanf("%f %f %f %f %f",&w1,&w2,&x1,&x2,&x3);
w1=w1+VT1+VT2;
w2=w2+VT3+VT4;
h1=HT1+HT2;
h2=HT3+HT4;
VR2=((w1*x1)+(w2*x2))/(x3);
VR1=(w1+w2)-VR2;
HR2=((h1*x1)+(h2*x2))/(x3);
HR1=(h1+h2)-HR2;
printf("\nHR1 is %3.2f \nHR2 is %3.2f\nVR1 is %3.2f \nVR2 is %3.2f\n",HR1,HR2,VR1,VR2);
//bending moment
loc[0]=x1;
loc[1]=x2;
loc[2]=x3;
loc[3]=x4;
vload[0]=w1;
vload[1]=w2;
vload[2]=VR1;
vload[3]=VR2;
hload[0]=h1;
hload[1]=h2;
hload[2]=HR1;
hload[3]=HR2;
for (c = 0 ; c < 4; c++)
{
for (da = 0 ; da < 4 - c - 1; da++)
{
if (loc[da] > loc[da+1])
{
swap=loc[da];
loc[da]= loc[da+1];
loc[da+1]= swap;
swap= vload[da];
vload[da]= vload[da+1];
vload[da+1]= swap;
swap= hload[da];
hload[da]= hload[da+1];

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

hload[da+1]= swap;
}
}
}
for(c=0;c<4;c++)
printf("\n LOCATION : %f \t V.LOAD: %f\t H.LOAD: %f\n",loc[c],vload[c],hload[c]);
vbm1=vload[0]*(loc[1]-loc[0]);
vbm2=vload[3]*(loc[3]-loc[2]);
hbm1=hload[0]*(loc[1]-loc[0]);
hbm2=hload[3]*(loc[3]-loc[2]);
bm1=pow((vbm1*vbm1)+(hbm1*hbm1),0.5);
bm2=pow((vbm2*vbm2)+(hbm2*hbm2),0.5);
bm=(bm1>bm2)?bm1:bm2;
printf("\nMax bending moment is %3.2f",bm);
printf("\nInput Kb and Kt");
scanf("%f %f",&kb,&kt);
bm=kb*bm;
T=kt*T*1000;
printf("\nT= %f B= %f",T,bm);
T=pow((T*T)+(bm*bm),0.5);
d=(16*T)/(3.14*sall);
d=pow(d,0.3333);
printf("\nThe diameter of the shaft is %3.2f",d);
getch();
}
void gearx2()
{
int ch,c,da,key;
float
d1,d2,d,x1,x2,x3,x4,su,kb,kt,sy,sall,PT1,PT2,PR1,PR2,pa1,pa2,w1,w2,v1,v2,h1,h2,hr1,hr2,vr1,vr2,hloa
d[4],vload[4],hbm1,hbm2,vbm1,vbm2,bm1,bm2,bm,P,N,T,loc[4],swap;
x4=0;
printf("\nEnter two dia");
scanf("%f %f", &d1,&d2);
printf("\nEnter ultimate and yield stress\n");
scanf("%f %f",&su,&sy);
sall=((0.18*su)<(0.3*sy)?(0.18*su):(0.3*sy));
printf("\nIs the pulley keyed? \n Press 1 if Yes\n Else press 2 \n");
scanf("%d",&key);
switch(key)
{
case 1:
sall*=0.75;
break;
case 2:

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

break;
default:
printf("\nInvalid Input\n");
}
printf("\nAllowable stress is %3.2f",sall);
printf("\n Input power(in Watt) and speed(in RPM)\n");
scanf("%f %f",&P,&N);
printf("\nInput pressure angle of gear 1 and 2 in degrees\n");
scanf("%f %f",&pa1,&pa2);
T=(60*P)/(2*3.14*N);
PT1=2*T*1000/d1;
PT2=2*T*1000/d2;
PR1=PT1*tan(pa1*PI/180.0);
PR2=PT2*tan(pa2*PI/180.0);
printf("\nEnter weights of gears,w1,w2 and distances x1,x2,x3\n");
printf("\n(For the values of 'x' take 1st support as origin and give value of 1st wt, w1 and
distace x1 and so on)\n");
scanf("%f %f %f %f %f",&w1,&w2,&x1,&x2,&x3);
v1=w1+PR1;
v2=w2+PR2;
h1=PT1;
h2=PT2;
//Reactions
{
vr2=((v1*x1)+(v2*x2))/(x3);
vr1=(v1+v2)-vr2;
printf("\nVR1 is %3.2f \nVR2 is %3.2f",vr1,vr2);
}
{
hr2=((h1*x1)+(h2*x2))/(x3);
hr1=(h1+h2)-hr2;
printf("\nHR1 is %3.2f \nHR2 is %3.2f",hr1,hr2);
}
//bending moment
loc[0]=x1;
loc[1]=x2;
loc[2]=x3;
loc[3]=x4;
vload[0]=v1;
vload[1]=v2;
vload[2]=vr1;
vload[3]=vr2;
hload[0]=h1;
hload[1]=h2;
hload[2]=hr1;

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

hload[3]=hr2;
for (c = 0 ; c < 4; c++)
{
for (da = 0 ; da < 4 - c - 1; da++)
{
if (loc[da] > loc[da+1])
{
swap=loc[da];
loc[da]= loc[da+1];
loc[da+1]= swap;
swap= vload[da];
vload[da]= vload[da+1];
vload[da+1]= swap;
swap= hload[da];
hload[da]= hload[da+1];
hload[da+1]= swap;
}
}
}
for(c=0;c<4;c++)
printf("\n LOCATION : %f \t H.LOAD: %f \t V.LOAD: %f\n",loc[c],hload[c],vload[c]);
hbm1=hload[0]*(loc[1]-loc[0]);
hbm2=hload[3]*(loc[3]-loc[2]);
vbm1=vload[0]*(loc[1]-loc[0]);
vbm2=vload[3]*(loc[3]-loc[2]);
bm1=pow((hbm1*hbm1)+(vbm1*vbm1),0.5);
bm2=pow((hbm2*hbm2)+(vbm2*vbm2),0.5);
bm1=absol(bm1);
bm2=absol(bm2);
bm=(bm1>bm2)?bm1:bm2;
printf("\nMax bending moment is %3.2f",bm);
printf("\nInput Kb and Kt\n");
scanf("%f %f",&kb,&kt);
bm=kb*bm;
T=kt*T*1000;
printf("\nT= %f B= %f",T,bm);
T=pow((T*T)+(bm*bm),0.5);
d=(16*T)/(3.14*sall);
d=pow(d,0.3333);
printf("\nThe diameter of the shaft is %3.2f",d);
getch();
}
void gearandpulley()
{

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

float
x1,x2,x3,P,N,T,d1,pa,d2,PT1,PR1,n,incl,VT1,VT2,HT1,HT2,su,sy,mu,theta,T1_1,T1_2,w1,w2,v1,v2,vr1,
vr2,h1,h2,hr1,hr2,x4,loc[4],vload[4],hload[4],d,swap,hbm1,hbm2,bm,vbm1,vbm2,bm1,bm2,kb,kt,sal
l;
int ch,c,da,key;
x4=0.0;
printf("\nEnter ultimate and yield stress\n");
scanf("%f %f",&su,&sy);
sall=((0.18*su)<(0.3*sy)?(0.18*su):(0.3*sy));
printf("\nIs the pulley keyed? \n Press 1 if Yes\n Else press 2 \n");
scanf("%d",&key);
switch(key)
{
case 1:
sall*=0.75;
break;
case 2:
break;
default:
printf("\nInvalid Input\n");
}
printf("\nAllowable stress is %3.2f",sall);
printf("\nEnter distance of gear from 1st bearing support(leftmost)\n");
scanf("%f",&x1);
// x1 is the distance of GEAR from leftmost support
printf("\nEnter distance of pulley from 1st bearing support(leftmost)\n");
scanf("%f",&x2);
// x2 is the distance of PULLEY from leftmost support
printf("\nEnter distance of 2nd bearing support from 1st bearing support(leftmost)\n");
scanf("%f",&x3);
// x3 is the distance of 2nd bearing from leftmost support
printf("\nInput power(in Watts) being transmitted and RPM");
scanf("%f %f",&P,&N);
T=(P*60*1000)/(2*PI*N);
printf("\nEnter Pitch circle diameter of GEAR, PRESSURE ANGLE and Pulley Diameter\n");
scanf("%f %f %f",&d1,&pa,&d2);
PT1=(2*T)/d1;
PR1=PT1*tan(pa*PI/180.0);
printf("\n Press 1 if tension ratio is known\n Press 2 if MU and Theta are known\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\nInput tension ratio\n");
scanf("%f",&n);

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

break;
case 2:
printf("\nInput mu, theta\n");
scanf("%f %f",&mu,&theta);
n=exp(mu*theta);
break;
default:
printf("\nInvalid choice");
}
T1_2=(2*T)/((n-1)*d1);
T1_1=T1_2*n;
printf("\nInput inclination of belt of pulley(in Degrees)(with respect to vertically downward
pointing vector)\n");
scanf("%f",&incl);
VT1=T1_1*cos(incl);
VT2=T1_2*cos(incl);
HT1=T1_1*sin(incl);
HT2=T1_2*sin(incl);
printf("\nT1=%3.2f \nT2=%3.2f",T1_1,T1_2);
//Reactions
printf("\nEnter weight of GEAR>> THEN>> PULLEY(w1,w2)\n");
scanf("%f %f",&w1,&w2);
v1=PR1+w1;
v2=w2+VT1+VT2;
vr2=((v1*x1)+(v2*x2))/(x3);
vr1=(v1+v2)-vr2;
h1=PT1;
h2=HT1+HT2;
hr2=((h1*x1)+(h2*x2))/(x3);
hr1=(h1+h2)-hr2;
printf("\nVR1 is %3.2f \nVR2 is %3.2f \nHR1 is %3.2f \nHR2 is %3.2f",vr1,vr2,hr1,hr2);
//bending moment
loc[0]=x1;
loc[1]=x2;
loc[2]=x3;
loc[3]=x4;
vload[0]=v1;
vload[1]=v2;
vload[2]=vr1;
vload[3]=vr2;
hload[0]=h1;
hload[1]=h2;
hload[2]=hr1;
hload[3]=hr2;

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida

for (c = 0 ; c < 4; c++)


{
for (da = 0 ; da < 4 - c - 1; da++)
{
if (loc[da] > loc[da+1])
{
swap=loc[da];
loc[da]= loc[da+1];
loc[da+1]= swap;
swap= vload[da];
vload[da]= vload[da+1];
vload[da+1]= swap;
swap= hload[da];
hload[da]= hload[da+1];
hload[da+1]= swap;
}
}
}
for(c=0;c<4;c++)
printf("\n LOCATION : %f \t H.LOAD: %f \t V.LOAD: %f\n",loc[c],hload[c],vload[c]);
hbm1=hload[0]*(loc[1]-loc[0]);
hbm2=hload[3]*(loc[3]-loc[2]);
vbm1=vload[0]*(loc[1]-loc[0]);
vbm2=vload[3]*(loc[3]-loc[2]);
bm1=pow((hbm1*hbm1)+(vbm1*vbm1),0.5);
bm2=pow((hbm2*hbm2)+(vbm2*vbm2),0.5);
bm1=absol(bm1);
bm2=absol(bm2);
bm=(bm1>bm2)?bm1:bm2;
printf("\nMax bending moment is %3.2f",bm);
printf("\nInput Kb and Kt\n");
scanf("%f %f",&kb,&kt);
bm=kb*bm;
T=kt*T*1000;
printf("\nT= %f B= %f",T,bm);
T=pow((T*T)+(bm*bm),0.5);
d=(16*T)/(3.14*sall);
d=pow(d,0.3333);
printf("\nThe diameter of the shaft is %3.2f",d);
getch();
}

Himanshu Verma

Mechanical Engineering

JSS Academy of Technical Education, Noida