LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timing

Hello, I am fairly new to labview and am having trouble minimizing the timing for a complete cycle of my program. I am using the PCI-6251 for relay testing and would like to reduce the test cyle period. I have narrowed down the main timing issue to be one of the SubVIs in my main program. Currently one cycle of this subVI will complete in approx. 30-35ms. I have attached the VI if it helps. Any suggestions for the structure or a different way to implement the tasks would be helpful. Thank you.
0 Kudos
Message 1 of 6
(2,658 Views)
30-35 msec or 30-35 seconds? I find it difficult to believe that the VI you posted takes only 30-35 msec to run.

Since you did not post any of the subVIs, without access to the subVIs it's impossible to tell if one of these can be improved in terms of speed. However, you can make some general coding improvements:
  • It seems that all your subVIs have the error in/error out clusters. Thus, you can simply wire them in a row and completely eliminate the sequence frame. Your code will be easier to read and edit.
  • The convention for the error in/error out is to have the "error in" input in the lower left corner and the "error out" in the lower right. This makes doing the first point easier and more intuitive.
  • You can eliminate most of your case structures by using the "Select" function (found in the "Comparison" palette).
  • Normally the "Stop" function is not used in a production-type LabVIEW application. This seems to imply that you're running your VI by using the "Continuous Run" button in the toolbar. If you're doing this, stop, and recode it since this is not the way you should be running a LabVIEW application.
0 Kudos
Message 2 of 6
(2,645 Views)
The units were correct, msec not sec. The stop is there incase the user wants to stop the program during a run, my application does not use continuous run, it runs for a set amount of cycles indicated by the user. I got rid of the stacked sequence and the period didn't change much, still ~30ms. So this leads me to believe it is in the other subVIs. I have attached the ones I think the problem may lie in. Please let me know if I am doing something inefficiently. Thank you.
Download All
0 Kudos
Message 3 of 6
(2,633 Views)
Just by looking at those 2 VIs nothing jumps out screaming. If this is something you're doing repeatedly then one thing you may want to consider is to create the tasks once at the beginning of your program rather than creating the tasks each time. Don't really know how much of an overhead this is, but it might buy you some time.

You should keep in mind, though, that since this is all software-timed your cycle time is not guaranteed.

Tip: In the "SwitchResistanceMeasurement" VI instead of using the formula node, just use regular numeric functions. The formula node just add unnecessary overhead for such a trivial calculation.
0 Kudos
Message 4 of 6
(2,618 Views)
Thanks for your help. I was able to narrow down what was taking up the majority of the time to run the cycles. It appears creating a task every time I want to run an operation was the problem. So I tried doing what you suggested and define the tasks all at the beginning. So I created a test program to do the most basic of operations I need to do. Would like to output two voltages and take voltage measurements to calculate resistance, then reset the voltages to zero. I created the channels and put the I/O sequence in a loop. And this is where I encountered another problem. Apparently, with M-series DAQ boards, I can only define one analog input and one analog output at the same time (otherwise you get the 50103 error). From my trials I was able to create 2 analog outputs and one analog input before the error occurred. In order to get ride of this error I could only think to go back to redefining the tasks and clearing them after each use. Is there a way (or "trick") to get around this. I need my cycle timing to be in the microsecond range (which it was if I removed one of the resistance measurements) with all for tasks. Please let me know if you have any suggestions. Thank you.

I have attached my sample program of what I am trying to do. Also, there is the resistance computation (note: both resistance measurement VIs are similar so I only included one)
Download All
0 Kudos
Message 5 of 6
(2,582 Views)
That's true, as described in this document. In your code you're trying to perform the two analog outputs at the same time.

I'm a little rusty with DAQmx, but my understanding is that you should be able to create a task that performs both outputs and both inputs simultaneously with DAQmx 7.3 and above, I think. You can create your tasks in MAX and then in LabVIEW instead of wiring to the "physical channel" input, wire to the "task in" input. If you open up MAX you should see a "NI-DAQmx Tasks" item. Here you can create tasks and name them. So, you can create an analog output task that causes both of your analog outputs to generate a signal. You would want "1 Sample (On Demand)" in the "Task Timing" section. Name this task something like "GenVoltages". In LabVIEW, right-click on the "task in" input of "DAQmx Create Channel". This will create a DAQmx task contant, and when you click on it you should see a list of tasks that have been defined in MAX. Select "GenVoltages". When you want to generate the voltages, use a single instance of "DAQmx Write", select the "1D DBL NChan 1Sampl" instance, and wire in an array instead of a single value. Each element of the array corresponds to a channel in the task. The read part of it should work the same way.
0 Kudos
Message 6 of 6
(2,574 Views)