LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with nested event structures

Solved!
Go to solution

Hi there,

 

I am rather new to Labview and wanted to use a nested event structure in one of my programs.

 

However I seem to fail to do it right.

 

I created a minimal example of the construction I am using, you may find it in the attachment.

 

The basic idea in this program is the following.

 

1. I start the program and go into a while loop

2. Once I press and hold a front panel button a counter is increment every 100 ms.

3. When I release the buttun the incrementation stops.

 

However, this is not working. What am I doing wrong?

 

Thanks in advance!

0 Kudos
Message 1 of 5
(2,781 Views)
Solution
Accepted by topic author LabNEW90

Never stack event structures. Never ever.

 

That being said, your code contains quite some illogical parts, e.g. a wait time while using a 0-timeout event case.

Please use a single event structure. In case the increment should run, set the timeout case to e,.g. 100 (using shift register) and once it is pressed again set it back to -1. Initialize the shift register with -1.

Also avoid using references and property nodes to read/write values. These are bad practise (in most cases) and bury lot of runtime performance.

Use a second shift register to keep the numeric value and increase the value in the timeout case. Update the terminal after the event structure.

 

Norbert


EDIT: My first line is a rule of thumb. With increasing LV skill and appropriate design, stacking of event structures is possible, but you have to know the rules. If not, you will fail hard.

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

Thanks Norbert!

 

I changed the program like recommended and now it works smoothly!

 

However I kept the numeric ctrl reference. As I said this program here was only a minimal example of my problem and in the real program I have to perform a more complicated action on an instrument from which i got an automation refnum. So I wanted to test the whole thing with a reference.

 

I will upload my improved program here, for others who may stumble upon the same problem and want to see the solution.

 

Thanks again!

0 Kudos
Message 4 of 5
(2,696 Views)

Thanks Bowen, I will have a look at it in case I encounter further problems with event structures. 🙂

0 Kudos
Message 5 of 5
(2,694 Views)