LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make 2 state machines run dependently ?

Dear friend, 

 

In this question, https://forums.ni.com/t5/LabVIEW/A-simple-labview-question-with-example-vi-attached-Thank-you/td-p/3... . I learned that the way I was doing is impossible.  Because the green wire to 2nd state machine will have value only 1st state machine stop!.  But my goal is first state machine will running, then 2nd will start to run after the 1st one gives true (the green from 1st one). I do need to keep 1st state machines keep running. In others words, the both state machine will be running eventually.  

 

I am doing this, because i am doing much bigger project, and there are 2 state machines.  If this cannot be done in one VI, maybe make 2 independent VI, and somehow 1st VI will inform 2nd VI start to run?  But I am not sure about it. Thank you.

Untitled.png

0 Kudos
Message 1 of 18
(4,172 Views)

Look at the queued message handler architecture.  You can have the message handler (or consumer) loop run like a state machine, and allow the queue to interrupt it for things like start, shutdown, etc.

0 Kudos
Message 2 of 18
(4,160 Views)
0 Kudos
Message 3 of 18
(4,151 Views)

@Gregory wrote:

You can do so using a notifier.


I've taken an irrational dislike to notifiers.  It seems every time I've used one that half way through the project I've regretted it and switched to a queue.

 

And since I'm on the rant, I've taken an irrational hated of occurrences because they seem such a simple perfect solution at first... and then you have to add some functionality and they promptly produce spaghetti code.

Message 4 of 18
(4,140 Views)

hi, gregoryj. 

 

You think queue is better? Because I am not familiar with both... lol

0 Kudos
Message 5 of 18
(4,127 Views)

Yes, I often prefer a queue over a notifier, but there are two cases where I use notifiers. 

  1. Sending a notification when something should happen, like in the example above.
  2. Create a temporary data transfer method like in DQMH to retrieve data out of a module.

Maybe it's just that the terminology of the notifier "wait on notification..." feels more natural than "dequeue element" when I want my code to be waiting on another process.

0 Kudos
Message 6 of 18
(4,121 Views)

Sunson, they are very similar, and in your case I imagine they would be identical. Here are a couple of differences between the two that I think are worth noting:

 

queue vs notifier.png

Message 7 of 18
(4,111 Views)

Hi gregoryj. 

 

Could you please help me edit my attached vi?  My target is,  the 1st one keep blinking, after true coming from 1st state machine. The 2nd one will start blink as well. BUT the 1st should NOT stop, but keep blinking as well.   I do have to keep those 2 state machines.  Thanks for your help in advance. 

 

 

Download All
0 Kudos
Message 8 of 18
(4,095 Views)

Sorry, I cannot open up LV 2017 files. Can you upload for previous version?

0 Kudos
Message 9 of 18
(4,091 Views)

Hmm. I dont have lower version, but the vi is very very simple. Could you check the picture?  For state machine, state 1, there are nothing (just state 1 then go to state 2). I only state "2" is doing the blinking thing. Thank you so much.

 

Untitled.png

0 Kudos
Message 10 of 18
(4,086 Views)