LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to execute a case structure only once

Solved!
Go to solution

Hi!

 

I`ve searched in many threads this question but I still don´t undestand how to make an event to execute only once when true, without having to stop and run again the VI for executing once again...

 

If I wire a boolean control, for example, to a case structure that contains a beep VI, it sounds continously when true... I want it to beep only once when true, but if I switch to false and true again, that beeps again only once... I haven´t found how... I´ve tried with shift registers, local variables, boolean logic, etc.. but I´m not doing it right... Anyone can help me? I´m not very good at boolean logic... in fact I´m not very good at programming in LabVIEW lol... but still I have to do this....

 

Thank you!! Have a great day... =D

0 Kudos
Message 1 of 4
(13,772 Views)
It sounds like you have the wrong mechanical action on the button. All you need is an event structure and a while loop:
0 Kudos
Message 2 of 4
(13,757 Views)
Solution
Accepted by topic author mia.lara

mia.lara wrote:

I`ve searched in many threads this question but I still don´t undestand how to make an event to execute only once when true, without having to stop and run again the VI for executing once again...

 

If I wire a boolean control, for example, to a case structure that contains a beep VI, it sounds continously when true... I want it to beep only once when true, but if I switch to false and true again, that beeps again only once... I haven´t found how...


 

There are a couple of confusing points in your description, for example a value change event executes only when the value changes, so it will only execute going off->on and on>off and will not continuously fire as you describe. And stopping and running the VI again should not make a difference.

In the second paragraph you suddenly talk about a case structure (what happened to the event?)

 

Could you please be a bit more specific. Why not attach one of your code attempts so we can hopefully understant what you actually have.

 

If you want the button to go true for an instant and go back to false automatically once it was read by the code, use a latch action button. If you want the button to toggle whenever you press it, but still only trigger the beep when the state goes from false to true, all you need is a feedback node and an "implies".

 

Have a look at the logic for the Off>On LED in the example posted here.

Message 3 of 4
(13,732 Views)

Hi!

 

Sorry for not using the proper terms... (english is my second language, and the diffuculty increases a little with technical terms... =P ). By an event I meant... something.. some code inside a case structure. As I have continously adquired data, in some point I will get a true value n times, so I was trying to simulate it with a boolean control with a "switch when pressed" mechanical action... And I wasn't able to make the VI beep just once...

 

But the example in your link is perfect!! Thank you! (Thanks to the other poster also...) The feedback node with the "implies" and "not" is all I need... Right now I'm analysing the logic with the "highlight execution" and reading about feedback nodes.. lol, like I said, I'm a little slow with these things but I'm learning...

 

Thanks again!!!   =D

 

0 Kudos
Message 4 of 4
(13,720 Views)