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: 

for loop time

One more thing to note is, your time calculation based on the oscillations and the period/frequncy has little to do with execution time of your overall vi. After your signal is generated, the for loop is running for 25000 times, and even though I don't think there are any complicated operations going on inside the loop, execution is still going to take the time based on the configuration of your machine. As  



------------------------------------------------------------------------------------------------------
Kudos are (always) welcome for the good post. 🙂
Message 11 of 17
(738 Views)

If you convert the Express VI to a regular VI by way of the right click menu, you can see what it going on inside.

 

Here is a copy of the VI profiler, and you can see the lower level subElapsedTime.vi is taking most of the time.  But I have no idea why.

Message 12 of 17
(734 Views)

Hi,

 

I had a look at your code now.

I think that the "build graph express VI's" are probably really slow.

I would recommend you to take those out of the loop..

If you want to have an indicator in the loop you should work with a chart, because charts are made to update quickly.

 

Take a look at this example from the community:

https://decibel.ni.com/content/docs/DOC-21714

 

There's also an in built tool "Performance and Memory Tool", which can help you to find parts in your code that are slow.

tools/profile/performance and memory..

 

Hope you're getting ahead!

 

regards,

adigator

Message 13 of 17
(718 Views)

Hi,

 

This finishes in 2-4 ms..

 

cheers

adigator

Message 14 of 17
(716 Views)

Hi,

 

replacing the mathscript node, moving all constant operations outside the loop, using the wveform more "natural" could result in this:

check.png

 

Btw.:

Did you ever check your formulas in the mathscript node?

check2.png

quotient = YS * nwaves / YS * npoints = nwaves*npoints !!! Simple pure math...

 

Your main problems are those repetitive re-calculation of constant values in the mathscript node.

Additionally displaying numbers in indicators takes time. Building graphs, that are never displayed, takes time. Building graphs in a loop generally takes time.

 

I didn't include your "if i==N-1" statement in my code. It's easy to do with a simple ReplaceArraySubset function - that's up to you!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 15 of 17
(713 Views)

First of all, thank you very much guys/ladies for all your help!

 

I have tried your codes, odessy and adigator, and they are much faster, but when I have connected the output to an oscilloscope, I had two problems that i already had with my code:

 

-frequency is not 80Hz ( something around 5Hz)

-frequency is not constant ( some oscilletions are slightly faster than others)

 

I really can't understand this. It might be from the code, or from the way I've sent the output to the oscilloscope. I have used daq-assistant>generate signal/analog output, and one sample on demand, placing the daq in the for loop, so I would obtain the Vx in each iteration. Is it a lame way to do this?

 

I'm sure everything would be easier without the for loop, but I do need to check the Vx voltage, so when it is in certain intervals the pockel cell will be "on" or off.

 

again, thank you very much for all your help

 

0 Kudos
Message 16 of 17
(690 Views)

Hi,

 

This is probably due to the way you write the analog output.

 

DAQ-Assistant executes some low-level code everytime you call it.

In your example, with one-sample mode, the DAQ-Assistant will always create a task, write one sample and clear the task in the loop.

This needs time and leads to your slow program.

 

Try to only do in loops what needs to be done in loops!

Create the task before the loop, write the samples in the loop, and clear the task after the loop.

 

Hope this helps,

regards

adigator

 

Message 17 of 17
(655 Views)