LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Iteration in a For Loop using a button

Hi,

 

I'm new to LabView so my question is a quite simple one.

I would like to build a program with a For Loop.

For each iteration, this program would create a couple of values (one set by the user and one random). The values are then stored in a file.

I would like the iteration to be conditionned by pressing a button and I clearly do not know how to do that.

I've tried things (like the enclosed VI) but I think I miss something here.

Thanks a lot!

 

0 Kudos
Message 1 of 14
(1,739 Views)

I can't open your vi (not yet running LabVIEW 2021) but it sounds like you've limited yourself by specifying a FOR loop. It sounds to me like your application is more of a state machine.

Message 2 of 14
(1,709 Views)

Thanks a lot, now I know where to look for!

i've still got some issues, but now it's just some debug.

 

0 Kudos
Message 3 of 14
(1,701 Views)

It seems I do not manage to debug the thing.

I've put the VI in a PDF.

As said previously, I would like the VI to retrieve some couples of numbers (called "Value to set" and "Random Value") every time I hit a button (here "Next value").

In this VI, the goal is to display the data on the front panel (I'd like to save the data in a file but that will be the second step of many others to come :-)).

 

Thansk again!

0 Kudos
Message 4 of 14
(1,690 Views)

try an event structure in a loop, you might like it : )

 

... see attached vi

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 5 of 14
(1,688 Views)

Yes, I've finally managed to do what I wanted to do, thanks!

0 Kudos
Message 6 of 14
(1,678 Views)

@Jay14159265 wrote:

try an event structure in a loop, you might like it : )

 

... see attached vi


Careful there! The terminals of latch action buttons belong inside their respective value change event case. If they are on the toplevel diagram (like you did!), they will never reset to false automatically when clicked.

0 Kudos
Message 7 of 14
(1,666 Views)

@altenbach wrote:

@Jay14159265 wrote:

try an event structure in a loop, you might like it : )

 

... see attached vi


Careful there! The terminals of latch action buttons belong inside their respective value change event case. If they are on the toplevel diagram (like you did!), they will never reset to false automatically when clicked.


Who said anything about reading and resetting boolean values? If you don't care about the value of the latching boolean you can stick it anywhere you want. But just in case the OP has no idea what we are talking about, Since altenbach is technically correct (the best kind or correct) this is how you should program latching booleans in event cases. 

snip.png

 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 8 of 14
(1,654 Views)

@Jay14159265 wrote:

@altenbach wrote:

@Jay14159265 wrote:

try an event structure in a loop, you might like it : )

 

... see attached vi


Careful there! The terminals of latch action buttons belong inside their respective value change event case. If they are on the toplevel diagram (like you did!), they will never reset to false automatically when clicked.


Who said anything about reading and resetting boolean values? If you don't care about the value of the latching boolean you can stick it anywhere you want. But just in case the OP has no idea what we are talking about, Since altenbach is technically correct (the best kind or correct) this is how you should program latching booleans in event cases. 

snip.png

 


Well, you cannot stick them outside the loop, so it's not ANYwhere.  😉 Besides, a better experience awaits the user if you stick it inside its respective event case because then it doesn't have to wait until the next loop iteration to "unpress" again.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 14
(1,640 Views)

@billko wrote:
Well, you cannot stick them outside the loop, so it's not ANYwhere.  😉 

They were (and one still is) outside the main loop. The only limitation is that you cannot stick them outside the diagram 😄

 

Sometimes I put the terminals in a place where they only reset once the triggered operation has completed, giving a cheap user feedback that that has not happened yet. But that's the exception)

0 Kudos
Message 10 of 14
(1,628 Views)