In this system there is a wheeled cart moving along a horizontal track. From the cart a pendulum is suspended. A spring is attached to the cart as shown.
There are two ways to find the equations of motion for a system like this, the direct Newtonian way or the indirect Lagrangian way. We show both methods here.
For both direct & indirect methods, we first need to get the kinematics right. Kinematics means the relations of the parts of the device, without regard to forces. In kinematics we are only trying to find expressions for the position, velocity, & acceleration in terms of whatever variables we have chosen.
The variables we choose here are:
We'll need the standard unit vectors,
The kinematics for the cart are simple
position
The kinematics for the pendulum are more complex.
position
The position is derived by a fairly simple application of trigonometry. The velocity and acceleration are then just the first and second derivatives of the position.
There is an alternative way to calculate the kinematics that you may see in a dynamics textbook. The idea is that you can define two or more coordinate frames which are moving with respect to each other. Suppose there is an object for which you want to find the velocity and acceleration with respect to the frame that is stationary (so that you can use Newton's equations). Suppose it is easy to define the motion of the object in a frame that is rotating or translating in some way. Then you can use standard formulas that convert from the moving frame into the stationary frame.
It is actually somewhat tricky to use these formulas, and it seems more straightforward to find the kinematics by taking derivatives of the position vector, as we did above. But for more complicated situations you may want to know about this alternative method of calculating kinematics.
We treat the cart and the pendulum bob as point particles. Begin by drawing the free body diagram for the cart and writing an expression for the net force acting it.
The variables are as follows
The forces on the cart are the spring force
Now using Newton's law
N
Next we draw the free body diagram for the pendulum. The forces on the pendulum are the tension in the rod and gravity. So we can write the net force as:
F = T cos θ j - T sin θ i - m g j
Using Newton's law
T
Now we can write the vector components of the above equations 1 & 2 as separate equations. This gives us 4 simultaneous equations.
T
Now we do some algebraic manipulations to eliminate the unknown tension
Multiply equation 5 by
T
Use equation 4 to replace
This simplifies to
m
Using the trig identity
x''cos θ + R θ'' + g sin θ = 0 (eqn 7)
Equations 6 and 7 are the equations of motion. We have two equations in the two variables
We will need to do some further manipulations of these two equations to get them into a form suitable for the Runge-Kutta numerical analysis method (see below).
The indirect method is based on the energy of the system. In the current example there are no non-conservative forces (ie. no friction or damping) so we get to skip some steps. Our first step is to find the Lagrangian of the system which is the kinetic energy minus the potential energy.
L = T - V
For the kinetic energy we need the velocity of the cart and pendulum, which we calculated earlier. Kinetic energy is given by
T
Applying the dot product rule to square the vectors we get
T
There are two stores of potential energy in this system: the spring and the gravitational potential of the pendulum.
Vspring = (1/2)k x2
Vgravity = m g height = m g(R - R cos θ)
So the Lagrangian for the system is
L
Next we will derive the equations of motion from Lagrange's Equation. For the
0 = ![]()
Note that
L = M x' + m(x' + R θ' cos θ)
L = - k x
Taking the derivative with respect to time of
L
L
= M x'' + m x'' + m R θ'' cos θ
which we can rearrange to be identical to the corresponding equation found above in the direct method
Here again is the Lagrangian for the system:
L
For the
0 = ![]()
Here are the partial derivatives:
L = m(x' + R θ' cos θ)R cos θ
L = -m(x' + R θ' cos θ)R θ' sin θ
Note that we can divide out the constant
L
L
=
We can fully expand this to
After lots of cancellations and using the identity
x''cos θ + R θ'' + g sin θ = 0 (eqn 7)
To solve the equations of motion numerically, so that we can drive the simulation, we use the
Runge-Kutta method for solving sets of ordinary differential equations.
To use the Runge-Kutta method, we need to get equations 6 and 7 into the following form:
x'' = f(x, x', θ, θ')
θ'' = g(x, x', θ, θ')
where
Here are the manipulations needed to get these equations into the desired form. First we rearrange equations 6 and 7 to the following:
x
Substitute equation 9 into equation 8 and then solve for
m R θ'2 sin θ + m g cos Qsin θ - k x
x'' = ------------------------------------ (eqn 10)
M + m sin2θ
Substitute equation 8 into equation 9 and solve for
cos θ[m R θ'2 sin θ - m R θ'' cos θ - k x]
-R θ'' = ----------------------------------------- + g sin θ
M + m
m R θ'2sin θ cos θ - k x cos θ + g(M + m)sin θ
θ'' = ---------------------------------------------
-R(M+m) + m R cos2θ
-m R θ'2sin θ cos θ + k x cos θ - g(M + m)sin θ
θ'' = ---------------------------------------------- (eqn 11)
R (M + m sin2θ)
Equations 10 and 11 are now close to the form needed for the Runge-Kutta method. The final step is convert these two 2nd order equations into four 1st order equations. First we define the first derivatives as separate variables:
Then we can write the four 1st order equations:
x' = v
θ' = ω
m R ω2 sin θ + m g cos θ sin θ - k x
v' = ------------------------------------ (eqn 10)
M + m sin2θ
-m R ω2 sin θ cos θ + k x cos θ - g(M + m)sin θ
ω' = ---------------------------------------------- (eqn 11)
R (M + m sin2θ)
This is now exactly the form needed to plug in to the Runge-Kutta method for numerical solution of the system.