LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to 6 variables consecutively in 3 steps (Case Structure?)

I have two inputs which, on three different occasions, have different values. So my data input can be split up into three sets of two inputs.

        When the first set of data is sent, the two inputs are processed and stored in indicator 1 and 2.

        When the second set of data is sent, the two inputs are processed and stored in indicator 3 and 4.

        When the third set of data is sent, the two inputs are processed and stored in indicator 5 and 6.

Unfortunately I can't go around this by using 6 different inputs. I need to have two inputs only in the beginning.

I've attached a file where I tried to do this with a case structure. However, the output tunnels are unwired in some of the cases, and I'm afraid that they'll assume new values and won't retain the values that the inputs sent to them.

Any help is helpful... naturally.

-Alex
0 Kudos
Message 1 of 19
(3,436 Views)
You simply have to move the indicators to inside the respective case.
Message 2 of 19
(3,429 Views)
That is true.

                But what if I need to have tunnels (i.e. I need to use that data outside of the case structure)?

I supose I just put the indicators there for the sake of my question.



Edit: I was thinking that I could keep the indicators inside each of the respective cases, and then have "local variables" outside of the cases as needed. Is this the best way?


Message Edited by ap8888 on 07-11-2008 11:35 AM

Message Edited by ap8888 on 07-11-2008 11:38 AM
0 Kudos
Message 3 of 19
(3,425 Views)
You could do something like below.  Use a Ring to choose which case (adds a bit of error checking for you), Case 1 = 0, Case 2 = 1 Case 3 = 2 etc.  Wire the output of the Ring through the case structure as well as your mathematical operation, then build an array out of your 2 indicator outputs and insert them into a 2 day array.  This way the output for Case one is stored at index zero of your Value Holder Array, output for Case two is stored at index 1...

Dont know if this is what you were looking for, it is just one way to keep track of all your outputs.





Message Edited by jmcbee on 07-11-2008 10:40 AM
Message 4 of 19
(3,413 Views)
Unfortunately I need to use a DBL for my case-chooser. I tried doing what you suggested, but I still got a problem.

Please see my attached file.
0 Kudos
Message 5 of 19
(3,409 Views)
You can use shift registers. Here's one with six separate ones and one with a cluster and a single shift register.
 
And you should never,ever use a dbl or sgl as a case selector. Convert to an integer.


Message Edited by Dennis Knutson on 07-11-2008 10:55 AM
Message 6 of 19
(3,404 Views)
Try this, had to init my Value Holder array.
Message 7 of 19
(3,397 Views)
Alex,

You are apparently calling problem.vi on several occasions with different values of the case selector, right?

If so, using a one-iteration while loop with uninitialized shift registers should work. This structure is often called a functional global and is the basis for the Action Engine. I have not tried it but the feedback node which can run without a loop which became available in recent versions of LV might work without the loop.

See the attached modification of your original VI.

You stated that you need a DBL for the case selection. The case structure will coerce that to I32, so be careful if your values are not EXACTLY integers. Mathematical errors due to the finite size of the binary representation of the numbers can cause values to be different from what you might expect.

Lynn
Message 8 of 19
(3,390 Views)
Thank you everyone!

I have another question that is slightly unrelated; it's small, so I didn't want to create another thread.

    Say I have the following structure: Main VI: SubVI1: SubVI2. In Main VI, SubVI1 is called at some instance, and SubVI1 calls SubVI2 within itself.

    Now imagine that in SubVI2, there's some data flow going on, and a few numbers are placed into an array or something.

    Well now, if in MainVI, I stop running SubVI1, that in turn should shut off SubVI2. When I rerun this process, does SubVI2 retain the values     that it contained in the last run?


0 Kudos
Message 9 of 19
(3,362 Views)
The only way subVI2 would retain values is if the values are stored in an uninitialized shift register or feedback node.

If the data come in on controls, the VI will use the values wired to the connector pane. If the connector pane is unwired, default values for the control are used.

Lynn
Message 10 of 19
(3,357 Views)