LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem when running several blocks of function together

Solved!
Go to solution

Hi,

 

I build quite a large system/function using LabVIEW. Therefore, for a convenient and to make it look tidy, I create a VI blocks to separate and combine some function together. But, my problem is when I did that, the simulation seems to run really slow and the the results are different compared when I had the whole system/function under one block.

 

For your information, each VI blocks that I created has a control and simulation loop. When I connected all of them together, I put all of them in another control and simulation loop as some function that I use to connect them together could not be used without the loop.

 

I was wondering, if having a control and simulation loop at each blocks actually contribute to this problems as each loop will run depends on the number of time I set to the loop.

 

If there any method to avoid this from happening? My system/function looks terribly messy and it will be hard for me to present it later at the end of my project.

 

 

Thanks.

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

tebu,

 

Hello! When you say "control and simulation loop" are you referring to an item from the Control Design and Simulation Module or just loops you are calling "control" and "simulation"?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ben Sisney
FlexRIO V&V Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 Kudos
Message 2 of 8
(3,512 Views)

yeap.. i was refering to an item from the Control Design and Simulation Module

0 Kudos
Message 3 of 8
(3,510 Views)

Hello,

 

Do you have any simple pieces of code that reproduces the issue? It sounds as though before using subVIs, you had a single simulation loop but now you have simulation loops within the subVIs and the subVIs are within a simulation loop as well. Is this correct?

 

-Zach

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

yeap. thats is my problem.

 

i'll try to come out with a simple VI file for you to have a look at it. sorry for a late reply.

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

Hi,

 

Attached are the simple block I created to show the problem I'm having.

 

1) Test1.vi is the example of the current arrangement I had for my project where I put all the function in the same block diagram which return make my block diagram look messy with too many function laying arounf.

 

2) Test2(block).vi is where I group some of the function in Test1.vi into a new VI file which I could then called in other VI.

 

3) Test3.vi is basically the same with Test1.vi except I replaced the function that I'd group previously with Test2(block).vi.

 

 

I was expecting the same result when I input value (let say 10), but the result in Test1.vi and Test3.vi is slightly different (in Test1.vi, the final curve starts ~4.75 whereares at Test3.vi the final curve starts at ~5.75)

 

I think it is due to the loop that I'm using but couldnt figure out how to overcome this problem (I need the loop as some function that I'm using could not be use without it). Appriciate if someone could help me to solve this and able me to group the function so that my diagram look tidier.

 

 

Thank you.

Download All
0 Kudos
Message 6 of 8
(3,417 Views)
Solution
Accepted by topic author tebu

Hello,

 

I believe what you are looking to accomplish is to use the simulation subsystem functionality. This allows functions to run outside of a simulation loop so that you can create a subVI. Once you select all the functions in your simulation loop that you would like to be in a subVI, select Edit»Create Simulation Subsystem. Let me know if that helps!

 

Also, here is some more information for that: https://www.ni.com/docs/en-US/bundle/labview-control-design-and-simulation-module/page/lvsimhowto/si...

 

-Zach

Message 7 of 8
(3,398 Views)

Superb! It works!

0 Kudos
Message 8 of 8
(3,355 Views)