Program freeze during while loop operation

Dear all.
I have a program that controls mass flow controller and LabJack data acquistion unit and I have a difficulty in fixing a program bug that cause while loop freeze after certain period time(about 1-10 hours after run start).
Basically, the program reads a control profile that consists of two rows of data (two steps) from the front panel and controls the flow controller and Labjack.
There are three while loops and one is for reading data from mass flow controller and writing control data to that device and LabJack, the other one is to monitor the elapsed time to change the control profile, and the another one is to measure the data from the Aglient miliohm-meter.
Each step (each control profile) has data for flow rate and duration time, etc. Once the time(duration) elaspsed, the control profile switch to the second profile (second row) and the software keeps running with new control profile. After the second step, the control step comes back to the first profile. This sequence keeps going in the while loop.
The problem that I encountered is that after a certain amount of time, the control profile is no longer switched to the other one, and even though I change the step manually, the profile is not switched to the other one. I found that there is no error message from the instrument when this thing happens and no memory increase, but the CPU usage jumps up to 50 ~ 70%. (You can see the screen shot in the attached file). Normal CPU usage is between 2 ~ 10 % for this program. I use LabView 8.2.
I tried to figure out this problem , but it's too difficult for me to find the bug.
It would be appreciated if you can give me some hints and suggestions.
Thank you very much.
Yoon.
Message Edited by swsyoon on 06-25-2009 05:49 PM
Message Edited by swsyoon on 06-25-2009 05:51 PM
Attachments:
RH cycling with LabJack_final.vi ‏401 KB
RH cycling_latest.zip ‏539 KB

My general suggestion for a problem like this, is to try and isolate the problem.  Cut things out of your program, until you have the simplest possible program that still causes the problem.
Also, perhaps you can make the program go faster and get the problem to happen quicker, for testing. 

Similar Messages

  • Program times out while looping at internal table with huge records - Needs fine tuning suggestions

    Hi,
    I am trying to execute a report. It times out while looping at vbap internal table. This internal table has 140000  records and does the validation within this loop and geenrates data for the output. Due to this huge volume, the program times out when executed foreground.
    There are no nested loops, so I cannot apply 'Parallel Cursor' here.
    Is there any way I can fine tune the program so that it doesn't timeout? Is it possible to apply 'Parallel Processing' . If yes, how?
    Thanks,
    Pavan

    Hi Pavan ,
                  ->sort your internal table by all primary key for vbap.
                  ->Read a Record from the table (use your condition here)
                  ->if record satisfys your where condition ,get that record index .
                  ->loop the table from the index (without condition) .
                  its like parallel cursor only but for single loop .;-)
                  ->use field symbols ,wherever possible .
               if still dump is coming ,contact your basis team .
    regards,
    Krishna.

  • Program hangs at While loop breakpoint while stepping

    I have a breakpoint set on a While loop. I run the program and it stops at the breakpoint. I set up some probes and continue to run through the loop. After several iterations the program will not respond to further run commands.

    This sounds incredbly bizarre.
    Could you post this code for us to look at?
    I have seen one strange thing using the debugging tools and this is not it.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Stopping a while loop using the time difference of two tick counts

    Hi Guys,
    I'm currently writing a code which test how long does it take for a formula node to perform its operation. The program uses a while loop to perform the calculation, and the program stops after calculating when tick count has reached 10 seconds. The program then displays the number of iterations it does in 10 seconds. 
    So initially I created 2 frames of sequence structure. In my first frame I have my initial tick count, and in my second frame I have my final tick count and the while loop. I used the subtract function and divide the output by 1000 to get the time difference. Then using the comparison function, I set if output > 10 then the program should stop, to do this I linked the output of the comparison function to the stop button inside the while loop. 
    However, when I tried to run the code, the program just didn't run. Hence I created a similar program which puts the last tick count in new frame sequence. When I ran this code, the program never stopped. 
    Do you guys have any idea what went wrong with my codes.
    Thank you!
    Erry
    Solved!
    Go to Solution.
    Attachments:
    1. Tick Count.vi ‏27 KB
    tickcoun2.vi ‏27 KB

    Dataflow!
    In both VI's the stop terminal of the while loop is controlled by a boolean whose source is ouside of the while loop.  So that loop will either run once, or run forever, depending on the value of the boolean that is calculated before the loop starts and shows up at the tunnel going into the loop.
    I would recommend looking at the online LabVIEW tutorials
    LabVIEW Introduction Course - Three Hours
    LabVIEW Introduction Course - Six Hours

  • While loop doesn't stop until 2 more clicks

    I have to say I am really not familiar with LV at all, but Im learning.
    So, why is that after I clicked stop bottom, I had to click my OK button twice, then my program stopped. Why it can't stop immediately?
    Besides, if I want to some the dice result by array, which wire am I missing?
    Thank you!
    Solved!
    Go to Solution.
    Attachments:
    dice.vi ‏15 KB

    Hi RawtoLV,
    You have a while loop within a while loop. When you run the other while loop stops when you pressed the stop button, the inner while loop still runs. Since your OK button is using Latch when released, what i noticed is that when you pressed that OK button, it quickly switched to from true to false which didn't stop that while loop operation (could be due to the wait). May I ask what are you actually doing with the sequence structure?
    I would suggest using event structure instead (http://zone.ni.com/reference/en-XX/help/371361K-01/glang/event_structure/):
    here some more info on event structure:
    http://www.ni.com/white-paper/3331/en/
    http://www.youtube.com/watch?v=8eO64fo3Pho
    Warmest regards,
    Lennard.C
    Learning new things everyday...

  • Problem with While Loop.

    Hi guys,
    i'm doing a pass exam java question, below is the question criteria.
    Write a program that allows a user to enter their mark attained in each unit and displays their grade. After all marks are entered the average mark is displayed.
    The main method should:
    Prompt the user to enter the number of units taken (check for NumberFormatException)
    Write a for loop to repeat for each subject, where each iteration
    Prompts the user to enter a mark ( a double) for unit 1, unit 2 etc. This should be in a while loop so if mark entered is less than 0 or greater than 100 the prompt will be repeated.
    Pass the mark to a method called getGrade.
    Display the returned grade
    Accumulate each mark
    Print the average mark to 2 decimal places
    The getGrade method should:
    Accept the parameter passed from the main method
    Determine the grade according to the following scale
    Return the grade
    The words that i highlighted in bold is the criteria.
    As you can see from the above question, i create an array , even though the question does not prompt me to create as what i know from tackling JavaQuestions "if it does not prompt me to add a criteria, it is ok to add it" :)
    below is my program code , in which the result i get is the same as the question result. BUT, from the above question it ask me to add a while loop, so if mark entered is less than 0 or greater than 100 the prompt will be repeated.
    But instead i use a do loop. :(
    so can anyone help me or show me how to create the while loop for mark entered is less than 0 or greater than 100 the prompt will be repeated, from my program code below. cause i want to know whether it possible to have a while loop instead of do loop for the my program and the while loop can work with an array criteria.
    thanks
    htw.
    import javax.swing.*;
    import java.text.DecimalFormat;
    public class Mark
        public static void main (String [] args)
            String unitStr;
            String markEnterStr;
            int validUnit;
            double total = 0;
            boolean validInput = true;
            DecimalFormat fmt = new DecimalFormat("#0.00");
            while (validInput)
            unitStr = JOptionPane.showInputDialog(null,"Enter number of units: ");
            try
            validUnit = Integer.parseInt(unitStr);
            double[] markArray = new double[validUnit];
            validInput = false;
            for (int index = 0;index < validUnit; index++)
                do
                markEnterStr = JOptionPane.showInputDialog("Please enter mark " +(index+1) +":");           
                markArray[index] = Double.parseDouble(markEnterStr);
                while(markArray[index] < 0 || markArray[index] >100);
                String correctMark = getGrade(markArray[index]);
                System.out.println(correctMark);
                total = total + markArray[index];       
            double average = (double)total / validUnit;
            System.out.println("Average = " +fmt.format(average));                   
            catch (NumberFormatException e)
            public static String getGrade(double x)
                String grade;
                if (x < 50)
                grade = "Fail";
                else if (x < 60)
                grade = "Pass";
                else if (x < 70)
                grade = "Credit";
                else if (x < 80)
                grade = "Distinction";
                else grade = "High distinction";
                return grade;
    }

    Hope u got it.
               markArray[index] = -1;
                while(markArray[index] < 0 || markArray[index] >100);
                markEnterStr = JOptionPane.showInputDialog("Please enter mark " +(index+1) +":");           
                markArray[index] = Double.parseDouble(markEnterStr);
                }VJ

  • Using a DAQ value in a location outside of the While Loop it is placed in

    I am writing a program that records the speed of a car and then is supposed repeat the action through the use of an actuator.  I was able to write the program to the point where I am saving the data into a .txt file and will be able to read it back out.  My problem is that I need to use a dbl value that I am calculating from the output of a DAQ Assistant block that is contained inside a while loop in another part of the program to compare current speed vs. recorded speed then output an action.  Everytime I try to draw a connection outside of the while loop, the actual value is not read outside of the loop.  I cannot put the other part of the program into the while loop because the while loop only performs every .1 to 1 second and I need the output to the actuator to be a continous string delievered to the serial port.  I also cannot create another DAQ Assistant block that reads the same port outside of the while loop.  I have thought about using a jumper to another input on the input card, but I would prefer not to use the extra space.
    So generally speaking, I'm wondering if there is a way to read a value obtained from a DAQ Assistant block outside of the while loop it is contained in.
    Thanks to anyone that can help!!!
    Travis

    Cheers,
    I am not 100% sure what your problem is but how about writing the red value into the local variable and reading it outside of the loop? Or enqueue the value into the queue and dequeue it in the other loop (Producer/Consumer Structure (Data))?
    Br,
    Jick

  • How to make the exchange of data between 2 while loop in real time

    hello
    I have 2 while loop
    the 1st while loop includes the data acquisition program
    the 2nd while loop includes the control program
    my question is how to make the exchange of data between 2 while loop in real time
    I tried with the local variable and direct wiring between the 2 while loop
    it does not work (there is a delay)
    Solved!
    Go to Solution.

    Bilalus,
    Queues are only good to transfer data if your application isn't deterministic. Since you are using Real Time, I am assuming that your application requires determinism. If you are using Timed Loops and you use queues to transfer data between your loops, you are losing determinism. In this case, you need to use the RT FIFO functions. 
    Warm Regards,
    William Fernandez
    Applications Engineering
    National Instruments

  • Delay to start a "while loop"

    Yes I would like to run a while loop only after I switch on a start button. For some reason the loop does not start. I put the while loop in a Case structure which I want to make true with the start switch.

    Hi,
    ALT 1: If the button is false, the case does nothing, and the program is
    finished. So, you'll have to put the entire program in another while loop
    (that quits whenthe program is done), or use the run continuously button to
    start the program.
    ALT 2: Make a while loop before the while loop that you have. Wire the
    button to the stop criterium, and change the stop criterium to "stop when
    true". Wire anything (e.g. the button wire) to the second while loop, just
    to synchronise the execution.
    Put a "wait ms", with e.g. 50 ms, in the while loops, or your program will
    use up 100% processor time. This is not nesseccary if the while loop only
    runs for a short (<200 ms) period.
    Regards,
    Wiebe.
    "JShaw" wrote in message
    news:5065000000080000003C80000
    [email protected]..
    > Yes I would like to run a while loop only after I switch on a start
    > button. For some reason the loop does not start. I put the while loop
    > in a Case structure which I want to make true with the start switch.

  • Photoshop Elements freezes during launch

    I have posted this before, and will do so again. I am using Photoshop Elements 13.x with a Mac OS X Yosemite installation. The program freezes during startup. If I follow the advice found HERE:
    A Reminder for Mac Folks upgrading to Yosemite | Barbara's Sort-of-Tech Blog
    And then restart my computer, the program will load and function properly a few times. It might be once, twice... or five times. But soon enough I have to repeat the procedure. It's unacceptable and if Adobe can't offer support or a solution I would like to know how to obtain a refund.

    Hello? Is there anybody out there?

  • Timer stops during in loop while continuous operation

    Hi, all
    I have a sequence loop in while loop that is controlled by a "elasped time function".  After several hours of program operation, the timer stops and causes cycle to freeze.  This always happens (about 1-10 hours after run start) despite the length of cycle steps.  I cannot determine the cause of this problem and any insight is appreciated. I use Labview 8.2v and have attached the vi and screen capture of the function loop.
    Attachments:
    RH cycling.vi ‏394 KB
    block.JPG ‏125 KB

    swsyoon wrote: I'm just wondering if all the loop needs a wait statement. Is it more stable for the program?
    Wy wait comment was just generi. Most likely it is not the caouse of your problem. Any while loop should only spin as often as needed. For example, to update a timer, the loop rate should depend on how many decimal digits of the time you need to show. SInce your code runs for a long time, maybe once/second is entirely sufficient.
    Still, this is certainly not the cause of your problems but it is impossible to debug your VI.
    We cannot run your VI, because of missing subVIs.
    Do you know if any of your subVIs contain third party DLLs?
    Your entire code structure is designed inside-out, making very little sense.
    What's the story with the start button? Are you using the "continuous run" button to operate this VI??? Don't!!!
    What's the story with the big case structure tied to the tab structure? Since your code is inside-out, operating the tab during run makes no difference in the code. Large portions of code are inaccessible.
    You have extrememly confusing code the way you wire in and out of frame one at the bottom. Maybe that code at the bottom should all go inside the first frame.
    You error handling is no handling at all. You just display the error indicators. Shouldn't the code depends a little bit on error status?
    Even the UI is confusing. Labeling a stop switch with ON/OFF makes no sense. You turn STOP to OFF to stop the VI.
    Can you check for memory leaks? Run the VI for extended periods and see if the memory use increases over time.
    Check all your subVIs. Who wrote them? All your subVIs deal with instruments and visa resources. Do you properly close all references before creating new ones? Can you attach a few of your subVIs? You constantly open Labjacks (last frame)... do you ever close them??
    All indications point to a serious resource leak somewhere.
    It would really be beneficial to tear down most of the code a rewrite it from scratch using a more reasonable design template. The outermost structure needs to be a while loop. What good is a tab structure if the code in the other tabs cannot run?
    LabVIEW Champion . Do more with less code and in less time .

  • 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 .

  • Why does Labview VI pause intermittently during motor control while loop?

    I'm performing some biomechanical testing using Labview to control stepper motor actuators. I have a PCI-7334 controller card and a MID-7604 driver. The testing is run in load control using a while loop that sends a number of steps to the stepper motor that is proportional to the difference between the actual and desired load. The VI intermittently pauses though and sits in active for several seconds (~5 sec to 20 sec). What could cause this problem?
    Thank you in advance for your assistance.

    Without the subVIs it is hard to see what is going on.
    Some general comments:
    1. Block diagrams should be limited to the size of one screen.  Yours is over 4 times as wide as my 27" screen.
    2. Sequence structures should be avoided.  LabVIEW is a datflow language and only rarely are sequence structures required. There is almost certainly a way to write your program without them.
    3. The use of local variables should be avoided.  Again, they have a place but most likely they are not needed in your program. They are prone to race conditions, make extra data copies, and force execution in the UI thread.
    4. Floating point data types are not recommended as case selectors. They will be rounded and coerced to integers.
    5. Learn about the Producer/Consumer Design Pattern and state machines.  
    One possible cause of your slowdown is having the Write to Spreadsheet File.vi inside the while loop. This VI is convenient to use but it opens, writes, and closes the file each time it is called.  I have no way to tell how much data you write on each iteration but as the file grows the OS may need to re-allocate space for the file or fragment the file. These operations can be slow.
    Do you really want to Abort the program in the False case?  This will leave any outputs in the last state they had been set. This could have your motor(s) running, clutch engaged, ...  In programs which control physical hardware an orderly shutdown procedure is usually better: set all outputs to a safe condition, close files, close DAQ tasks, and indicate the status to the user.  Calling Stop allows none of this to happen.
    Lynn

  • What is the maximum size of indexed array that can be created during execution of while loop?

    Hello,
    I am using a ring acquisition to take in images. If i write them as files in the loop, it slows down the acquisition unacceptably. Therefore i am converting image to array and storing the array until the acquisition is complete and then reading the array and converting back to image to save. The program sometimes runs out of memory (after a couple of minutes). Can anyone think of a way where i can store the array/images within the execution (without losing image information), without slowing it down and to avoid this memory problem?
    I have included the VI.
    Thanks in advance for any help or advice.
    kindest regards,
    FraserD
    Attachments:
    LL_Ring_in_IMAQ_8_bit_array_then_write_as_png.vi ‏94 KB

    When you build the array of pictures you do it using auto-indexing out of a while loop. That means that memory is aquired for a copy of the previous picture array and the array is rebuilt on every iteration, this is slow and requires a lot of extra memory.
    If you want to speed things up try initializing a shift register with a 3D array of a size that will be able to hold a certain number of pictures, then replace the "pages" as new pictures are aquired, replace operations do not require copying of the previous array and will thus be much much faster. The difference is exeptional when dealing with large arrays/amounts of data.
    Now, the shift register buffer could be built into a functional global, and you can add a push/pop logic to it so that you can have a p
    arrallell loop that works on writing the elements to disk. You could use a que for this, but I think even though you specify a size limit to the que it still aquires memory as new elements are added (correct me if I'm wrong people...:-)), so a functional global acting as a circular buffer og fixed size frame for a que should be better.
    MTO

  • How should I set up my VI so that I can use the linear fit coefficient data analysis program, when my values are coming from while loops within a sequence structure?

    I'm attempting to create a calibration program, using the printer port, and a Vernier Serial Box by modifying a calibration program designed for the serial box.
    There are six calibration points, and to collect them, I have it controlled by while loops so that the numbers are taken when a button is pushed, and this is inside a sequence structure so that I can get the six different points. I feed these numbers into two different arrays (for x and y values) and then try to use the linear coefficient analysis on these points, but the values for the slope and intercepts it returns are not correc
    t.
    If I cut out the array and coefficient analysis, and feed the same numbers in directly without the while loop and sequence structures, it produces the proper values... I don't know why the numbers it is producing are different, and I'd really like to know.
    Thanks,
    Karinne.

    I would use a data manager sub-vi that would be called by each from of the sequence structure that produced a data point. The data manager sub-vi could auto append new items or could place items in a specific entry of an array. Later on when you want to calculate the linear fit, call the sub-vi to return the array of values.
    Stu

Maybe you are looking for