While loop control using hardware.

Hi
I would like to be able to run a while loop until i get a signal from my hardware (either on a counter channel or a regular AI channel).
Any Ideas??
R

Once you determine what the signal needs to be, put a boolean value (T/F) to it and wire that result to the While loop "run/stop" input.
For Example, if your signal to stop the loop is a specific value (eg counter = 100), use an "Equal?" vi to 100 and wire into a Select vi (from the comparison palette). When the counter = 100, have a constant "True" go out, else a constant "False" (which is wired to the while loop "run/stop" input).
Good luck with it, Doug

Similar Messages

  • How to stop a while loop when using tab control

    How do you use a tab contol to stop what is happening on one tab when you switch to another tab?  In the test example I attached, I have a while loop nested inside a case structure controlled by the tab control.  When I tab to page two the elapsed timer starts but when I switch to another tab it does not stop.  I can't come up with an easy way to stop or exit the while loop when I change tabs. 
    Thank you
    Danny
    Attachments:
    tab control.vi ‏24 KB

    I played with it a little more and came up with this fix.  This fixes it but is not tied to the changing tabs as I was looking for.  Is this just too many nested loops and a bad idea?
    Danny
    Attachments:
    tab control fix maybe.vi ‏26 KB

  • Stepper motor closed loop control using 7344

    I have some question about the closed loop control of stepper motor using 7344. From the NI website I got that closed loop steppers work differently from closed loop servos. Instead of adjusting the output on each PID iteration like a servo system, closed loop steppers will do a pull-in move at the end of a move to adjust for any difference between the target position and the encoder feedback. By default, it will attempt the pull-in move three times.
    Now for example I got five points: (0,0) (10,20) (30 40) ( 31 60) (50 65). The request time interval I set as 10ms. This mean that in the first 10ms, the machine should move from (0 0) to (10 20). But for some reasons the machine can not move to (10, 20), it moves to (8,16) and the first 10ms passed. In the second 10ms, how it move? Move from (8 16) to (30 40), If like this, the following error will accumulated. In practise, it is not accumulated. Is there anyone can explain something about the closed loop control of stepp motor? Thanks a lot!

    Requested Interval is additional data for the Position buffer type. The Position buffer type requires a Requested Interval parameter, and indicates the time between contouring data points in milliseconds. For all other buffer types, the Requested Interval parameter is ignored.
    The controller will use the closest value it can that is greater than or equal to the interval value you requested. Your time interval must be an even multiple of the PID rate.
    For example, given a PID rate of 250 ms, a time interval of 11.2 ms between points is physically impossible, so a call to configure buffer with an interval of 11.2 causes the  buffer to actually be configured for 11.25 ms, since 11.25 is the nearest possible interval greater than 11.2. The following table shows valid intervals for each PID rate.
    My question is like this. For example I got five points: (0,0) (10,20) (30 40) ( 31 60) (50 65). The request time interval I set as 10ms. This mean that in the first 10ms, the machine should move from (0 0) to (10 20).  If it is impossible for the machine to move from (0 0) to (10 20), there are two ways to solve this problem. First is the time interval is 10ms and assume it move to (8 16) within 10ms and take (8 16) as the start point and (30 40) as the end point of the second move. Second is extend the time interval, assume it takes 14ms to move from (0 0) to (10 20). After 14ms, the (10 20) is the new start point for the second move. I think it works as the second ways.If not, the following error will accumulated.  Is there anyone can explain something about the closed loop control of stepp motor in detail? Thanks a lot!

  • How to stop a period counter in a while loop without using abort execution%3F

    I am using a NI x series 6343 andcounting pulses, but when i try to stop the counter with a boolean operator nothing happens, ihave to go and use abort execution, 
    Help

     the stop sign does not do anything, it just stops after the timeout.
    Which is exactly what you're asking it to do.
    The STOP button is not a magic ABORT function.  It's a simple TRUE/FALSE variable.
    The way you have it set up is:
    repeat
       Get some data (Timeout = 10 sec)
       Process the data
    until STOPped
    It's going to check that STOP value (is it pressed or not) ONCE, sometime during the loop.  Maybe before your GET DATA, maybe during, maybe after - you don't know.
     Whenever the GET DATA thing returns (after 10 sec, or after getting some data), then it willl use that value and decide to loop again, or to stop.
    If you want to abort the GET DATA operation, you have to find another way.
    One way is to use a shorter timeout.  Do you have to track it down to 1 pulse every 10 sec?  If not shorten your timeout and go from there.
    Another way is to find a way to abort the operation.
    Again, I'm not familiar with the EXPRESS stuff you're using, so I don't know the details.  In all my 26 years of LabVIEW programming, I've never once used EXPRESS stuff.
    Using the regular NIDAQ stuff, you would
    INIT a task
    START a task (Task ID)
    repeat
       READ a task (TaskID, timeout = 0.1 sec, or something)
       if TIMED OUT
           do nothing
       else if ERROR
           announce error
       else
           Process data
       end if
    until STOPPed or ERROR
    CLEAR task(Task ID)
    It's more complicated, but you have more control. 

  • I have a VI with a while loop controlled by "stop" button. How can I finish the running of this VI in a another VI programmablly.

    I mean I want to control the "start" and "stop"
    of a VI with another VI.
    Thanks

    1... Change your slave VI to stop on the button OR a global boolean variable.
    2... When your slave VI does stop, set the global variable to FALSE (ready for next time).
    3... Set the global to TRUE from the master controlling VI, on button click, or whatever is supposed to stop the slave.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Trouble Using TimerEvent in While Loop

    Hello,
    I am attempting to use a TimerEvent in a while loop. In the example I have created below, the init function should loop through the values myArray, tracing each value at three second intervals. It seems, however, that because I am incrementing the currentNum value outside of the while loop (in the timerHandler function), that the loop just keeps running until Flash stops responding.
    var myArray:Array = new Array("one", "two", "three", "four", "five");
    var currentNum:int;
    var myTimer = new Timer(3000, 1);
    function init():void {
    while ( currentNum < myArray.length ) {
    trace(myArray[currentNum]);
    myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerHandler);
        myTimer.start();
    function timerHandler(e:TimerEvent):void {
    currentNum += 1;
    init();
    I am wondering if what I am trying to do is simply not possible or if I am missing something.
    Thanks in advance for any thoughts on the matter.

    Thanks, Ned. That makes sense. I was able to work around my problem by getting rid of the while loop and using a conditional statement to test if I had reached the end of the array.
    var myArray:Array = new Array("one", "two", "three", "four", "five");
    var currentNum:int;
    var myTimer = new Timer(3000, 1);
    function init():void {
    traceArrayValue();
    function traceArrayValue():void {
    trace(myArray[currentNum]);
    if (currentNum + 1 < myArray.length) {
    myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerHandler);
        myTimer.start();
    function timerHandler(e:TimerEvent):void {
    currentNum += 1;
    traceArrayValue();
    init();

  • Why the execution time increases with a while loop, but not with "Run continuously" ?

    Hi all,
    I have a serious time problem that I don't know how to solve because I don't know exactly where it comes from.
    I command two RF switches via a DAQ card (NI USB-6008). Only one position at the same time can be selected on each switch. Basically, the VI created for this functionnality (by a co-worker) resets all the DAQ outputs, and then activates the desired ones. It has three inputs, two simp0le string controls, and an array of cluster, which contains the list of all the outputs and some informations to know what is connected (specific to my application).
    I use this VI in a complex application, and I get some problems with the execution time, which increased each time I callled the VI, so I made a test VI (TimeTesting.vi) to figure out where the problem came from. In this special VI I record the execution time in a csv file to analyse then with excel.
    After several tests, I found that if I run this test VI with the while loop, the execution time increases at each cycle, but if I remove the while loop and use the "Run continuously" funtionnality, the execution time remains the same. In my top level application I have while loops and events, and so the execution time increases too.
    Could someone explain me why the execution time increases, and how can I avoid that? I attached my test VI and the necessary subVIs, as well as a picture of a graph which shows the execution time with a while loop and with the "run continuously".
    Thanks a lot for your help!
    Solved!
    Go to Solution.
    Attachments:
    TimeTesting.zip ‏70 KB
    Graph.PNG ‏20 KB

    jul7290 wrote:
    Thank you very much for your help! I added the "Clear task" vi and now it works properly.
    If you are still using the RUn Continuously you should stop. That is meant strictly for debugging. In fact, I can't even tell you the last time I ever used it. If you want your code to repeat you should use loops and control the behavior of the code.
    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

  • Stop 2 while loops into another

    hi,
    I'm a beginner in labview and i've got  problem!!!
    My program is composed of 3 while loops (2 into one) and i'd like to stop it with only one STOP button.
    I can't use local variable with stop so i'm wedged!!!
    I use LV 6.0
    I think it's very difficult but .....
    Sorry for my english, it is very bad!!!
    Thanks!!
    Lacoule

    Hi Lacoule,
    I guess you could not use local variables for boolean controls with a latch function, only a switch function works with local variables.
    One simple way to achieve what u want is, (assuming that you stop button is in the inner loop) use stop button to stop the inner + enter a pre-defined string or numerical value in a global or local variable and when the control comes out to the outer while loops, just use a  compare function to generate a true state and can stop the other two loops.
    I hope this helps.
    -Mohan.

  • Ai read in while loop

    I am acquiring data from a DAQ e series card. i intialized the daq by using AI config out side while loop . i used AI start and AI read in while loop . iam acquiring data from 5 channels. the buffer size ia 1000 and so is the scan rate in AI start.I want to save the acquired data in the file. i am also displaying data o n chart. every thing is working fine. my problem is i want to save 500 points in one seconds. for this i changed the while loop execution time by using waint until multiple sec VI and assign it 10  i was expecting that now iwll save more data point in file as now loop will execute more fast but it does not happen like this. is there any way to minimize the executing time of whil loop.i checked if i deleted AI start and AI read then loop execute very very quickly. should i place AI start and AI read out side loop but then how will it acquire data contiously. I m attaching gif file of the protion of my VI .any suggestion?
    Attachments:
    myVi.GIF ‏72 KB

    I was working quickly, and from memory, so my apologies for errors or non-clarity in my previous post. :-(
    The AI START VI, should be used OUTSIDE the loop, since you only want to START the task ONCE.
    When the task is complete (your WHILE loop is done), then call the AI CLEAR task to clean up (ONCE).
    If you set the NUMBER OF SCANS TO ACQUIRE input to AI START to zero, that has a special meaning: acquire data indefinitely. It will not stop on it's own (assuming no errors occur), you have to explicitly stop it.
    If you do this, you have to read the data often enough to avoid buffer overflow, which means the incoming data is filling up the buffer faster than you're emptying it.
    I have attached a picture of the general idea. If you really want to use the CPU efficiently, then consider the shift-register idea in the picture - you process on batch of data WHILE the next batch is coming in. If you want a simpler solution, forget the shift-reg, and process it directly after reading it. If your buffer is twice the size of your processing size, you'll be OK.
    Message Edited by CoastalMaineBird on 09-14-2005 07:45 PM
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks
    Attachments:
    DAQExample.png ‏16 KB

  • Do While loop with query?

    There seems to be no way to do a do-while loop without using
    Cfscript.
    Is there a way to place a cfquery inside cfscript?

    How so?
    The algorithm I'm trying to write is sort of recursive.
    Basically, I have a column in a table generated like so:
    Row 1: Sum of (account 1, account 2)
    Row 2: Sum of (account 3, account 4)
    Row 3: sum of rows 1-2
    Row 4: Sum of (account 5, account 6)
    Row 5: Sum of rows 3-4
    So basically, I'm trying to query for all of the accounts
    that make up row 5 (which in this case is ALL of the accounts). It
    looks like I'm going to have to work backwards from the starting
    row (5) and keep checking the rows that its composed of until I hit
    some base case (no more summation rows?)

  • How to use while loops to implement a simple climate control.

    Hi,
    I am currently a 4’th year computer systems engineering student in South Africa doing a primitive climate control project in LabVIEW 8.0. Although my knowledge and skill level of LabVIEW is far from that of an expert, I really enjoy working with it. The project consists of a motor driving some fan blades, a resistor heater and an analog temperature sensor. The basic functionality entails that a user specifies a desired temperature and then the program will heat if the current temperature is lower than desired or cool if the current temperature is above the desired temperature.
    What I want to add is an acceptable temperature difference so that the fan and heater do not switch constantly as the threshold temperature is reached. Rather leave the current temperature to linger between the maximum (current + acceptable difference) or minimum (current – acceptable difference) allowed temperature before heating or cooling it to the desired temperature once again.
    I have attached 2 VI’s:
    Final Assignment: I tried to achieve the sensible climate control by making use of a formula node. As soon as I substituted the if statements in the formula node with while statements, the VI did not respond. It did not give any errors, it just didn’t respond.
    Final Assignment2: I tried the same but by making use of while loop structures. The while where my Input DAQ is works fine, but none of the other while loops work.
    Please advise me on possible solutions for my problem/project.
    Thank you in advance.
    D. Weppenaar
    Attachments:
    Final Assignment1.vi ‏254 KB
    Final Assignment21.vi ‏256 KB

    1. Your VI does not respond because your formula node is trapped in an infinite loop and cannot exit if you're out of the deadband. Replace the words "while" with "if" (or similar) and you might be getting somewhere. Sorry, I don't have DAQ installed, but what determines the loop rate?
    2. You have a dataflow issue. Only the inner loop on the left will run. All other loops must wait because they depend on data from the first loop. data is only available at an output tunnel of a loop once the loop finishes and a loop cannot start until all input tunnels contain data. Also the first loop can never stop, because the stop button is outside the loop and will never get read once the inner loop starts. The stop button needs to be in the innermost loop.
    Most likely, all code segments should run synchronized, so delete all the inner loops. They serve no purpose. All yon need is the big outer loop as in the first code.
    There are many ways to directly observe what is going on. For example you could run the VI in execution highlighting mode while watching the diagram.
    Clearly, you need to become more familiar with LabVIEW basics. Maybe do a tutorial? Right now you might think that dataflow is a hindrance while in fact it is one of the most powerful advantages of dataflow programming. You simply need to be familiar with its logic.
    LabVIEW Champion . Do more with less code and in less time .

  • Control a while loop in the sub vi using a button in the main vi?

    Dear all,
      I want to be able to control ( turn on or off) a while loop in the sub vi from a button control in the main vi. How can I use the Control Reference to achieve it?
      Thank you in advance. 

    Like this
    look at attached vi's
    Run the main vi
    Attachments:
    main_boolean.vi ‏12 KB
    sub_boolean.vi ‏16 KB

  • Using user input to control while loop

    Hi! I'd like to use a user specified value to terminate my while loop. For example, acquire for 3 seconds as opposed to acquiring until the user hits the 'stop' button. I've attatchted my code and would appriciate if you could give me some suggestions.
    Thanks,
    Katie
    Attachments:
    Acq_on_3_Channels.vi ‏463 KB

    Replace "Wait Until Next ms Multiple" with Timeout.vi. The example shows how to use this vi.
    Because the duration is given by software, it will not be very accurate. Anyway, it can not be more accurate then the cycle time. If you reduce the cycle time in order to get a better precision, then the CPU usage will increase.
    If you need a higher precision, then it will be necessary to use a hardware timing. This can easily be done be using an additional counter that is configured to generate a pulse on its output. This pulse is then used to gate the 3 other counters. This allows a very high and repetitive precision (period of the internal timebase of the counter)!
    Attachments:
    Example_with_timeout.llb ‏28 KB

  • How to use one single boolean button to control a multiple while loops?

    I've posted the attached file and you will see that it doesn't let me use local variable for stop button, but I need to stop all the action whenever I want but more than one single button on the front panel would look ugly... The file represents the Numeric Mode of
    HP 5371A. thanks for your time
    Attachments:
    NUMERIC.vi ‏580 KB

    In order to use a local variable, you can change the mechanical action of stop button (Switch When Pressed will work), or create a property node for it and select values. You'll also have to do a lot of work changing those for loops into while loops so that you can abort them.

  • 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

Maybe you are looking for

  • Does ECC 6.0 Provide a Search-as-you-type Enhancement for Sold-To Party Field?

    In our quest to continually simplify the creation of sales orders, I would like to know if SAP has provided any way to simplify the search and entry of the customer sold-to or ship-to party.  What I am looking for is a way to enter the customer's nam

  • Can't get GTX 970 to render - it's still using the CPU

    Hello guys. I'm using trial of Premiere Pro CC 2014 on Windows 8.1 x64. Decided to try out my new machine - i5-4690K, EVGA GTX 970 FTW, 16GB DDR3 2400 Mhz, Samsung 850 Pro. So I have this test video 1080p 60FPS 1min 2s short which I'm exporting to H.

  • Download and install newest version but still get error - "requires latest version of flash player"

    I keep getting a message that something won't work because the latest version of flash player needs to be installed.  I go through the download and install for flash player but still get the message.  After the install I never get any setup steps.  I

  • Sim card tray stuck might be broken

    Hi, i just bought an iphone 3gs and the sim tray got stuck because i put it the wrong way and when i took it im scared i might broke something because now it doesnt read my sim card.. I dont know if the warranty covers my stupidy, should i try apple

  • Problems configuring the database cache

    I am trying to configure the db cache and running into problems with the step of starting the management engine component. I get: Starting the Management Engine Component failed Reason: Lost connection to cache roma-icache Processing failed. I also g