LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Priority button in a state machine

Hello guys . i am working with this state machine for a HMI  to communicate with a specific instrument . 

1/ i want that if i press the "stop measurment button" at any time in any state of my prgramm, this button stops the instrument instantaneously without having to wait that all the sequences are done ( beacuse once all the sequences are done, the instrument stops automatically) . Can i set a priority in labview states ??? 

( i didn't post all the program due to its confidentiality so i just wrote a descriptin in every state) 

2/ i want to calculate the execution time of every state

pleaaase help  me !!! 

 

 

0 Kudos
Message 1 of 23
(2,334 Views)

Put the case structure with sequences inside the timeout event and add an event for the stop button. All other state can be handled with event cases.

Keep the timeout in a shift register and manipulate the timeout from -1 to finite if sequences should execute.

0 Kudos
Message 2 of 23
(2,325 Views)

can u do this in the vi that i attached bellow cuz i didnt understand you and thank you so much

0 Kudos
Message 3 of 23
(2,320 Views)

You need a queued message handler rather than a simple state machine.

 

With a QMH the event loop is always running and a pripority command can be added to the state queue with Enqueue at opposite end.

A brief mod is attached (incomplete)


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 23
(2,317 Views)

i tried ur method but the problem that occured is that i want that once i clic on start measurment button it executes seq1 then seq2 then seq3 then seq4 and then the state machine returns to the state wait for event . In the code attached in the vi bellow once i clic on start measurement it go to the state sequence 1 and returns to the state wait for event whereas i want to execute seq1 until seq4 and return to the wait for event state .  Please can u have a look at the vi that i did ? 

0 Kudos
Message 5 of 23
(2,241 Views)

@JASMIN185 wrote:

can u do this in the vi that i attached bellow cuz i didnt understand you and thank you so much


You did not attach your typedef. Also make sure to save for previous. Your latest attachment is in LabVIEW 2021, which many cannot open.

0 Kudos
Message 6 of 23
(2,236 Views)

here's the VI 

0 Kudos
Message 7 of 23
(2,230 Views)

Do you have the typedef of the original VI?

0 Kudos
Message 8 of 23
(2,227 Views)

No, the vi came stripped of dependencies.   Hence the really nasty split from the SSM to QSM<events> I assume the OP could 

 

GO TO GRAMMAS HOUSE as a better explanation of priority messaging but I failed to add that link

 

A simple enqueue in a loop should give a nice sequence of "non-priority" steps.  The message handler would not need a wait for events case (the dequeue element automagically does that!)


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 23
(2,212 Views)

I still think all we need is one simple loop as I suggested.

 

Of course the term "immediately" is a bit soft when external instruments are involved, because the might need a clean shutdown procedure.

0 Kudos
Message 10 of 23
(2,205 Views)