LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Hmm well let's see if a different explanation leads to another solution:


SubVI2 has a shift register structure like the one you created for me above (where the three inputs come from SubVI1). So, as before, there's a SIX outputs that are stored in total.

Say on the first run, 2 out of 6 outputs are complete. Now on the second run, the second pair should be comlete; BUT the question is whether the first pair is now given default values or does it retain the values from the first time the VI was run?

0 Kudos
Message 11 of 19
(994 Views)
With the shift register, if you do not initialize it, it will retain the values.
0 Kudos
Message 12 of 19
(989 Views)
Thank you everyone.

One more question (I promise):

@johnsold wrote:

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

I'm not sure how to avoid this problem. Is there a way that I convert my DBL to a 32bit integer, and avoid this problem?
0 Kudos
Message 13 of 19
(985 Views)
Yes.  There are conversion functions on the Numeric Palette under Conversion.  For instance, there is a To Long Integer conversion.  Wire in the double on one side, comes out I32 on the other.  It rounds off the fractional part to the nearest integer.  (Even integer if it is exactly 0.5)
0 Kudos
Message 14 of 19
(980 Views)
You got one more question so now we get one more.

Actually, no one minds more questions when they show that you are making progress and learning something. Even the most experienced users often learn something new, sometimes because of a question.

Where does the DBL come from? Why is it a DBL, in other words?

Lynn
0 Kudos
Message 15 of 19
(975 Views)


@johnsold wrote:
You got one more question so now we get one more.

Actually, no one minds more questions when they show that you are making progress and learning something. Even the most experienced users often learn something new, sometimes because of a question.

Where does the DBL come from? Why is it a DBL, in other words?

Lynn


Here is where I express embarrassing facts. Actually, the DBL is a numerical control all the way from the primary VI (the one that calls the SubVI that calls this subVI2). I wanted to let the user select between 1, 2, and 3.

Now this is when you tell me that there's a way of doing all of this with an integer; a way that I don't know!

By the way, is it true that "conversions" in LabView take up plenty of memory, and it's best to avoid them as much as possible?

 

 




Message Edited by ap8888 on 07-11-2008 02:16 PM
0 Kudos
Message 16 of 19
(972 Views)
A numerical control can be any representation that you want. You could also use an enum, text ring, or menu ring. Then instead of choosing between 1,2,3, the user can have text to choose between. A menu or text ring output a integer. When you wire an enum to a case statement, the text of the enum shows in the case selector label.
0 Kudos
Message 17 of 19
(967 Views)
No need to be embarrassed, you never learn anything without trying.

When a numeric control is placed on the panel, it is DBL by default. You can change it to any other numerical representation as needed.

Conversions: Conversion of a single numeric only takes as many bytes as are needed for the new representation. It also does not take much time.

Conversions of large strings or arrays can take a lot of memory and time.

The reasons "coercion dots" are to be avoided on the diagrams are more than just memory and time issues. If the case selector in your program had been obtained by numerical calculation rather than from a control, the result could be different from what you would expect.

Coercion dots warn the programmer that LV is changing the representation of the data, and thus, possibly the value. By avoiding them, you avoid having the program do something different from what you expect. (Well, help avoid. There are other kinds of programming errors also!).

Lynn
0 Kudos
Message 18 of 19
(963 Views)
I would use a globally initialized feedback node and do everything with arrays. It is much easier to deal with a few simple arrays that with hordes of wires, tunnels, controls, and indicators.
 
Here's a quick draft. (Of course the feedback node only retains the old data in the same run. Whenever you restart the VI, it is back to all zeroes.
 


Message Edited by altenbach on 07-11-2008 01:10 PM
0 Kudos
Message 19 of 19
(938 Views)