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

Similar Messages

  • 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

  • Using the Wait function in while loops?

    Hi,
    I have a rather complicated top level VI with about 20 subVIs and the main VI has on big while loop around it and another smaller one inside, basically it runs rather slow and I have no idea how to set the wait function. I mean what factors should I consider..what would be the difference between setting it to 10 and 100 (besides the obvious 10ms vs 100ms)? I just want to increase the performance of the executable, so it is not that slow. Can you offer some hints as to what I need to take into consideration when determining my delay? And also, are while loops the only place that I should use the delay or are there other instances too?

    Adding waits is not a fix-all for slow running applications. Its just one thing that can be done to improve things. If you determine that a sub-vi is causing your problems then you need to find out exactly what that vi is doing to slow you down. If its because there is a loop inside it that is running constantly as fast as it can, then a delay in that loop may help. If that is not your problem then you need to look at other ways to boost performance. It sounds like you have alot of locals variables, each instance of a local variable makes a copy of the data that's in the control. If the controls/indicators that you have local variables of contain large amounts of data then you may be filling up memor
    y with copies of it.
    I suggest that you study the "Performance and Memory Management" chapter of the LabVIEW manual. This can found in the printed manual of the older versions, in the online manuals that install with 6i, or on NI's web site here: http://zone.ni.com/devzone/conceptd.nsf/2d17d611efb58b22862567a9006ffe76/732cec772aa4fbe586256a37005541d3?OpenDocument , which is Application Note 168. This should give you some good ideas of what to look for to improve your performance.
    Hope this helps.
    Brian

  • Using User Input Rather Than "strStartFolder".

    Hi guys!  
    This script is very simple but it's part of a project I've been working on for some time now.  Any VBS guru (or novice for that matter) will be able to tell what it does after a brief scan of the code.  Again, like I said, this is a very simple
    script.
    For newcomers, this script siimply looks for duplicate files in a folder on one or more of your drives.
    However, I'm having 2 issues...  
    First, I need to change the script to where the Wscript engine is used to ask for user input via an InputBox and for that data to be read into a variable which could be "strStartFolder"?  If
    not, any variable will do, but having to enter in location you wish to search by editing the script manually is not practical.
    strStartFolder instead of someone having to edit the code manually each time and enter the path to the folder you wish to scan.  In this example, I have last scanned the "Largest Vidz Appz and Musik Folder" on drive H:\.  I did this manually
    of course...  
    I have played with this using several methods which all only seemed to work "partially".  
    The second issue I am having is that you cannot scan just a drive.  It MUST be a folder.  If you input, for example, "H:\" you will receive an error stating that either permission has been denied or the path cannot be found.  
    Still being somewhat of a noob myself when it comes to scripting I'm sure there is some simple parameter I can/could have entered to fix this but I tried, "H:\*", H:\*\", H:\*.xxx"\ (.xxx being the extension of course) and other things).
     Nothing seems to work but I believe that is because of who the original VBS was coded initially.   Again, this is why I come to the greatest resource on the net.
    One more thing, when all is said and done the script should ask for a user's input via Wscript so that an InputBox greets them with a message such as, "Please enter the location you wish to scan for duplicates:".  And then, depending on their
    answer (being of correct syntax, etc, etc) the script runs and outputs a file named "dups.txt" using the Cscript engine.  
    Please note that I have been running the script as follows to allow for output to a text document.  "C:\cscript //nologo FindDuplicates.vbs > duplicates.txt", I would like to avoid having to do this as well if possible but it's ok if not. 
    Running this script by "double clicking" can be a disaster if you have tons of duplicate files.  So asking for user input is the only area where Wscript need be used.  But hey, this is why I'm here.  For guidance...  
    This is cake for most of you so I will be interested in seeing the different ways you all come up with resolving this issue.  
    Anyway, here is the script!  Thanks in advance for your help!
    Dave
    Set objDictionary = CreateObject("Scripting.Dictionary")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strStartFolder = "H:\Largest Vidz, Appz and Musik Folder"
    Set objFolder = objFSO.GetFolder(strStartFolder)
    Set colFiles = objFolder.Files
    For Each objFile in colFiles
    strName = objFile.Name
    strPath = objFile.Path
    If Not objDictionary.Exists(strName) Then
    objDictionary.Add strName, strPath
    Else
    objDictionary.Item(strName) = objDictionary.Item(strName) & ";" & strPath
    End If
    Next
    ShowSubfolders objFSO.GetFolder(strStartFolder)
    For Each strKey in objDictionary.Keys
    strFileName = strKey
    If InStr(objDictionary.Item(strFileName), ";") Then
    arrPaths = Split(objDictionary.Item(strFileName), ";")
    Wscript.Echo strFileName
    For Each strFilePath in arrPaths
    Wscript.Echo strFilePath
    Next
    Wscript.Echo
    End If
    Next
    Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
    Set objFolder = objFSO.GetFolder(Subfolder.Path)
    Set colFiles = objFolder.Files
    For Each objFile in colFiles
    strName = objFile.Name
    strPath = objFile.Path
    If Not objDictionary.Exists(strName) Then
    objDictionary.Add strName, strPath
    Else
    objDictionary.Item(strName) = objDictionary.Item(strName) & ";" & strPath
    End If
    Next
    ShowSubFolders Subfolder
    Next
    End Sub
    Again, thank you in advance for your help..  And why is some of my text here in this post showing in smaller font than other text?  It seems to be dependent on the line you type on?  This is,
    of course, not the problem I came here to resolve, I am only curious.  ;-)
    DB
    PAinguIN

    Thank you for your response!  
    So if I used the "MyMessage" variable after the "=" in the line below then the users input should be the folder that is searched as long as your lines are added before this line correct?
    Thanks again!
    DB
    strStartFolder = "H:\Largest Vidz, Appz and Musik Folder"
    PAinguIN

  • How to create database from scratch using user input

    what I am trying to do is to create database via my java code (using hibernate and my sql) and based on user input.
    The details like the name of table.... or the number of columns in it are all supposed to be determined from user input (only the first time).
    On subsequent run the program should remember the previously created database and hence work with it.
    Can somebody help me through this?
    Suppose I did create it using firing queries from my program then the next problem is how my program would start up next time......?????

    Anuvrat wrote:
    what I am trying to do is to create database via my java code (using hibernate and my sql) and based on user input.
    The details like the name of table.... or the number of columns in it are all supposed to be determined from user input (only the first time).
    On subsequent run the program should remember the previously created database and hence work with it.
    Can somebody help me through this?Presumably because you want to (fun) rather than because you need to (job or project.)
    If the second then don't do it.
    >
    Suppose I did create it using firing queries from my program then the next problem is how my program would start up next time......?????You would start by learning about DDL which is the common name for the languages, which vary by database, used to create the entities that represent the structure of a database. Until you figure out the syntax of that you can't do anything in java.

  • Using "User Input" in "Collect Payments"  instead of "Fixed Amount"

    I've enabled "Collect Payments" on my form and I need to allow "User Input" instead of "Fixed Amount". I'm stuck... How do I do this?

    Thanks Josh. I Appreciate it.
    I did figure it out about 10 mins after I posted the question but thanks again man
    Tom Ruley
    Founder and President
    The National Remember Our Troops Campaign, Inc.
    P O Box 34093
    Baltimore, Maryland 21221
    Website:  http://www.nrotc.org
         Email:  [email protected]
        Phone:  410-687-3568
            Fax:  443-596-0730
    Please remember our troops, our veterans and our military families.  Try to do something... anything... to honor their service and sacrifice

  • Using the counter to create a input variable in while loops

    I'm using a loop to increment oscillator freq on my lock-in. I want this incrementation to be based off the loop counter. But when I do this, it gives me some kind of circular reference error. Can I make my own counter inside the loop instead? How? See the attached screen shot for details.
    Attachments:
    loop_problem.JPG ‏138 KB

    Hi Jesse,
    You can attach a copy of your vi instead of a screen capture, because the the screen capture is difficult to read. Unless there is confidential code, of course.
    The first thing I noticed is that there are some improperly wired vi's. I can't comment much because the screen capture was not clear.
    However, the "circular referrence error" means that you have a wire which exits a loop and re-enters it.
    If you need to pass a value back to the beginning of a loop, then use a Shift Register. Right click on the edge of a loop and select "Add Shift Register". It can be initialized by wiring a value (or control) to the input of the loop.
    -JLV-

  • Using mouse to operate controls while not looking.

    We are using LabView to control an electron gun power supply. We need to view the spot on a phosphor screen while operating the controls. It is very difficult to keep the mouse on the up/down arrows, when not looking at the front panel. It would be nice if we didn't need to point the mouse at anything in particular, rather could move it right/left or up/down. Ideally, we'd click on the parameter to be controlled, then have it start at the current value with mouse movements changing the value about that starting point.

    > Sliders was the direction I was leaning toward but I still have
    > problems with the voltages jumping to a new value when I first click
    > on the slider if I'm not real careful with the mouse position. I'm
    > aiming for that feel you get turning a pot to fine tune something.
    Interesting. If you are going with a screen control and mouse, you can
    take the slider into the control editor, grow the thumb horizontally,
    shrink it vertically, and then shrink the housing, the background behind
    the thumb. This tinkering will make it harder for the slide to jump
    around when initially clicked on. You will need to hit the thumb, but
    that should have very little bump.
    Another approach is to use a real pot or HW knob. A couple years ago I
    was play
    ing with iMovie and purchased a USB knob. By setting the
    increment, min and max for a numeric, and configuring the knob to
    produce up and down arrow keys, you can tab to the appropriate numeric,
    then turn the knob. It is easy to set the knob to set the rate of the
    keys sent, so you can also use the spring loaded lower ring to do a
    constant velocity increment, turn the ring farther, and increment
    faster, release and stop.
    These knobs are not very expensive and can be found on the web. Mine
    was from a company called Contour, not sure what their name is now.
    A similar approach would be to use a USB joystick. There are some
    joystick VIs on devzone I think.
    Greg McKaskle

  • Passing BAPI standard Inputs using User inputs

    Hi,
    I have a requirement where i need to update SAP using an Adobe Interactive form.
    I got a BAPI which can do this job.It worked fine with BAPI standard inputs...
    But my requirement is to show something different in form and its corresponding value should be passed to BAPI.
    Eg: I should provide a dropdown box which has A,B,C...etc if A is selected I should pass 100 as input value to BAPI and if B is selected in dropdown I should pass 200.
    Along with this I should also pass few more standard inputs..
    Any help is greatly apprecited.
    FYI.. I developed this using JAVA Webdynpro .
    Rgds
    Vara

    Hi,
    For this do one thing .
    Create a local attribute.
    Craete a simple type.
    Move to Enumeration and fill the Value & Description fields.
    What ever you want to display in the dropdown give it in the "Description".
    The value you want to pass to R/3 give it in "Value".
    Now give the attribute type as the "Simple type" that is created by you
    Now when ur passing data to R/3 do one thing.
    Pass the data available in the local attribute to teh RFC import parameter.
    Sorry i dont have any idea
    On passing more data then this.
    "Along with this I should also pass few more standard inputs"
    Thanks & Regards,
    Lokesh

  • Feedback using analog input to control digital output

    Hi all,
    I've got a program that I intended to open and close two valves (and thus actuate two pneumatic cylinders) based on the readings from load cells mounted to each cylinder. The idea was that it would send a digital out to open the valve and extend a cylinder, then close the valve when the load reaches a pre-determined value (with frequency dictated by increasing or decreasing the inlet air pressure and thus the fill time of the cylinder). It would then do so for the other cylinder in a loop. The issue I have is that the response time of the loop actuating the valves was too slow-for a desired force of 1800 N I had to set the limit to 1100 Newtons. It was nice and consistent in this regard but then I started having instances where the valve would stay open long enough to apply a force of 3600+ N. The biggest need in this program is to maintain a consistent load and ensure that the max. load is not being exceeded. I've used local variables and a queue to pass the load values to the valve actuation loop but it did not seem to make a difference. I don't know if part of my problem is the mishmash of data types I'm using in passing the load cell values or if a notifier would be a better bet.
    Attached is my code (LV 8.2). Thanks in advance if anyone can offer some guidance.
    Attachments:
    Controlled_valves.vi ‏192 KB

    Here's a version in LV 8.0 and an image of the block diagram, for those running older versions of LabView.
    I'd greatly appreciate any help anyone might provide as I'm getting killed here. Thanks!
    Attachments:
    Controlled_valves.vi ‏207 KB
    Block diagram.JPG ‏177 KB

  • How to use Pl/sql block to edit check user input

    Hi,
    Please advise on PL/SQL Block code that could be used to Check User input from within a Loop and proceed conditionally based upon User Supplied compliant Input. Thanks in advance.

    Hi,
    yakub21 wrote:
    You could use the ACCEPT to get user input and then assign the input to a variable that could then be verified.
    I believe that anything is possible because we don't yet have proof that it is not!
    I do have code that can accept user input. Is it PL/SQL code? Sybrand was clearly talking about PL/SQL:
    sybrand_b wrote:
    Pl/sql is for server side code, it is not a front end tool, and it is incapable of the functionality you describe.If you do have PL/SQL code that accepts user input, please post an example. A lot of people, including me, would be very interested.
    Pass the user-input value to a variable and then assign that value to another variable from within a Declare of a PL/SQL Block.
    The opportunity here is to figure a way to loop with user input until desired input is entered by the user before proceeding with the code. I'm using PL/SQL Block because I don't want the code to persist. I just want to run it as part of database configuration procedure. ThanksIt sounds like you're talking about SQL*Plus, which is a very poor tool for looping or branching.
    It's possible, but it's not pretty. The following thread shows one way of looping in SQL*Plus:
    Re: How to give the different values to runtime parameters in a loop?

  • SubVi with feedback nodes used more than once inside a While Loop

    All,
    I have a subvi that does a set of operations and uses 3 feedback nodes. I am using this subvi inside a While Loop a total of 4 times. I've noticed that all instances used share the same result at each corresponding feedback node but I would like to have an individual result from each of them. Is there an easy way to go around this problem? I have come up with ways to avoid this: a) create a different vi for each time the subvi was used. b) use global variables instead of feedback nodes. Is there any easier way to go around this issue?
    ExamplePlease note that both subvi's are the same) If on my first subvi I calculate a maximum value and get 1.29 (then goes to feedback node) on my second subvi i get 1.01 my feedback node at the second subvi still registers the maximum value to be 1.29. (and I want it to be 1.01!)
    Hope this is not too confusing, I've been scratching my head with this for a while, can't find the "easy" button. Thanks in advance.
    -Pop
    Im using 9.0.
    Solved!
    Go to Solution.

    Attaching the code would be helpful. Anyway, I am not sure how multiple feedback nodes are supposed to operate so I will defer that to others to answer. As far as being able to use distinct values or instances if you are using a subVI you could mark it as reentrant. That way each call to it will behave as it it were a copy of the VI and it will have its own memory space. This should include the feedback node. You may be ending up with a single subVI and in reality a single feedback node. If you need to pass data between calls than simply wire the data through. You could also use an Action Engine to store and retrieve values. An AE is a MUCH better solution than a global variable.
    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

  • 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();

  • 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

  • How to validate a user input for where clause?

    I have a situation to validate a where clause which is input by the user.
    Because the query will be run against huge tables and we need to notify the user if they input the clause is not valid.
    I use the below query to try:
    Select 'A' from blablabla where user_input_where_clause and 1=0;
    however, it can not capture the error when the user input:
    'name=123' while the right condition should be name='123'.
    Can you pls advise ?

    In this particular case, Oracle will not even try to run the SQL statement because of the syntax error. IF the WHERE condition supplied does not make sense, Oracle will not execute the statement, so it does not matter if the query accesses huge tables.
    SQL> Select 'A' from blablabla where 'name=123' and 1=0 ;
    Select 'A' from blablabla where 'name=123' and 1=0
    ERROR at line 1:
    ORA-00920: invalid relational operator
    SQL>IF you have a restriction as to what type/value can user specify for the where condition (asuming it would make sense to SQL engine), you would have to do it before submitting to the database.
    Note, however, that user could specify any condition they like, having potentially damaging effects.

Maybe you are looking for

  • Function Module: HTTP_GET

    Hi. I am using FM: HTTP_GET to fetech same data (its a XML file) from web. My program works fine only if executed in foreground. If I execute the code in backgound the job terminates with error: Job started Step 001 started (program ZTEST, variant ,

  • Enabling comments/mark-up

    I need to enable commenting and mark-up in Reader 8.0. I need to be able to use the More Tools drop-down menu. I use Jaws To PDF softrware for writing PDF's. Autodesk's Design Review is not ready for prime time and from what I see that is available w

  • Running CMD command in PS

    In PS2, I always use cmd.exe /C to run DOS commands. However, I ran into this scenario: The first try, using cmd.exe /C, failed with the above error. The second try, running the command directly, was successful. Anyone can explain why? Thanks.

  • Elements 11 Pixelated Photos

    I have elements 11 and whenever I try to zoom into the photo, it gets really pixelated really quickly and I'm not able to do very detailed editing.. Any suggestions on what I could do to fix that? (Using Windows 8) ps.. I also have PSE 8 installed on

  • Autoatic Figure Numbering

    Hello, We are using InDesign CS3 for a large document. We have heading styles 1-5 defined in in the paragraph styles, they are done as a list called "Headings" so that you get A. Heading 1 A.1 Heading 2 A.1.1 Heading 3 A.1.1.1 Heading 4 A.1.1.1.1 Hea