LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control simulation loop vs. Traditional while loop

Dear

 

Spoiler
 

 

I really confuse about the difference between control simulation loop and traditional while loop 

 

 

their is no an information about such difference in NI web or user guide 

 

The labview Control and Simulation Module contains a block diagram  for simulation of linear and nonlinear continuous-time and discrete-time dynamic systems

 

but also we can use  traditional while loop  for simulation of linear and nonlinear continuous-time and discrete-time dynamic system 

 

 

 

so what are the difference ??

is my information for  traditional while loop  is wrong ???

 please for any member can list his difference as he see to see all possible differences 

 

while.jpg

 

 

 

thank in advance

best regards

  

hi ?Q>

0 Kudos
Message 1 of 4
(4,568 Views)

mangood,

 

The While Loop is LabVIEW is used to just 'repeat' the operation inside the loop until the boolean is change to ON. It does not have notion of time or, the most important, it does not have a solver unless if you code this up. You can use 'wait until next ms' to enforce time and, then, you can try to do integration by any method obtained in text book.

 

Now, the Control and Simulation loop was designed to solve nonlinear equations. It has a 'solver' under the hood that evaluate the expressions inside the loop. It also has notion of time and it keep track of several states. Also, it allows the signal flow feedback where this would be a broken wire in LabVIEW dataflow. (http://zone.ni.com/reference/en-XX/help/371894G-01/lvsim/sim_simulation_loop/). One more thing: if you are using simulation functions (from the Simulation Palette), most of those functions can only be dropped inside the SIM loop.

 

So, in general, if you do not have any Simulation function (like the integrator) or you don't need to solvers, you should just use the for loop. We have several examples in PID and Fuzzy Logic that don't require the simulation loop since they are solved by using simple discrete time-steps and we used pure LabVIEW code for doing simulation. However, as you start to get more complex system, you will notice that discrete time-steps could not be good enough to solve complex plants, so then you would need to model and use the Control and Simulation loop.

 

Hope this helps to clarify,

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 2 of 4
(4,523 Views)

One more thing... you information about While loop is not incorrect, but it would need a lot of coding to make this simulation to work (you have to develop your own solver). The Control and Simulation loop help you to have this coded for you and you can just focus on the nonlinear equation to be solved.

 

Of course, this is true if you are not using the Single-stepping subsystem. In the mode, we allow you to drop the Subsystem into a simple while, for loop or Timed-loop and we would script the solver 'under the hood' for you. The major difference in this mode is that you only allow you to use "fixed step size" solver. Here is the documentation:

 

http://zone.ni.com/reference/en-XX/help/371894G-01/lvsimconcepts/sim_c_subsys/#Running_a_Subsystem_i...

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 3 of 4
(4,522 Views)

@Barp wrote:

One more thing... you information about While loop is not incorrect, but it would need a lot of coding to make this simulation to work (you have to develop your own solver). The Control and Simulation loop help you to have this coded for you and you can just focus on the nonlinear equation to be solved.

 

Of course, this is true if you are not using the Single-stepping subsystem. In the mode, we allow you to drop the Subsystem into a simple while, for loop or Timed-loop and we would script the solver 'under the hood' for you. The major difference in this mode is that you only allow you to use "fixed step size" solver. Here is the documentation:

 

http://zone.ni.com/reference/en-XX/help/371894G-01/lvsimconcepts/sim_c_subsys/#Running_a_Subsystem_i...


thank you barp

 

i note the second differnce between the loops is the feedback node as shown below

where thier is no feedback node in simulation loop if wire feedbacked to input

feedbacknode.png

 

hi ?Q>

0 Kudos
Message 4 of 4
(4,466 Views)