03-01-2016 09:01 AM
Hello,
I think, notifier is quite suitable for your problem. Just you shuld add timeout to '' wait on notification''.
03-01-2016 10:36 AM
@Blokk wrote:You want first a setup case, and after perform different number of steps, based on the setup parameters.
A perfect place for a state machine (only a single while loop required usually). You need an Idle state when you wait for the user inputs. After the user starts the initialize state, which will calculate the required number of steps for the other states. At the end the system automatically moves back to the Idle state, and waits for the user to setup and launch another run.
No need for Flat sequence structure at all. With a state machine you can just do much more (like aborting sequence in midway, not possible with sequence structures)
Thanks.
Indeed the state machine is the best concept for my setup.
Finally I've got what I wanted.
The only shortcoming - the while loop stops on "grater" condition whereas operator I used is "equal or greater".
Thanks to all participants. I accept all your notes/suggestions/precepts and will try do my best.
03-01-2016 01:03 PM - edited 03-01-2016 01:22 PM
Do not let the initial difficulties of LabVIEW learning take away your eagerness to go on. You will see as you learn more and more on the way, the fun factor will just increase in LV programming. Believe me, this was just the same for me too.
About the comparison problem: what you see is not a LV behaviour. It is the behaviour of a computer 🙂
You cannot just compare double floating values this way. You need to do some tricks:
http://digital.ni.com/public.nsf/allkb/B01682241DD825948625665100663F61
I made some modifications on your VI, and also added a Stop button to stop the VI properly (do not use the red Abort button to stop a VI, it is not a good practice for several reasons!).
The inner "Wait until next ms mul." is not needed either, you have already a Wait function in the outer while loop. I understand probably why you put the timing also the inner loop, since you set up the State Machine in a bit wrong way. I also fixed this logic for the transitions between the states. Of course, this is only one possible solution what I show here...
Mechanical action of your buttons: use the latch behaviour, not the switch one here!
Also, when you wanna post a VI in the future, I recommend to use a snippet ( http://www.ni.com/tutorial/9330/en/ ) , so you make easier to others to help (a simple screenshot is not really useful!).
EDIT: obviously, the value below the Precision num control should be 10 🙂 I fixed the snippet.
03-01-2016 02:18 PM
One more note to this rather simple example I put together. You could just go from the "running" state to the "Idle" state if the Reset button is not pressed (since then the "previous x value" will be exactly the same as the initial x value). I only wanted to show you with this setup that the Comparison function works with that little trick.
03-02-2016 05:13 AM
Useful and elegant complement
Thanks !