DYNAMIC ANALYSIS OF SLIDER CRANK MECHANISM
1.AIM :
WRITE A MATLAB PROGRAM TO DO DYNAMIC ANALYSIS OF SLIDER CRANK MECHANISM AND ANIMATE THE MECHANISM.
2.OBJECTIVES :
- Calculate the values of linear displacement, linear velocity and linear acceleration of slider as a function of crank angle and plot the same.
- Animate the working of slider crank mechanism.
3.THEORY AND GOVERNING EQUATIONS :
Slider crank mechanism is an arrangement of mechanical parts designed to convert straight line motion to rotary motion or to convert rotary motion to straight line motion.
A Slider crank mechanism consists of a turning pair and a sliding pair. The 2 links namely crank and the connecting rod foms the turning pair and the slider forms the sliding pair.
The mechanism can be seen in the image below:-
The length of the crank and the connecting rod is L1 and L2 respectively.
To find the coordinates to 3 points varying with the crank angle θ.
Let point P1 be at origin, so coordinates will be,
`x1 = 0`
`y1 = 0`
Coordinates of point P2 will be,
`x2 = L1 * cos(θ)`
`y2 = L1 * sin(θ)`
Coordinates of point P3 will be,
`x3 = x2 + sqrt((L2)^2 - (Y2 -Y3)^2)` using pythogoras
`y3 = 0` if slider is not at an offset distance from point P1
The linear displacement of slider is given as
`X = L1 * [ (1-cos(θ)) + (n - sqrt(n^2 - (sin(θ))^2))]`
The linear velocity of slider is given as
`V = L1*omega*[sin(θ) + (sin(2θ)/(2n))]`
The linear acceleration of slider is given as
`a = L1*omega^2*[cos(θ) + (cos(2θ)/(n))]`
where `n =(L2)/(L1)`
The program calculates the variation of linear displacement, linear velocity and linear acceleration of slider as a function of crank angle (assuming the surface to be smooth) and plot each, this helps one to understand how the dynamic properties of the mechanism is varying.
Slider crank mechanism is mainly used in engines and it analysis can help with understanding the variation of different parameter and this will further help to improve.
4.MATLAB PROGRAM :
clear all
close all
clc
%taking input from user
%length of crank
a=input('Enter the length of crank (in m) : ');
%length of connecting rod
b=input('Enter the length of connecting rod (in m) : ');
%slider offset distance
h=input('Enter slider offset distance from crank origin (if not then enter 0) : ');
%angle by which crank will move
x=input('Enter angle(in degrees) by which the crank should move(in anticlockwise direction) : ');
%angular velocity of crank
k=input('Enter angular velocity of crank (in rad/s) : ');
%taking point 1 at origin
p1=[0 0];
%initializing counter variable ct
ct=1;
n=b/a;
theta=linspace(0,x,x); %creating array of angles
for i = 1:length(theta)
%calculating point p2 coordinates
p2 = a*[cosd(theta(i)) sind(theta(i))];
%calculating point p2 coordinates
p3 = [(p2(1)+sqrt(b^2-(p2(2)-0)^2)) h];
%calculating linear displacement of slider
term1=1-cosd(theta);
term2=(n - sqrt((n*n) - (sind(theta).^2)));
disp(:,i)= a*(term1+term2);
%calculating linear velocity of slider
term1=(sind(2*theta))/(2*sqrt((n*n) - (sind(theta).^2)));
velocity(:,i)=a*k*(sind(theta) + term1);
%calculating linear acceleration of slider
accl(:,i)=a*k*k*(cosd(theta)+(cosd(2*theta)/n));
%plotting slider crank mechanism
figure(1)
%plotting crank
plot([p1(1) p2(1)],[p1(2) p2(2)],'linewidth',3);
axis([-a-2 a+b+2 -a-2 a+2]) %marking axis
hold on
%plotting connecting rod
plot([p2(1) p3(1)],[p2(2) p3(2)],'linewidth',3);
%marking point p1
plot(p1(1),p1(2),'marker','o','markersize', 8,'markerfacecolor','g')
%marking point p2
plot(p2(1),p2(2),'marker','o','markersize', 8,'markerfacecolor','g')
%marking slider
plot(p3(1),p3(2),'marker','s','markersize', 15,'markerfacecolor','g')
pause(0.01);
%storing the current plot in an array 'M' at position of value of ct
M(ct)=getframe(gcf);
hold off %to overwrite the next plot in the next iteration
%increasing the value of counter by 1
ct=ct+1;
end
% creating animation movie of slider crank mechanism from captured frames
%command to generate the movie of array 'M'
movie(M);
%creating a video named slider_crank_mechanism of type '.avi'
videofile = VideoWriter('slider_crank_mechanism.avi','uncompressed AVI');
%opening the videofile
open(videofile);
%write the movie generated using array 'A' to the videofile
writeVideo(videofile,M);
%closing the videofile
close(videofile);
%plotting slider displacement v/s crank angle plot
figure(2)
plot(theta,disp);
xlabel('crank angular position (degrees)');
ylabel('Linear displacement of slider (m)');
%plotting slider velocity v/s crank angle plot
figure(3)
plot(theta,velocity);
xlabel('crank angular position (degrees)');
ylabel('Linear velocity of slider (m/s)');
%plotting slider acceleration v/s crank angle plot
figure(4)
plot(theta,accl);
xlabel('crank angular position (degrees)');
ylabel('Linear acceleration of slider (m/s^2)');
Explanation:-
- Initially length of crank, connecting rod, slider offset distance,angle by which crank will move and angular velocity of crank is taken as an input from user.
- Point p1 is considered as origin.
- An array of crank angle is created and a 'for loop' is used.
- Inside for loop the coordinates of point p2 and p3 is calculated.
- Further the values of linear displacement, linear velocity and linear acceleration for each crank angle is calculated and stored in an array.
- The slider crank mechanism for each crank angle is plotted and used to create animation.
- Finally the plot of linear displacement, linear velocity and linear acceleration of slider is plotted against crank angle.
5.RESULTS :
Command window Screenshot:-
Linear displacement of slider v/s crank angular position plot
Linear velocity of slider v/s crank angular position plot
Linear acceleration of slider v/s crank angular position plot
The youtube link to the animation video of the slider crank crank mechanism is given below:-
Errors faced:-
Wrote wrong syntax for 'linspace()' command
6.CONCLUSION :
Variation of linear displacement, linear velocity and linear acceleration of slider as a function of crank angle was calculated and plotted also the working of slider crank mechanism was animated.
Studying the variation of parameters will help to improve the system.
7.REFERENCES :