LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to synchronize events

Solved!
Go to solution

Hi,

 

I have an application which is started by one of the following ways (phase 1 in the attached vi.):

1) The user presses the START button on the front panel

2) The user uses a scanner to scan a label containing a specific character ("[" char. for example) that also initiate the program.

 

After the program starts it runs some tests (Phase 2, not seen in the vi.) and doesn't return to the starting point. Instead it goes to a second state where the user can once more initiate the program by pressing the START button or by using the scanner (represented by phase 3).

 

The problem is, once the START button is chosen at phase 1 it remains "LOCKED" (TRUE), although the Button's indicator shows the opposite, and so the START button "value change" event in phase 3 is automatically activated, even though the button wasn't pressed a second time.

 

How can I avoid this phenomenon ? I must have the phase 3 events activated only when the user makes an action (button press or scanner "press").

 

Can any one help ?

0 Kudos
Message 1 of 6
(3,102 Views)
Use statemachine architecture to handle the state changes.See the example programme attached.
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 2 of 6
(3,070 Views)

Baji's program should work.  The use of a state machine is a good idea for programs like this.

 

The reason your original program doesn't work is that you should never create two event structures that handle the same events.  In your VI, both event structures capture the value change of the start button.  So once the original event structure is done and the next frame the sequence is done, the next event structure will run right away because it has the Start Button value change in its event queue.

 

Just because an event structure is not in the order of execution at that particular moment in time doesn't mean that it is not capturing events and queueing them up to be ready for execution once the flow of the program hits the event structure.

Message 3 of 6
(3,059 Views)

Hi,

 

Baji's program is indeed a good idea to handle the states (thanks for that Baji).

However, in my case I have "START1" state and "START2" state. Both states must be separate and both should handle the same event for the same button.

I understand from your answer this can not be done using events.

Do you have any other idea\method how to implement this ?

0 Kudos
Message 4 of 6
(3,051 Views)
Solution
Accepted by topic author Mentos

You just need to keep track of which phase to run next in a shift register.

 

See the attached modification.

0 Kudos
Message 5 of 6
(3,043 Views)

OK,

 

I'll make the necessary modifications in my program.

I guess it should work.

 

Thanks!!!

0 Kudos
Message 6 of 6
(3,023 Views)