Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

incorrect wait time

hi, all, Happy new year first:)
 
I'm new to Labview, and now i met a problem in my first labview project.
 
i need to control 2 instruments, and one of them needed to be ON and OFF(Reset) periodically.
 
At first(Ver. 6), what i did is use a flat sequence structure, case 0 is set-up these 2 instruments, case 1 is using two tick count and a while loop continus calculate the running time and compare with the desired timing, case 2 is reset the instrument,  and case 3 is same as case 1.
but the problem is this program always make my CPU usage 100%.
 
so in Ver 6.1, I change case 1 and 3 to "wait", it did consumes less CPU but it is not correct, the loop time became shorter and shorter as the program runs.(As we can see from the attached pic).
 
if my descripition is not clear,these two VIs are attached below.
 
can anyone give me some suggestions to optimise the first program, so it not take so much CPU usage or point out what's the error with the wait function?
 
thanks a lot!
 
Best Regards
 
oahcchao
 
 
0 Kudos
Message 1 of 7
(3,801 Views)
Oahcchao,

at first glance I can not see a failure on your side. Maybe this is an internal failure within LabVIEW or the OS?
There is, however, another possibility: If important parts of your waiting periods are occupied by the device driver, this can be a cause for this behaviour: If you use an IVI drive with state caching it may 'improve' the actions from iteration to iteration. You can check this out by deactivating state caching in the ivi driver setup or with a command. AND you can insert a 'tick count ms' node inbetween each of your existing sequence steps and calculate the difference between consecutive 'tick count ms's.

But this is all more or less a shot into the blue. Hopefully someone from NI will give you a better answer.

Greetings from Germany!<br>-- <br>Uwe
Message 2 of 7
(3,795 Views)

hi, Lul,

Thanks a lot for ur advice.

I'm doing what u said, see can find any thing wrong or not.

in the mean time of program running,thank you first:)

Regrads

Oahcchao

0 Kudos
Message 3 of 7
(3,790 Views)

Hi Oahcchao,

When using a while loop in LabVIEW without any wait time, LabVIEW will run as fast as possible causing the CPU ussage to be 100%.  Most of the time this is not a problem.  It is just LabVIEW taking advantage of all unused resources.  Here is a KnowledgeBase entry that describes this in more detail:

http://digital.ni.com/public.nsf/websearch/8638139D6236D42086256A340073554A?OpenDocument

I noticed in your original VI (ver 6) that you have wait time placed in the sequence structure but not in the while loop.  Try placing a Wait function with a 1 wired to it in the while loop as well.  You should be able to do this with your version 6.

Message 4 of 7
(3,759 Views)

hi, Michael,

   Thanks a lot for your advice. and sorry for replying u so late, because this project is in a hurry and i just ran the program over night.

   Now the CPU usage problem is solved, and i can make sure the loop time is correct -- i used stop-watch to check every cycle time.

   but the DAQ graph is still the same, looks like cycle time is becoming shorter and shorter.  I think there are some problems with my DAQ program, but i cannnot find what's wrong.

   The attached file is my DAQ program, can anyone point out what's wrong with my XY-Graph?

   and how to use the running time as x-axis, i mean, it starts from 00:00, and after one second, it will ends at 00:01, something like this, i tried the "relative time" in the properities of XY-Graph, but it not works.

    Thanks again for the help from all of you guys. Really.

Regrads

Oahcchao

 

0 Kudos
Message 5 of 7
(3,740 Views)
Oahcchao,

When doing continous DAQ tasks I might suggest not using the DAQ Assistant.  If you take a look at the shipping examples that come with LabVIEW, you can get a good idea of how you could program a continous acquisition signal.  If you go to Help >> Find Examples you can see a lot of examples under Hardware Input and Output >> DAQmx >> Analog Measurements >> Voltage.  I might suggest the Cont Acq&Graph Voltage-Int Clk.vi as a reference.

As Michael mentions, it is always a good programming practice to place a wait function (Wait or Wait Until ms Multiple) in your while loop.  As for your x-scaling, I believe I have a solution for you there.  If you right-click on the x-axis you can select Formatting, you can access the Graph Properties pop-up.  Change the Type to Absolute time, and you will notice that you can time and date format.  Change the time format to HH:MM and select date unused for the date format.  This should give you a running time on the x-axis. 

Hope this helps!
Andy F.
-----------------------------------------------------------------
National Instruments
Message 6 of 7
(3,700 Views)
Thanks, Andy,
 
    your post really helps. I think i sloved all the problems i currently facing. Thanks a lot.
 
    All the Best.
 
Regards
Oahcchao
0 Kudos
Message 7 of 7
(3,665 Views)