06-10-2022 02:45 AM
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!
06-10-2022 07:23 AM
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.
06-10-2022 08:17 AM
Thanks a lot, now I know where to look for!
i've still got some issues, but now it's just some debug.
06-10-2022 10:12 AM
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!
06-10-2022 10:17 AM
try an event structure in a loop, you might like it : )
... see attached vi
06-10-2022 10:55 AM
Yes, I've finally managed to do what I wanted to do, thanks!
06-10-2022 11:51 AM
@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.
06-10-2022 01:26 PM
@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.
06-10-2022 02:12 PM
@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.
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.
06-10-2022 02:49 PM
@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)