LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What possible solutions are there for making a loop run faster?

Hi Guys,

 

I am a Labview 8.5 user, and am fairly new to the program. My project is to create a multichannel analyzer using Labview, interfacing with a digital oscilloscope.

I have achieved this but the trouble is that the histogram is very slow.

What i have done is acquired the waveform from the oscilloscope and performed an amplitude measurement on the waveform, i have then created a histogram that bins all these voltage measurements. All three of these steps have been placed in the same while loop.

It behaves properly it just seems as though the iterations for the loop run a lot slower than they should.

 

Would anyone have any suggestions on how i could make it run faster?

 

Thanks in advance. 

0 Kudos
Message 1 of 12
(4,720 Views)

Hi there

 

There's an almost endless number of possible reasons why your loop seems to be too slow.

 

First of all: Check the specification of your  oscilloscope to see what is technically possible.

 

Make sure to initialize your hardware only once, right befor you enter the loop and close the hardware only once, right after the loop.

 

You may want to search the driver database at ni.com for an existing LabVIEW driver of your oscilloscope.

 

And after all: Post some code (zipped) for us, than we can have a closer look (like i said, there are lots of possible reasons)

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 2 of 12
(4,702 Views)

joel17 wrote:

Would anyone have any suggestions on how i could make it run faster?


Sure, if you show us your code we might be able to suggest improvements.. 😄

 

  • Where is the slowdown?
  • How fast does the histogram parts execute with synthetic data?
  •  How fast does the DAQ parts run if you skip the histogram processing?
  • What is the CPU load during run?
  • What determines the loop time?
  • How many points do you graph and how often does the graph get updated?
Message 3 of 12
(4,695 Views)

Hello again,

Sorry for the late reply. I may have found a solution to my problem, but now i dont think my VI is performing as it should.

I changed my type of measurement from an amplitude measurement to a peak detect and now the histogram updates much faster, although the spectrum i obtain is not what it should be. I have attatched both my original and updated code.

Any assistance would be greatly appreciated.

 

Thanks for you patience.

Joel 

Download All
0 Kudos
Message 4 of 12
(4,641 Views)

Hi Joel,
 
Looks like you have done a lot of work for this VI. You say your spectrum (I assume your histogram) is incorrect; what exactly is wrong with it? Did it produce results that you agreed with before you made your changes? In order to help debug your code, I strongly suggest using subVIs to clean up your block diagrams. Take a look at the LabVIEW help found here: https://www.ni.com/docs/en-US/bundle/labview/page/creating-subvis-from-sections-of-a-vi.html. Ae you still concerned with your loop times, because there is a lot to be said on how to alter your code to impove performance.

 

Joshua B.
National Instruments
0 Kudos
Message 5 of 12
(4,579 Views)

 

Hi Joshua,

 

You are correct in assuming i meant my histogram. In the 'histogram part original.zip' VI the histogram that i obtain is one that I expect. It is an energy spectrum from a Sodium 22 radiation source. The other VI does not obtain the correct spectrum but behaves a lot quicker. I believe it is the original VI that i must work on in order to make it run faster. Thankyou for the link, I will check it out now to try and clean the VI up as you suggest.

 

Thanks for your reply,

 

Joel 

0 Kudos
Message 6 of 12
(4,521 Views)
You might consider restructuring you code so that you can move the Write to File or Histogram VIs outside the while loop. Also, if you don't use Express VIs but use the Write to Text/Binary/TDMS File equivalents or General Histogram VI you could increase you loop speed. Scrutinize your VISA code to make sure all the steps that you have included in the while loop are completely necessary each time the loop executes (I don't know your equipment, so if the code works and isn't broken...)
Message Edited by Joshua B. on 01-28-2009 12:06 AM
Joshua B.
National Instruments
0 Kudos
Message 7 of 12
(4,478 Views)

Since I can't stress the basics enough...the How can I Learn LabVIEW page has great tutorials on the basics of dataflow programming and the File I/O VIs amoung other things. Since you seem to have done a lot already, you are probably OK, but it never hurts to show the link off to others: http://www.ni.com/academic/lv_training/how_learn_lv.htm .

 

Message Edited by Joshua B. on 01-28-2009 12:14 AM
Joshua B.
National Instruments
0 Kudos
Message 8 of 12
(4,476 Views)

 

Thanks for the suggestions.  I will give them a go and hopefully the speed of the iterations increases. I am still fairly new to LabView so the link was very helpful. All your help has been greatly appreciated.

 

Joel 

0 Kudos
Message 9 of 12
(4,443 Views)

Hello again,

 

I spent my day today trying your suggestions and although they did make the loop run a bit faster unfortunately it was not to the extent that I need. It is currently taking the VI about an hour to obtain a statistically sufficient spectrum when I need to take about 5 minutes.

The instrument I am reading from is a Tektronix MSO 4104 Mixed Signal Oscilloscope and i have downloaded the driver from the link below...

 

 http://sine.ni.com/apps/utf8/niid_web_display.model_page?p_model_id=11631

 

I think the problem may be the amplitude measurement I am using. Is there any way to make the measurement quicker? I tried placing the amplitude measurement in a for loop within the stacked sequence, although this just increased the number of counts for the same measurement in the histogram rather than making more measurements.

 

Thanks again

Joel 

0 Kudos
Message 10 of 12
(4,425 Views)