02-27-2014 05:08 AM
Hello
I've been trying to use state machine with elapsed time function in order to sequentially start and stop my code. The arrangement is to start the code for 1 minute then stop for 5 minutes. I've attached the code, the problem is when I place the elapsed time function out of the while loop it doesn't work, on the other hand when I place it inside the loop it does work but it doesn't give the true signal to move to the next state.
Could you please have a look to my code and help me to solve this issue.
Regards
Rajab
Solved! Go to Solution.
02-27-2014 06:51 AM
Hi Rajab,
what is the difference between the first 5 states of your StateMachine? They all get some data using DAQAssistent and wait for some amount of time! So why create different states for them? I really start to shiver when I open a frontpanel and get 5 "Stop" buttons presented…
Why don't you call the first state with 5 different wait times?
What's the purpose of this construct?
Did you test the working principle of ElapsedTime in a simple example VI to understand it? After that you can incorporate it in your state machine…
02-27-2014 07:51 AM - edited 02-27-2014 07:53 AM
why all the while loops, wire bends...? how do you reset your elapsed timers? did you not like the example code given in your previous post.....
02-27-2014 11:18 AM
Hi GredW
I didn't think that the wait function will do the job as I want the code to stop and then start again.
I've used the true Boolean just to stop the code when the case wait 5 minutes called.
I did use the elapsed time on the same code and I was able to stop it after 1 minute, but I don't know how to start it again after 5 minutes!!!
By the way I'm still beginner in labview, that's why I'm asking for help !!!
Regards
Rajab
02-27-2014 11:23 AM
Hi apok
Honestly the code was a bit complicated for me, when I run it keep showing wait case only, didn't want to bother you for more explanation. So what I did I tried to simplified it
thanks
Rajab
02-27-2014 11:37 AM
@Rajab84 wrote:
... when I run it keep showing wait case only,
yes it does, because it is waiting for you to press the "start" button to process....just drop your daq express vi into the state cases and change the elapsed timer constants to 60( 1minute) and 300(5minutes)
inorder to use the elapsed timers again and again...you must reset the timer upon execution to start it, that is why we use a shift register to send amd hold boolean values.
02-27-2014 12:16 PM
Thanks apok for your help
even with pressing start it keeps running on wait case
could you please explain the code for me, the use of Boolean crossing, increment , and equal functions
Best Regards
Rajab
02-27-2014 01:22 PM
@Rajab84 wrote:
Thanks apok for your help
even with pressing start it keeps running on wait case
could you please explain the code for me, the use of Boolean crossing, increment , and equal functions
Best Regards
Rajab
OK..I modded the example to stop after 2 cycles. Also recommend taking the free online LabVIEW tutorials.
02-28-2014 12:34 PM
Hi apoke
thanks a lot for explaining, I really appreciate it. I still have a problem. When I run your code alone it works prefect but when I insert my code to the case (min 1) the elapsed time function stops working. Do I need to use my vi as a sub-vi??
I've attached simple example to explain what I mean, just run it and see how the code freezes on case (min 1) and the elapsed time indicator showing 00.
please frogive me for my question, Itried to solve it my self but I couldn't
Regards
Rajab
02-28-2014 01:01 PM
Your 1-minute case structure has a while loop inside of it generating random numbers as fast as it can until you hit the Stop2 button. Until that while loop stops, the other code in the case structure will not execute again until your outer while loop iterates again.
Try running your code with Highlight Execution on so you can understand how dataflow determines your execution order.