Timed loop inside a flat sequence not terminatin​g

Inside a while loop there is an event structure.  Inside that there is a flat sequence.  On one of the frames there is a timed loop that quits after so many iterations.  The timed loop finishes but the flat sequence doesn't execute the next sequence.  What am I not doing right?

First, you have too many local variables.  This could be leading to race conditions.
I think you have a couple problems in the use of event structures.  It is a bad idea to put any long running code inside an event case.  It will prevent the Event Structure from handling any other events in the mean time.  You have several timed loops running that in that one sequence frame.
But the bigger problem is the next sequence frame.  You have a while loop that only ends once all the queues are empty.  Can you guarantee that all the queues get emptied?
You have laid out the code very neatly, but you have used a lot of odd things in there.  (Number to boolean array, to cluster, to unbundle the cluster to individual indicators.)  Why not just go from Boolean array to and index array function.  No need for the intermediate cluster conversion.  Why not set up the indicators as an indicator array and just write to them directly.
The code is so much intertwined between when queues are created, filled, emptied, destroyed, events happen...  And this is all multiplied by at least 4 times for each camera.  And there are 4 major event structures going on.  This is a very ambitious project for an inexperience LabVIEW user.  You need to step back, get one thing working right, and design so that you can scale the architecture upward.  Many of the structures you have essentially duplicated and belong in subVI's.

Similar Messages

  • Error -50103 occured with timed loop inside a while loop

    Hello everyone,
    i wrote an application to sample analog voltage from  DAQ6024E card (see the attachments).
    I have a big while loop in the VI because a I want to add some other functions later.
    In the "WHILE_Cont Acq&Graph Voltage-Int Clk.vi" I use a while loop inside the big while loop to read the samples. It's working properly.
    but when I use a timed loop inside the big while loop (see "TIMED_LOOP_Cont Acq&Graph Voltage-Int Clk.vi"), I get an error -50103 from the timed loop.  It seems that the first cycle is ok, but after the first cycle the error occurs.
    I don't know what happens with the timed loop, anyone can help me? what does the error -50103 mean? thanks a lot!
    PS: I am using LabVIEW 8.0
    Message Edited by molo511 on 10-22-2006 05:21 AM
    Message Edited by molo511 on 10-22-2006 05:23 AM
    Attachments:
    TIMED_LOOP_Cont Acq&Graph Voltage-Int Clk.vi ‏143 KB
    WHILE_Cont Acq&Graph Voltage-Int Clk.vi ‏75 KB

    hi molo511,
    I tested your program but only with simulated devices. I had to delete the wire to the timing, so that the timed while loop runs with 1kHz. Did you already try this? Because this works on my PC.
    I also found a link in our database that might be interesting for you.
    http://digital.ni.com/public.nsf/websearch/04BEDD9E9E91ED3486256D180048116D?OpenDocument
    Greets
    Philipp N.
    NI Application Engineer

  • Metronomes​, while-loop​s and flat sequences

    I'm making a loop that is supposed to write a poll message to the serial port once every minute and read a message from the same port once every 256 ms. It is supposed to proceed untill a stop button is hit. It is based upon a while loop that contains two different flat sequence structures that each contains a metronome ("wait until next ms").
    The intention of thisis that the program goes through the loop and every 256 ms it reads the serial port and every 60 000 ms it sends a polling message. However, the indicators I've connected to the metronomes doesn't seem so show a linear increase in the ms timer. The poll timer occasionally increases a little (in two minutes it might increase 20 ms). The read timer does not increase at all. Poll count increases very irregularly.
    Does the flat sequences interfer with each other? Can this loop be changed in any manner in order to work properly?
    Attachments:
    poll_loop2.GIF ‏13 KB

    The loop is dominated by the "minute" timer, what will happen is that it will wait the minute, write, go to the 1/4 minute timer do it's read, the back to the minute timer. This is because LabVIEW is a data-flow language. There are a number of different ways to do this, one being having two loops, one writing, one reading, but with out some synchronization between the two they might drift. Another method would be to have an event structure, with the timeout value set to 250 mS, putting the read and write into a case structure in that timeout event. Having a time check, or even a resetable counter (use a shift register on the loop) to determine whether to write or read, with an event for the operator to stop the whole thing. I do a diagram, but have a meeting in a couple of minutes :-)
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Timed loop in LabVIEW DLL does not exit nicely

    Hello!  I have what I think is a simple timed loop in LabVIEW that exits after 100 iterations by throwing an error, and letting the loop "stop on error".  This works fine when run in the regular LabVIEW environment, however, when compiled as a Dynamic Linked Library (DLL) and called from LabWindows it forces me to terminate execution, rather than exiting nicely.  What's more, it seems to quit the actual Virtual Instrument call just fine and proceed to the next line of code, but when my main() function in LabWindows completes there must still be something not cleaned up that is causing it to not exit nicely.  Any ideas?   I've tried adding a call to QuitLabVIEW and that doesn't seem to do it.
    Thanks in advance - hoping you'll point out some really easy mistake. )
    Attached is a picture of the timed loop.
    Below is an excerpt of code from LabWindows:
     int main ()
     CallMyLabVIEWDLL();  //This line successfully launches and closes the window for my LabVIEW virtual instrument
    MessagePopup ("My Title:", "This happens after the call to your LabVIEW DLL");    //This popup shows up - indicating the call to the DLL has completed
    //But after the code has completed LabWindows still says "Running", rather than shutting down.
        return 0;
    Solved!
    Go to Solution.
    Attachments:
    LabVIEWTimedLoopDoesntExit.png ‏103 KB

    Update:  I tried the simplest possible "While" loop and it works.  If I replace it with the simplest possible Timed Loop, it doesn't.  (See attachments.) 
    The only thing I could find in a search for why a time loop would break a dll is a patch for lvalarms from LabVIEW 8.5.1 .... I'm running LV 2010 so I don't believe that's an issue.  Correct me if I'm wrong?
    Thank you!
    Attachments:
    Doesnotwork.png ‏43 KB
    DoesWork.png ‏9 KB

  • Why does a CRIO-9004 only provide a timed loop of 1kHz (clock) and not 1MHz?

    I essentially have a compact CRIO-9004 and require a PID loop with update rates around 4-5 kHz. Additionally, I was hoping to use multiple 'timed loops' in the program in order to synchronize certain events. During this coding, the timed while loop will not work with a 1MHz clock rate and I am stuck with a clock rate of 1kHz instead. NI claims that PID loops in conjunction with the CRIO may have up date rates as high as 200 ksps. However, it appears that by employing the 1kHz clock that I can only obtain 1 ksps.
    What are my options?
    Thanks,
    Shane

    John-
    The 9215 has a conversion time of 4.4us when scanning 1 channel (see page 14 of the 9215 operating manual).  This equates to a little over 227KS/s.  The 100KHz value is if you are reading from all 4 channels.
    Link to operating manual:
    http://digital.ni.com/manuals.nsf/websearch/5F2E96​40C1CFE645862573AF007ABAD9
    Dustin
    Message Edited by Support on 10-16-2009 09:16 AM

  • Stopping Timed Loop inside a Reentrant VI

    I just converted a project over from 8.5 to 2009 and I found that some of the funtionality that was working in 8.5 no longer works in 2009 (probably for good reason...).
    Anyway, I found that if I tried to use the stop timed loop vi to stop any timed loops in reentrant vi's that I get a -804 error. The stop timed loop sub vi was in the same reentrant vi in the application, but I found it also did not work if it was outside the reentrant vi.
    It does get a little hairy when thinking which loop you are trying to stop because of the reentrancy, but if the names passed into the instances are different for the loops then it shouldn't be a problem right?
    See attached for a very simple example of this occuring.
    Note: Just running in windows...not in RT
    Solved!
    Go to Solution.
    Attachments:
    Stop Time Loop.LLB ‏41 KB

    I resorted to using an alternative way to stop the loops as well.  Does anyone at NI know if this is a feature or a bug or if there is anyway to use the stop timed loop function with a timed loop in a reentrant vi?
    Thanks.
    Whoops... Just read your post.  Thanks for the update.
    Message Edited by klessm1 on 01-06-2010 10:55 AM

  • My First while loop inside PL/SQL block not working , please help

    Hi ,
    I am new to PL/sql and struck at PL SQL blocks , please help to solve this .
    declare
    v_A number constant :=10 ;
    j number constant := 3 ;
    BEGIN
    WHILE j < v_A
    LOOP
    DBMS_OUTPUT.PUT_LINE('Hai');
    END LOOP;
    END;
    please help as how to resolve this .
    Thanks in advance .

    btw it's a useful habit to use indentation to highlight the block structure. Also it's worth deciding what your convention will be for keywords (I use uppercase, lowercase is also fine as far as I'm concerned but I've set up my editor to uppercase them) and variables, database object names etc (I use lowercase), e.g:
    DECLARE
       v_a CONSTANT PLS_INTEGER := 10;
       j   CONSTANT PLS_INTEGER := 3;
       i PLS_INTEGER := j;
    BEGIN
       WHILE i <= v_a LOOP
          DBMS_OUTPUT.PUT_LINE(i);
          i := i +1;
       END LOOP;
    END;or perhapsdeclare
       v_a constant pls_integer := 10;
       j   constant pls_integer := 3;
       i pls_integer := j;
    begin
       while i <= v_a loop
          dbms_output.put_line(i);
          i := i +1;
       end loop;
    end;When I see "declare" and "BEGIN" in the same block of code I worry about the standard of code I'm going to see...

  • Execution time of a flat-sequence

    Hello there -
    Is there any way to get a measurement of how long each part of
    the flat sequence takes to execute?  Anything like matlab's "tic" and "toc"
    commands in labview?  I have been playing with it for a while now and
    have yet to discover if Labview has this functionality.  Anyone know of
    anything like this?
    I currently have a VI that controls the realtime acquisition of a CCD camera via Firewire and a USB spectrometer.  The VI collects data from each of these devices (triggered by an external source at 10Hz), and dumps them into a Matlab script which does analysis on the CCD image and spectrum.  The bulk of the VI sits inside a while loop, which continues to run until the user presses the stop button.  Inside this main loop is a flat-sequence.  The sequence goes:    ACQUIRE DATA --->  PROCESSING DATA ---->  MATLAB SCRIPT ----> PLOTTING GRAPHS -----> OUTPUT DATA TO FILE.   
    The problem here is that the VI runs at 5Hz, while we are triggering it at 10Hz.  Originally, it was my thought thought that the matlab algorithm was to blame, but I used the matlab commands "tic" and "toc" to determine that the matlab algorithm runs in 15-20ms.  I did this by putting a "tic" command at the top of the matlab algorithm and a "toc" command at the bottom.  The problem, as I have now discovered is that the rest of the labview code takes ~180ms to execute.  (This was discovered by putting the "tic" at the bottom of the program, and the "toc" at the top of the program, thereby measuring the execution time of everything except the matlab algorithm).  Each time a trigger signal from the external source comes in, it starts the flat-sequence structure (which takes ~190ms), and then waits for another trigger signal, always missing every second signal.  My eventual goal is to reduce the bloat, and get the algorithm down to less than 100ms, so that I can run the VI and acquire data at 10Hz rather than 5Hz.  If anyone can offer some help with this, it would be much appreciated!
    Eric
    P.S. - I have attached a copy of the VI that I am working on, but unfortunately, it most likely will not run on your computer....the VI will not run unless it is connected to a triggered spectrometer and CCD camera....but I have attached it anyways incase anyone who can help might want to take a look.
    Attachments:
    RTSpider.vi ‏376 KB

    can we divide the program into 2 parts and use background process for acquisition and front end process for analysis?
    I mean, create 2 VIs from the present VI and then launch the acquisition program dynamically as a background process and fire events in Main VI from acquisition VI and process it.  not sure how much it is going to reduce. lets give a try....
    Anil Punnam
    CLD
    LV 2012, TestStand 4.2..........

  • Restarting counter in Timed Loop

    I have a timed loop inside a state machine, used to start/stop a data acquisition sequence.
    It works fine, but I'm monitoring the "i" count and Actual End [i-1] values and after the start/stop/start sequence
    these values continue to grow and don't get reset to zero.  I would expect a While Loop to reset the "i"
    variable every time is is called, but I don't see any option for resetting the time looped.
    I can get around it, but I would expect a reset method for this loop, so I'm just wondering if I'm missing something.
    Maybe I need to use "Create Timing Source" instead of the setting it iin the dialog box?
    Labview 2010f1 on Windows Vista SP2 PC

    This might help. Here is a part of the png file you posted. I put in "Structure Name>" to point to the Structure Name input. Notice that the name "bob" is listed as the Structure Name. You must be on Win7 which uses different fonts than XP - that's probably why the name is only half visible.
    Note that the Clock name is connected to the (timing) Source Name input.
    I'm attaching an updated version of the file with the Timing Loop name wired directly.
    Thanks for posting your timed loop interations3 program in 2009. When I run this code, the Iteration Count DOES reset when the Timed Loop is restarted.
    steve
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.
    Attachments:
    New timed loop interations.vi ‏42 KB

  • Unable to run Timed Loops

    Bit of an odd one that had me scratching my head.
    I have a development system consisting of a PC running a 7842R, acquiring analogue and digital data from the FPGA, loading it into a shared variable, and reading it out within a timed loop on the host as one parallel loop in a producer-consumer architecture.
    All's well until one day last week when I noticed my host VI becoming unresponsive.
    After a bit of digging, I find that the timed loop doesn't run at all. Replacing with a while loop with a wait at least allows me to show that the error is timed loop related, but it's not a viable long term option for me. Creating a new project and a new VI with a simple timed loop showed the same behaviour.
    A restart of the system, and rerunning the same VIs, and no problems since.
    So, questions:
    1) Has anyone else seen this behaviour?
    2) Any idea what causes it? A service crashing, for example?
    3) Is there a way of recovering without a reboot? If it's a service crash, I'm hopeful.
    The system will eventually form part of a production test environment, hence the query.
    Edit - also, wiring error terminals of a timed loop is a good way of highlighting errors of course.
    FWIW, LV2012 SP1 32bit, Win7 64bit, Core2 Duo, 4GB RAM, tassels from the handlebars etc.
    CLD

    The timed loop is used to read all elements from a DMA FIFO and load them into a buffer FGV, which spits out packets of N samples long once they've assembled within the FGV. Ordinarily, I'd do this with a timed while loop and be perfectly happy to do so. However, the elements are actually an interleaved array, meaning that I have to demux them in the correct order that they were loaded.
    I use timed loops for a number of reasons: on my current Windows host, I've found that using a while loop has caused me more problems with respect to disordered packets, and that at least with using multiple timed loops (two, at most), I can assign priority to the acquire loop. Finally, it's also a development platform, and will be deployed onto an sbRIO once the electronics integration is finished in a week or two!
    W.r.t. system resources, there's very little else running on that system, but that doesn't normally stop Windows
    I recognise it's not ideal to run a software timed loop under Windows, but when you cannot run a blank project with Optimizing timed loop rate.vi from the shipped examples with nothing else running, it makes me curious to know why!
    CLD

  • Unrecoverable Error w/ Timed Loop

    When I use a timed loop I get an "Unrecoverable Error" (status light on FP-20xx blinks four times) after compile and run - although not immediately. When I replace the timed loops with regular while loops everything is o.k.
    TommyH

    Hi TommyH,
    Thanks for the information. I understand that all this stuff can be a little overwhelming. That's OK. We'll get through it.
    Sounds like this is a case of the code not being able to execute within the allowed amount of time. So, in this case I would suggest not using the timed loop because the code will not be able to execute within 1ms. I would suggest using the regular while loop and using a wait until next millisecond multiple timer. You will need to experiment with the code to determine how long to wait. Give this a try and let me know how it goes.
    Best Regards,
    Brooks W.
    National Instruments

  • Timed loop not starting - works after closing and opening project

    Refer the image below - a simple timed loop should run when the Run button is pressed. What happens is that the parallel vi runs (see arrow) but the vi inside the loop doesn't.  Both vi's shown run forever (i.e. the timed loop is only used to specify the CPU).  
    When I press the Abort Execution button, strangely it can then be seen that the execution highlighting runs into and through the timed loop and probe 50 is updated.
    This sorted itself out after I closed the project and opened it again so its not a critical issue - was simply wondering what could cause this?

    That program looks kinda weird.
    First of all, avoid to use flat sequence structures whenever you can, or use it only when you are going to initialize something, or when your program has an specific sequence.
    I think you have a problem the way you are conecting the subvis. Remember that in LabVIEW,  the flow of the data will determine the order of execution, and in your case, the conections looks kinda weird.
    I have a question; Do the subvis need to run simultainously?, or what do you need to do exactly

  • Run once inside timed loop

    I have a timed loop that monitors equipment. Whenever there is a fault I have it send a notification email. My problem is how to stop it from sending email every single time the time loop is executed. I tried placing the send email inside a for loop but quickly realized that the entire loop itself is reiterted. Any help is much appreiciated.
    Solved!
    Go to Solution.

    Hi icemaker
    I'm not really sure what you mean. Wouldn't a case structure be a solution?
    Could you post some code so we can see what you are doing?
    Best Regards
    David
    NISW
    Message Edited by Davidek on 10-02-2009 09:58 AM
    Message Edited by Davidek on 10-02-2009 10:00 AM

  • Continuous loop for flat sequence

    Hi, I currently using LabVIEW 8.2 and still learning about LabVIEW. I’m doing a project on a FMS model using USB 6501 to run the program and I’m required to run the program continuously. I was given a program from a previous student and I’m supposed to modify the current program.  The purpose of the program is to gather stock from the warehouse and place it in a different slot.
       I have a sample of the program and layout of the model where the lift is to move to the left and back to the right. I’m currently stuck as I can’t figure out how to run the flat sequence continuously.
      Firstly, it would just run once and stop at the right even when I’m using while loop.
      Secondly, when pressing the stop button it wouldn’t stop the program midway, it would continue to run until the frame ends. Is there a way to stop the frame when an error occurs?
    Please advice. Thanks.
    Attachments:
    LIFT LOOP.vi ‏288 KB

    You definetly have to switch to a reliable architecture!
    I think that your application must have several security features to prevent damage of hardware or even humans. So you must not use a program which just moves the lift from startpoint to endpoint without any chance to break the movement!
    That being said, i see two approaches:
    a) Statemachine
    b) Producer/Consumer
    The backdraft of Statemachine is its polling character. So you can only react to "worst cases" only within your given timeframe. The timeframe is the polling time plus all latencies including signal delays and similar. This can easily add up to about 1s and more.
    Producer/Consumer can possibly react a little faster if it is event based. The backdraft is that you need a rather good knowledge of LV in order to implement this properly.
    Another thing for applications like this are latencies created by the OS. Maybe it is necessary (not only recommended) to switch to a RT system or even FPGA in order to keep proper reaction times.....
    Maybe it is a good idea to talk about this application with an NI Alliance Member .
    hope this helps,
    Norbert 
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • While loop inside a timed loop

    Hi everybody!
       I'm using:
           - LV 7.1 + RealTime;
           - compactFieldpoint;
       I've noticed a strange behaviour, when I put a while loop inside a timed loop.  Let's fix timed loop with these settings:
           - 1 KHz clock
           - 1 ms period (yes, I know it's short....)
           - offset 0 ms
           - Phase 0
           - Discard missed period (ON) and MAintain original Phase (ON);
           - Timeout: -1.
       If inside this loo, I put a traditional while loop, waiting (say) for an event to occur, and if this event does not arrive, my cFP-2020 hangs! I mean, it becomes unreachable for the debugger, and, more, if I run a ping to it's address, after some cycles it becomes unreachable also from ping!
       Clearly, this code statement lock the fieldPoint, because if I remove the inner while loop all works.
      I know that with 1 ms period, timed loop always finishes late, but I set to discard missed period and timeout to -1. 
       It seems to me that sometimes Timed Loop add heavi overhead to programs, I'm turning to all while loop based tasks, even if my application has to be real-time!
       Advices welcomed! Have a nice day!
    graziano
    Solved!
    Go to Solution.

    I think the issue here is that putting your while loop inside a Timed Loop increases the priority for that task. Timed Loops can have dynamic priorities set over eachother, but they all run between Above Normal and Time Critical priority. My guess is that the debugger and built-in TCP functions run at Above Normal priority or less. This means your cFP isn't hanging, it's doing what it thinks is best. It's trying to finish this task before handling any lower-priority tasks.
    The suggestion to put a Wait function in your loop is an OK one. Keep in mind that you can actually set your wait time to zero instead of one and get the same positive benefit of handling other tasks. I would also suggest that you might look into waiting for this event in a lower priority (non-Timed) loop, and then transmit the appropriate data to your Timed Loop using an RT-FIFO or something. That might give you better handling. Just a thought....
    Jarrod S.
    National Instruments

Maybe you are looking for

  • MLGR to send a doc 'Report Goods Receipt to Buyer' proccessed wrong

    Hi We are using output type MLGR to send a doc 'Report Goods Receipt to Buyer' which is defined under->Output Types->Mail title and texts. Its 'Proccessing Routine' is: RSNASTSO Form Routine is: SAPOFFICE_AUFRUF All is well when we use MB02 MLGR,'Sim

  • IMac G5 Sleep/Restart/Shut Down Not Responding - 10.4.11

    I have a 20" G5 PPC iMac running 10.4.11 with 2.5 GB RAM. I recently restarted the machine after it had been shut down over a long weekend. Everything booted up and worked as usual until I tried to load iPhoto, which froze with the spinning wheel. I

  • How to test HTTP file?

    Hi all, I have a simple senario to test HTTP file. I want HTTP file to be written into XI as a file. Can anyone tell me the steps involved in this? I have created a HTTP service as sender with HTTP as communication channel, sender message interface.

  • Exceptions not thrown on interrupted SocketChannel.write()

    I just noticed a behaviour of java.nio.channels.SocketChannel.write() that makes me wonder. If write() blocks(), and the channel is closed during this blocking by another thread, AsynchronousCloseException should be thrown. However, in most cases thi

  • Batch Change Crop Ratio Only?

    I just went through a whole folder full of images cropping them to focus on the subject. When nearly done, I realized that all along I'd been cropping to a 5x7 ratio instead of the 4x6 ratio I'm supposed to use. Is there any way I can lift/stamp this