 LabNEW90
		
			LabNEW90
		
		
		
		
		
		
		
		
	
			12-17-2014 06:18 AM - edited 12-17-2014 06:19 AM
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!
Solved! Go to Solution.
 Norbert_B
		
			Norbert_B
		
		
		
		
		
		
		
		
	
			12-17-2014 06:32 AM - edited 12-17-2014 06:33 AM
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.
 BowenM
		
			BowenM
		
		
		
		
		
		
		
		
	
			
			
    
	
		
		
		12-17-2014
	
		
		08:10 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		06-16-2025
	
		
		01:54 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		 Content Cleaner
		
			Content Cleaner
		
		
		
		
		
		
		
		
	
			
		
You may find this to be useful reading:
12-18-2014 06:12 AM
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!
12-18-2014 06:14 AM
Thanks Bowen, I will have a look at it in case I encounter further problems with event structures. 🙂