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.

Tags: NI Software

Similar Questions

  • Detect the change of the value in While loop

    Hello

    I recently took a code example in examples of using Labview and I'm putting the analog output through my data acquisition card 4461 pxi. I want to have a continuous waveform, but being able to change the volume and the waveform will adjust automatically and be issued through the card.

    In the code, I have everything first to open a .wav file and write it. While playing continuously through the while loop, but I want the signal to change automatically when the volume is changed. I know that I should probably use a structure of the event but the while loop, I use to play the signal will never stop unless the user presses stop so it would play permanently in a structure of the event even when the value changes (I tried).

    So now I try to see if there is a way to make my time stop loop when the volume value.

    You must correct the issues (forget the events if you are not sure of them):

    1. If wire you the digital volume to the wall of the while structure, then the whole in structure only tell that one value that happens on the node and will not read new values.

    2. to read the new values, move the Volume Terminal inside any building (which will shock your other code that depends on it), or use a local Variable inside any node.

    3. to check if the value has changed, you must compare the value to the previous value. To do this, use a shift on the while loop register to store the previous value and then compare it to the new value with the function "not equal?". Wire the Boolean result of this to the conditional Terminal.

    A better way for you might be to wrap the multiplication and Analog Write function into the while loop so that you're constantly replaying the waveform and it's continuously being re-scaled by the volume value. This will mean your volume control is being continuously polled (once per waveform playback) and used to scale the waveform each time. You'll need to figure out how to stop, send and play the waveform once per iteration of the while loop by bringing the Stop VI inside too. 
  • default Boolean value

    I have a Sub VI that I use to launch a panel where he made a few selections, then made hits.  What is happening inside a while loop.  I took the associated Boolean value the while loop and it connected to the output of the Sub VI.

    I use this subroutine inside my main VI VI, and what I'm trying to do is to hide the front panel of the VI main until the user presses 'Done' on the Sub VI.

    The problem is that even though I explicitly set the value of the Boolean false inside an imposing flat sequence, there always seems to be initialized in my main VI.  I say this because I put a probe and it simply says "Not executed" until I press the fact, how it becomes true.  I expect what follows 'false' until I pressed 'done '.

    I looked through the forum here and have also tried to set its default value with LabView, both without success.  If anyone can help?

    I have attached the VI Sub, and a picture of how I use it in the main VI.

    Thank you

    Stream!

    Your loop where hide you the front panel are not even starting to run your sub - VI has not completed.  You need to hide the front before you start your Subvi.  Then when your time strand begins, it will take place either once if the Boolean value coming is eternally true, or to run if the value Boolean false.

    In addition, there is no reason to hide the front panel in a loop structure.  You're going just to hide several times as fast as your processor will allow (then it would only do once or forever.)

    I recommend you watch the LabVIEW tutorials online
    LabVIEW Introduction course - 3 hours
    LabVIEW Introduction course - 6 hours

  • store the value obtained in the while loop

    Hello

    I'm data acquisition (1,000 points every 0.1 s) in a while loop. I would like to calculate the average y of the first sample of 1000 points when I click on a Boolean 'calibrate', store that value somewhere (outside the while loop?) so that it can subtract from each new amplitude y. In the vi below, a new average value is calculated in each loop, although I would only use the first.

    You don't need to store the value outside the while loop. Keep the offset of the value when calibrate button is pressed and subtract the value with earned value. I modified your find VI the VI attached.

  • Retaining the last value without a while loop

    Hello

    I'm using LabVIEW 2013. My VI is attached. I'll send in a 'Curr. Random random numbers TestPlan Row"time. I'm eager to keep his last number, whenever this VI is not called and then reset the value to its new value whenever the VI is called again and a new number has been sent. Also attached is a screenshot at the VI.

    Please note that I can't use a WHILE loop, so it must keep its value in a different way...

    Thanks in advance for any help!

    SM

    Maybe a feedback node?

  • How to reset a while loop based on a value change event?

    Hi all

    I work in a labview program that sends voltage to a laptop via USB 6008, tension is amplified by an op-amp, and then he comes back in the laptop. I created a program and a working circuit, but my current challenge is how to reset the average of the values of voltage coming into the laptop, after that the user changes the digital control (which controls the output voltage). In other words, I need to be able to reset the number of iteration and the sum to 0 each time this happens.

    I looked upward to reset the counters of iteration through shift registers, but I'm not sure it will work in this case, but I'm also not sure how to reset the sum of an array (if possible). I have spent a lot of time to read these forums and tutorials from various sites, so I think it can be done with the correct nesting of the case structures, structures of the event and while loops, but I don't know how. I am new to LV, just started to learn in mid-January, so any help is appreciated.

    Thanks in advance,

    Graeme

    You just need the structure of single event with the bargains.  Use the case of timeout to get your new values and find the average (100ms timeout value and get rid of the wait function (ms)).  Keep the amount and the number of items in the shift registers.  Wire these values through each case of the event.  In the event of changing the value: control, just set the values to 0.  Then add a Stop button value change event to stop your program.

  • Having trouble getting Boolean button While loop is not updated

    Hello world

    I'm trying to understand how continuous image capture works. So, I tried to implement a simple while loop with a button "continuous Capture". It seems that when the "Continuous Capture" button becomes false, the while loop could not update and stop. No idea how to solve this problem? Thanks in advance.

    Kind regards

    Han Yen

    Move Boolean Capture next to the loop of inter 2.

  • While/loop and reset the value i in time loop

    Hello!

    I have a question about the use of while/loop for.

    I read the data of 5 devices.

    Starting with the 0 position when I = 0, I read the data at position 0.

    And when I click on NextPosition, then I = 1 and stop when I = 5.

    But in the meantime, if I want to break the system of position 3 for now. I click on the BREAK.

    I chose the position back to 0, it will go to this post.

    But if I click on NextPosition, the value is always my 0 and not 1, which is the next position upward.

    In addition, whenever I click NextPosition, it will count up to i = 5 and to stop the program.

    Is there a way I can address the issue?

    Thanks for trying!

    I don't know what your needs are, so I guess you want to keep hitting the same device until you press the button of the next device and you want to be able to specify that one then.

    In the attached code, I changed your mechanical action of the pause button and renamed position Reset.

    I also changed the code suchthat conditionally, we increment the device number (only when the next button is hit).

    I have alos moved local so that us do not draft times and put it in the case of the rest the structure so it is written or read but not both.

    If this does not meet your needs;

    1) look in bulb mode and see where I went wrong

    (2) If you are unable to set up a truth table of all combinations buttn and doc what steps should occur for each condition.

    Always trying to help,

    Ben

  • Add new values to an existing 1 d table in a while loop

    Hello

    I have a while loop that collects data from a DAQ Assistant and stores it in a 1 d table. The number of rows is defined by the user. I'm trying to average of data for each iteration of the loop. So far, I'm only able to get the table to smash the previous table with the new values.

    If the number of loops = 3

    First iteration second iteration third iteration 1 d New Array [divide by loop #]

    4.97                                      4.99                                               4.98                                            14.94                       for the average]
    4.97                                      4.99                                               4.98                                            14.94
    4.96                                      4.98                                               4.97                                            14.91
    4.98                                      5.00                                               4.99                                            14.97
    4.97                                      4.99                                               4.98                                            14.94

    I would like to make it as broad as possible because the number of loops will vary depending on user input.


  • Time to toggle Boolean in while loop?

    Hey everybody,

    I need to toggle a Boolean variable for a short period of time (~0.5 seconds, but it doesn't have to be exact, as long as it can be changed) when the trigger signal is on.

    -basically the variable Signal should remain False until the trigger indicator is True

    -Signal must turn to True for ~0.5 dry and turn return False after

    The program must be substantially while loop (loop data acquisition). Using the calendar could affect the acquisitive data (not shown in the sample program).

    I tried to do this with a case structure and sequence flat but in vain. Any suggestions are welcome. THANKS FOR YOUR HELP!

    Something like that?

  • Sharing data between multiple while loops, competitor rates

    Hello

    I am trying to Exchange data between competitor while loops running at different speeds.  What is the recommended way to do this?    In practice, I have 12 indicators and 3 cards I would update (on screen) in the slower loop, although the data acquired and stored on disk in the fastest loop.  The image below is a simplified version of what really works my candidacy.

    I currently use local variables and shared to achieve this.  I heard however that local variables are evil because of their use of memory (data are copied instead of who passed by reference).

    Thanks for your suggestions,

    Adam

    Hi Adam,.

    Yes, here you go.

    Mike

  • Change the values of the cluster in while loop and in the face at the same time

    Hello.

    I have a little problem in a test program, that I'm working on. I'll try to simplify as much as possible. I have a cluster control that contains two controls A and B. I want to:

    1. switch to update the value of the command A a while loop
    2. allow the user to change the value of the B control through the face, while the loop is running

    To change the value of order in the while loop, I first get the cluster control cluster, update the value of the control for a way to group by name and finally rewrite the cluster in the cluster control.

    The problem is that if the user changes the value of the B control while control that is in the middle of the update, the new value of B control is lost because it was read before updating in the face. Is there a way to get around this?

    DennisBengs wrote:

    1. switch to update the value of the command A a while loop
    2. allow the user to change the value of the B control through the face, while the loop is running

    Then they do not belong in the same cluster.  They are disconnected obviously enough that they do not go hand in hand.

    Where it can get really complicated, it is that you're talking about the user and code changing the same cluster.  It is very dangerous and very difficult to manage.  You might be able to get there with a driving force.  But walk slightly, my friend.

  • creation of the loop for a Boolean value

    Hello

    I'm still a beginner at so forgive me if this sounds simple...

    I created 16 Boolean values with all the false value.

    Now with a loop for, I try to create 16 buttons, and when each button is pressed, the respective boolean compared to this button will change to true. Looks something like below:

    Somehow, this does not work... someone can point me to an error in the coding? Thank you very much!


    Couple things...

    It is standard for a button work onRelease, not delivery.

    -at your service delivery made reference to the button. Not the root
    panel mounting as you probably want to target. The real problem, however, is the
    the reference to I in the button. If you do a trace (i); within the delivery
    you will find that each button will trace 17. This is because the button don't
    not to maintain a local reference to i - just button refer to the final
    value of i in the main timeline... it's called scope. Sometimes issues of concern
    can be a real challenge. What you need to do is to create a local variable
    in the buttons and I store it in this variable.

    for (var i = 1; i)<= 16;="" i++)="">
    This ["button" + i] .i = i;
    This ["button" + i] .onPress = function() {}
    This ._parent ['status' + this.i] = true;
    }
    }

    --
    Dave-
    Developer leader
    www.blurredistinction.com
    Adobe Community Expert
    http://www.Adobe.com/communities/experts/

  • How to get the updated values of the loops while they are running

    Hello

    I am trouble with a very basic problem, how to access the updated values of the "loop FOR" during operation?  Basically, the VI I is currently working on two sub vis calls each sub VI has a loop for, and the two screws may or may not work for the same number of iterations. My goal is to read the values in each terminal within the loop of two sub VIs, in primary VI. I tried to do this using Global Variables, but in main VI it will display only the last iteration of the two value sub live. Could someone please tell me whrere I go wrong? Is there any other/better way to do this.

    I appreciate any input on this issue.  

    Pass a reference of the main VI control to the Sub screws.  See attached example.

  • 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

Maybe you are looking for

  • dead Bluetooth keyboard keys

    I found that after a few weeks of non-use, some of the keys on my keyboard no longer works, 'remove' caplock and 'space '. Everything else works. No calamity to the keyboard that I am aware.  Is it repairable?

  • How can I remove the automatic log on some sites

    I allowed firefox to remember the user name and passwords on some pages. How to 'remember the United Nations' these passwords?

  • Can I set a default for all my folders on Vista?

    Why does every folder I'm going in that I constantly have to change display settings for what I want?  I want only the name, size, type, date created, accessed, modified, but just about every folder I open has a lot of stupid things, I don't want as

  • a database of Oracle 12 c is able to run the Oracle 11.2 clusterware?

    We run 11.2.0.2 Oracle clusterware (and 11.2.0.2 databases). This is a failover cluster - 'a CCR node.Now, we need to run an Oracle 12 c on the cluster server.Is this possible?Are there restrictions?Is it certified?

  • refreshing

    Hi allhope all are very well? I test instance (applications in addition to db) but with the old prod instance data and I want to update with the latest data of the prod instance (application more db) and I prod instance.could all rman backup please,