LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I keep running event-based state machine by a single event

Solved!
Go to solution

Hello Folks,

 

I need your help.

 

In the event-based state machine when a Boolean is true then the event will occur but I want to keep my event running until Boolean (I’m using mechanical action “Switch when pressed”) is false.  

 

Thanks.

- Reduanul

0 Kudos
Message 1 of 23
(1,703 Views)

Could you attach your code? It sounds like you are running your code inside the event structure. I would recommend moving your code to its own loop and sending messages to start and stop based on the boolean events (you will get a value change event for both T-F and F-T).

0 Kudos
Message 2 of 23
(1,689 Views)
Solution
Accepted by topic author REDUANUL

@REDUANUL wrote:

Hello Folks,

 

I need your help.

 

In the event-based state machine when a Boolean is true then the event will occur but I want to keep my event running until Boolean (I’m using mechanical action “Switch when pressed”) is false.  

 

Thanks.

- Reduanul


I typically use the Value(Signaling) Property Node for this.

 

Here's an example of what I think you are asking...

PnCapture.PNG

I would probably put the Val(Sgnl) property node inside a case that follows your Boolean so it only triggers a value change when true.

========================
=== Engineer Ambiguously ===
========================
Message 3 of 23
(1,663 Views)

Please define "Keep the event running". Do you want to remain inside the event (not recommended) or re-enter the same event over and over as long as the boolean is true? What else needs to happen in parallel?

 

I sometimes use the timeout event for the bulk of the work and switch the timeout (held in a shift register) based on the new switch value between "short" and "-1" (i.e. infinite).

 

In any case, we need significantly more detail to give advice. Show us your VI.

0 Kudos
Message 4 of 23
(1,652 Views)

@ RTSLVU,

 

Thanks for your advice but in my code, it's not working probably I have to do another way around.

 

@ altenbach,

 

Sorry for not being attaching the full code but for easy understanding please have a look:

111111.png

 

 

Here when I press the ON/OFF button all messages are executed once but afterward Event Handing loop wait for another event from other cases or from the ON/OFF case. 

 

So what I am trying is, when ON/OFF remained pressed messages will execute continuously instead of once. Then in the false case Event handling loop will wait for another event. Hope it helps you.

 

0 Kudos
Message 5 of 23
(1,640 Views)

@REDUANUL wrote:

So what I am trying is, when ON/OFF remained pressed messages will execute continuously instead of once. Then in the false case Event handling loop will wait for another event. Hope it helps you.

 


Use my timeout suggestion.

0 Kudos
Message 6 of 23
(1,638 Views)

Here's how that could look like. (Assuming that your subVIs execute and return quickly, you can easily adapt it to your scenario.)

 

 

Message 7 of 23
(1,629 Views)

@ altenbach,

 

I tried your approach. I not getting where is the problem.

 

Here is my implementation:

 

ggg.PNG

 

I wired the timeout case according to your suggestion as well. Till now event handler only executing the message once to the Message handling loop.

0 Kudos
Message 8 of 23
(1,616 Views)

@REDUANUL wrote:

Here is my implementation:


No, that's just a picture.

0 Kudos
Message 9 of 23
(1,609 Views)

@altenbach wrote:

@REDUANUL wrote:

Here is my implementation:


No, that's just a picture.


And the picture doesn't even show all of the code. I don't think that you implemented the code the way altenbach suggested.

0 Kudos
Message 10 of 23
(1,577 Views)