LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to speed up my VI?

Hi Everybody,

 

I have done a program in order to get the minimum intensity and its corresponding voltage, but I don't know why the while loop runs so slow. The signal's frequency is 10Hz but the while loop seems run much slower than that, and also the array of voltage and intensity do not generated synchronous. Could anyone help me to speed up the code and synchronous the two array? Thanks a lot.

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

@cun wrote:

Hi Everybody,

 

I have done a program in order to get the minimum intensity and its corresponding voltage, but I don't know why the while loop runs so slow. The signal's frequency is 10Hz but the while loop seems run much slower than that, and also the array of voltage and intensity do not generated synchronous. Could anyone help me to speed up the code and synchronous the two array? Thanks a lot.


Cun,

 

You haven't included the subvi's as part of your attachment, probably best to zip them up and use a project or library structure.

 

Try using the probes to see where exactly your program is slowing down.

 

Strokes

0 Kudos
Message 2 of 8
(3,226 Views)

Also, please disclose how your DAQmx Task is configured, # of samples, sample rate, # of channels, etc.

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

Well, there are a number of problems, even discounting anything in your subVIs causing trouble.

 

Your while loop(s) are sucking up every nanosecond of CPU time, not letting anything from the outside get in. Putting a delay of even 1 ms will help that, and may let you get your stop button press noticed. At the moment, your loop will refresh when you write to the serial port, read from the serial port, read the DAQ, or refresh your graph, whichever takes the longest time.

 

There is no reason that your Intensity and Voltage readings should be synchronized. They are coming from two different sources, each with their own timing characteristics.

 

You write to the serial port and then read immediately (perhaps even before you write, since there is nothing to ensure that the write happens first), without even checking to see if there are any bytes available. This can easily cause a "delay" in your data, since the data present at the port may (will almost certainly) be the result of one or more commands you sent out in previous iterations of the loop. An error wire going through these (and other functions) will help make things sequential (and let you know where things go wrong).

 

And lastly (at least from a quick look), you've got a lot of indicators which are refreshed every run-through, particularly your chart, which would have to be completely rewritten on each iteration. You just might not even be able to get 10 Hz speed on even just a constant FP refresh.

 

Good luck,

 

Cameron

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 4 of 8
(3,211 Views)

Sorry for that, here they are.

Download All
0 Kudos
Message 5 of 8
(3,200 Views)

And also another one here.

0 Kudos
Message 6 of 8
(3,196 Views)

You didn't wire the "Wait for Data Timeout (msec)" on the Serial read, thus it's going to use the default value of 500ms. That's will greatly slow down your loop settings.

 

Other monir things others have already mentioned.

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

0 Kudos
Message 7 of 8
(3,192 Views)

Oh, I see. That is really helpful. Thanks a lot!

 

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