LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Latch after 10 seconds

Solved!
Go to solution

Hello guys, i need your help, i'm sure it's pretty simple but i have no idea how to do it.

In my program i have to implement a temporary override fonctionnality. So when i press my button the signal become true and 10 seconds later the button has to automatically turn off so the signal become false. However the program MUST keep working during these 10 sec, so if i press other button it must work and not wait. i've checked the button properties and it looks like the option "latch when release" but the release have to be done 10 secondes later.
i hope you understand what i've said.
Have you any idea please ?

0 Kudos
Message 1 of 10
(6,166 Views)

Use a small independent while loop with an event structure. Have an empty event for the button change and a timeout event. Start with a timeout of -1 (infinite) and whenever the value changes (AND the new value from the event terminal is TRUE!), set the timeout to 10000. In the timeout case, reset the button to FALSE with a local variable and set the timeout back to -1.

 

(Also add an event for the stop button, so this loop stops when the main code stops)

0 Kudos
Message 2 of 10
(6,149 Views)

First, thanks for your answers, appreciate it.

 

I can't use the event case structure, it block the program until i click on the button.

I'm new with labview, can you post an example please, maybe i'm using it badly ?

0 Kudos
Message 3 of 10
(6,099 Views)

it would be good to see your code, might be that you misunderstood altenbach.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 4 of 10
(6,088 Views)

My program has a lot of VI-subVi,

you can see enclosed my main and my input vi to generate datas.

The override functionnality has to work when i click on the button Int_PB1

 But during the 10 sec of overriding i must be able to change the value f others buttons.

With an event structure, the program wait until i click on Int_Pb1 to change the other values, that's not what i have to do

Download All
0 Kudos
Message 5 of 10
(6,081 Views)

even with altenbachs suggestion, you will not accomplish what you want, because of data flow.

you should put all your gui stuff inside the main.vi,

add an extra loop with an event-structure, use this to react on the appropriate events,

then trigger in another loop your Control.vis


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 6 of 10
(6,071 Views)

You don't need to keep setting the start time of the Wait. However, except when you Reset, it shouldn't make any difference, so it won't change anything.

 

I expect that the problem you're having relates to a misunderstanding of Dataflow in LabVIEW (but perhaps instead I'm misunderstanding what you want the program to do).

 

My guess is that you're using the Input VI you uploaded to interact with the other two VIs that can be seen in Main.vi, and are unhappy that nothing happens until you press Stop (in Input.vi). This is because the values don't come out of the Input.vi until Input.vi finishes - so the next VI can't start.

 

If you want to communicate between multiple sections of code, you need to rework your communication. One possibility might be a State Machine, which would allow you to use an Event Structure in an 'Idle' case and check back and forth for timers on various button presses. You should take care to avoid allowing any cases to take too long for an individual iteration - this is what can make code feel unresponsive (and by feel, I mean be unresponsive!).


GCentral
0 Kudos
Message 7 of 10
(6,067 Views)

Thanks for all your answer, but i don't understand why i have to change all the structure of my program for something which seems really simple.

i press my buton, it become true, 10 seconds later it come back to his default value, false.

So basically i push my button, i start a timer, when 10 seconds elapsed the program change the value of the button via the property node value.

I just can't use and event structure because it block the program, that's why i used a case structure in my code. it's almost working, i just have some problem with the reset of the timer

0 Kudos
Message 8 of 10
(6,064 Views)

if your "Controller.vi" and "View.vi" return (almost) immediately, then you don't need to change much.

if not, these two will block your loop in "Main.vi" until they have executet, one after the other, only then will your "Input.vi" be able to react on GUI changes.

but if you want to have your 10s wait on a button, then your "Input.vi" will block for 10s,

and only after that will your "Controller.vi" and "View.vi" be executed.

 

starting even simple programs with a sensible design pattern is not a bad thing.

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 9 of 10
(6,057 Views)
Solution
Accepted by topic author ghamm03

@ghamm03 wrote:

 

I can't use the event case structure, it block the program until i click on the button.


I strongly suggest to go back to the LabVIEW tutorials, then implement a proper state machine as suggested by others already.

 

In any case, here's what I had in mind. The event loop runs completely out of band of the main code. In your case you would use a value change event on the cluster element.

 

OnForTen

Download All
0 Kudos
Message 10 of 10
(6,043 Views)