LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to add using case structure

Hi, this may sound very simple. but i'm a bit stuck.
 
i need a button then when press, will always add a constant. i probably need an add function, a control and an indicator. i've placed them at all the respective pins of the add function. but i do not know where to connect the button (boolean) function.
 
any suggestions?
0 Kudos
Message 1 of 5
(2,963 Views)
You would just use a case structure and wire the boolean to the case selector.
even simpler, just use a switch.
 
Let us know if you need more detailed help. 🙂


Message Edited by altenbach on 01-19-2008 11:35 PM
Download All
0 Kudos
Message 2 of 5
(2,948 Views)
hey, thanks!
 
i somehow managed to create another method of incrementing too. but i still another button that when pressed, will decrement by one. at the value will still be displayed from the same indicator. like a cancel button. if i accidentally increment to 3, i want to cancel it, so the number becomes 2 back.
 
attached is my VI for the increment.
i'm using ver. 8.
 
regards,
aisyah
0 Kudos
Message 3 of 5
(2,923 Views)

Yes a shift register is the preferred method for a task like that. Since you did not say what exactly you wanted to increment, I did not go there. 😉

However, your VI has problems and can be improved as follows:

If you would place an indicator at the iteration counter, you would see that your while loop always spins as fast as the computer allows, many millions of times per second. This consumes all CPU for no reason at all. This is much faster than any user interaction can take place and thus overkill. Much better is an event structure. Now the loop only spins when one of the buttons is pressed. The reaction time of the code is actually faster because you are not polling the controls and, at the same time, the VI uses insignificant amounts of CPU (~ zero!).

Since you are counting integers, you should also use a blue representation (e.g. I32) instead of orange (DBL) for the counter. I added a button to decrement the value of needed.

See if this makes sense. 🙂

0 Kudos
Message 4 of 5
(2,917 Views)

hey, thanks.

the vi i attached was just a scope of what i needed. i'm using it in a bigger VI which works in the attached VI (below). so the while loop is necessary.

0 Kudos
Message 5 of 5
(2,896 Views)