LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting a loop to run for a set time

Sorry if this is a repost but i couldn't find the answer to my problem.

I'm just getting started with labview and am creating a simple program that communicated with a Keithley 2000 Multimeter. I have made the program read from the device and create a graph of the DC voltages. I want the user to be able to set a time for how long they want the program to run for. Could someone please explain to me how to do this or show me a guide that explains it?

I have attached my program I am creating. Thanks in advance.
0 Kudos
Message 1 of 41
(5,365 Views)
The easiest way is to use the Elapsed Time Express VI located on the Timing pallette.  Take the output of that and OR it with the stop button going in the stop condition node for the loop.
0 Kudos
Message 2 of 41
(5,342 Views)

One other tip for your program:

You should put the initialize VI before the loop and the close VI after the loop.  Doing these operations on each iteration of the loop can be very costly in terms of performance, at best.  At worst, depending on how the sub-VI's were written, could cause memory leaks that could crash the program.

0 Kudos
Message 3 of 41
(5,338 Views)

Here are a few more tips to what has already been said above:

Your xy graph express vi is set to "clear on each call", meaning you show only one point at any given time. Pretty useless as a display.

Use a timed loop or place some wait inside your loop so it runs at a determined rate, independent of computer hardware. If you do that, your points will be equally spaced in time an all you need is a "waveform chart" display wired to your Y.

Once the loop rate is fixed, you can precalculate the number of loop iteration you need for your desired elapsed time and you could even use a FOR loop.

Your tick count use is wrong. The tick count is an increasing U32 number that starts at a random value and wraps at the 32 bit boundary. To get relative time starting at zero, take a tick count before the loop and another inside the loop while taking the difference to get the elapsed time in milliseconds.

For the option string, it seems silly to use a hidden control. Use a diagram constant instead.

Message 4 of 41
(5,334 Views)
Thanks for all the help. Ill do what everyone said and post back with my results.
0 Kudos
Message 5 of 41
(5,288 Views)
Im stumped again.

I put a wait time of 100ms thinnking then the reading would come at a steady pace?
I also converted the grapgh to a Waveform chart. Now the only reading on the chart that i get is 0.
And I dont think the timing device is correct.
0 Kudos
Message 6 of 41
(5,258 Views)

You may want to go into the properties of the waveform chart and increase the history from 10 to something larger.  10 is not a lot of points.

Are you sure you are getting a voltage that is not 0?  Is it a very small voltage close to 0?  Your waveform chart has a property set for 0 digits of precision.  So if your voltage is less than 0.5, it will show up as 0.

As for timing, your loop will run no faster than 10 times per second.  But if the operation of the get data point VI takes longer than 100 ms, than the overall loop will run slower.

0 Kudos
Message 7 of 41
(5,247 Views)
Well, did you enter something other than 0 into the numeric control?
 
If you pace the loop at 100ms, you should also set the x-axis increment of your chart to 0.1 for clarity. You also set your chart history to only 10 points, so you will only see about the last second of data. Is this what you want?
0 Kudos
Message 8 of 41
(5,244 Views)

If you don't have automatic error handling turned on, why don't you wire up the error clusters and see if you are getting an error? Also, I'm curious why you are using the IVI driver instead of the LabVIEW driver.

The code for timing how long to run the loop is fine. I don't know if the 100 msec wait is long enough for the instrument.

Your wiring could be a bit neater as well. With so little code, it's easy to what goes where but if you keep up this style with more complicated programs, they will become much more difficult to understand.

0 Kudos
Message 9 of 41
(5,240 Views)
I changed the history to 1000. And then made it 3 digits long (even tried 10) and I still get 0. The voltage on the meter is reading 3.7XXXX mVDC.
0 Kudos
Message 10 of 41
(5,241 Views)