home

PDF (letter size)

PDF (legal size)

Equation of motion of spring pendulum on a moving cart

Nasser M. Abbasi

May 21, 2025   Compiled on May 21, 2025 at 9:56pm

Let original length of pendulum be \(L\) and extension at instance shown be \(u\). The inertial frame has unit vectors \(\hat {I},\hat {J},\hat {K}\). The cart moves horizontally only and at instance shown is moving in positive direct at distance \(X\) from origin. Let unit vectors for the body frame be \(\hat {\imath },\hat {\jmath },\hat {k}\).

The bob has three degrees of freedom. In other words, to locate the bob at any time, we need to know \(X,\theta ,u\,\) where \(X\) is the horizontal displacement of the cart, \(\theta \) is the angle the pendulum spring makes with the vertical and \(u\) is the amount of extension of the spring. So will end up with three equations of motion, one for each degree of freedom.

We always start by finding the position vector of bob which is

\begin{align*} \bar {r}_{OB} & =\bar {r}_{OA}+\bar {r}_{AB}\\ & =X\hat {I}-\left ( L+u\right ) \hat {\jmath }\end{align*}

Hence the velocity vector of bob is

\begin{align*} \left ( \frac {d}{dt}\bar {r}_{OB}\right ) _{inertial} & =\frac {d}{dt}\left ( X\hat {I}-\left ( L+u\right ) \hat {\jmath }\right ) _{inertial}\\ \left ( \bar {v}_{B}\right ) _{inertial} & =\left ( \frac {d}{dt}X\hat {I}\right ) _{inertial}-\left ( \frac {d}{dt}\left ( L+u\right ) \hat {\jmath }\right ) _{inertial}\\ & =\dot {X}\hat {I}-\left ( \frac {d}{dt}\left ( L+u\right ) \hat {\jmath }\right ) _{body}-\bar {\omega }\times \left ( L+u\right ) \hat {\jmath }\\ & =\dot {X}\hat {I}-\dot {u}\hat {\jmath }-\dot {\theta }\hat {k}\times \left ( L+u\right ) \hat {\jmath }\\ & =\dot {X}\hat {I}-\dot {u}\hat {\jmath }+\dot {\theta }\left ( L+u\right ) \hat {\imath }\end{align*}

For help with the sign used for cross product between vector, this diagram is used.

For example \(\hat {k}\times \hat {\imath }=\hat {\jmath }\) since the motion is counter clockwise hence positive. While \(\hat {k}\times \hat {\jmath }=-\hat {\imath }\) since motion was negative.

Now we can find the acceleration of the bob in inertial frame using the above result as follows

\begin{align*} \left ( \frac {d}{dt}\bar {v}_{B}\right ) _{_{inertial}} & =\left ( \frac {d}{dt}\left ( \dot {X}\hat {I}-\dot {u}\hat {\jmath }+\dot {\theta }\left ( L+u\right ) \hat {\imath }\right ) \right ) _{inertial}\\ \left ( \bar {a}_{B}\right ) _{inertial} & =\left ( \frac {d}{dt}\dot {X}\hat {I}\right ) _{inertial}+\frac {d}{dt}\left ( -\dot {u}\hat {\jmath }+\dot {\theta }\left ( L+u\right ) \hat {\imath }\right ) _{inertial}\\ & =\ddot {X}\hat {I}+\frac {d}{dt}\left ( -\dot {u}\hat {\jmath }+\dot {\theta }\left ( L+u\right ) \hat {\imath }\right ) _{body}+\bar {\omega }\times \left ( -\dot {u}\hat {\jmath }+\dot {\theta }\left ( L+u\right ) \hat {\imath }\right ) \\ & =\ddot {X}\hat {I}+\left ( -\ddot {u}\hat {\jmath }+\ddot {\theta }\left ( L+u\right ) \hat {\imath }+\dot {\theta }\dot {u}\hat {\imath }\right ) +\dot {\theta }\hat {k}\times \left ( -\dot {u}\hat {\jmath }+\dot {\theta }\left ( L+u\right ) \hat {\imath }\right ) \\ & =\ddot {X}\hat {I}-\ddot {u}\hat {\jmath }+\ddot {\theta }\left ( L+u\right ) \hat {\imath }+\dot {\theta }\dot {u}\hat {\imath }-\dot {\theta }\hat {k}\times \dot {u}\hat {\jmath }+\dot {\theta }\hat {k}\times \dot {\theta }\left ( L+u\right ) \hat {\imath }\\ & =\ddot {X}\hat {I}-\ddot {u}\hat {\jmath }+\ddot {\theta }\left ( L+u\right ) \hat {\imath }+\dot {\theta }\dot {u}\hat {\imath }+\dot {\theta }\dot {u}\hat {\imath }+\dot {\theta }^{2}\left ( L+u\right ) \hat {\jmath }\\ & =\ddot {X}\hat {I}-\ddot {u}\hat {\jmath }+\ddot {\theta }\left ( L+u\right ) \hat {\imath }+2\dot {\theta }\dot {u}\hat {\imath }+\dot {\theta }^{2}\left ( L+u\right ) \hat {\jmath }\end{align*}

Simplifying gives the acceleration of the bob

\begin{equation} \left ( \bar {a}_{B}\right ) _{inertial}=\ddot {X}\hat {I}+\hat {\imath }\left ( \ddot {\theta }\left ( L+u\right ) +2\dot {\theta }\dot {u}\right ) +\hat {\jmath }\left ( \dot {\theta }^{2}\left ( L+u\right ) -\ddot {u}\right ) \tag {1}\end{equation}

Now that we found the bob acceleration, we can find its equation of motion

\begin{equation} \bar {F}_{B}=m\bar {a}_{B} \tag {2}\end{equation}

Where \(\bar {F}_{B}\) is sum of all external forces acting on the bob. We have now to make free body diagram in order to find these forces.

From the diagram above we see that external forces on bob are

\begin{equation} \bar {F}_{bob}=-R_{2}\hat {\jmath }-R_{1}\hat {\imath }+k_{2}u\hat {\jmath }-mg\cos \theta \hat {\jmath }-mg\sin \theta \hat {\imath } \tag {3}\end{equation}

Substituting (3,1) into (2) gives equation of motion for bob as

\begin{equation} -R_{2}\hat {\jmath }-R_{1}\hat {\imath }+k_{2}u\hat {\jmath }-mg\cos \theta \hat {\jmath }-mg\sin \theta \hat {\imath }=m\ddot {X}\hat {I}+\hat {\imath }\left ( \ddot {\theta }\left ( L+u\right ) +2\dot {\theta }\dot {u}\right ) m+\hat {\jmath }\left ( \dot {\theta }^{2}\left ( L+u\right ) -\ddot {u}\right ) m \tag {3A}\end{equation}

To express \(\hat {I},\hat {J}\) in terms of body basis \(\hat {\imath },\hat {\jmath }\) or to expression body basis \(\hat {\imath },\hat {\jmath }\) in terms of inertial basis \(\hat {I},\hat {J}\)  we will use the following diagram

From the above diagram we see that

\begin{align} \hat {I} & =\hat {\imath }\cos \theta -\hat {\jmath }\sin \theta \tag {4}\\ \hat {J} & =\hat {\imath }\sin \theta +\hat {\jmath }\cos \theta \nonumber \end{align}

Or in matrix form

\[\begin {pmatrix} \hat {I}\\ \hat {J}\end {pmatrix} =\begin {pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end {pmatrix}\begin {pmatrix} \hat {\imath }\\ \hat {\jmath }\end {pmatrix} \]

Similarly, we can express body basis in term on inertial basis as

\begin{align} \hat {\imath } & =\hat {I}\cos \theta +\hat {J}\sin \theta \tag {5}\\ \hat {\jmath } & =-\hat {I}\sin \theta +\hat {J}\cos \theta \nonumber \end{align}

Or in matrix form

\[\begin {pmatrix} \hat {\imath }\\ \hat {\jmath }\end {pmatrix} =\begin {pmatrix} \cos \theta & \sin \theta \\ -\sin \theta & \cos \theta \end {pmatrix}\begin {pmatrix} \hat {I}\\ \hat {J}\end {pmatrix} \]

Replacing \(\hat {I}\) in (3A) by \(\hat {I}=\hat {\imath }\cos \theta -\hat {\jmath }\sin \theta \) so that all basis are in body frame gives

\[ -R_{2}\hat {\jmath }-R_{1}\hat {\imath }+k_{2}u\hat {\jmath }-mg\cos \theta \hat {\jmath }-mg\sin \theta \hat {\imath }=m\ddot {X}\left ( \hat {\imath }\cos \theta -\hat {\jmath }\sin \theta \right ) +\hat {\imath }\left ( \ddot {\theta }\left ( L+u\right ) +2\dot {\theta }\dot {u}\right ) m+\hat {\jmath }\left ( \dot {\theta }^{2}\left ( L+u\right ) -\ddot {u}\right ) m \]

Or by components, the above gives two equations

\begin{align} -R_{1}-mg\sin \theta & =m\ddot {X}\cos \theta +\left ( \ddot {\theta }\left ( L+u\right ) +2\dot {\theta }\dot {u}\right ) m\tag {6}\\ -R_{2}+k_{2}u-mg\cos \theta & =-m\ddot {X}\sin \theta +\left ( \dot {\theta }^{2}\left ( L+u\right ) -\ddot {u}\right ) m\tag {7}\end{align}

Or

\begin{align} -\frac {R_{1}}{m}-g\sin \theta & =\ddot {X}\cos \theta +\ddot {\theta }\left ( L+u\right ) +2\dot {\theta }\dot {u}\tag {6}\\ -\frac {R_{2}}{m}+\frac {k_{2}}{m}u-g\cos \theta & =-\ddot {X}\sin \theta +\dot {\theta }^{2}\left ( L+u\right ) -\ddot {u}\tag {7}\end{align}

For the equation of motion of the cart we have for the horizontal motion

\begin{align} \bar {F} & =M\bar {a}\nonumber \\ F-k_{1}\left ( X-L_{0}\right ) -c\dot {X}-R_{2}\sin \theta +R_{1}\cos \theta & =M\ddot {X}\tag {8}\end{align}

And for the vertical motion and since cart does not move in vertical direction then

\[ -Mg+2N+R_{2}\cos \theta +R_{1}\sin \theta =0 \]

Since \(2N=Mg\) then

\begin{equation} R_{2}\cos \theta +R_{1}\sin \theta =0\tag {9}\end{equation}

So far, we have found 4 equations. They are (6,7,8,9), But we have 5 unknowns, they are \(\ddot {\theta },\ddot {X},R_{1},R_{2},\ddot {u}\). We need one more equation. Typically this is the moment equation. Taking moments around point \(A\) where pendulum is attached. This gives (using \(\tau =I\ddot {\theta }\,\) where \(I=mL^{2}\) for point mass pendulum, and here \(L\equiv \left ( L+u\right ) \) to account for the extension, which is the current length of pendulum). Hence moment equation for the pendulum is

\begin{align} -mg\sin \theta \left ( L+u\right ) & =m\left ( L+u\right ) ^{2}\ddot {\theta }\nonumber \\ \ddot {\theta }+\frac {g}{L+u}\sin \theta & =0\tag {10}\end{align}

\(R_{1},R_{2}\) can now be found by elimination from (9,8) which gives

\begin{align} R_{1} & =-\cos \left ( \theta \right ) \left ( F+k_{1}L_{0}-k_{1}X-c\dot {X}-M\ddot {X}\right ) \tag {11}\\ R_{2} & =\sin \left ( \theta \right ) \left ( F+k_{1}L_{0}-k_{1}X-c\dot {X}-M\ddot {X}\right ) \tag {12}\end{align}

Hence we now have 3 equations in 3 unknowns \(\ddot {\theta },\ddot {X},\ddot {u}\). The equations are (6,7,10)

\begin{align} -\frac {R_{1}}{m}-g\sin \theta & =\ddot {X}\cos \theta +\ddot {\theta }\left ( L+u\right ) +2\dot {\theta }\dot {u}\tag {13}\\ -\frac {R_{2}}{m}+\frac {k_{2}}{m}u-g\cos \theta & =-\ddot {X}\sin \theta +\dot {\theta }^{2}\left ( L+u\right ) -\ddot {u}\tag {14}\\ \ddot {\theta }+\frac {g}{L+u}\sin \theta & =0\tag {15}\end{align}

Where \(R_{1},R_{2}\) are given by (11,12). This completes the solution.

Numerically we can now solve the above using some numerical values for \(g,k_{1},k_{2},c,m,M,L,L_{0}\) and with 6 initial conditions for \(u\left ( 0\right ) ,u^{\prime }\left ( 0\right ) ,X\left ( 0\right ) ,X^{\prime }\left ( 0\right ) ,\theta \left ( 0\right ) ,\theta ^{\prime }\left ( 0\right ) \) and run the simulation showing the motion. The force \(F\) on the cart, can be anything we want. For an example \(F=\sin t\) or it can be zero also (but now we have to give the cart some non zero initial position or non zero initial velocity to make it move).

If we did not have a cart at the top, and the pendulum was hinged on a fixed point at the top, then now \(\ddot {X}=0\) and \(R_{1}=R_{2}=0\) and the above 3 equations reduce to two only (since we have lost one degree of freedom)

\begin{align} -g\sin \theta & =\ddot {\theta }\left ( L+u\right ) +2\dot {\theta }\dot {u}\tag {13}\\ \frac {k_{2}}{m}u-g\cos \theta & =\dot {\theta }^{2}\left ( L+u\right ) -\ddot {u}\tag {14}\end{align}

In addition, if we did not have a spring, but a normal bob pendulum on massles rod, then \(u=0\) now and the above two equations reduce to only one (since we lost one more degree of freedom \(u\)). This results in the standard pendulum equation of motion

\[ \ddot {\theta }+\frac {g}{L}\sin \theta =0 \]

Numerical simulation of motion can be now done using (13,14,15).