From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

why is my control simulation so slow?

Hi,

 

would anyone know why my control model simulation is so slow? I put an indicator of the current iteration of the control modelling loop and it takes a very long time to iterate. I've attached my simulation to this post. 

 

Thanks

0 Kudos
Message 1 of 5
(2,699 Views)

You have a Simulation Loop inside a while loop where you run the simulation for 10 s before getting the results in the graph. Since you place the Graph out side the loop, you will only see the output of the whole simulation (the 10 s) which takes sometime.

 

It looks like you want to see and interact with your simulation every timestep and, in this case, your code in incorrect. The simulation loop is all that you need to 'loop' and interact every timestep. To do that, you can change the final timestep to be "inf" and use the function "Utility >> Halt Simulation" to define when you want to stop. Also, you would need to use 'SimTime Waveform" to see the graphs as it runs.

 

Also, notice that the functions "CD Draw Transfer Function Equation.vi" can consume sometime if you run those in a loop. In general, if you don't want to update every timestep, you should just run once or run in a slower timerate, like every 2 s.

 

 

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 2 of 5
(2,669 Views)

Hi, i  made an PID controller in simulation loop, the time simulation is 30s, first i read the mesurement from a text file, then i calculate the error, after that i use the PID controller. the results are as expected but the simulation time runs to slow.( every text file contains 30000 value (one value for every 1 ms))

0 Kudos
Message 3 of 5
(2,395 Views)

Hey Omar,

 

This post is back from 2011, please make a new Service Request for increased visibility.

 

A few things that would be slowing down your code:

  • Write To Measurement File is inside the loop. Consider placing this outside the While Loop, or using the Write Delimited Spreadsheet VI in the loop
  • You also have 7 Read Delimited Spreadsheet functions in the loop. This will open up 7 different files per loop iteration. Consider placing this before the loop.

Bdog

0 Kudos
Message 4 of 5
(2,356 Views)

you are right the file mesurement slowed down the loop thanks a lot

0 Kudos
Message 5 of 5
(2,345 Views)