Challenge

FINAL INDEPENDENT PROJECT

AIM: Create a MATLAB program which shows a simple simulation for the crank-slider mechanism for the crank shaft-piston mechanism

Theory:

A slider-crank linkage is a four-link mechanism with three revolute joints and one prismatic, or sliding, joint. The rotation of the crank drives the linear movement the slider, or the expansion of gases against a sliding piston in a cylinder can drive the rotation of the crank.

There are two types of slider-cranks: in-line and offset.

  • In-line: An in-line slider-crank has its slider positioned so the line of travel of the hinged joint of the slider passes through the base joint of the crank. This creates symmetric slider movement back and forth as the crank rotates.
  • Offset: If the line of travel of the hinged joint of the slider does not pass through the base pivot of the crank, the slider movement is not symmetric. It moves faster in one direction than the other. This is called a quick-return mechanism.

Piston motion equations


The motion of a non-offset piston connected to a crank through a connecting rod (as would be found in internal combustion engines), can be expressed through several mathematical equations. This article shows how these motion equations are derived and show an example graph.

Definitions

  • `l` = rod length (distance between piston pin and crankpin)
  • `r` = crank radius (distance between crank pin and crank center, i.e. half stroke)
  • `A` = crank angle (from cylinder bore centerline at TDC)
  • `x`= piston pin position (upward from the crank center along cylinder bore centerline)
  • `v`= piston pin velocity (upward from the crank center along cylinder bore centerline)
  • `a`= piston pin acceleration (upward from the crank center along cylinder bore centerline)
  • `omega`= crank angular velocity

Kinematics of the in-line slider-crank

The displacement of the end of the connecting rod is approximately proportional to the cosine of the angle of rotation of the crank when it is measured from the top dead center (TDC). So the reciprocating motion created by a steadily rotating crank and connecting rod is approximately simple harmonic motion:

`x= r cos alpha + l`

where x is the distance of the end of the connecting rod from the crank axle, l is the length of the connecting rod, r is the length of the crank, and α is the angle of the crank measured from the top dead center (TDC). Technically, the reciprocating motion of the connecting rod departs from sinusoidal motion due to the changing angle of the connecting rod during the cycle, the correct motion, given by the Piston motion equations is:

`x=r cos alpha+ sqrt(l^2-r^2 sin^2alpha)`


As long as the connecting rod is much longer than the crank `l>r` the difference is negligible. This difference becomes significant in high-speed engines, which may need balance shafts to reduce the vibration due to this "secondary imbalance".

MATLAB Code:

%Simulation for the crank-slider mechanism 
%[0,0] is the pivot of the crank shaft
clear all
close all
clc
% l = rod length (distance between piston pin and crank pin)
% r = crank radius (distance between crank pin and crank center, i.e. half stroke)
% x = piston pin position (upward from crank center along cylinder bore centerline)
l=30;
r=10;
X=[0 0 0];
Y=[0 r r+l];
X_Piston=[-7 7 7 -7 -7];  
Y_Piston=[l-5 l-5 l+5 l+5 l-5];
h = plot(X,Y,'LineWidth',2,'XDataSource','X','YDataSource','Y');
axis([-3*r 3*r  -2*r 2*r+l]);
set(gca,'DataAspectRatio',[1 1 1]) 
grid on
hold('all')
g = plot(X_Piston,Y_Piston,'r','LineWidth',2,'XDataSource','X_Piston','YDataSource','Y_Piston');
angle=0:0.01:2*pi;
x_circle=r.*cos(angle);
y_circle=r.*sin(angle);
i = plot(x_circle,y_circle,'LineWidth',2);
ct=1; 
for A=0:0.08:4*pi    % A = crank angle (from cylinder bore centerline at TDC)
    x=r*cos(A)+sqrt(l^2-r^2*sin(A)^2);
    N=[r*sin(A) r*cos(A)];
    P=[0 x];
    X=[0 r*sin(A) 0];
    Y=[0 r*cos(A) x];
    Y_Piston=[x-5 x-5 x+5 x+5 x-5];
    refreshdata(h,'caller') 
    refreshdata(g,'caller') 
    refreshdata(i,'caller') 
    drawnow
    pause(.1)
    M(ct) = getframe(gcf); % Capturing the current plot
    ct = ct+1;             % Incrementing ct 
end
movie(M)    % Making a movie from frames

% Creating a video file to save the animation
videofile = VideoWriter('cs.avi','Uncompressed AVI');
open(videofile);

%Write the Movie in the video file crafted
writeVideo(videofile,M)
close(videofile)

Output:

Animation clip:

Link:- https://youtu.be/xaVvNMfQPmc

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.