While loop doing AO/AI ... Performanc​e?

Hi!
I have been trying to get a VI to do concurrent Analog
data in and out and both the input and output rates and
waveforms can change while the VI is running. My problem
is this:
(a) If I try putting the read and write operations in
separate while loops, one or the other loop will
die in a buffer over/underrun.
(b) If I put both into the same loop, then this works
but I am limited in the choice of data-rate parameters
because eventually one or the other DAQ VI will take
too long.
At this point I have only one loop and the buffers are big
enough to hold 10 iteration. Every time one of the loops
dies I reset it. Still this seems awkward. Is there a
way of improving on the loop overhead and putting t
he
input and output in separate loops? Or any other way to
improve performance?
Rudolf

Ok, I knew that ocurences did something useful but I am
still a bit confused:
* Can you set an occurrence for an output event. None
of the examples I've seen say so but it looks like
it should work
* How do occurrences actually help with the "hanging"
problem. Does the compiler see the occurrence in
a loop and change the wait parameters?
I looked at devzone but most of the stuff I found there,
even the promising looking stuff was all about
synchronizing and triggering, not about occurrences.
Rudolf
JB wrote:
: Once in the read function, the program "hangs" until the number of
: data points is in the buffer. The same applies to the write function.
: This means that most of the time, your program is waiting.
: To sol
ve this problem, you must use DAQ occurrences (--> hardware
: events).
: For examples for using daq occurrences, type "daq occurrence" in the
: search of the LabVIEW help or even better, at
: http://zone.ni.com/devzone/devzoneweb.nsf
: Hope this helps

Similar Messages

  • Event structure in a while loop does an extra iteration

    In this program, after the user has measured all the values, he or she will press a calibration complete button and the results of the measurement will be displayed.  However when the program runs and this button is pressed, the event structure does one more iteration.  Is there a way for the while loop to read the control before the event structure executes to prevent this?
    p.s.  I know that the wiring is probably a lot more complicated than it needs to be so if there is a better way to place values into a particular space in an array let me know
    Thanks
    Chris O.

    Probably just a matter of the order of execution in your data flow.
    Please post a VI so we can see what is going on now.
    Never mind.  You have since posted it.  SMerucurio's suggestion of a separate event case for the other button should work fine.
    Message Edited by Ravens Fan on 06-30-2008 01:20 PM
    For putting an element into a specific location of an array, look at "Replace Array Subset".  This should allow you to replace your groups of shift registers with a 1-D array since you are basically building 1-D arrays after your case structures anyway.
    Message Edited by Ravens Fan on 06-30-2008 01:24 PM

  • While loop does not execute

    I wish to write a text file that is tab separated for viewing in UNIX, however the tab character provided in Labview is read as a ^M in the UNIX file and in notepad. If you have any suggestions, they would be appreciate

    In article <506500000008000000206F0000-1042324653000@exchange​.ni.com>,
    "smd169" wrote:
    > I wish to write a text file that is tab separated for viewing in UNIX,
    > however the tab character provided in Labview is read as a ^M in the
    > UNIX file and in notepad. If you have any suggestions, they would be
    > appreciate
    When I write a tab delimited file on my Linux box I just get tabs. The
    only time I see the ^M is when I use a carriage return instead of a tab.
    To suppress the ^M in Linux I've been told to use line feeds or the combo,
    carriage return/line feed. I tried it and it works. Sorry if this
    doesn't answer your question. Perhaps results are different on a pure
    Unix system? Maybe it's the text viewer... I used less and joe to verify
    my results
    -Kevin

  • Is there a way to run a For Loop independen​tly within a While Loop in LabVIEW 2013?

    In my program I would like to run a For loop inside of a While loop, and have them run independently, at their own execution rates.  As a test, I wrote a simple VI with a While loop with 1 second timing, and into this I inserted a For loop with 3 second timing.  I created indicators for both iteration terminals.  Upon running the VI, I found the While loop waits for the For loop to run N times before the While loop executes again.  I also found that sometimes the first iteration of the For loop will end at 1 second rather than 3 seconds, and the STOP button to terminate execution of the While loop does not always work.
    Solved!
    Go to Solution.

    ksinks wrote:
    Thanks, how would you synchronize the loops?  I have gone through the Getting Started exercises and manual.
    Why would synchronization matter? Did you want them to run independantly at their own speed or not?
    Regardless, there's a synchronization pallette with functions for this, as Occurance.
    Other solutions include a common loop counter and a case structure executing every X'th iteration, or having the faster loop send a queue or event every X'th loop that controls the slower loop.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Execution conflict between a SubVI and a while loop

    Hi,
    I have wired the conditional terminal of a while loop with a boolean control. The same boolean control is responsible to terminate a SubVI (not inside the while loop) which also contains a while loop (I am using a reference to the control here). When I first use the boolean control, the SubVI is being terminated, but the while loop in the main VI is not. In order to terminate the main VI, I have to use the boolean control once more. In order to avoid that, I created a "status"-indicator within the SubVI, which is set to true once the SubVI is terminated, and wired that from outside the main VI's while loop to its conditional terminal. Of course, now the while loop does only execute once the subVI transmits the status value.
    The thing is, I want both the while loop to execute before the status value is being transmitted (so, only the conditional terminal is supposed to wait for the value) and use the boolean control only once in order to terminate the VI.
    Any ideas?

    Ok.  I kind of expected to see this.
    First of all, change the "Control: Mouse Down" event into "Control: Value Change".  DO NOT USE  A LOCAL VARIABLE!!!  Wire the result straight out to the termination terminal.  You want something like this:
    Your writing to a local is a race condition.  The control was read before you wrote to it.  Therefore the loop was going an extra time around.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Stop loop.png ‏13 KB

  • Re-start producer while loop

    Hi,
    I'm trying to figure out the best way to implement a producer/consumer architecture. I'm hoping there is something simple that I don't understand.
    I have a state machine executing in it's while loop, doing things like saving and processing data. The data is being passed through a queue from a separate while loop. I'm currently starting that producer loop using occurrences, and I can stop it with a local variable. 
    What I can't figure out is how to restart that loop from within the state machine?  In essence, I'd like to have a switch that says "Collect Data" and it will turn the producer while loop on and off but leave the main program running in the meantime. 
    Thanks for any suggestions. 
    mike

    Basically, i find producer/consumer architectures where the consumer creates "commands" (Edit: which do more than simple notification tasks) for the producer quite absurd.
    I would switch to a three loop architecture:
    Producer A is responsible for UI display/control. It feeds Consumer A which is infact Producer B.
    Producer B (aka Consumer A) is the DAQ consumer. It will acquire data due to the settings passed by Producer A. The DAQ data will be passed to Consumer B.
    Consumer B handles the data passed by Producer B. If necessary, it can create custom user events in order to notify Producer A about certain situations in the software.
    An approach with an Action Engine can be similar in regard to functionality, has its own advantages and disadantages.
    hope this helps,
    Norbert
    Message Edited by Norbert B on 01-14-2010 12:13 PM
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Do while loop doesn't end

    my do while loop does not exits can help?
    do{
                   a++;
                   System.out.print("Enter account number "+a+" (Press ENTER to exit) : ");
                   account=CspInput.readString();
                   item[a-1] = account;
                   System.out.print("Enter credit card expenses for "+account+" : $");
                   price=CspInput.readDouble();
                   amount[a-1]= price;
                   System.out.println("");
                   if((a-1)==0)
                        summaryByMonth[i-1]=item[a-1]+"\t\t"+fmt.format(amount[a-1])+"\n";
                   else
                        summaryByMonth[i-1]+=item[a-1]+"\t\t"+fmt.format(amount[a-1])+"\n";
                   totalAmount[i-1]+=amount[a-1];
              }while(account != null && account != " ");

    si0ngch33 wrote:
    my do while loop does not exits can help?
    do{
                   a++;
                   System.out.print("Enter account number "+a+" (Press ENTER to exit) : ");
                   account=CspInput.readString();
                   item[a-1] = account;
                   System.out.print("Enter credit card expenses for "+account+" : $");
                   price=CspInput.readDouble();
                   amount[a-1]= price;
                   System.out.println("");
                   if((a-1)==0)
                        summaryByMonth[i-1]=item[a-1]+"\t\t"+fmt.format(amount[a-1])+"\n";
                   else
                        summaryByMonth[i-1]+=item[a-1]+"\t\t"+fmt.format(amount[a-1])+"\n";
                   totalAmount[i-1]+=amount[a-1];
              }while(account != null && account != " ");Either use a debugger or put some print statements in the loop to see what the actual value of account is:
    Example:
    do{
        //... bunch of code
        System.out.println("DEBUGGING - account is '"+account+"'");
    }while(account != null && !account.equals(" "));

  • Dsc periodic I/O "stop while loop" usage?

    I'm using LabView 8.5.1 with DSC.  I have created a working periodic I/O server VI and successfully deployed it. 
    The one glitch I am running into is what happens when the Shared Variable Engine I/O process is terminated.  I normally terminate it by using "remove process" from Variable Manager.
    The I/O server wizard lets me choose the while loop for termination during the build process, but any code following the while loop is not executed.  In fact, the process continues running for 10 seconds until the "abort VI timeout" is reached, at which point the VI stops.  The "stop" terminal of the main while loop is wired to a "create control" "STOP" button on the front panel.  Publishing or not publishing the "STOP" control during the I/O wizard process has no effect.
    I'd like to do cleanup steps after the while loop terminates.  Unfortunately the "Heat Exchanger" example has no code after the while loop to illustrate the concept.
    What am I missing? 
    Thanks,
    Mike

    Hi Van - let me clarify my question...
    I don't believe that the termination portion of the DSC "periodic I/O server wizard" actually works properly, or at least an example is needed of how to make it work.
    It appears to me that the wizard functionality of "choosing the server termination method" might not work.  Within the wizard, the two options are to abort the running server VI, or to choose a "while loop" to be forcefully-terminated with a standby timeout value to force a VI abort anyway, if the while loop does not exit.
    I set up a simple server VI with one main while loop that does RS-232 I/O with a "running" beep on a 1 second timer.  After the while loop is another small block of code that closes the serial port, and a different "terminating" beeper.  When I run the VI interactively, both beeps work fine.  When I use the wizard to turn it into a server and it is deployed to the SVE, the beeps begin normally.  When I stop the SVE process via "remove process" in Variable Manager, the "running" beeps continue for another 10 seconds until the abort timeout occurs, even though with the wizard I specified the only while loop in the VI to be aborted.
    The heat exchanger example works fine.  Unfortunately it does not have any code following the while loop, so it doesn't shed any light on this issue.  Ideally that example would be updated a little to show how to use the "while loop termination" feature.
    Basically my request comes down to this:  is there a way to actually make this work, or is it another in the list of bugs in 8.5.1?
    Thanks,
    Mike

  • SqljCircle &JdbcCircle Class(while loop)

    Have compiled and run these two clsses but it only seems to be inserting one record from a RADIUS_VALS table into an AREAS table when it should be looping three records, any ideas why the while loop does not seem to be working??
    Philip

    Do not compare String contents with "==". Use equals().

  • How can I update cluster items from inside a while loop that does not contain the cluster?

    I have a VI that contains front panel clusters and two while loops. The main cluster contains items such as a doubles "distance" and "stepsize" and boolean "step" (a whole buch of this type stuff). The first loop contains an event structure to detect front panel changes and the second contains code and sub VIs to perform operations based on detected events.
    The operator can enter data into either double or click the boolean. If distance is changed the second loop does what is required to process the change. The same happens with stepsize. If step is clicked the ±stepsize value is added to distance and the result is processed. In each case the front panel should track the result of the input and subsequent processing.
    Because the clusters are outside the while loop, they are not updated unless I click 'highlight execution' which seems to allow updating each time the execution highlight is updated. There are other issues if I move the clusters into one of the loops.
    I've tried referencing the clusters and using local variables and nothing works. It looks like overkill to use shared variables for this.
    Any ideas would be greatly appreciated.
    Thanks,
    Frank    

    Hi Ben,
    Thank you for the response. I followed the link and tried reading everything you posted on AEs but I'm afraid that I didn't understand it all. It seems that each AE example had a single input and a single output (e.g. a double). Is this the case? 
    What I have is a couple of front panel clusters containing (approximately) 18 control doubles, 8 indicator doubles, 5 boolean radio button constructs and 26 boolean control discretes. I clusterized it to make it readable. In addition I'll eventually have a cluster of task references for hardware handles.
    All I want to do is update the front panel values like I would do in a C, VB or any other language. I've tried referencing the cluster and using the reference from inside the loops. I've tied using local variables. Neither works. I'm experimenting with globals but it seems that I have to construct the front panel in the gloabal and then I wouldn't know how to repoduce that on the front panel of the main VI.  Sometimes it seems that more time is spent getting around Labview constructs than benefitting from them.
    I hope the 'Add Attachment' function actuals puts a copy of the VI here and not a link to it.
    Thanks again for the suggestion,
    Frank 
    Attachments:
    Front Panel Reference.vi ‏33 KB

  • How do I create a start/stop button for each separate while loop within my program, when each of them does a different task?

    I have a multimeter VI with separate while loops to accomplish the different tasks of reading  voltage, current, etc. Each while loop has a stop button, but I need a button that will have to be pressed in order for the while loop to even start. I tried putting another while loop around the present one, but it still has to run once before it will stop. I want the user to have to press the button before it runs, because they interfere with each other.
    I am just learning so patience and your kind assistance is greatly appreciated!
    ElectroKate

    iZACHdx wrote:
    Hello,
    I'm not entirely clear with everything you have going on and what you want your final functionality to be, but you can use sequence structures to prevent a loop from starting until the user presses a button like this:
    -Zach
    I have to ask, why is an NI employee using examples using sequence frames? The same thing could be accomplished using data flow by simply wiring the value of the first stop button out of teh first while loop and connecting it to the second loop. This would then use data flow to control the sequence. Why show new users bad programming methods?
    As to the original question I would concur with altenbach on using an event structure.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Why does while loop pause during operation

    Hi everyone,
    I have written the attached code which will eventually be a part of a bigger program. The program is intended to log some test value, in this case just the date and time  to a csv file  when a button is pressed (log in WHITE, loop1).  Loop2 is intended to read a test value from a line in the first csv file and then add an extra test value to the end of that line when the serial number matches and then saves that line to a new csv file. This all works well but loop2 seems to pause a few times before continuing when either of the log button is pressed. I tried putting the code in 1 while loop with no success. Can anybody see what I am doing wrong?
    Attachments:
    ResinV10_csv.vi ‏25 KB

    Maiz wrote:
    Can anybody see what I am doing wrong?
    In addition to waht has been said already, your code is extremely convoluted.
    How often does the "read" file change? Do you really need to read the entire file with thousands of rows every ms just to look at one row?. If the file never changes, you could read it once before the loop.
    The way do do array opearions is mind boggling. You take one row, Index out the first element twice in parallel (once is enough!), then you index out the first element, built it into an array of one element, and compare that array with a scalar. Would't comparing the orignal element with the scalar be equivalent?
    Index array is resizable, you only need one instance.
    Getting five elements in a row just to build them back into a 1D array seems rather pointless. If the array has only five elements, there is nothing to do, and if it has more elements, you cold use "array subset", and if it has fewer elements, use "reshape array" to size 5.
    The correct format for reading strings is %s (not %.10f).
    Since you want both loops to run at the same speed, why don't you put it all in one loop? (this even eliminates the local variable) Then you could use a parallel loop for the file saving, using queues in order not to slow down the main loop. In the parallel loop, open the files before the loop, use lowlevel writes inside the loop, and close the files once the program stops.
    Can you explain your setup and what the program is supposed to do? I am sure it could be done with 20% of the current code.
    LabVIEW Champion . Do more with less code and in less time .

  • Does anyone here knows how a while loop works?

    The following code works...
    DECLARE
    zz NUMBER := 1;
    BEGIN
    While zz < 10
    LOOP
    zz := zz + 1;
    END LOOP;
    END;
    If I put a prompt in it like so it does not....
    DECLARE
    zz NUMBER := 1;
    BEGIN
    While zz < 10
    LOOP
    prompt Look THEO I am looping...;
    zz := zz + 1;
    END LOOP;
    END;
    I get the following error...
    prompt Look THEO I am looping...;
    ERROR at line 6:
    ORA-06550: line 6, column 14:
    PLS-00103: Encountered the symbol "LOOK" when expecting one of the following:
    := . ( @ % ;
    I get the same kind of error if I put a create, select or pretty much any other statement than an assignment in the loop.
    Am I to believe that a while loop in SQL*Plus is particular to what kind of statement is in it?
    Any help would be appreciated.

    PROMPT is a SQL*Plus command. If you would like to output text to the screen while looping in a procedure you should use DBMS_OUTPUT.PUT_LINE(). This will also require you to use the following command at the SQL*Plus promptSET SERVEROUTPUT ON;Your code will look like thisDECLARE
        zz NUMBER := 1;
    BEGIN
      While zz < 10
        LOOP
          DBMS_OUTPUT.PUT_LINE('Look THEO I am looping...');
          zz := zz + 1;
      END LOOP;
    END;This will output Look THEO I am looping... 9 times. If you would prefer that it only be displayed 1 time then you can move the DBMS_OUTPUT.PUT_LINE between the BEGIN and WHILE commands.

  • How fast does a while loop executes

    hi how fast does a while loop actually checks its condition??
    depending on the processor speed??
    anyone??

    Sorry I write that wrong,
    heres how it should be:
    public class whileLoop{
    int time, time2;
    time = System.currentTimeMillis();
    public timer()
    while //watever//{
    time2 = System.currentTimeMillis();
    time2 = time2 - time;
    system.out.println(time);
    class use{
    whileLoop a = new whileLoop();
    public void main(String args[]){
    a.timer();
    }

  • Why does a sequence structure execute if a while loop is to the left of it?

      I have a while loop in a case structure whose boolean is wired to a sub vi.  To the right of this structure I have a sequence that executes regardless of the while loops condition.  I assumed that the program would not continue to the case structure until the while loop stopped.  Then it would proceed to the case structure.
    Thank You

    jemengineering wrote:
      I have a while loop in a case structure whose boolean is wired to a sub vi.  To the right of this structure I have a sequence that executes regardless of the while loops condition.  I assumed that the program would not continue to the case structure until the while loop stopped.  Then it would proceed to the case structure.
    As others have mentioned, you have to familiarize yourself with the core idea of dataflow programming. One of the great powers of LabVIEW is the fact that things can occur in paralell unless there is data dependency.
    A good start would be the LabVIEW beginners online tutorial:
    http://www.ni.com/swf/presentation/us/labview/aap/default.htm
    The quiz #1 on slide 11 deals with the above issues. Try to answer it. 
    In your particular case, you need to force execution order. This can be done by creating a data dependency (preferred) or by the use of a sequence structure. You could e.g. create a 2-frame flat sequence and place the loop in the first frame and the case structure in the second frame.
    The picture shows a few scenarios for comparison. Can you spot the differences?  Understanding dataflow is crucial for writing any LabVIEW program.
    Message Edited by altenbach on 07-31-2006 06:49 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ExecutionOrder.png ‏19 KB

Maybe you are looking for