LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incrementing front panel control from button trigger in Simulation Loop

Solved!
Go to solution

I want the "Index" control to be automatically incremented when the OK button is pressed. This works fine. However, the Index control gets automatically incremented every time the VI is started and when the Stop button is pressed. Even if the Case Structure is wired with a False constant (meaning it should never be executed), the Index control is still incremented.

 

Is there a bug when using local variables inside case structures in the Simulation Loop? This does not occur when using a While loop.

Incrementing control in Simulation Loop

0 Kudos
Message 1 of 6
(4,030 Views)
Solution
Accepted by topic author BingoCard

I think since a Simulation Loop doesnt have shift registers, you will need to use a feedback node.

I have NO experience using simulation loops, I'm just trying to help out. Smiley Wink

See the attached example to see what I am talking about.

Message Edited by Cory K on 08-12-2009 08:21 PM
Cory K
0 Kudos
Message 2 of 6
(4,006 Views)

Your VI works for indicators. Howveer, in my situation I need to increment a control. I want users to be able to increment the "Index" control manually and everytime the "OK Button" is clicked.

 

Thanks

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

Oh, then you may either use a local variable or a property node.

I was just trying to avoid using locals, but in this case, you could probably use them.

Cory K
0 Kudos
Message 4 of 6
(3,984 Views)

If I use a local variable outside the case structure, it continuously keeps updating the numeric control and I cannot manually increment or decrement it anymore. If I place the local variable inside the case structure, then it automatically increments the control whenever the VI is started or when the Stop button is clicked.

 

I think there's a bug in the Simulation module: it always executes the case structure when a local variable of a control is inside.

 

Ideally I want my Simulation Loop based program to behave like the VI attached and pictured below.

 Incrementing Control via Button in While Loop.gif

 

 

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

I'm a little late on this, but better late than never.

 

Short story:

 

Put your case structure in a regular subVI. You might also want to change the "SubVI Node Setup" to execute only on continuous steps (without including minor time steps).

 

OR

 

Replace the case structure with a Select node. Wire the incremented index value in the true case and the old index value in the false case.

 

Long story: It's not a bug so much as quirky behavior of a Simulation loop that should probably be documented better for power users. The complexity of what is actually happening when you run a Simulation loop is hidden from the user. I believe that each diagram of a case structure must be executed on the first and last steps so that simulation blocks get properly initialized and finalized. This works fine for native simulation blocks, but causes problems when you start introducing persistent "states" that the Simulation is unaware of (your global).

 

Hope this helps!

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