10-16-2009 05:07 PM
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?
Thank you.
Solved! Go to Solution.
10-16-2009 06:32 PM
10-16-2009 06:38 PM
10-16-2009 06:46 PM
10-16-2009 07:13 PM
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.
10-16-2009 09:18 PM - edited 10-16-2009 09:19 PM
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.
10-17-2009 04:26 AM - edited 10-17-2009 04:29 AM
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?
10-17-2009 05:40 AM - edited 10-17-2009 05:49 AM
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.
10-17-2009 04:17 PM - edited 10-17-2009 04:19 PM
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
10-19-2009 04:28 PM
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!