LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic simulation loop question

Hi. I've been searching this board for quite some time, but couldn't find what I'm really looking for.

 

I'm an absolute beginner when it comes to Labview. I'm working on a school project that includes controlling the pneumatic actuated inverted pendulum via Labview 2011 and cRIO9074, and I'm having trouble understanding all of the parameters in the simulation loop that grant real time simulation. What really bothers me are three parameters and their correlation: scan period (scan engine properties), step size and period (simulation properties). Right now I've achieved real time simulation with this parameters: scan period (10ms), step size (0.01ms), period (1(I don't know what unit)). When I try to change scan period to 5ms, the whole simulation speeds up twice ("simulation time" function displays 2s for every 1 second that passes in real time. 

 

So can someone please explain these parameters in normal words (context help is confusing) and how to achieve real time simulation for desired sampling time?

 

Thanks in advance! 

0 Kudos
Message 1 of 8
(3,665 Views)

fellow newbie here.. i find it helps to post screendumps of what you have and/ or rudimentry flowcharts of what your tring to achieve.

0 Kudos
Message 2 of 8
(3,662 Views)

There's more extensive help than the context help. Even from the context help, you can click "detailed help" to get to LabVIEW's help file. Did you look through this material? Here are a few tips:

 

  • for real-time, only use a fixed step solver (RK1-4)
  • choose the step size you desire, then select the "1 kHZ" or "1 MHz" clock. Select "Auto Period" and then you don't have to worry about calculating the period.

 

Step size determines how much time is added to the simulation time every time the diagram executes. Period determines how many ticks of the hardware clock pass between every execution of the sim loop. If you want "real time" which implies that the simulation time passes at the same rate as actual time, then the "Auto Period" option will look at your step size, look at the clock you've selected, and automatically calculate the period required to run at real time.

 

As stated in the help context, the unit of period depends on the clock you've selected. If you've selected a 1 kHZ clock, there are 1000 clock ticks per second and the unit of period (each clock tick) is 1 ms. If you select the 1 MHZ clock, there are 1,000,000 clock ticks per second so the unit of period is 1 us.

 

Say you select the 1 kHZ clock and choose a period of 15. This means the simulation loop will execute once every 15 ms of actual time. If you want real-time, you should set the step size to 15 ms. This would cause the simulation time to advance at the same rate as actual time. If you set the step size to 30 ms, the simulation time will run twice as fast as actual time.

 

I don't know anything about scan period; that is not a simulation parameter. Hope this helps, and good luck.

Message 3 of 8
(3,648 Views)

I came back to this project after some time, and I'm still confused about those parameters. Thanks for that explanation, but it's not quite what I'm looking for.

 

I'm doing a real-time project via cRIO9074 and I set up my Simulation Loop to synchronize to timing source. Now, the timing source is not 1kHz clock, it's synchronized to scan engine. I can acess "scan engine" under cRIO9074  properties in project tree and I set it up to 5ms. Trouble is, I don't know how to set up the rest (step size and period under simulation parameters) to achieve real time execution.

 

I've seen people using Timed Loop which offers the same "synchronize to scan engine" option without "unnecessary" (for me) "step size" and "period" option, but I have to use Simulation Loop.

 

Any help is welcomed.

0 Kudos
Message 4 of 8
(3,588 Views)

Anyone? This is really important.

0 Kudos
Message 5 of 8
(3,551 Views)

Sljiva,

 

I just want to make sure you're using the Control Design and Simulation Module. By simulation loop you are referring to the Control and Simulation Loop? 

 

Here is the detailed help for the parameters of the Control and Simulation Loop. 

http://zone.ni.com/reference/en-XX/help/371894E-01/lvsim/sim_configparams/

 

Kyle Hartley
Senior Embedded Software Engineer

0 Kudos
Message 6 of 8
(3,526 Views)

Yes, I'm using Control and Simulation Loop.

0 Kudos
Message 7 of 8
(3,511 Views)

Hi sljiva,

 

It might be helpful if you post some screenshots of your existing code.  That would help us better understand your application and question.  Thanks!

Michael B.
Applications Engineer
0 Kudos
Message 8 of 8
(3,485 Views)