LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simulating a 2nd-order pendulum system

Solved!
Go to solution

I know there are lots of forum posts about 2nd-order solvers, but I can't seem to find one that I can apply to my particular problem.

 

I'm developing a software model of a pendulum attached to a movable (along one axis) support.  My end goal is to simulate the pendulum's response - given a set of initial conditions - following an impulse to the support.

 

The ODE has the form:                  Θ"(t) + x''(t)*cos[Θ(t)] + sin[Θ(t)] = 0

 

where x(t) is a function independent of Θ.

 

I've been playing around with the ODE Solver.vi and a few of the model construction VIs in the Control Design & Sim toolkit.  I've made a few disparate bits of progress, but I can't see a clearly-defined end in sight.  Any input would be appreciated.

 

Cheers,

0 Kudos
Message 1 of 6
(4,720 Views)

hello theflyingmountaineer, 

 

You stated that you have tried a few things like the ODE Solver.vi and the Control Design & Sim toolkit. Can you describe what you have tried and if you have some specific purpose for using these tools I'd love to try and accomidate that. 

 

 

I believe that if you break your 2nd order ODE into 2 first order ODE's there are a variety of way that you can solve the equation. Here is an article that explains why I am talking about.

http://zone.ni.com/reference/en-XX/help/371361J-01/lvanlsconcepts/solving_odes/

 

 

and here is a document that shows the different solvers in LabVIEW

http://zone.ni.com/reference/en-XX/help/371361J-01/lvanlsconcepts/ode_solvers_in_labview/

Ryan
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(4,689 Views)

Hello

 

Have you seen this shipping example?

 

C:\Program Files (x86)\National Instruments\LabVIEW 2012\examples\Control and Simulation\Case Studies\Nonlinear\Pendulum\SimEx Nonlinear and Linear Pendulum Simulation.vi

 

It describes how to obtain a nonlinear simulation of the pendulum using LabVIEW ODE Solver and the Contro and Simulation Loop and, also, gives you how to define the linear simulation using the Control Design functions and the linearization functions of Simulation.

 

Notice that this example was added in 2012. Hope this helps...

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 3 of 6
(4,677 Views)
Solution
Accepted by topic author theflyingmtneer

Thanks, Barp.  That example is actually where I got the most useful information about addressing this problem.  Unfortunately I didn't find it until after I posted..... I've always been terrible about using the Example Finder Smiley Embarassed

 

I accomplished most of what I was after by following the example's paradigm of creating a subsystem representative of the 2nd-order equation and passing parameters to it inside of a simulation loop.  Below is the pendulum subsystem along with the equation it represents.  As far as I can tell, feedback conditions are handled automatically in simulations as it was unnecessary for me to place feedback nodes in the wires.

 

 

2nd-Order Subsystem

 

Here is the implementation inside the simulation loop:

 

Implementation in a Control & Simulation Loop

 

The waveform chart is plotting the stimulus and response signals of the subsystem.

 

The little piece of code at the beginning (Iteration Counter) was my implementation of an iteration counter.  The simulation loops are a strange beast and I had to figure out a way to step through my stimulus array inside the loop.  Using the Simulation Time function and step size parameter, one is able to track the current "iteration" of the simulation loop.

 

This is also my first time really delving into the features of the CDS toolkit, and I found the 3-hour ppt course (http://www.ni.com/white-paper/5855/en) very helpful.

Download All
0 Kudos
Message 4 of 6
(4,670 Views)

On the index part of the array, you should use the 'indexer' function. It will do the indexing of the array taking into account time and the variable step size. This example would help you understand how to use the Indexer:

 

C:\Program Files (x86)\National Instruments\LabVIEW 2012\examples\Control and Simulation\Simulation\Utilities\SimEx indexer.vi

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 5 of 6
(4,664 Views)

Nice!!  Thank you!

0 Kudos
Message 6 of 6
(4,662 Views)