Accessing Data within while loops

I have LabView 6.0
I have a while loop for my GUI that accesses various sub VIs. One of the Sub VI is a LED on/off thing, which basically checks the communication with the PIC board that I have. For turning the LED on or off, I have to sent a unique command.
Since the Sub VI for the LED on/off is inside a while loop it continuously executes. I want the SubVI to execute only when the status of the boolean controlling the LED has changed from the previous value. I tried giving a feedback from the SubVI to indicate whether there is a change, but Labview will not allow such loops.
I then took the SubVI outside the while loop, keeping the boolean control (so that it continuously checks) inside the while loop. I would like the SubVI to execute depending on the boolean control change. I tried using occurances, but I think these execute only once. I tried accessing the boolean control through a local variable, but the value of the local variable would not change outside of the while loop. (even tried property indicators).
Any solution would be appreciated.
I could post the VI, but there are too many sub VIs... Dunno if it would be appreciated.
Thanks!

If you need to post a VI, it is best to strip out those parts which do not have any effect on the problem you are facing. With subVIs, do a Save with Options..>>Development Distribution. This will create an .llb file with your VI and subVIs.
Queues and global variables can transfer data between independent nodes. I am not sure when the datatypes of queues changed. In LV6 you may need to flatten your data to string typpe before passing it to a queue. The functional global or LV2 style global is a subVI consisting of a loop which executes only once and which contains the data in an uninitialized shift register. Many threads on this forum have discussed these options.
Lynn

Similar Messages

  • Can not pass data after while loop

    Hello.
    I have created a VI for my experiment and am having problem passing data outside a while loop to save on an excel file. The VI needs to first move a probe radially, take data at 1mm increment, then move axially, take data radially at 1mm increment, then move to the next axial position and repeat. It would then export these data to an excel file. The VI is a little complicated but it's the only way I know how to make it for our experiment. I have tested it and all the motion works correctly, however I can not get it to pass the data after the last while loop on the far right of the VI where I have put the arrows (Please see the attached VI ). Is it because I'm using too many sequence, case, and while loops?  If so, what other ways can I use to make it export data to the excel file?
    Any help would be appreciated. 
    Thank you,
    Max
    Attachments:
    B.Dot.Probe.Exp.vi ‏66 KB

    Ummmm .... gee, I'm not even sure where to begin with this one. Your VI is well .... ummmm... You have straight wires! That's always nice to see. As for everything else. Well... Your fundamental problem is lack of understanding of dataflow programming. What you've created is a text program. It would look fantastic in C. In LabVIEW it makes my heart break. For a direct answer to your question: Data will not show up outside a while loop until the while loop has completed. This means your most likely problem is that the conditions to stop that specific loop are not being met. As for what the problem is, I don't even want to start debugging this code. Of course, one way to pass data outside of loops is with local variables, and hey, you seem to be having so much fun with those, what's one more?
    This may sound harsh, and perhaps be somewhat insulting, but the brutal truth is that what I would personally do is to throw it out and to start using a good architecture like a state machine. This kind of framework is easy to code, easy to modify, and easy to debug. All qualities that your code seems to lack.
    Message Edited by smercurio_fc on 08-17-2009 10:00 PM

  • If/Than function imbeded within While Loop with mulitiple outputs

    We are a Senior Design Group who is having much troubles with LV as none of us are programers and especially unfamiliar with all that LV has to offer. 
    Here is what we are thinking that the program we need needs to look like but have no real clue as to how to implement it in LV.
    WHILE Time Elapsed < 10 seconds
      {  IF Voltage = 1 V
         THAN Output Sound File 1 and Write "1" to Excel File in "A1" and Reset Time Elapsed
         IF Voltage = 1 V again
         THAN Output Sound File 2 and Write "2" to Excel File in "A2" and Reset Time Elapsed
         IF Voltage = 1 V again (for the 50th time)
         THAN Output Sound File 50 and Write "50" to Excel File in "A50" and Reset Time Elapsed
    Once 10 seconds elapses we need to break out and start the above program again (once 1 V is reconized again), except Write to Excel File in "B1....B50"
    Thank you for any help
    Struggling Students

    See here

  • Read single value within while loop

    Hi,
    I have a setup with one output, driving a coil.
    I then have two inputs: one to measure the voltage of my coil (the actual voltage) and the second to measure the voltage of a sensor mounted close to the coil.
    The setup works fine to monitor both channels continuously, however, I want to monitor the second value only once every 5 seconds.
    How can I go about doing this? Every 5 seconds I just want a single measurement from the second channel.

    You haven't given us any info on your device, but I assume it's not super-fancy and can change sample rates per channel.
    This article here explains what you want to do. Your device has a single clock, so you're essentially limited to (forces to match?) your highest sampling rate requirement with all channels and then down-sample from there if you don't want all of the data for some of the other channels.

  • How do you access data within a public class?

    Hi,
    This is my problem. I have a class which is used to take in user input. All methods and variables are public becuase I want to replicate this class over and over. (like a word processor that can have many open documents).
    What I want to be able to do is when I click on a saveAll toolBar icon not in the class but separate, I want to be able to tell each class that I have instanced to save it's data. Is this possible when I'm using public methods and variables? I don't think getting each class to listen for the mouse click on the saveAll icon is the way to go, for I will have all classes trying to save at the same time.
    Any suggestions greatly welcomed as I can't figure this out.
    Adrian

    Well, under special circumstances, you might consider having a desktop (the contentpane of your frame should be a desktop), and your input classes (which are like documents in the word processor) should be internal frames. The menu belongs to the frame. Now when the user selects a menu item, you may use the getAllFrames[] method of the desktop pane to retrieve all of your internal frames.
    Then it needs no extra efforts on your part to keep track your document classes; instead, you have to add or remove your documents to/from the desktop. That is, when a document is closing, it must remove itself from the desktop.

  • Does the inner while loop have to be stopped before the outer loop will run?

    too many while loops cause my controls to be very sluggish.

    Hello,
    The outermost while loop executes everything inside it over and over. Therefore, if you have a while loop inside another while loop, the first iteration of the outer while loop will execute the inner loop, and then the inner while loop will execute over and over again until it is stopped. At this time the outer while loop will perform another iteration, and the process will repeat until the outer loop is stopped. Generally, embedding while loops within while loops is not recommended.
    Please visit the below sites for more information on program efficiency.
    http://zone.ni.com/devzone/conceptd.nsf/webmain/b6605678ad7a09a8862568eb007a6d7a?OpenDocument
    http://zone.ni.com/devzone/learningcenter.nsf/03f7c60f17aad210862567a90054a26c/1b36040af87887078625
    6cbc006fe314?OpenDocument
    I hope this helps!
    --Liz F

  • 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

  • While loop and data acquisition timing worries

    Hello everyone, 
    I apologize in advance if this is a silly question, but I could not find the answer around here. 
    I have made a VI to record continuously from 64 analog channels at a 5kHz sampling rate. I then stream this data to a tdms file. The data acquisition and write functions are in a while loop. 
    I the same loop, I have a bunch of other loops, that each run on their own wait timers to help limit the amount of memory they take up. I am now worried that this may somehow affect my data acquisition timing.
    If I put a bunch of timed loops within another loop, does the outer loop run at the same pace as the slowest of the inner loops? And could that mess up my sampling rate?
    I have attached my VI, in case what I just wrote makes no sense at all. 
    Thanks for any tips...
    Attachments:
    Record_M8viaDAQv3.vi ‏237 KB

    Well, looking at your code you will only write to your TDMS file one time. You have multiple infinite loops within the main/outer loop. That means that the main loop will only run a single iteration because it cannot complete an iteration until all code within it completes. With at least two infinite loops inside the loop it will never complete. Not too mention the only way to stop your code is to hit the stop/abort button. NOt a very good way to stop your code. As someone once said using the abort to stop your code is like using a tree to stop your car. It will work but not advised.
    As Ben mentioned try to understand data flow better. You have unnecessary sequence frames in your code where normal data flow will control the execution sequence.
    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

  • How do I make one while loop that runs 1 piece of data at a time?

    I have a question about a while loop.  Currently, I have 4 or 5 dynamic data lines that I would like to run through a while loop that will tell me if the data is within a certain range or not.  However, the ranges are different for each piece of data, and I dont know how to do each one separately.  Do I have to make 5 different while loops? Thanks!

    pg22aw wrote:
    I have a question about a while loop.  Currently, I have 4 or 5 dynamic data lines that I would like to run through a while loop that will tell me if the data is within a certain range or not.  However, the ranges are different for each piece of data, and I dont know how to do each one separately.  Do I have to make 5 different while loops? Thanks!
    Do you want to compare the value with a defined value and also the ranges for the 5 data is different?. What are you doing in the while loop. If the data is in an array of dynamic data you can seperate the amplitude value and check the whole array of value with the ranges that is also build same as the data theh you will get the output as a boolean array.
    The best solution is the one you find it by yourself

  • Question in ABAP syntax, read & insert data from internal table, while loop

    Hi, SDN Fellow.
    I am from Java background and learnt ABAP, I don't usually write much ABAP code.
    I am trying to implement the following logic in a RFC now.
    I have one z-custom database table, the structure as the following:
    It has two columns, with these sample data.
    Says datable table is ZEMPMGRTAB.
    EmployeeID,ManagerID
    user10,user1
    user9,user1
    user8,user1
    user7,user2
    user6,user2
    user5,user2
    user4,user2
    user2,user1
    The logic is this:
    I have a input parameter, userid. I am using this parameter to have a select statement to query the record into export table,EXPTAB 'LIKE' table ZEMPMGRTAB.
    SELECT * FROM  ZEMPMGRTAB
      into table EXPTAB
       WHERE  EMPLOYEEID  = USERID.
    Say, my parameter value, USERID ='USER4'.
    Referring to the sample data above, I can get the record of this in my EXPTAB,
    EmployeeID,ManagerID
    user4,user2
    Now, I want to iterately use the EXPTABLE-ManagerID
    as the USERID input in SELECT statement, until it has no return result. Then, insert the new records in
    EXPTAB.
    In above new loop case, we will get this table content in EXPTAB,
    EmployeeID,ManagerID
    user4,user2
    user2,user1
    I kind of think of the pseudocode logic as below:
    (These may not be a valid ABAP code, so I need help to convert/correct them)
    DATA:
    IWA TYEP ZZEMPMGRTAB,
    ITAB
    HASHED TABLE OF ZZEMPMGRTAB
    WITH UNIQUE KEY EMPLOYEEID.
    SELECT * FROM  ZEMPMGRTAB
      into table ITAB
       WHERE  EMPLOYEEID  = USERID.
    *Question 1: I cannot insert a internal table to export table, it is *incompatible type, what is the alternative way fo this?
    *Question 2: How can I access thedata of the internal table like this,ITAB-MANAGERID? As if I can, I would do this:
    * IWA-EMPLOYEEE = ITAB-EMPLOYEEID. IWA-MANAGERID = IWA-MANAGERID. INSERT IWA INTO TABLE EXPTAB.
    * Question 3: Is the 'NE NULL' - 'not equal to NULL' is right syntax?
    IF ITAB NE NULL.
    INSERT ITAB INTO EXPTAB.
    ENDIF
    * Question 4: Is my WHILE loop setup right here? And are the syntax right?
    WHILE ITAB NE NULL.
    SELECT * FROM  ZEMPMGRTAB
      into table ITAB
       WHERE  EMPLOYEEID  = ITAB-MANAGERID.
    IF ITAB NE NULL.
    INSERT ITAB INTO EXPTAB.
    ENDIF
    REFRESH ITAB.
    ENDWHILE.
    Assume all the syntax and logic are right, I should get this result:
    EmployeeID,ManagerID
    user4,user2
    user2,user1
    If I have a new entry in datable table,ZEMPMGRTAB like this:
    user1,user0
    My pseudocode logic will get this result:
    EmployeeID,ManagerID
    user4,user2
    user2,user1
    user1,user0
    I truly appreciate if you can help me to validate the above syntax and pseudocode logic.
    Thanks in advance.
    KC

    Hi,
    FUNCTION ZGETSOMEINFO3.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(USERID) TYPE  AWTXT
    *"     VALUE(FMTYPEID) TYPE  AWTXT
    *"  EXPORTING
    *"     VALUE(RETURN) TYPE  BAPIRETURN
    *"  TABLES
    *"      APPROVERT STRUCTURE  ZTAB_FMAPPROVER
    *"      ACTOWNERT STRUCTURE  ZTAB_FMACTOWNER
    DATA: T_RESULT TYPE STANDARD TABLE OF ZTAB_FMAPPROVER.
    **Question 1: For this line, I got an error says "Program ''USERID" *not found. Is the syntax right, as the USERID is a parameter for the function.
    perform add_line(USERID).
      ENDFUNCTION.
    form add_line using i_user type ZTAB_FMAPPROVER.EMPLOYEEID
                        changing T_RESULT TYPE ZTAB_FMAPPROVER.
    data: ls_row type ZTAB_FMAPPROVER.
    * Get record for i_user
    select single * into ls_row from ZTAB_FMAPPROVER
    where EmployeeID = i_user.
    if sy-subrc NE 0.
    * Do nothing, there is not manager for this employee
    else.
    * Store result
    QUESTION 2: I am still got stuck on this line of code. It still *says that "T_RESULT" is not an internal table "OCCURS n" *specification is missing. I thought the line: "T_RESULT TYPE *ZTAB_FMAPPROVER" means declare internal table, T_RESULT as type of ZTAB_FMAPPROVER". Am I understand it wrongly?
    append ls_row to t_result.
    * Call recursion
    perform add_line using ls_row-ManagerID
                              changing t_result.
    endif.
    endform.
    Thanks,
    KC

  • Getting data from a while loop while running.

    Hello,
    I did a program that call a sub-VI which is doing experiment and have its own timer.
    The sub-VI is a while loop and the stop condition of this loop is the elapsed time of my timer.
    What I want to do is to be able to get the elapsed time in my main program during the execution of the sub-VI (every second of its execution).
    First I assign the elapsed time in the sub-VI as an output of it. But of course the elapsed time is only updated in the main VI only when the while loop has finished. So I tried several solution: property nodes, local variable, global variable.
    When I am using global variable, I can see the elapsed time being updated during the while loop when I open the global variable VI. But the result is always the same: in the main VI the elapsed time is only updated at the end of the while loop.
    I think that is the global variable is updated every time, I could be able to get its data to my main VI?
    Does anyone have an idea?
    Thank you,
    Meach

    I tried using shared variable and reference without succes.
    I will keep searching.
    I enclose my VI that I simplify the most but with still keeping the shape of my real program. If you can take a look I will really appreciate.
    The goal is on the top-level VI to be able to see the updating data time in real time.
    Thanks,
    Meach
    Message Edited by Meach on 07-23-2008 04:13 PM
    Message Edited by Meach on 07-23-2008 04:14 PM
    Attachments:
    Elapsed Time.zip ‏25 KB

  • How can I write waveform data from a while loop?

    Alright, I have a NI-5122 high speed digitizer that I need to acquire 10,000 waveforms. I am currently using the NI example code "niScope EX Multi Record Fetch More Than Available Memory.vi" to do this and then onto that later. I set the Number of Records to 10,000, min record length to 8192, and the min sample rate to 100M (S/s). On the Fetch vi,  I set it to get a 1D Dbl array and then send it to the while loop edge for auto indexing. What I want is to take each waveform and write it to a file next to the previous waveform not append it to the bottom of the previous one. I can do 100 and sometimes 1000 waveforms with my current setup and then use "write measurement to file.vi" to save the data, but at 10,000 it says that the memory is full. I have 256 MB on the NI-5122 and 4G of memory on my host computer. My reasoning is that if the NI-5122 can hold all that data then why can't my host computer. I have tried to fetch using 2D Dbl and transpose that matrix and send the data to "write measurement to file.vi" inside the loop and append the data that way, but when I do this the card does not acquire any data. Which seems like a software problem. I know this is probabaly worded poorly, so just post a response if further explanation is needed.
    Thank you.

    Hello,
    It sound like you might have received a LabVIEW: Memory is full message.  Are you also graphing this data as it is being acquired?  Are you building an array inside the loop?  At the 100 MS/s rate, you are using a lot of memory to acquire, graph, build and transpose array data, and then write to file.  If you are saving to file and do not necessary need to see the data, I would suggest taking the graphical indicator out of the code.  Please review some of the KnowledgeBases linked below about the LabVIEW: Memory is full.
    KB 36QD14V3: Why Do I Receive a "Memory is Full, VI Stopped at Loop Tunnel 0xXXXX" Error?
    KB 3ZNDGRS9: LabVIEW "Memory is Full" Error
    Samantha
    National Instruments
    Applications Engineer

  • How do I create a start/stop button for each separate while loop within my program, when each of them does a different task?

    I have a multimeter VI with separate while loops to accomplish the different tasks of reading  voltage, current, etc. Each while loop has a stop button, but I need a button that will have to be pressed in order for the while loop to even start. I tried putting another while loop around the present one, but it still has to run once before it will stop. I want the user to have to press the button before it runs, because they interfere with each other.
    I am just learning so patience and your kind assistance is greatly appreciated!
    ElectroKate

    iZACHdx wrote:
    Hello,
    I'm not entirely clear with everything you have going on and what you want your final functionality to be, but you can use sequence structures to prevent a loop from starting until the user presses a button like this:
    -Zach
    I have to ask, why is an NI employee using examples using sequence frames? The same thing could be accomplished using data flow by simply wiring the value of the first stop button out of teh first while loop and connecting it to the second loop. This would then use data flow to control the sequence. Why show new users bad programming methods?
    As to the original question I would concur with altenbach on using an event structure.
    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

  • I currently have one input but need to run two loops. I cannot get the two while loops to run so that they both pick up the same data, they are both picking up alternate samples. How can I get them to both pick up all of the values?

    The system I am trying to create calculates a number of values based on an input. I need to make the calculations and display the values for an entire production run and for each hour. The only way I know to do this is to create two while loops, one looking at all the values that are received and one looking only at the values for hour long periods.
    Any help would be great.
    Thanks
    RossH

    Why do you think that you have to have two loops to accomplish this task? Why not use one loop and accumulate the same data into two data sets based on the two sets of criteria?

  • In the attached VI why does one loop coerce the data type while the other doesn't?

    In the attached VI why does one loop coerce  the data type while the other doesn't?
    Solved!
    Go to Solution.
    Attachments:
    AAA.vi ‏8 KB

    I'm guessing you created the Enum on the front panel.  If you right-click it and create an indicator, it will match the type, and be an enum.  LabVIEW represents enums as U16, but because the types aren't identical (for example, your enum has 3 values, but a U16 has 65,536 values), LabVIEW automatically coerces (or converts) the smaller (enum) representation into the larger (U16) value.

Maybe you are looking for

  • Idoc generated for creation of sales order

    Hi all, In my project we have two different boxes-I and B.When a purchase order is created in I Box an idoc is triggered which goes to the B Box and creates a sales order.I want to do some changes in E1EDKA1 and E1EDPA1 segment in the idoc in I Box s

  • Abandoned Call Rings on Agent Phone

    Hello, I have a strange situation reported by a supervisor that, abandoned call keep rings on agent phones and when one of the agents answers the call she hears busy tone. To reproduce this issue, we made some test calls and hung up the call just bef

  • Launching an AIR app from another (when offline)?

    I have a pair of AIR applications that are meant to work together as part of an application suite. One feature is that a user should be able to click a button in APP_1 and launch APP_2 (if installed). To do this I created a "LaunchButton.swf" that lo

  • Is there any way that I can sort images by resolution?

    Hello Have you guys found out any way or apps can sort images by resolution? I've tried Path Finder and Forklift, neither of them can do it . For now, I'm doing this with winxp on a PD5...

  • Photoshop: How to change program language from national to English?

    Hello, I've just installed photoshop from the Cloud. I reside in Poland but need an English version of the program. My version is now Polish - how do I change that? Please help asap, I don't understand a word!