### Damped Oscillation of a Simple Pendulum

##### Rupesh
updated on Apr 17, 2020, 11:18am IST

AIM:

To write a MATLAB code for simulating the transient behavior of a simple pendulum and to create an animation of its motion.

SIMPLE PENDULUM:

A simple pendulum consists of a ball (point-mass) m hanging from a (massless) string of length L and fixed at a pivot point P. When displaced to an initial angle and released, the pendulum will swing back and forth with the periodic motion. By applying Newton's second law for rotational systems, the equation of motion for the pendulum may be obtained

tau = I alpha qquad Rightarrow qquad -mg Lsintheta = mL^2 frac{d^2theta}{dt^2}

and rearranged as

frac{d^2theta}{dt^2} + frac{g}{L}sintheta = 0

If the amplitude of angular displacement is small enough, so the small-angle approximation  holds true, then the equation of motion reduces to the equation of simple harmonic motion

frac{d^2theta}{dt^2} + frac{g}{L}theta = 0

The simple harmonic solution is

theta(t) = theta_o cos(omega t)

where theta_ois the initial angular displacement, and omega = sqrt{g/L}the natural frequency of the motion. The period of this system (time for one oscillation) is

T = frac{2pi}{omega} = 2pisqrt{frac{L}{g}} .

The period of a pendulum does not depend on the mass of the ball, but only on the length of the string. Two pendula with different masses but the same length will have the same period. Two pendula with different lengths will different periods; the pendulum with the longer string will have a longer period.

With the assumption of small angles, the frequency and period of the pendulum are independent of the initial angular displacement amplitude. A pendulum will have the same period regardless of its initial angle

REAL NONLINEAR SIMPLE PENDULUM:

When the angular displacement amplitude of the pendulum is large enough that the small-angle approximation no longer holds, then the equation of motion must remain in its nonlinear form

frac{d^2theta}{dt^2} + frac{g}{L}sintheta = 0

This differential equation does not have a closed-form solution but instead must be solved numerically using a computer. MATLAB numerically solves this differential equation very easily with the built-in function ode45.

DAMPED OSCILLATION OF SIMPLE PENDULUM:

Dampers are used in oscillating systems for primarily dissipating the energy of the system to

• have a controlled motion or prevent oscillation
• to alter the frequency of oscillation which helps in avoiding resonance
• to reduce the dynamic stresses induced which boosts fatigue life.

By applying Newton's second law for rotational systems

Ialpha+bl^2omega+mglsintheta=0

ml^2(d^2theta)/dt^2+bl^2(d theta)/dt+mglsintheta=0

(d^2theta)/dt^2+b/m(d theta)/dt+g/lsintheta=0

This is a differential equation of 2^(nd) order. The inbuilt function used in this code 'ode45' cannot process a 2^(nd) order ODE. Hence we convert this equation into two 1^(st) order ODEs, and then feed them into a user-defined function 'ode_func' which is further served as an input to the inbuilt function ode45.

Breaking down into 1^(st)order ODEs,

Assume theta=theta_1 be a solution of the 2^(nd) order ODE and,

(d theta_1)/dt=theta_2.........................................................................1

Now we convert the 2^(nd) order ODE into  two 1^(st) order ODEs with variables theta_1 and theta_2.

implies(d^2theta)/dt^2=(d^2theta_1)/dt^2=(d theta_2)/dt^

substituting the above in,

(d^2theta)/dt^2+b/m(d theta)/dt+g/lsintheta=0

(d^2theta_1)/dt^2+b/m(d theta_1)/dt+g/lsintheta_1=0

(d theta_2)/dt+b/m(d theta_1)/dt+g/lsintheta_1=0...................................2

LHS array of the below equation is the output of the user-defined function 'ode_func', which is inturn fed an as input to the inbuilt function 'ode45',

[(d theta_1)/dt       (d theta_2)/dt]=[theta_2        (-g/lsintheta_1- b/mtheta1)]

The 'ode45' along with above matrix takes in time interval 't_0' array and the initial conditions of  angular displacement(in radians) and and angular velocity (in radians/second) in form of arrays and gives out a (lengthX2) matrix where length is the length of t_0 array.And the 2 colums contain angular displacement and angular velocity corresponding to the time interval element of 't_0'.

PROGRAM:

MAIN PROGRAM:

clear all
close all
clc

%input parameters
l=1;
m=1;
b=0.05;
g=9.81;

%time interval taken as an array
t_0=linspace(0,20,300);

%initial conditions that contains (displacement in radians)
x_0=[0;3];

% using the inbuilt function ode45 that uses time interval, the initial condition
%and user-defined function as its input.

%we have done function calling for the user define function while feeding
%it as an input to the ode45
%'result' is the final array, that ode45 gives us back which contains two columns
%first one has displacement and the second one has angular velocity after every
%0.06 seconds interval
[t,result]=ode45(@(t,x) ode_func(t,x,l,m,b,g),t_0,x_0);

% to ensure the velocity and displacement curves w.r.t time
%comes  in the same figure we have used
%hold on
figure(1)

%plot the first column of the result array w.r.t time
plot(t,result(:,1));

hold on

%plot the second column of the result array w.r.t time
plot(t,result(:,2));
legend('Angular displacement','Angular Velocity');
xlabel('TIME')
ylabel('AMPLITUDE')

%defining this variable 'gh' to access individual elements of array M
gh=0;

%using for loop to access each element in the 'displacement column' of the array,'result'
%and assigning it to a variable theta
%theta is further used to locate the exact position of the pendulum at the
%end of each interval of 0.06 sec

for j=1:length(result(:,1));
theta=result(j,1);
x=l*sin(theta);
y=-l*cos(theta);
figure(2)

plot([-1 1],[0 0],'color','r','linewidth',3)
hold on
plot([0 x],[0 y],'linewidth',1)
plot(x,y,'-o','Markersize',5,'Markerfacecolor',[0.1 0 0])

axis([-2 2 -2 2])

%using this pause to ensure that the displacement of the pendulum is in sync
%with their specific time intervals
%there are 299 such time intervals
%so a new plot is plotted for each time interval according to the
%corresponding value in the 'result' arrays displacement column
pause(0.06)
hold off
gh=gh+1;
% writing each frame of the plot to an array called M
M(gh)=getframe(gcf);

end

%generating a movie with that array 'M'
movie(M)

%OPENING A NEW FILE NAMED Simple_Pendulum of FILE type Uncompressed AVI
f=VideoWriter('Simple_Pendulum.avi','Uncompressed AVI');
open(f)

%writing the contents of array M into the NEW FILE
writeVideo(f,M)
close(f)


USER DEFINED FUNCTION USED AS AN INPUT FOR ode45:

function [dx_dt]=ode_func(t,x,l,m,b,g)
x1=x(1);
x2=x(2);
dx1_dt=x2;
dx2_dt=(-b/m)*x2-(g/l)*sin(x1);
dx_dt=[dx1_dt;dx2_dt];
end

RESULT:

The amplitude of the Angular displacement ( in radians ) and Angular Velocity(in radians/seconds) is plotted with respect to Time( in seconds).

The simulation of the damped oscillation is performed for the first 20 seconds.

### More projects by Rupesh

##### Week 4
Rupesh updated on Jun 24, 2020, 12:11am IST
AIM: To check for the geometrical errors and to mesh with the given component for the below-mentioned element Quality criteria.   S.No  Quality Criteria  Value  1 Target/Average length   1 2 Minimum Length  .5 3 Maximum Length  3 4 Aspect  3 5 Warpage 15 6 Skewness… Read more
##### Week 3
Rupesh updated on May 25, 2020, 07:56pm IST
AIM: To check the geometrical errors and mesh the given sheet metal component of uniform thickness for the given Quality criteria using ANSA.   S.No  Quality Criteria  Value  1 Target/Average length   5 2 Minimum Length  3 3 Maximum Length  7 4 Aspect  3 5 Warpage 15 6 Skewness… Read more
##### WEEK 7
Rupesh updated on May 03, 2020, 06:17am IST
1. Running A MATLAB demo ‘Speed control of a DC motor using BJT H-bridge’. Analyzing the reason for armature current shoot up when motor changes direction from forward to reverse and trying to prevent the same. Solution: ORIGINAL INBUILT MODEL:(run for a stop time of 1 second) 'Working of this model: Armature… Read more
##### week 11
Rupesh updated on Apr 25, 2020, 07:40pm IST
1. For a defined driving cycle, calculate the energy required for braking. Solution: Here we have chosen NEDC drive cycle whose characteristics looks like this The above has been generated using below-built Simulink model  Note the velocity profile alone has been written into a separate file that is processed upon… Read more
##### week 10
Rupesh updated on Apr 21, 2020, 08:54am IST
1. Why power electronics circuit are efficient? In practice, which types of losses occur in the power electronics circuit? Solution: When a dc motor is connected to a battery of its rated voltage, it starts running at full speed immediately. Now when we need to reduce the speed of the dc motor, a mechanical resistance… Read more
##### week 9
Rupesh updated on Apr 17, 2020, 12:04pm IST
Discuss the equivalent circuit network of the induction motor MATLAB model. SOLUTION: The equivalent circuit of a single-phase  simplified induction motor as shown in MATLAB DOCUMENTATION In the figure: R1 is the stator resistance. R2 is the rotor resistance with respect to the stator. L1 is the stator… Read more
Rupesh updated on Apr 17, 2020, 11:18am IST
CHALLENGE 1: Use ADVISOR tool and simulate the following   1. For EV_defaults_in file, if cargo mass is 500 kg with all other default conditions, can the vehicle travel for 45 km with FTP drive cycle? Conclude your observations. 2. In the above case, try changing the battery capacity and repeat the simulation.… Read more
##### Wide Open Throttle Response of GM EV1 ELECTRIC VEHICLE
Rupesh updated on Apr 17, 2020, 11:18am IST
CHALLENGE 4: Model the WOT (Wide Open Throttle) response of GM EV1 car. Compare it with the official figures for the performance of a real vehicle. Prepare a table showing variation in acceleration time with a 5% change in vehicle parameters.   SOLUTION: WIDE OPEN THROTTLE(WOT): This is when the accelerator is… Read more
##### OPTIMIZATION USING GENETIC ALGORITHM
Rupesh updated on Apr 17, 2020, 11:18am IST
AIM: The focus of this study is to perform maximization using genetic algorithm, i.e to find the maximum value of the given function using the inbuilt function ga. GENETIC ALGORITHM: It is a method to solve optimization problems based on NATURAL SELECTION that mimics biological evolution. We can use it for both maximization… Read more
##### TEMPERATURE SENSING USING THERMISTOR
Rupesh updated on Apr 17, 2020, 11:18am IST
AIM: To use a thermistor in Simulink to sense the temperature of a heater & turn on or turn off the fan as per below conditions: Temperature source: 20 °C from 0 to 10 seconds, 27 °C from 10 to 30 seconds, 23 °C from 30 to 50 seconds Fan conditions: ON if the temperature above 25 °C,… Read more
##### PARSING NASA THERMODYNAMIC DATA
Rupesh updated on Apr 17, 2020, 11:18am IST
AIM: To calculate thermodynamic properties such as specific heat, specific entropy, specific enthalpy using MATLAB with the help of data generated by NASA.  PROCEDURE: The data is given in a file that is used for the aforementioned calculations. We carefully scrutinize the file for patterns based on which… Read more
##### MATLAB Simulation of 2R ROBOTIC ARM
Rupesh updated on Apr 17, 2020, 11:18am IST
AIM:  To write a program in MATLAB to simulate the forward kinematics of a 2R ROBOTIC ARM. THEORY: A 2R ROBOTIC ARM contains  a) 2 rotating links and one fixed link b) 2 rotational joints   DEGEREE OF FREEDOM of this 2D planar mechanism is given by KURTZBACH CRITERION DOF=3(N-1)-2J-H where,    … Read more
Rupesh updated on Apr 17, 2020, 11:18am IST
PROJECT 1:  AIM: To plot a function y(x)=(x-1)*(x-3)^2*(x-9)^2 using basic Simulink blocks.  Basic blocks used here are: Ramp is used in place of x(because it is set with a slope of 1 for 10 seconds) Display is used to display the final value of the function.   Scope is used to display the… Read more
##### week 6
Rupesh updated on Apr 17, 2020, 11:18am IST
1.   An Electric Vehicle's Drivetrain with a 72V battery pack in shown in the diagram below. The duty ratio for acceleration operation is 'd1' and for the braking operation the duty ratio is 'd2'. The other parameters of the  electric vehicle are given below,              … Read more
##### OPTIMIZATION USING GENETIC ALGORITHM
Rupesh updated on Apr 17, 2020, 11:18am IST
##### Polynomial Curve Fitting Using MATLAB
Rupesh updated on Apr 17, 2020, 11:18am IST
For root finding, we used a given function to identify where it crossed zero i.e, where does f(x)=0??So where does this given function f(x)come from in the first place? Analytical models of phenomena e.g.( equations from physics.) Create an equation from observed data-This is precisely what we have done in this project.… Read more
##### SIMULINK MODEL OF A DOOR BELL
Rupesh updated on Apr 17, 2020, 11:18am IST
AIM: To Make a Simulink model of Doorbell using solenoid block to create a situation where the switch is closed for 2 seconds and then released the physical movement of the plunger.    THEORY: ELECTROMAGNET: Electromagnets are non-permanent magnets that produce a magnetic field as long… Read more
##### PARSING NASA THERMODYNAMIC DATA
Rupesh updated on Apr 17, 2020, 11:18am IST
##### BASIC MECHANICS OF VEHICLE
Rupesh updated on Apr 17, 2020, 11:18am IST
CHALLENGE 1.1: What should be the maximum speed of the motor used in an electric scooter capable to run at 90 kmph, if the fixed gear ratio is 7 and tire size is 90/100 R10 53J?  Solution: TIRE CODE:   Therefore 90/100 R10 53J means Section width:90 mm Aspect Ratio:100% implies Height of the tire… Read more
Rupesh updated on Apr 17, 2020, 11:18am IST
CHALLENGE 1: AIM: To determine the work done as the tool moves through a distance of 100 mm.         The force on a cutting tool of a shaping machine varies over the length of cut as follows:         Distance (mm)     0     20     40     60     80     100… Read more
##### SIMULATING THE CONTROL LOGIC OF A WASHING MACHINE AND CAR GEAR
Rupesh updated on Apr 17, 2020, 11:18am IST
WASHING MACHINE: AIM: To implement control logic of a “washing machine” using Stateflow as per given sequence:  If the power supply is available, the system gets activated  If the Water supply is not available, stop the process & indicate through LED Soaking time should be 200s followed by the… Read more
##### FUNDAMENTALS OF VEHICLE
Rupesh updated on Apr 17, 2020, 11:17am IST
CHALLENGE 1: To find the ratio of hill-climbing power required by fully loaded tata ultra truck to the half-loaded one? Solution: There are a wide variety of trucks offered by the TATA MOTORS. For our study, we have taken the values of TATA ULTRA 1518. THEORY: HILL CLIMBING POWER= F_(hc)*v where, F_(hc) is the… Read more
##### RANKINE CYCLE SIMULATOR
Rupesh updated on Apr 17, 2020, 11:17am IST
AIM: To plot a T-S and H-S diagram of a Rankine cycle for the given inputs, and to calculate its net work output and back work ratio using MATLAB and Xsteam library. THEORY: Given the fact that the Carnot cycle is the father of all thermodynamic cycles because of its maximum efficiency in a certain working temperature… Read more
##### A MATLAB Code plotting P-V diagram and Efficiency Calculation of an Otto Cycle
Rupesh updated on Apr 17, 2020, 11:17am IST
AIM: To calculate the Thermal Efficiency of otto cycle and to write a program to plot  its  P-V diagram using MATLAB. THEORY: A Spark Ignition Engine using petrol as its fuel, follows a thermodynamic cycle upon which when applied air standard assumptions we get an otto cycle. AIR STANDARD ASSUMPTIONS: 1)… Read more
##### WEEK 4
Rupesh updated on Apr 17, 2020, 11:17am IST
CHALLENGE 1: What is the difference between the mapped and dynamic model of engine, motor and generator? How can you change the model type?  Solution: A mapped model is a precalculated dataset for which the output values are readily available for the corresponding inputs. The values here are mapped and stored as data… Read more
##### week 5
Rupesh updated on Apr 17, 2020, 11:17am IST
How can you distinguish between power cables and signal cables in the wiring of an electric vehicle? SOLUTION: The cross-section area of the cable shows the difference. Cables with higher cross-section areas are power cables and ones with lower cross-section areas are signal cables 2. What voltage levels are considered… Read more
##### ihev week 8
Rupesh updated on Apr 11, 2020, 06:17am IST
CHALLENGE 1: HOW INDUCTION MOTOR OPERATION IS SIMILAR TO MECHANICAL CLUTCH? THE SLIP in induction is due to the difference between the synchronous speed and the actual speed of the rotor. While in the mechanical clutch it is due to the relative velocity between the two engaging plates of the clutch. It is due to this slip… Read more
##### RANKINE CYCLE SIMULATOR
Rupesh updated on Feb 26, 2020, 03:31am IST