Problem running two parallel while loops

Hello world

I'm new to Labview and is actually my first attempt. I intend to acquire data from two rockers simultaneously through two different ports. When I run my program attached with execution has highlighted, the second loop gets higher priority. How to prevent this? Also, I'm getting error codes when running arrives at the stage where Visa read data are passed to sweep of string function. Please suggest corrections to correct these problems.

PS: I have not yet plugged on devices, that's why the properties of connection for the two Ports are the same at the moment.

Kind regards

Avi0111


Tags: NI Software

Similar Questions

  • 2 parallel while loops with functional overall to share data

    Hello

    I'm having a problem with the sharing of functional with globals data between two parallel while loops:

    1. One of the loop (bottom) generates a random number periodically and write the total functional sample.
    2. Another loop (above) has a structure of event and when it expires, he would read the functional global and intrigue, a chart data point.

    The problem is sometimes the functional overall seems to be 'locked' and the output becomes zero constant. It also seems that whenever I first open the VI, it works fine. But for the second time running, he begins to have the problem.

    You must initialize your VI stop FGV FRONT of your lower loop begins.  Even if you use a global variable that is functional, you have a race condition.  FGV is read in the lower loop until it had a chance to be initialized with a value of false in the upper loop.  Functional global variables do not forget their data between executions of the VI.  So it is always set on stop the last time that you ran the VI.  This works your VI the first time it's because VI does not have in memory, so when it loads, it loads with the default value False in the shift register.

  • Functions don't run when a loop running in a while loop

    Hi all

    I have a loop within a while loop. All main functions are running in this while loop. However, once the for loop executes other functions in the while loop don't work anymore until the loop for stop execution. Could someone help me with this problem? Thank you.

    Kind regards

    Nicky

    Hi Nicky,

    Ah, well I don't have much suggestions but maybe you can try with a conditional for the loop. I've attached an example. You can go through it. I don't know if it's a good idea to use this way, but again, if this can help, so I'm glad that.

    To create a condtional for loop, place a normal for loop on the block diagram, right-click and select terminal condtional.

    Kind regards

    Amine31

    (Give congratulations to good answers and Mark as a Solution If your problem is resolved)

  • Error with parallel while loops

    Hello

    I need to connect 6 different instruments gpib. I am using parallel loops, but the problem is when I try to open 2 or 3 Subvi simultaneously (the intstrument drivers), I just open one because of everything in a loop to run the Subvi. The program should be able to open all the Sub - VI independently.

    Can give you some ideas?

    Thank you

    A. Castillo

    Look at the detailed help for functions to notify.  Then follow the links to the examples included with LV

    Another problem that you have, whether you use your curls greedy or reporting or another technique, is to know how to stop your hand while loop.  All the subVIs must be called before the loop stops.  This is the fundamental paradigm of LV

    You will probably need to rethink your primary architecture to something that will actually do what you want.  Plan and design before your departure from the coding.  Note requirements for the program and determine which parts are dependent on othrer parts, then select a program architecture that can meet the requirements.

    Lynn

  • How to end parallel while loops

    Hi, I'm using LV8.5.  I have 2 while loops, running in parallel.  Loop1 is faster (waiting time of 100 ms) and Loop2 is slower (several minutes waiting time).  I use a local variable (STOP button) Boolean to commonality between the loops.  The button is in the loop faster (Loop1) and the local variable is in Loop2.  When I try to end the While loop, Loop1 stops immediately, while I have to wait for Loop2 finish.  Is there a simple way to make two loops to stop immediately?  I have been using a Control\Stop Application, but may not be the right solution.

    Thank you.

    Hi shanx2,

    reduce waiting time in your second loop and count the iterations instead. The loop will do the same, but the stop will react much faster. Another possibility would be to use a queue instead. Connect to a timeout that corresponds to the current time-out period, you use and send a message to stop the loop. You can choose between the queue has been exceeded or not. Connect this result to the conditional loop. You can send the message from the queue after the first loop was arrested.

    Mike

  • Stopping at two simultaneously while loops in a sequence

    I'm under two loops while at the same time. A while loop is used to produce a square using the acquisition of data USB of NOR-6343 wave. The another while loop contains my main code. I make sure that my square wave while loop stops after the hand while the loop is over. I used the function "To highlight the Excution" to see if my code is excuting in order and the way I expected to and it seems to do, but when I hit the button stop the square wave while loop stops so that the main while loop always ends excuation. The main while loop takes a series of measures using the data acquisition Toolbox, so I need to make sure that the square wave is being emitted during the execution of the loop of mian.

    Currently to work around this problem, I wired a constant numberic (101) inside the large loop for a numberic out indicator. And I used a cheque codition "Equal" in the square wave while loop and set it so that this loop stops when he sees the value. This seems to work and made sure my square wave still series, while the main loop is excuting finishing. Even if it works, I want to know if there is a better way. Attached are a couple of screenshot of the loops.

    I vote for using a notification utility.  You must order the loop at the end.  Do a front panel indicator to stop a loop is not a good practice.

  • How to synchronize parallel while loops?


    This will do what you want?

  • Sharing of Boolean values across while loops

    I'm new to Labview and I try to use an angular encoder as a type of switch.

    I want to take measures continuously from the angle of the encoder and turn on an analog output signal, each time comes in a certain angle. When the encoder drops from this angle, I need the signal to turn off.

    To do this, I try to run two parallel while loops. We measure the angle of the encoder, while the latter creates the output signal. What I want to do is to put a logical statement in the measurement loop that will record 'true' if the maximum angle is reached. I try to get that 'real' statement in the loop of generation of signals as a trigger to turn on (using a case structure and the "DAQmx Start Task.vi") output. The question I have, is that the 'real' statement cannot exit the loop to measure up to the end of the loop. But since I'm running it continuously, the loop ends. Thank you.

    Create a local variable of the Boolean in anxiety.  Right-click on the local area and select change reading.  Put this inside the loop else local.  If you have a loop that writes to the Boolean value and a loop that reads from the local.  Now you can remove the wire that comes from a single loop and feeds on the other.  Then your curls will work in parallel (if there is no other dependencies of data between the two loops).

    As an alternative to local variables, you can use a queue to transfer data from one loop to the other.  A loop (the producer) will write to the queue.  The other loop (consumer) reads from the queue.  See the examples on the architecture of producer-consumer for more information.

  • run a while loop in separate vi, minimize the window flashing

    My apologies in advance for not including a VI; I cannot give it, cannot even provide screenshots.

    I have a state machine base with a cluster of Boolean values that are analyzed in the 'default' State, the scan index = true determining the next State. All other States to return to the default state. The State of 'stop' stop the loop with a Boolean constant = True, located inside the structure case wired to the time entry conditional loop (all States have a Boolean constant False wired to it). Apart from the cases

    statement, the wire connected to the conditional entry is connected to a Boolean indicator, ' Stop, in really. The time delay within the State of the machine while loop is currently set at 100 ms.

    In addition to the 'State' shift register, the state machine has a "boolean" shift register. All States, except one, feeds the value passed the Boolean value through to the next State (i.e. wired directly from left to right the structure of the case). The exception is the State which inverts the Boolean value, with the output of the inverter transferred to the State following and also connected to a Boolean flag, 'Show the State', the

    indicator outside the case statement but inside the while loop. All other States wire just the previous state of the Boolean value through the following State, unchanged.

    In addition to the State of the machine while loop, I have a parallel while loop (scourge of the LV forums). All entered conditional loop is connected to a local variable to 'stop, really. " A True/False case in this while loop structure contains a Subvi in the case of True value. The Boolean value of entry to the case statement is connected to a local variable for 'Show status'. The Subvi, which is in the real case is to display the State of the

    user.

    The Subvi which provides status through its frontage runs a script in python via a 'comand prompt"vi. The necessary update to the python command send is ~ 1/second. Within the Sub - VI is a 1 second delay time after execution of the code.

    It works but I'm doing some improvements with minimal impact on what I have.

    Two cases of VI properties that relate to the conduct of the State Subvi (floating or default, modal does not at all):

    1. with "Firm when previously closed" selected, the window switches VI (via the main switch VI) open and closed but when it is open there is the a second window flash that could cause seizures in some users.

    2. with "closes when previously closed" deselected, the window remains open and it is difficult to tell the difference between the running state and is not running. In addition, the Subvi window will not be reduced for this option.

    Is there a little invasive change, I have the code in force to stop a second flash described in #1 above and activate / deactivate the Subvi status window?

    Thank you

    Jeff


  • Write on the worksheet while loop problem

    Hello dear Labviewers. I have a 'writing on spreadsheet"with a table 2D DBL connected on it, but the problem occurs inside the while loop. I want exactly those time six values in my excel document, but it restarts after every "two seconds" and I cannot get rid of this problem. I want exactly the same numbers in the Excel document as it is in the table.

    I tried to move the two "write to the spreadsheet' boxes outside the while loop, but the Excel document does not display a single value in the table, when I do this. It shows that the two headers

    My second problem is rounded off on the numbers. Even if I wrote "%.6f" in the part of the format, it gives me a single decimal value.

    Thanks in advance

    Orlando

    Orlando says:

    Thanks for the help Ravensfan

    But the "worksheet to write" not a not an output port, then how can I do this?

    I downloaded my VI

    I never said anything about writing about a spreadsheet file with an output port.

    See the attached VI for changes.  It's only the new data of this iteration of the loop that will write it on the spreadsheet file VI, not made all of the table from all iterations.  There is an entry of table 1 d to the spreadsheet file.

  • How to set up the execution in a way independent while loops?

    Hello

    I hope someone here can help point me in the right direction for that.  My system at this stage is still quite simple, I just data collection of 2 resistance probe and a pressure sensor, their output in the Panel before and sometimes to write.  I have put architecture in place to call parallel loops running at the frequency I would ideally like to do.  that is, I want the RTD to update every seconds and the pressure transducer for updating chaque.5s, I want to write to the file at a rate defined by the user and I want the Panel before updating a half second (correspondence with the pressure transducer).

    Now, in the structure, I wrote, it should run all the while loop once before it can restart the sequence.  Technically, the code works, but it takes ~1.5s to the RTD to collect and update and so the whole VI takes ~1.5s to complete.

    I don't care if the RTD is slow to update, but as I use the sensor as a gauge of the cell pressure I need to know at a high frequency that the pressure is in the cell, and I don't want to wait 2 seconds for the information.

    I know I'm starting to get into a much more advanced architecture for this and ive spent the last googler 6 hours trying to find a procedure for how it works but I can't figure out a way to have the whiles stop waiting for RTD loop finish.  I guess that this is to divide the VI in several screws and construction of a library, but the resources I could find about it were not very useful for a beginner like me.  If someone could point me in the right direction on where I should look then that would be great!

    Thank you

    Zach

    Zach,

    Because you created the tasks of data acquisition elsewhere, we do not understand how you have set up. Continuously, starting and stopping tasks may be slower than setting up of a permanent task and let it run.

    You have not indicated that you use the DAQ hardware.  It is often better to leave in the DAQ hardware clock set ignition rather than rely on software distribution. The pressure loop reads 1000 samples at a time and calculates their.  If you're not sampling at 2000 s/s or faster, the loop ends late due to waiting for data.  In two loops DAQ, you do not use the calendar information.  Acquire the data in tables rather than waveforms.

    The Dequeue functions in the loop at the bottom have no wait times for this loop will not iterate until all three queues have data. As the pressure loop runs faster than the loop of RTD, the queue of pressure slowly fills.

    The upper and lower loops are vying for the data.  The preview queue item does not delete data from the queue, but the functions of the Dequeue elements in the loop of the low fact.  If data is deleted form the queue before the upper loop resembles it, it will never be saved. With your installation there is no way to ensure that you get all the data or that you do not read and record the same data more than once.

    You don't have anything set up to stop one of the loops.  You use the Cancel button to stop your VI?  If Yes, STOP! Other aprticpant on the Forums said: "using the button abandon to stop a VI is similar to the use of a tree to stop a car.»  It works, but can have unintended consequences. "Things like closing of files, freeing up the queues, by closing the task of acquiring data, and other things can occur when the program is interrupted.  You do not shut down your computer by pulling the plug.  Stop your program also neatly.

    Ok.  I have highlighted some of the things that can keep your program to run as desired.  What can you do about them?

    1. you probably don't need call loops.  Normal so the loop should be good enough.

    2 put a stop button on the front panel. Put the terminal in loops (bottom) and connect it to a function to send a Notification and the status of the Terminal loop (stop sign).  Put wait Notification functions in each of the other loops.  Put a period shorter than the time loop minimum on all of them if the lops can work.

    3. see the comments above regarding the DAQ bed material.

    4 use the Dequeue timeouts to adjust the pitch of the loop the loop where the data is used.  Also make sure that all data is removed.  You need to think about your time together and what are the bottlenecks.  Except if you expect this system to grow to much larger dat sets, I probably acquire ALL data (pressure and RTD) at the same rate and reduce the displayed amount by the average like you do for pressure data now.  If you want different final data rates, just average different amounts of data.

    5. it might be useful to learn how to work the State machines.  Display, averaged and recorded files could be managed in a loop by a simple state machine while allowing for more flexibility in the calendar.

    6. Another good reason to consider a state machine is that initialization and shutdown processes can easily be handled in the corresponding States. At this point you do nothing with errors. A state machine would enable you to handle errors (for example, the cancellation of the selection of the user files) without stopping the program.

    Lynn

  • Start stop while loop with tab control

    I want to be able to start and stop a while loop by entering and leaving a tab.  I use a structure of the event to do so, but it seems not elegant or the right way to do it.  The only way I could get to the kind of work is by unchecking the lock front panel in case of structure.  I have attached a sample vi of what I have so far.

    The problem is that you can't even stop the program by pressing the stop button until you exit the tab, which is not a user friendly interface.

    The event should just manage basic user events.  Any given event does not take a lot of time to run.  While you are in the diagnostics tab, your code is stuck in this while loop.  Although the setting of the front panel of the lock allows you to do other things, the LabVIEW is just put on hold all these other events of the UI (like Stop button value change) and cannot handle them inside while the loop stops and allows outside while loop to go through again.

    You should have a parallel while loop to manage waveform graph.  You can use notifiers or queues or a motor of action FGV (see Ben Action Engine Nugget) to switch the starting or stopping of the update of the chart of waveform until the parallel of while loop.

  • VI is paused and while loop has highlighted

    I'm in parallel while loops and for some reason when it should start to run loops, it pauses for the VI and highlights one loops. It was not last week when I ran it so I don't know what is the issue. I've included a screenshot of the beginning of the code, the loop that is highlighted is the down right. Also, what is the red dot on the wire in error right after the structure of sequence?

    Thank you

    lvuser333 wrote:

    I'm in parallel while loops and for some reason when it should start to run loops, it pauses for the VI and highlights one loops. It was not last week when I ran it so I don't know what is the issue. I've included a screenshot of the beginning of the code, the loop that is highlighted is the down right. Also, what is the red dot on the wire in error right after the structure of sequence?

    Thank you

    Someone snuck into a breakpoint on you.  The red dot is the stopping point, and that's why your VI made a break.

  • When boolean is set to skip a step in the while loop

    Hey guys,.

    I have a program that controls a fan that pumps gas at a certain speed. This entire process is run in a while loop. When we move from the gas by a gimbal which is located on the front, we immediately jump in a cycle of breakdown and then goes back to the pumping of the gas at the rate previous, but we do not know how to achieve this. Can you guys give advice? Thank you!

    Sincerely,

    The Z.

    Hello,

    A shift in your loop register may be able to achieve this type of functionality. If wire you the switch in the shift register to the right and register in the structure in case of wire left shift, the loop must travel once more before moving on to the HP gas. Here is a link to a tutorial on shift registers:

    http://www.NI.com/gettingstarted/labviewbasics/shiftregisters.htm#shift records

    -Erik S

  • for loop in while loop

    To all,

    I have a question, I have a loop within a while loop. The loop runs and displays the log data. It seems that, until I have stop the while loop that log data display. It almost seems that the for loop runs until the while loop is stop.

    The following accessory is an example of what I have in my code. But the because the loop runs in this example. My code is the same idea, but the loop seems to run when I start my program with execution of climax. Otherwise, it runs once I left the while loop.

    All entries?

    Thank you

    Cosmica

    I tried your VI and there is nothing wrong the way in which it executes. Nothing happens until the second tab is selected and you press the 'off' button, date on which the loop FOR runs until the indicator shows a "9". In subsequent runs, again, it count up to nine, but it is so fast that you never see. For the observer, the indicator remains at nine.

    Of course you would see things a little bit better if you place the small waiting inside various parts of loops. At present, the VI consumes all CPU do nothing but turn empty loops for always while spending from time to time some nanosecods to iterate through the loop FOR. You also destroy your resource VISA with tunnels of default output, so the fence at the end probably will fail. Overall, the code seems too complicated for what you want to do. Do you really need to link a case control tab structure? Seems unnecessary. The for loop should run when the button is pressed, since this implies automatically that Your ' e on the second tab, you don't need to read the tab control. It's redundant!

Maybe you are looking for