Assignment 2:
SimMechanics Modelling
Advanced Dynamics with Applied Computer Modelling
Keval Chauhan
D13123499
Contents
Introduction ............................................................................................................................................... 3
Model Parameters ..................................................................................................................................... 3
Flowchart .................................................................................................................................................. 4
MATLAB Results ................................................................................................................................. 5
Appendix, .................................................................................................................................................. 9
MATLAB CODE: ............................................................................................................................... 10
SimMechanics ..................................................................................................................................... 12
Introduction
In this study, the parameters of four bar linkage is examined using MATLAB script & SimMechanics.This
assignments examines the parameters of a four bar linkage for two scenarios,
The MATLAB coding is used to calculate the position of the pins for one complete revolution and the
SimMechanics program is used to build a model of the four bar linkage.
Model Parameters
Y
y
b
Link 4
Link 3
2
O2
Link 2
d
O4
Flowchart
MATLAB Results
Movement of Pin A
80
60
40
Y Axis (mm)
20
0
-20
-40
-60
-80
-80
-60
-40
-20
0
20
X Axis (mm)
40
60
80
Movement of Pin B
140
120
Y Axis (mm)
100
80
60
40
20
0
-20
20
40
60
X Axis (mm)
80
100
120
120
Y Axis (mm)
100
80
60
40
20
0
-50
50
X Axis (mm)
100
Appendix
MATLAB CODE:
clear all
clc
a=40;
b=80;
c=90;
d=100;
% SCENARIO 1
i=1;
theta_store_2(i)=0;
theta_store_3(i)=0;
theta_store_4(i)=0;
store_Ax(i)= 0;
store_Ay(i)= 0;
store_Bx(i)= 0;
store_By(i)= 0;
COG_link3x_store (i) = 0;
COG_link4x_store (i) = 0;
for theta2=0:360 % one complete revolution
k1 = d/a;
k2 = d/c;
k3 = (a^2-b^2+c^2+d^2)/(2*a*c);
R = theta2 * (pi / 180);
% To calculate theta_4
A = cos(R)-k1-(k2*cos(R))+k3;
B = -(2* sin(R));
C = k1 - ((k2+1)*cos(R))+k3;
theta4_R =2*atan((-B-(sqrt((B^2)-(4*A*C))))/(2*A));
theta4 = theta4_R * (180/ pi);
% To calculate theta_3
k4=d/b;
k5=(c^2-d^2-a^2-b^2)/(2*a*b);
D=cos(R)-k1+(k4*cos(R))+k5;
E=(-2)*sin(R);
F=k1+(k4-1)*cos(R)+k5;
theta3_R =2*atan((-E-(sqrt((E^2)-(4*D*F))))/(2*D));
theta3 = theta3_R * (180/ pi);
theta_store_2(i)=theta2;
theta_store_3(i)=theta3;
theta_store_4(i)=theta4;
Position_Ax = (b*cos(R));
Position_Ay = (b*sin(R));
Position_Bx = (Position_Ax +(c*cos(theta3_R)));
Position_By = (Position_Bx +(c*sin(theta3_R)));
COG_link3x= ((Position_Ax +Position_Bx)/2);
COG_link4x= ((Position_Ay +Position_By)/2);
store_Ax(i)= (b*cos(R));
store_Ay(i)= (b*sin(R));
store_Bx(i)= (Position_Ax +(c*cos(theta3_R)));
store_By(i)= (Position_Ay +(c*sin(theta3_R)));
store_COG_L3x (i) = ((Position_Ax +Position_Bx)/2);
store_COG_L3y (i) = ((Position_Ay +Position_By)/2);
i=i+1;
end
figure (1)
hold on
plot(store_Ax,store_Ay);
hold off
title ('Movement of Pin A');
xlabel('X Axis (mm)');
ylabel('Y Axis (mm)');
grid on
figure (3)
hold on
plot(store_Bx,store_By);
hold off
title ('Movement of Pin B');
xlabel('X Axis (mm)');
ylabel('Y Axis (mm)');
grid on
figure (2)
hold on
plot(store_COG_L3x,store_COG_L3y);
hold off
title ('Movement of COG link 3');
xlabel('X Axis (mm)');
ylabel('Y Axis (mm)');
grid on
SimMechanics