07-17-2021 01:30 PM
Hello, I have a lot of random values and I want to specify a value with the push of a button. I used the case structure for this. But the value is only saved in the case and I cannot use the value outside of the case. How can I save the value?
Thank You
07-17-2021 02:48 PM
@Pantheraxxx wrote:
But the value is only saved in the case and I cannot use the value outside of the case. How can I save the value?
You just pass the value out of the case structure. If you had a loop, I would say to use a Shift Register so you can reuse that value on the next iteration. But with your small set of code, I'm not sure what you are trying to do.
07-17-2021 02:54 PM
This is an little example from my Real Program. My job is to save one value from many different values with one button.
Can you show me how can i use the shift register for this programm? I dont understand it
thank you
07-17-2021 10:20 PM
@Pantheraxxx wrote:
This is an little example from my Real Program. My job is to save one value from many different values with one button.
Can you show me how can i use the shift register for this programm? I dont understand it
thank you
I'm new myself but here are the resources I saved for shift registers.
here's some info on shift registers
https://www.ni.com/getting-started/labview-basics/shift-registers
and here is a decent (Though basic) video on them
https://www.youtube.com/watch?v=wkjcHispZNY
You'll also need to look up event structures, and auto indexing for loops (at least in my experience). I'm sure the others on here have more elegant solutions but that will get the job done. Experimenting with the different mechanical actions on the buttons won't hurt either.
07-18-2021 12:32 PM
Your question is not clear and your VI does not even have a toplevel loop.
You are using terms that are very ambiguous ("lots", "specify", "save", "push" (you have a switch with switch mechanical action, not a push button!))
You currently only generate exactly one random number, not "a lot".
Do you want to retain the last random numbers from separate runs, one for each boolean state? Do you want to maintain two evergrowing arrays of numbers?
If your real problem is to deal with lots of random values, then please attach a VI that simulates that. (And please don't maximize the front panel and diagram windows. It is extremely annoying to stare at a mostly white (or gray monitor) without the ability to look at other things, e.g. the help windows, which you definitely need!)
It is often easier to tell is what you want to do, not how you want to do it. My gut feeling is that you are currently barking up the wrong tree. How is the code used? What is the purpose? How does the user interact with the running program (And No, "run continuously" is not the way!). What should the user see in response to his actions? What should happen without user interaction? What is the loop rate?
07-18-2021 12:52 PM
@Pantheraxxx wrote:
Can you show me how can i use the shift register for this programm? I dont understand it
To use a shift register, you need a toplevel loop to anchor it. I typically prefer a feedback node, depending on the rest of the program architecture.
See this quick draft for some idea. (and no, to pick between two inputs, you don't need a case structure. A select keep all code in view for easier maintenance.).
You need to decide how to initialize the feedback node, i.e. define what the value should be until the button is pressed for the first time. (NaN? Zero? First random value?, etc.)
07-18-2021 01:35 PM
@altenbach wrote:
@Pantheraxxx wrote:
Can you show me how can i use the shift register for this programm? I dont understand it
To use a shift register, you need a toplevel loop to anchor it. I typically prefer a feedback node, depending on the rest of the program architecture.
See this quick draft for some idea. (and no, to pick between two inputs, you don't need a case structure. A select keep all code in view for easier maintenance.).
You need to decide how to initialize the feedback node, i.e. define what the value should be until the button is pressed for the first time. (NaN? Zero? First random value?, etc.)
That is absolutely beautiful code. Is it possible to put that in the "Example Code" section? It took me over an hour to solve this problem with my attached greenhorn code. I'm all about making the beginner materials better (especially since I practically live there these days). I'm willing to do legwork to make that happen.
07-18-2021 01:52 PM - edited 07-18-2021 01:53 PM
Some comments on your code:
07-18-2021 02:42 PM
Thank you altenbach!
I'll be working through all those sugestions pointers things I need to learn, and studying your code. That's what I call paydirt. I'll make sure to pass on what I learn.