MyPhysicsLab – Pendulum and Cart

In this simulation there is a cart moving along a horizontal track. From the cart a pendulum is suspended. A spring connects the cart to a wall. Friction acts on the cart and on the pendulum.
You can change parameters such as gravity, mass, pendulum length, spring stiffness, and friction (damping). You can drag the cart or pendulum with your mouse to change the starting position. Click the "reset" button to start from a resting position.

คลิกเข้าไปทดลอง  คลิกค่ะ

ทดลองไม่ได้ให้ Download  มา setup ที่เครื่องของท่านก่อนครับ Download จากฟิสิกส์ราชมงคล

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.


diagram of cart & pendulum variables and i, j unit vectors
For both direct and 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 here are:
  • x = position of cart (0 = spring unstretched)
  • θ = angle of pendulum (0 = pendulum hanging straight down)
  • R = length of rod (constant)
We'll need the standard unit vectors, i, j, k. We use bold and overline to indicate a vector.
  • i = (1,0,0) unit vector in horizontal direction
  • j = (0,1,0) unit vector in vertical direction
  • k = (0,0,1) unit vector in z direction (out of the page)
The kinematics for the cart are simple position = x i
velocity = x' i
acceleration = x'' i
The kinematics for the pendulum are more complex. The position is derived by a fairly simple application of trigonometry. The velocity and acceleration are then the first and second derivatives of the position. position = x i + R sin θ iR cos θ j velocity = x' i + R θ' cos θ i + R θ' sin θ j acceleration = x'' i + R θ'' cos θ iR θ' 2 sin θ i + R θ'' sin θ j + R θ' 2 cos θ j


We treat the cart and the pendulum bob as point particles. Begin by drawing the free body diagram for the cart and writing expressions for the forces acting on them. Define the following parameters and forces:
  • N = normal force (from the track the cart is on)
  • T = tension in the rod
  • M = mass of cart
  • m = mass of pendulum
  • g = gravitational constant
  • d = cart friction constant
  • b = pendulum friction constant
  • k = spring stiffness
cart forces cart forces

pendulum forces
pendulum forces
Just by looking at the free-body diagram we can fairly easily figure out some of the forces on the cart. (The pendulum friction force is trickier, it's explained in the next section).
  • spring force = −k x i
  • normal force = N j
  • gravity = −M g j
  • tension in the rod = −T cos θ j + T sin θ i
  • cart friction = −d x' i
  • pendulum friction = bR θ' (cos θ i + sin θ j)

The forces on the pendulum bob are:
  • tension in the rod = T cos θ jT sin θ i
  • gravity = −m g j
  • pendulum friction = −bR θ' (cos θ i + sin θ j)

Torque Force from Pendulum Friction

torque force of pendulum friction
torque force of friction
We consider the torque from friction of the pendulum to be a vector perpendicular to the plane where the pendulum and cart move. That is, the torque is in the direction of the unit vector k which extends out of the plane. The magnitude of the torque is given by b θ' where θ' is the angular velocity. We can regard the force from the torque as being equivalent to a force applied at the end of the pendulum rod (see illustration). From Newton's Third Law (every action has an equal and opposite reaction) we know that the same force is applied at the other end of the rod, but in opposite direction.

A torque that is the result of a force F applied at the end of the rod R is given by the cross product R F = (Rx, Ry, 0) (Fx, Fy, 0) = (Rx FyRy Fx) k Here we are showing a 3-space vector as (x, y, z) which is the same as x i + y j + z k.   We regard the force F as being perpendicular to the rod, so that F = f (−Ry, Rx, 0) ⁄ R where f is the unknown magnitude of F and R is the length of R so that R = √(Rx2 + Ry2). The direction of F is chosen so that positive torque leads to increase in θ. Then the cross product becomes R F = (Rx FyRy Fx) k = f (Rx2 + Ry2) ⁄ R k = f R k Now we can find f: b θ' k = R F = f R k f = bR θ'
This result makes sense: consider that to produce a given amount of torque, you would need a stronger force applied at the end of a short rod, or a weaker force with a longer rod. The force is then given by F = f (−Ry, Rx, 0) ⁄ R = bR θ' (cos θ i + sin θ j) Note that R = R(sin θ, −cos θ, 0) which justifies part of the above equation. This torque force F is applied at the pendulum bob, and its opposite is applied at the cart.

Direct Method for Finding Equations of Motion

We add up the forces described above to find the net force on the cart F = N jM g jT cos θ j + T sin θ ik x id x' i + bR θ' (cos θ i + sin θ j) Now using Newton's law F = M a and the cart acceleration we found earlier, we have
   N jM g jT cos θ j + T sin θ ik x i + bR θ' (cos θ i + sin θ j) = M x'' i (1)
Adding the forces on the pendulum gives F = T cos θ jT sin θ im g jbR θ' (cos θ i + sin θ j) Using Newton's law F = m a and the pendulum acceleration we found earlier, we have
   T cos θ jT sin θ im g jbR θ' (cos θ i + sin θ j) = m(x'' i + R θ'' cos θ iR θ' 2 sin θ i + R θ'' sin θ j + R θ' 2 cos θ j) (2)

Now we can write the vector components of the above equations (1) and (2) as separate equations. This gives us 4 simultaneous equations.
   T sin θk xd x' + bR θ' cos θ = M x'' (3)
NM gT cos θ + bR θ' sin θ = 0
   T sin θbR θ' cos θ = m(x'' + R θ'' cos θR θ' 2 sin θ) (4)
   T cos θm gbR θ' sin θ = m(R θ'' sin θ + R θ' 2 cos θ) (5)
(We ignore the second of the four equations, but we could use it to find the unknown normal force N on the cart). Next do some algebraic manipulations to eliminate the unknown tension T. Adding together equations (3) and (4) and rearranging we get:
(M + m)x'' = m R θ' 2 sin θm R θ'' cos θk xd x' (6)
Multiply equation (5) by sin θ T sin θ cos θm g sin θbR θ' sin2 θ = m R θ'' sin2 θ + m R θ' 2sin θ cos θ Use equation (4) to replace T sin θ. bR θ' cos2 θm x'' cos θm R θ'' cos2θ + m R θ' 2sin θ cos θm g sin θbR θ' sin2 θ = m R θ'' sin2θ + m R θ' 2sin θ cos θ Using the trig identity cos2θ + sin2θ = 1 this simplifies to
bR θ' + m x'' cos θ + m R θ'' + m g sin θ = 0 (7)

Equations (6) and (7) are the equations of motion. We have two equations in the two variables x,θ and their derivatives. 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).

Indirect (Energy) Method for Finding Equations of Motion

The indirect method is based on the energy of the system. (A good textbook that covers this is Fundamentals of Applied Dynamics by James H. Williams Jr.   You will find the same "Mass and Plane Pendulum Dynamic System" discussed on page 234 of the 1996 edition.) Our first step is to find the Lagrangian of the system which is the kinetic energy minus the potential energy. L = TV
  • L = the Lagrangian
  • T = kinetic energy
  • V = potential energy
For the kinetic energy we need the velocity of the cart and pendulum, which we calculated earlier (see kinematics above). Kinetic energy is given by 12m v2. Note that we use the vector dot product to square a vector, v2 = v v. So we have T = 12 M (x' i)2 + 12 m (x' i + R θ' cos θ i + R θ' sin θ j)2 Applying the dot product rule to square the vectors we get T = 12 M x' 2 + 12 m ((x' + R θ' cos θ)2 + (R θ' sin θ)2)
There are two stores of potential energy in this system: the spring and the gravitational potential of the pendulum. Vspring = 12 k x2 Vgravity = m g height = m g(RR cos θ) So the Lagrangian for the system is L = M2 x' 2 + m2 (x' + R θ' cos θ)2 + m2 (R θ' sin θ)2k2 x2m g R(1 − cos θ)

Generalized Forces: Friction

To deal with the friction forces we calculate the amount of non-conservative work done by tiny movements in the variables. Note that we consider only non-conservative forces like friction here -- conservative forces like gravity or springs are handled by the potential energy calculations in the Lagrangian.

A tiny change of Δx in x results in an amount of non-conservative work from friction given by ΔW = −d x' Δx so we define the "generalized force" Wx = −d x' Similarly, a tiny change of Δθ in θ results in an amount of non-conservative work from friction ΔW = −b θ' Δθ, so we define another generalized force: WQ = −b θ'

Equations of Motion from Lagrangian

Next we will derive the equations of motion from Lagrange's Equation. For the x variable Lagrange's Equation is
   Wx = \frac{d}{dt} \left( \frac{\partial L}{\partial x'} \right) - \frac{\partial L}{\partial x} (8)
Note that x' and x are treated as separate variables when taking partial derivatives. Here are the partial derivatives:
L  = M x' + m(x' + R θ' cos θ)
L  = − k x
Taking the derivative with respect to time of \frac{\partial L}{\partial x'} and subtracting \frac{\partial L}{\partial x} equation (8) becomes d x' = M x'' + m x'' + m R θ'' cos θm R θ' 2 sin θ + k x which we can rearrange to be identical to equation (6) found above in the direct method: (M + m)x'' = m R θ' 2 sin θm R θ'' cos θk xd x'
For the θ variable Lagrange's Equation is
   WQ = \frac{d}{dt} \left( \frac{\partial L}{\partial \theta'} \right) - \frac{\partial L}{\partial \theta} (9)
Here are the partial derivatives:
L  = m(x' + R θ' cos θ)R cos θ + m θ' R2 sin2θ
L  = −m(x' + R θ' cos θ)R θ' sin θ + m R2 θ' 2sin θ cos θm g R sin θ
(Notice that we can factor out m R from each of these terms.) Taking the derivative with respect to time of \frac{\partial L}{\partial \theta'} and subtracting \frac{\partial L}{\partial \theta} equation (9) becomes b θ' = m R [(x'' + R θ'' cos θR θ' 2 sin θ)cos θθ' sin θ(x' + R θ' cos θ) + θ'' R sin2θ + 2 θ' 2R sin θ cos θ + (x' + R θ' cos θ)θ' sin θR θ' 2sin θ cos θ + g sin θ] After lots of cancellation and using the identity sin2θ + cos2θ = 1 this reduces to equation (7) from the direct method: bR θ' + m x'' cos θ + m R θ'' + m g sin θ = 0
Which technique do you like better, direct or indirect? It seems that the indirect method is the choice of professionals. It requires more calculus, but the calculations are a lot easier. Compare what was done here to the earlier calculations for frictional torque in the direct method. On the other hand, the direct method is necessary for figuring out the forces within the system, like the tension in the rod, or the normal force of the track on the cart.

Numerical Solution

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 f, g are functions to be determined. So we want to solve for each second derivative in terms of lower derivative variables. If you look back at equations (6) and (7), you can see that they need some manipulation to isolate the second derivatives over to the left hand side. After solving for θ'' and x'' (either by hand or with an algebra program like Mathematica) we get:
x'' =   m R θ' 2 sin θ + m g sin θ cos θk xd x' + bR θ' cos θ
M + m sin2θ
θ'' =   m R θ' 2 sin θ cos θ − (m+M)g sin θ + k x cos θ + d x' cos θ − (1 + Mm)bR θ'
R (M + m sin2θ)

If we define a couple of new variables, we can change this into four first-order equations (that is, four equations with only first derivatives).
  • v = velocity of cart
  • ω = angular velocity of pendulum
x' = v θ' = ω
v' =   m R ω2 sin θ + m g sin θ cos θk xd v + bR ω cos θ
M + m sin2θ
ω' =   m R ω2 sin θ cos θ − (m+M)g sin θ + k x cos θ + d v cos θ − (1 + Mm)bR ω
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.

MyPhysicsLab – Physics Simulation with Java

     Click on one of the physics simulations below... you'll see them animating in real time, and be able to interact with them by dragging objects or changing parameters like gravity. Get Java software if you don't already have it.
single spring
single spring
double spring
double spring
chaotic pendulum
chaotic pendulum
double pendulum
double pendulum
2D spring
2D spring
double 2D spring
double 2D spring
colliding blocks
colliding blocks
cart with pendulum
cart with pendulum
dangling stick
dangling stick
rigid body collisions
rigid body
sumo wrestling simulation
sumo wrestling
roller coaster
roller coaster

roller coaster with spring
roller coaster
with spring
roller coaster with 2 balls
roller coaster
with 2 balls
roller coaster with flight
roller coaster
with flight
molecule 2
molecule 2
molecule 3
molecule 3
molecule 4
molecule 4
molecule 5
molecule 5
molecule 6
molecule 6


ศัพท์วิทยาศาสตร์ ฉบับราชบัณฑิตสถาน

A  B  D  F  G  H  I  J  K  L  M  N  O  Q  R  S  T  U  V  W  X  Y 

                        ถ                                       อ   

นักวิทยาศาสตร    หน่วย      ศัพท์แผ่นดินไหวตัวอักษรจาก A-M   จาก N-Z

  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


หมวด :

| | | | | | | | | | | | | | | | | | | | | | | |

    ศัพท์เคมี    ศัพท์คณิตศาสตร์   ศัพท์ฟิสิกส์   

       บทความวิทยาศาสตร์      ศัพท์ชีววิทยา      สื่อการสอนฟิสิกส์      ศัพท์วิทยาศาสตร์    

พจนานุกรมเสียง 1   แมว    วัว 1    วัว 2    วัว 3    เหมียว   แกะ     พจนานุกรมภาพการ์ตูน

พจนานุกรมภาพเคลื่อนไหว   ดนตรี  Bullets แบบ JEWEL  พจนานุกรมภาพต่างๆ  ภาพเคลื่อนไหวของสัตว์ต่างๆ  โลกและอวกาศ




ฟิสิกส์ 1(ภาคกลศาสตร์) 

 ฟิสิกส์ 1 (ความร้อน)

ฟิสิกส์ 2 



เอกสารคำสอนฟิสิกส์ 1

ฟิสิกส์  2 (บรรยาย)

แก้ปัญหาฟิสิกส์ด้วยภาษา c  







เอกสารการสอน PDF




ตารางธาตุ(ไทย1)   2  (Eng)











 อะไรเอ่ย ?
















  การเรียนการสอนฟิสิกส์ 1  ผ่านทางอินเตอร์เน็ต

1. การวัด

2. เวกเตอร์

3.  การเคลื่อนที่แบบหนึ่งมิติ

4.  การเคลื่อนที่บนระนาบ

5.  กฎการเคลื่อนที่ของนิวตัน

6. การประยุกต์กฎการเคลื่อนที่ของนิวตัน

7.  งานและพลังงาน 

8.  การดลและโมเมนตัม

9.  การหมุน  

10.  สมดุลของวัตถุแข็งเกร็ง

11. การเคลื่อนที่แบบคาบ

12. ความยืดหยุ่น

13. กลศาสตร์ของไหล  

14. ปริมาณความร้อน และ กลไกการถ่ายโอนความร้อน

15. กฎข้อที่หนึ่งและสองของเทอร์โมไดนามิก 

16. คุณสมบัติเชิงโมเลกุลของสสาร

17.  คลื่น

18.การสั่น และคลื่นเสียง

   การเรียนการสอนฟิสิกส์ 2  ผ่านทางอินเตอร์เน็ต  

1. ไฟฟ้าสถิต

2.  สนามไฟฟ้า

3. ความกว้างของสายฟ้า 

4.  ตัวเก็บประจุและการต่อตัวต้านทาน 

5. ศักย์ไฟฟ้า

6. กระแสไฟฟ้า 

7. สนามแม่เหล็ก


9. ไฟฟ้ากระแสสลับ 

10. ทรานซิสเตอร์ 

11. สนามแม่เหล็กไฟฟ้าและเสาอากาศ 

12. แสงและการมองเห็น

13. ทฤษฎีสัมพัทธภาพ

14. กลศาสตร์ควอนตัม

15. โครงสร้างของอะตอม

16. นิวเคลียร์ 

   การเรียนการสอนฟิสิกส์ทั่วไป  ผ่านทางอินเตอร์เน็ต

1. จลศาสตร์ ( kinematic)

   2. จลพลศาสตร์ (kinetics) 

3. งานและโมเมนตัม

4. ซิมเปิลฮาร์โมนิก คลื่น และเสียง

5.  ของไหลกับความร้อน


7. แม่เหล็กไฟฟ้า 

8.    คลื่นแม่เหล็กไฟฟ้ากับแสง

9.  ทฤษฎีสัมพัทธภาพ อะตอม และนิวเคลียร์