LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simplification Needed: Multiple buttons with similar execution

Solved!
Go to solution

Hello,

A vi I am currently working on needs many buttons on the front panel. However, the execution for each is quite simple and similar all throughout.The following figure shows the buttons on the left and right side of the Case Structure. Inside the Case Structure, the same commands remain essentially the same except with the change of a number as the input of the Zaber Write vi (in this case it is a 2). Does anyone have a better idea for me to execute these functions in a more compact way? 

 

 

Multiple Buttons.JPG

 

Thank you.

Alfredo
0 Kudos
Message 1 of 11
(5,185 Views)
you can just use the select.vi for those small case's.
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 2 of 11
(5,175 Views)
Solution
Accepted by AlfredoT
this might help:
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 3 of 11
(5,172 Views)
What version of LabVIEW are you using? Don't you have the event structure available? You could eliminate all of those adds and case statements if you do. Can you post your VI?
0 Kudos
Message 4 of 11
(5,169 Views)

Dennis Knutson wrote:
What version of LabVIEW are you using? Don't you have the event structure available? You could eliminate all of those adds and case statements if you do. Can you post your VI?

This would be my first thought as well.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 11
(5,158 Views)

Is it possible that more than one button could be pressed at a time?  If so, then an event structure might not help.

 

But if more than one button could be pressed, then the numbers that are added don't make sense.  You would think they'd be a binary series.

 

Regardless,  this would be a simpler implementation.  (I shortened it to just 4 buttons.)

 

 

By the way, if you make your loop terminal, Stop if True, then you can get rid of the Not! function going into it.

Message Edited by Ravens Fan on 10-16-2009 10:19 PM
Message 6 of 11
(5,148 Views)

It depends if your buttons are switch action (any combination of buttons can be true: 2^N possible cases)

or latch action (only zero or one can be true: N+1 possible outcomes).

 

Here is code for both cases as shown.

 

 

 

 

(If you want some weird, nonconsecutive case numbers, you can index into a lookup table before going to the case structure.)

 

Overall, your code shows some very odd programming style that makes little sense. Can you attach the actual program?

Message Edited by altenbach on 10-17-2009 02:29 AM
0 Kudos
Message 7 of 11
(5,133 Views)

Regarding Altenbach's example abve, you can even enumerate the numeric output, then the cases can be made to read "Button 1, Button 2..." (or whatever) rather that "1, 2..." etc. This is a huge help if you have more than a few buttons, and takes just a minute to do.

buttonCases.GIF

In the above example, the +1 function is to "get past" the Default, and inside the enumerator, the first position is "Default" or "Nothing".
Message Edited by Broken Arrow on 10-17-2009 05:49 AM
Richard






0 Kudos
Message 8 of 11
(5,125 Views)

From the looks of things you will only send one command at a time to the Zaber device.  I would use a type def ring control (set to allow non-sequential values Properties>edit items>uncheck"Sequential values") and send the value to the Zaber. 

 

Code an control are attached Pictures worth 1000 words

 

1.PNG

 

 

 

 

 

 

 

 

 

Message Edited by Jeff Bohrer on 10-17-2009 04:19 PM

"Should be" isn't "Is" -Jay
Download All
0 Kudos
Message 9 of 11
(5,101 Views)

It is not possible for two buttons to be pressed at the same time.

 

Jeff: Thank you for your vi's. Unfortunately I was unable to open them since they are from a slightly older version.

 

My code is attached for those that had requested it.

 

Also, I don't know how to use Event Structures and my LabView version is 8.6.1 so I do have them. I will look into them.

 

Thank you!

Alfredo
0 Kudos
Message 10 of 11
(5,052 Views)