C programming, Design a Spring (Helical) Under Given Static and Fluctuating Load for a Given Spring...

12
Project report: Objective: Design a spring (helical) under given static and fluctuating load for a given spring index so that the spring design lie within safe limit. The torsional shear stress in helical spring is given by Theoretical solution: τ = (k s 8PD)/(ПD 3 where k ) s And c is the spring index =1+(.5/C) C=D/d τ = (k s 8PC)/(ПD 2 This is the shear(torsional) stress which actually acts upon the helical spring under a steady load P ) The allowable stress (shear) is given by τ d =0.3Sut Where S ut is the tensile strength (ultimate) in shear. S ut varies according to the grade of painted and cold-drawn steel wires. There are 4 grades of this wire and S ut For the safe design these written condition should be satisfied varies accordingly the spring wire diameter. τ < τ But ,for wire dia., we take trial and error method. We start from d=0.3mm. and as d keeps on increasing τ decreases and when τ reaches below τ d d S (allowable) the design is in critical satisfactory and this wire diameter is permissible. Since d changes accordingly, ut changes and we make calculations until and unless τ reaches below τ d. FOR FLUCTUATING LOADING: Pm and Pa Pm = (Pmax+Pmin)/2 Pa = (Pmax- Pmin)/2 Accordingly τm=Ks(8PmC)/( ПD 2 τa= K(8PaC)/( ПD ) 2 ) where k is wahl’s factor introduced due to stress concentration in spring fibre [email protected]

description

C programming

Transcript of C programming, Design a Spring (Helical) Under Given Static and Fluctuating Load for a Given Spring...

Project report:

Objective:

Design a spring (helical) under given static and fluctuating load for a given spring index so that the spring design lie within safe limit.

The torsional shear stress in helical spring is given by Theoretical solution:

τ = (ks 8PD)/(ПD3

where k)

sAnd c is the spring index

=1+(.5/C)

C=D/d τ = (ks 8PC)/(ПD2

This is the shear(torsional) stress which actually acts upon the helical spring under a steady load P

)

The allowable stress (shear) is given by τd

=0.3Sut

Where Sut is the tensile strength (ultimate) in shear. Sut

varies according to the grade of painted and cold-drawn steel wires.

There are 4 grades of this wire and Sut For the safe design these written condition should be satisfied

varies accordingly the spring wire diameter.

τ < τBut ,for wire dia., we take trial and error method. We start from d=0.3mm. and as d keeps on increasing τ decreases and when τ reaches below τ

d

d

S

(allowable) the design is in critical satisfactory and this wire diameter is permissible. Since d changes accordingly,

ut changes and we make calculations until and unless τ reaches below τd.

FOR FLUCTUATING LOADING:

Pm and Pa Pm = (Pmax+Pmin)/2 Pa = (Pmax- Pmin)/2 Accordingly τm=Ks(8PmC)/( ПD2

τa= K(8PaC)/( ПD)

2

)

where k is wahl’s factor introduced due to stress concentration in spring fibre

manoj.

k.gan

gwar@

gmail

.com

K= (4c-1)/(4c-4)+(.615/c) Again for oil –hardened and tempered steel wire Sse’=.22Sult Ssy= .45 Sult For designing eqn

, we have

τa/(Ssy/f.s.-τm)=.5Sse’/(Ssy-.5Sse’) This eq. can be obtained by the fig. From this designing eq, we are able to determine the factor of safety for the safe designing. This all procedure , we do in c programming language. Through computer , we input the actual force and spring index C and then determine k and ks. Then in programme, we make a loop for wire dia. , initially starting from d=.3mmand incrementing it by .1 mm. For a given grade of spring material .We, try to formulate τ < τd If this condition satisfies, The particular designed spring wire is obtained

.

Then for no. of active turns , we make certain conditions i.e. whether the style of ends are plain, plain ends(ground) ,square ends, square ends(ground). Accordingly, no. of active turns are obtained. Then we obtain free length by calculating spring axial deflection δ =(8PD3N)/(Gd4

and then determine free length. )

Free length= solid length+ δ+margin = (Nt.d)+ δ+margin D=C.d Where D is the mean dia. Of coil and c is the spring index.

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

/*design of spring*/#include<math.h>#define pi 3.1415void staticload(void);void fluctuatingload(void);void colddrawn(void);void oilhardened(void);int c,g,ch,counter,end,type,grade[4],swgw[2],*pointer,*pointer1;float p,d,ks,k,kc,t,td,nt,na,deflection,solidlen,freelen,G,D;void main(){ int choice; printf("\n\n\n\n\n\n\n\n\n\n\n Minor Project Program on DESIGN OF SPRING FOR STATIC & FLUCTUATING LOAD"); getch(); printf("\n\n\n\n\n\n\n\n\n\n\n\n developed by Manoj Kumar Gangwar 30559, Rajiv Kumar 29541, Pankaj Kumar 29540"); getch(); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n Under guidence Prof. P.C. Gope"); getch(); clrscr(); while(1) { printf("\n press 1 for static load"); printf("\n press 2 for fluctuating load"); printf("\n press 3 for exit "); printf("\n enter ur choice between 1 ,2 ,3"); scanf("%d",&choice); switch(choice) { case 1: staticload(); break; case 2: fluctuatingload(); break; case 3: clrscr(); exit(); } }}void staticload(){ clrscr(); printf(" enter applied force in Newton, in case of fluctuating enter pmax,\n\n spring index,\n\n choice for wire, 1 for cold drawn, 2 for oil hardened,\n\n grade of wire for cold drawn 1,2,3,4 or for oil hardened 1 for sw & 2 for vw,\n\n no. of active turn,\n\n style of ends, 1 for plain, 2 for plain & ground, 3 for square, 4 for square & ground,\n\n compression/extension spring, 1 for comp. & 2 for exten.,\n\n value of G in N/mm^2.\n\n"); scanf("%f %d %d %d %f %d %d %f",&p,&c,&ch,&g,&na,&end,&type,&G); ks=1+(0.5/c); k=((4*c-1)/(4*c-4)+(0.615/c)); kc=k/ks;

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

if(ch==1) { colddrawn(); printf(" wire dia=%f coil dia=%f no. of coil total=%f solid length=%f free length=%f",d,D,nt,solidlen,freelen); getch(); printf("\n sut=%d",grade[g-1]); getch(); } else{ oilhardened(); printf(" wire dia=%f coil dia=%f no. of coil total=%f solid length=%f free length=%f",d,D,nt,solidlen,freelen); getch(); printf("\n sut=%d",swgw[g-1]); getch();}}void colddrawn(){ pointer=&grade[0]; for(counter=1;counter<=8;counter=counter+1){ if(counter==1) { d=0.3; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1720;*(pointer+1)=2060;*(pointer+2)=2460;*(pointer+3)=2660; } else if(counter==2) { d=0.4; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1700;*(pointer+1)=2040;*(pointer+2)=2430;*(pointer+3)=2620; } else if(counter==3) { d=0.5; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1670;*(pointer+1)=2010;*(pointer+2)=2390;*(pointer+3)=2580; } else if(counter==4) { d=0.6; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1650;*(pointer+1)=1990;*(pointer+2)=2360;*(pointer+3)=2550; } else if(counter==5) { d=0.7; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1630;*(pointer+1)=1970;*(pointer+2)=2320;*(pointer+3)=2530; } else if(counter==6) {

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

d=0.8; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1610;*(pointer+1)=1950;*(pointer+2)=2280;*(pointer+3)=2480; } else if(counter==7) { d=0.9; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1590;*(pointer+1)=1920;*(pointer+2)=2250;*(pointer+3)=2440; } else if(counter==8) { d=1.0; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1570;*(pointer+1)=1900;*(pointer+2)=2240;*(pointer+3)=2400; } td=0.3*grade[g-1]; if(td>t) break;} if(td<t){ for(counter=1;counter<=5;counter=counter+1){ if(counter==1) { d=1.2; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1540;*(pointer+1)=1860;*(pointer+2)=2170;*(pointer+3)=2340; } else if(counter==2) { d=1.4; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1500;*(pointer+1)=1820;*(pointer+2)=2090;*(pointer+3)=2290; } else if(counter==3) { d=1.6; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1470;*(pointer+1)=1780;*(pointer+2)=2080;*(pointer+3)=2250; } else if(counter==4) { d=1.8; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1440;*(pointer+1)=1750;*(pointer+2)=2030;*(pointer+3)=2190; } else if(counter==5) { d=2.0; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1420;*(pointer+1)=1720;*(pointer+2)=1990;*(pointer+3)=2160; }

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

td=0.3*grade[g-1]; if(td>t) break;}} if(td<t){ for(counter=1;counter<=6;counter=counter+1){ if(counter==1) { d=2.5; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1370;*(pointer+1)=1640;*(pointer+2)=1890;*(pointer+3)=2050; } else if(counter==2) { d=3.0; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1320;*(pointer+1)=1570;*(pointer+2)=1830;*(pointer+3)=1980; } else if(counter==3) { d=3.5; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1270;*(pointer+1)=1510;*(pointer+2)=1750;*(pointer+3)=1890; } else if(counter==4) { d=4.0; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1250;*(pointer+1)=1480;*(pointer+2)=1700;*(pointer+3)=1840; } else if(counter==5) { d=4.5; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1230;*(pointer+1)=1440;*(pointer+2)=1660;*(pointer+3)=1800; } else if(counter==6) { d=5.0; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1190;*(pointer+1)=1390;*(pointer+2)=1600;*(pointer+3)=1750; } td=0.3*grade[g-1]; if(td>t) break;}} if(td<t){ for(counter=1;counter<=3;counter=counter+1){

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

if(counter==1) { d=6.0; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1130;*(pointer+1)=1320;*(pointer+2)=1530;*(pointer+3)=1670; } else if(counter==2) { d=7.0; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1090;*(pointer+1)=1260;*(pointer+2)=1460;*(pointer+3)=1610; } else if(counter==3) { d=8.0; t=(ks*8*p*c)/(pi*pow(d,2)); *pointer=1050;*(pointer+1)=1220;*(pointer+2)=1400;*(pointer+3)=1540; } td=0.3*grade[g-1]; if(td>t) break;}} if(td<t){ printf("\n out of range"); printf("\n press any key to exit"); getch(); exit();} if(end==1) nt=na; else if(end==2) nt=na+0.5; else if(end==3||end==4) nt=na+2; solidlen=nt*d; D=c*d; deflection=(8*p*pow(D,3)*na)/(G*pow(d,4)); if(type==1) freelen=solidlen+deflection+na*0.5; else if(type==2) freelen=solidlen;}void oilhardened(){ pointer1=&swgw[0]; for(counter=1;counter<=2;counter=counter+1){ if(counter==1) { d=1; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1760;*(pointer1+1)=1670;

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

} else if(counter==2) { d=1.2; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1720;*(pointer1+1)=1620; } td=0.3*swgw[g-1]; if(td>t) break;} if(td<t){ for(counter=1;counter<=4;counter=counter+1){ if(counter==2) { d=1.5; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1670;*(pointer1+1)=1570; } else if(counter==2) { d=2.0; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1620;*(pointer1+1)=1520; } else if(counter==2) { d=2.5; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1570;*(pointer1+1)=1470; } else if(counter==2) { d=3.0; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1520;*(pointer1+1)=1430; } td=0.3*swgw[g-1]; if(td>t) break;}} if(td<t){ for(counter=1;counter<=1;counter=counter+1){ if(counter==1) { d=3.6; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1480;*(pointer1+1)=1400;

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

} td=0.3*swgw[g-1]; if(td>t) break;}} if(td<t){ for(counter=1;counter<=3;counter=counter+1){ if(counter==1) { d=4.0; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1480;*(pointer1+1)=1400; } else if(counter==2) { d=4.5; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1440;*(pointer1+1)=1370; } else if(counter==3) { d=5.0; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1440;*(pointer1+1)=1370; } td=0.3*swgw[g-1]; if(td>t) break;}} if(td<t){ for(counter=1;counter<=2;counter=counter+1){ if(counter==1) { d=6.0; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1400;*(pointer1+1)=1340; } else if(counter==2) { d=7.0; t=(k*8*p*c)/(pi*pow(d,2)); *pointer1=1360;*(pointer1+1)=1300; } td=0.3*swgw[g-1]; if(td>t) break;}}

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

if(td<t) { printf("\n out of range"); printf("\n press any key to exit"); getch(); exit(); } if(end==1) nt=na; else if(end==2) nt=na+0.5; else if(end==3||end==4) nt=na+2; solidlen=nt*d; D=c*d; deflection=(8*p*pow(D,3)*na)/(G*pow(d,4)); if(type==1) freelen=solidlen+deflection+na*0.5; else if(type==2) freelen=solidlen;}void fluctuatingload(){ float pmin,pm,pa,tm,ta,sse,ssy,sut,fos; staticload(); printf("\n\n and now enter p-min\n\n"); scanf("%f",&pmin); if(ch==1) { d=d+1; for(counter=1;counter<=1;counter=counter+1){ if(d==0.3) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1720;*(pointer+1)=2060;*(pointer+2)=2460;*(pointer+3)=2660;} else if(d==0.4) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1700;*(pointer+1)=2040;*(pointer+2)=2430;*(pointer+3)=2620;} else if(d==0.5) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1670;*(pointer+1)=2010;*(pointer+2)=2390;*(pointer+3)=2580;} else if(d==0.6) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1650;*(pointer+1)=1990;*(pointer+2)=2360;*(pointer+3)=2550;} else if(d==0.7) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1630;*(pointer+1)=1970;*(pointer+2)=2320;*(pointer+3)=2530;} else if(d==0.8) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1610;*(pointer+1)=1950;*(pointer+2)=2280;*(pointer+3)=2480;} else if(d==0.9) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1590;*(pointer+1)=1920;*(pointer+2)=2250;*(pointer+3)=2440;} else if(d==1.0)

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

{printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1570;*(pointer+1)=1900;*(pointer+2)=2240;*(pointer+3)=2400;} else if(d==1.2) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1540;*(pointer+1)=1860;*(pointer+2)=2170;*(pointer+3)=2340;} else if(d==1.4) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1500;*(pointer+1)=1820;*(pointer+2)=2090;*(pointer+3)=2290;} else if(d==1.6) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1470;*(pointer+1)=1780;*(pointer+2)=2080;*(pointer+3)=2250;} else if(d==1.8) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1440;*(pointer+1)=1750;*(pointer+2)=2030;*(pointer+3)=2190;} else if(d==2.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1420;*(pointer+1)=1720;*(pointer+2)=1990;*(pointer+3)=2160;} else if(d==2.5) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1370;*(pointer+1)=1640;*(pointer+2)=1890;*(pointer+3)=2050;} else if(d==3.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1320;*(pointer+1)=1570;*(pointer+2)=1830;*(pointer+3)=1980;} else if(d==3.5) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1270;*(pointer+1)=1510;*(pointer+2)=1750;*(pointer+3)=1890;} else if(d==4.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1250;*(pointer+1)=1480;*(pointer+2)=1700;*(pointer+3)=1840;} else if(d==4.5) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1230;*(pointer+1)=1440;*(pointer+2)=1660;*(pointer+3)=1800;} else if(d==5.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1190;*(pointer+1)=1390;*(pointer+2)=1600;*(pointer+3)=1750;} else if(d==6.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1130;*(pointer+1)=1320;*(pointer+2)=1530;*(pointer+3)=1670;} else if(d==7.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1090;*(pointer+1)=1260;*(pointer+2)=1460;*(pointer+3)=1610;} else if(d==8.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer=1050;*(pointer+1)=1220;*(pointer+2)=1400;*(pointer+3)=1540;} else {printf("\n taking original calculated dia because d+1 not exist ");d=d-1;}} D=c*d; printf("\n d=%fD=%f",d,D); sse=0.22*grade[g-1]; ssy=0.45*grade[g-1]; printf ("\n sut=%d",grade[g-1]); getch(); }

manoj.

k.gan

gwar@

gmail

.com

file:///Z|/Manoj%20DOCUMENTS/c%20GOP%20project/c%20GOP%20project/P.txt[21-Jan-14 12:29:45 AM]

else if(ch==2) { d=d+1; for(counter=1;counter<=1;counter=counter+1){ if(d==1) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1760;*(pointer1+1)=1670;} else if(d==1.2) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1720;*(pointer1+1)=1620;} else if(d==1.5) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1670;*(pointer1+1)=1570;} else if(d==2.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1620;*(pointer1+1)=1520;} else if(d==2.5) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1570;*(pointer1+1)=1470;} else if(d==3.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1520;*(pointer1+1)=1430;} else if(d==3.6) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1480;*(pointer1+1)=1400;} else if(d==4.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1480;*(pointer1+1)=1400;} else if(d==4.5) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1440;*(pointer1+1)=1370;} else if(d==5.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1440;*(pointer1+1)=1370;} else if(d==6.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1400;*(pointer1+1)=1340;} else if(d==7.0) {printf("\n taking d=d+1 for extra safety for fluctuating load");*pointer1=1360;*(pointer1+1)=1300;} else {printf("\n taking original calculated dia because d+1 not exist ");d=d-1;}} D=c*d; printf("\n d=%fD=%f",d,D); sse=0.22*swgw[g-1]; ssy=0.45*swgw[g-1]; printf ("\n sut=%d",swgw[g-1]); getch(); } else if(ch>2){ printf("\n error"); getch(); exit(); } pm=0.5*(p+pmin); pa=0.5*(p-pmin); tm=(ks*8*pm*D)/(pi*pow(d,3)); ta=(k*8*pa*D)/(pi*pow(d,3)); fos=(0.5*sse*ssy)/(ta*(ssy-(0.5*sse))+tm*0.5*sse); printf("\n\n factor of safety=%f",fos); getch();}

manoj.

k.gan

gwar@

gmail

.com