LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple booleans controlling one boolean input for a case structure

Hello,

I have four boolean buttons and a case structure with a boolean input. I would like to write the program so that whenever any one of the four boolean button changes value, the case structure reads true for one loop interation, and then returns to false.

I have tried all sorts of things and can't seem to figure it out.

Ultimately, the ideal function of the program is so that whenever you push any one of the four boolean voltage controllers, that voltage case is chosen in the case structure, the time in seconds is written to a file, and the elapsed time timer is reset.

I have attached my program. Let me know if you have suggestions. Thanks.


0 Kudos
Message 1 of 7
(4,036 Views)
Hi Zappow,
change the mechanical action of your four buttons to "latch when released". Create an event structure and create one event case for all four buttons. Insert your case structure into this event case and connect the value output from the left side to your case structure input.

Mike
0 Kudos
Message 2 of 7
(4,034 Views)
Mike,
Thanks for the speedy response. This fixes my button and file-saving issue.
However, with this setup, the time counter still doesn't work.
The event structure for all four buttons has a true boolean constant connected to my file-saving case structure. If I connect this to my elapsed time express VI reset button, the timer doesn't count.

I would like the time counter to count continuously, and only reset when a button value changes.
0 Kudos
Message 3 of 7
(4,016 Views)
Hello Zappow,
After looking at your code I realized that as soon as your event occurs on the voltage value changes you send out the true constant to the reset input of the Elapsed Time express VI and into the case structure.  However, it looks like you never reinitialize it back to false.  So every iteration of that loop with consistently reset the Elapsed Time express VI and then run through the true portion of the case structure.  I believe that if you reinitialize that boolean back to false after you have sent the true to the express VI and the case structure then you should continue execution as normal and your timer will still continue to count.  I hope this helps!  Please let us know if that doesn't solve your issue.
Thanks!
Bob H
Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(3,988 Views)

Hi Zappow,

please explain what you try to do. Your timer can´t do what you want, because you have an event structure in thie while loop. The loop executes only if you press a button. The same is with your stop button. If you press the stop buttons nothing happens til you press one of the voltage buttons. I recommed to use only one Event Structure per FP and you should create events for the stop buttons.

Mike

0 Kudos
Message 5 of 7
(3,966 Views)


Zappow wrote:
However, with this setup, the time counter still doesn't work.
The event structure for all four buttons has a true boolean constant connected to my file-saving case structure. If I connect this to my elapsed time express VI reset button, the timer doesn't count.

The timer does not count because you have not wired a timeout to the lower event structure. The default timeout is -1, so the lower loop never spins via timeout
 
It is useless to have a wait in a loop that also has a timeout case. Just wire an approriate timeout value to the timeout terminal and remove all waits. It is also not necessary to have a 1ms ttimeout if your timeout values only displays to 100ms resolution. Can you explain why you think you need two loops and all that extra code?
 
Attached is a quick rewrite that solves some of the problem. Since I don't have any hardware, I replace the voltage out with a meter.
 
You have way too many FP controls and indicators. Use arrays!
 
Let me know if yo have any questions. Modify as needed.
Message 6 of 7
(3,958 Views)
Thanks for all your help.
10 days ago, I hadn't even heard of Labview, so that may explain why my code is so wonky. I've never even really programmed before.
I eventually got my program to work, and do what I want, through brute force method.
Now I think I'll try and take some of your tips and clean it up - make it a little cleaner and more elegant.
Thanks.
0 Kudos
Message 7 of 7
(3,932 Views)