Seth on Simulink

October 9th, 2008

Challenge: Metronome and Cart Equations of Motion

I haven’t seen much activity on the Metronome Synchronization Challenge, so I want to provide a peak at the basis for my solution.  I took the approach of modeling a pendulum, and then linking its dynamics to the dynamics of a cart.  The challenge is choosing the right coordinate systems to assign to each of these bodies, even though they move together.

The Pendulum

If the pendulum was all by itself, we could describe its motion by modeling the angle, , as it deflects from vertical.  The only force on the pendulum bob is gravity.  Because the pendulum is constrained to rotation about the pivot point, we only need the component of gravity in pendulum frame of reference.

Pendulum forces due to gravity 

If we incorporate the motion of the cart, we find the linking of the acceleration of the cart to the acceleration of the pendulum bob.  If the cart is accelerating, the reference frame of the pendulum accelerates, and this means that the pendulum will experience an opposite force/acceleration.

Accelerations of a cart on the pendulum

Combining these two ideas in the  frame centered on the pendulum pivot, we can write the pendulum equation of motion.

Momentum in the system

To understand the acceleration of the cart, I want to look at the change in the  component of the momentum.  Here are some definitions:

Length of the pendulum:        
Mass of the pendulum bob: 

Mass of the cart:                      

The momentum of the pendulum bob in the  direction

The momentum of the cart is

The friction of the cart on the surface is the only resistance I want to model in the system, and we can describe this force as proportional to the velocity, . This represents of the change of momentum.

Combine these terms to describe the momentum in the  direction.

Up to this point, I have looked at the problem of a single pendulum on a cart.  Adding another pendulum is just another momentum term, and to keep track of the pendulums we will introduce  and  .

Taking the derivative of this equation gives us the acceleration of the cart:

System Equations

This equation for the cart, along with the dynamics of the pendulum provides the equations of motion for the system.  Rewriting these as the highest order derivatives gives us something we can create in Simulink.

Are you up to the challenge?

Can you modify the model I provided in my last post to implement these equations?  Post your solution by October 15th to the File Exchange with the keyword metronome.

3 Responses to “Challenge: Metronome and Cart Equations of Motion”

  1. ABindemann replied on :

    Hmmm, is a simple pendulum an appropriate mechanical model for a metronome? What you’ve modeled is a vertically hanging, gravity stabilized pendulum rather than a spring stabilized inverted pendulum. Based on your approach you should “flipud” your metronome scope ;-)

  2. Seth replied on :

    @ABindermann - you are right… I should flip the metronome scope. Is this an appropriate mechanical model for a metronome? I have played around with a version using an inverted representation and a spring to stabilize it, and I didn’t see much difference in the behavior. The other experiment I tried was adding friction to the metronome and an energy reserve to kick the pendulum back. I found all of this made things more complicated without much benefit.

    This is the metronome I was thinking about as I approached the problem:

  3. Thomas Steffen replied on :

    I have uploaded a file, but it will take a while to appear. I think the synchronisation will not work with a purely linear model, because that will produce several resonance frequencies. I modelled the driving force of the metronome, and that did the trick.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Seth Popinchalk is an Application Engineer for The MathWorks. He writes here about Simulink and other MathWorks tools used in Model-Based Design.
  • Mohamamd: Hi Suth, I try to simulate a load tap-changing transformer in simulink but its control part has to be...
  • Han Geerligs: Hello Guy, thanks for the clarificaton and link. However in the documentation I am missing the...
  • Guy: @Han, you probably already know, but I think it is good to share with everyone. To zoom in use the key...
  • Han Geerligs: Hi Seth, Once again I’d like to point out that my biggest accelerator is using mouse and keyboard...
  • XaL: Hi, thanks for the tips. As someone wrote in http://blogs.mathwor ks.com/seth/2009/03/ 13/new-%C2%A0rele...
  • Uba osy: Hi, in the introductory example for fuzzy logic toolbox it was noted that using non fuzzy means, you could...
  • Prashant: How can I have same example but instead AC(1 to 10V 50 or 60Hz) and DC(0.5 to 10 V) then adding AC+DC but...
  • adrian chavarro: Great tool, for educational and sicentific, simulation. I would like to know where can i place a...
  • Ashish Sadanandan: @wei, I was talking about the case where the compiler would perform the ‘model_Xdim...
  • wei: @Ashish, I agree with your observation on compiler optimization but fail to see why Han’s code would be...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.