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: 

how do I make the VI as fast as the sub VI?

Solved!
Go to solution

I am trying/learning to build larger VIs from subVI's but, I noticed a tricky problem...I am losing all my speed!!!  One VI "DC voltmeter..." measures voltage, and the other "voltage reader.." uses it as a subVI to measure voltage and then do a simple multiplication operation on the measured voltage.  Why is the larger VI SO MUCH SLOWER??  It's a LOT slower than the simpler vi.  Why is the "voltage reader" so much slower than the "DC voltmeter"?  How can I structure it so I don't lose so much execution speed???

 

If I put the WHILE Loop on the DC voltmeter, as shown in the third listed VI, the data stream is very rapid.  Where is the speed going when you convert it to a subVI?  Am I wiring these things correctly?

 

Thanks,

Dave

0 Kudos
Message 1 of 6
(2,470 Views)

There is overhead when creating the task and setting the sampling rate. That's why your subVI is slower.You need to create your DAQ task and set the sampling rate in it's own SubVI outside your while loop, then enter your loop and do the DAQ read only. When the loop terminates, then call the DAQ Clear Task. 

0 Kudos
Message 2 of 6
(2,460 Views)

Hi Thanks, but, isn't what you are describing the original vi titled "DC voltmeter (DAQmx) FORUM_nov 25.vi"  This vi goes superfast!

 

I thought that creating the component vi's and then connecting them  together would make editing the overall vi easier than creating all the code as a single vi.  I could easily configure the components as you suggest, but, then I wouldn't be using vi's.  Or, are you suggesting to highlight the code outside the WHILE loop and making that the subVI, instead of importing an entire finished vi from the functions pallette, ..:Select VI'?

 

What is the correct way to implement small vi's to build big vi's?

 

Dave

0 Kudos
Message 3 of 6
(2,418 Views)

Sorry about the weird yellow snarly face above...I don't know how it got there!  HIt some magic key and didn't notice.

Dave

0 Kudos
Message 4 of 6
(2,417 Views)
Solution
Accepted by dav2010

dav2010 wrote:

What is the correct way to implement small vi's to build big vi's?


For DAQ tasks like this, I like to have a single VI that sets up the task (adds channels, setup timing, etc.).  So you are correct in that everything before the while loop is a good canidate to be a subVI.

 

A more general answer, anything that is a simple, logical block of code should probably be a subVI.  This is especially true if you find that you are duplicating code (turn it into a subVI instead of duplicating).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 6
(2,405 Views)

@dav2010 wrote:

Sorry about the weird yellow snarly face above...I don't know how it got there!  HIt some magic key and didn't notice.

Dave



Go to your Profile and My Settings.  Go to the Preferences Tab then Display.   For Emoticons, choose None rather than Use Default (Smiley) or any of the other ones.

 

That will prevent certain key combinations such as 😛 (colon P) or 😄 (colon D) from showing up as emoticons.  You had typed colon-S, so that looks like the Smiley Frustrated icon for anyone who didn't fix that setting within their profile.

0 Kudos
Message 6 of 6
(2,396 Views)