LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure doesn't fire

Hello,

 

There is simple case:

  • 2 buttons: START and STOP
  • when START is clicked, the VALUE increments
  • when STOP is clicked, VI should STOP

START functionnality is OK, whereas STOP doesn't work.

 

Where I've been mistaken.

 

Thanks in advance

 

Pavel

 

While&Event_structure_STOP_doesnt_work.JPG

Message 1 of 28
(5,018 Views)

Basic rules for event structures:

 

1. DO NOT USE MORE THAN ONE EVENT STRUCTURE PER VI unless you are very well aware of what you are doing

2. USE A SINGLE EVENT STRUCTURE FOR SINGLE SOURCES. In your case: use ONE event structure to handle all frontpanel activity

3. Put the source of the event inside the event structure case handling that source' events

4. Don't use loop timing and timeout event concurrently

5. NEVER nest event structures unless VERY sure about what you are doing (don't to document this!)

6. Beware of FrontPanel locking!

7. .... (many more following)

 

Guess which ones are not met by your code....

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 28
(5,009 Views)

There is nothing wrong with using mutiple event structures in the same VI, well... almost.

 

No seriously, there is a list of caveats and recommendations about that.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 3 of 28
(4,996 Views)

This appears to be a bug in LabVIEW.

You can work around it by changing the Value Change event in the 1st event structure so it doesn't defer FP updates.

However I would reccommend restructuring it to use only one event structure.

 

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 4 of 28
(4,976 Views)

Thank for suggestions,

 

I've modified the VI, leaving only one Event structure.

Am I correct while saying that for the scenario, that I described in my 1st mail, the only solution is to employ "state machine" (or case structure) ... at the condition that only one event structure is employed.

 

Regards

 

Pavel

 

While&Event_structure_STOP_working_version.JPG

0 Kudos
Message 5 of 28
(4,972 Views)

Hi Pavel,

 

your VI can improved a lot by using latching switches and a shift register for "Running"…

 

Get rid of all those local variables!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 28
(4,961 Views)

Hi GerdW,

 

But if "non-latched" switches are imposed by concept, can this VI be still improved ?

Concerning "Running", frankly speaking I didn't understand how to employ it with shift registers.

Could you explain a little bit more (if you have a time, of course)

 

Thanks in advance.

 

Pavel

 

0 Kudos
Message 7 of 28
(4,951 Views)

Pavel,

 

you can get rid of the "parallel case" by simply modifying the timeout time and get the code (increment and display) into the timeout case.

 

Do something like this:

Timeout.PNG

Do NOT forget to set timeout back to -1 in any event case which stops the timeout!

 

Norbert

 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 8 of 28
(4,935 Views)

Norbert,

 

I think Pavel has found a bug.

 

If you take his example, and edit the event in the fist frame such that it does NOT disable FP unitl Event completes, it works fine.

 

The bug appears to be that the first event case is failing to enable FP when it completes.

 

I call it a bug.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 28
(4,912 Views)

@Ben wrote:
[...]

I call it a bug.

 

Ben


Ben,

 

i am not sure if i should say "contradiction".

The point is that this scenario is definitely NOT recommended and it is for sure not tested for.

 

Now for the point i am not sure about:

I assume that LV internally treats the code to something like this:

UserEventBranching.PNG

Make a test: Press Stop before Start. If everything would be as simple as you think, the first loop would stop when pressing "Start" and immediatly the second event structure should de-queue the stop.

This is not happening which indicates that both event structures use the same event-queue!

As the source of the structures is the same (FrontPanel) i find this rather expected.....and hence the first structure doesn't revoke the lock on the panel as the second would have to execute as well to make that possible.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 10 of 28
(4,895 Views)