08-08-2011 05:17 PM
Hello everyone
I have a problem with this scenario:
What I want is, that I can enter a series of arrays and then it will choose the first row because the first cycle number is 0, the second is 1 and so on. I want this loop to continue until I've left my arrays empty. The probelm is when I test it, it immediately stops, but when I highlight everything seems to work fine.
This is a program I'm trying to write so it can control some dosing pumps - I put in a number and weight and then it converts it into a set point % which will trigger the pumps. When the countdown is finished then it should start dosing with the next weight and time.
I'm fairly new to labVIEW. I've tried looking everywhere but I haven't found that could help me, I count on you! 😉
Thank you very much
Theis
Solved! Go to Solution.
08-08-2011 05:40 PM
I think this will do what you want.
08-08-2011 05:50 PM
You don't want to be peeling off an element of the array unless the time has actually elapsed. This means you need to stay at the current index until the time has elapsed. Also, the delay needs to be inside the loop. Otherwise it does you no good. This is assuming that you basically just wanted to check once a second.
You can accomplish this with a while loop or a for-loop. Mark posted an example using a for-loop. The thing I don't like about that specific example is that you're sitting inside the for-loop for potentially LOOOONG times with no way out. A better solution is to provide a break-out capability. I don't know where this is being used, but assuming a top-level you can use a front-panel button for that. You just need to loop around and stay at the current setting while the specific time elapses.
Attached is a quick 5-minute draw-up of your VI modified.
08-08-2011 06:08 PM
That will work but you will want to use a constant of 60000 instead of 3600 since the Wait function works with ms. If your dealing with whole numbers for your time, set your array to U16, not double.
08-08-2011 06:20 PM
You are right about the constant. I was thinking seconds per hour for some reason. Mental lapse when whipping up something quick.
08-08-2011 06:22 PM
You could use the OpenG Wait VI which accepts an abort notifer. This would allow you to abort quickly since it handles the looping for you with the period checks. I didn't want to force the OpenG solution since the OP probably doesn't have them installed right now.
08-08-2011 06:31 PM
@Mark Yedinak wrote:
You are right about the constant. I was thinking seconds per hour for some reason. Mental lapse when whipping up something quick.
Yes, I figured that's what you were thinking. But even then, smercurio is correct, I would be concerned about spendind so much time within this loop.
08-08-2011 06:34 PM
@MoReese wrote:
@Mark Yedinak wrote:
You are right about the constant. I was thinking seconds per hour for some reason. Mental lapse when whipping up something quick.
Yes, I figured that's what you were thinking. But even then, smercurio is correct, I would be concerned about spendind so much time within this loop.
I agree. I just think a nice elegent state machine comparing the current time with the desired wait time, a short wait cycle and check for abort was a bit too much at this time for the user.
08-09-2011 03:20 AM - edited 08-09-2011 03:22 AM
Thank you very much all of you! It almost works!
I must say that you guys put a lot of effort into helping me, I'm grateful.
I went with this solution:
I added the "stop 2" button, which starts everything.
I just have a slight problem. When I want to pause I press the stop button again and it pauses. When I start again - by pressing the stop button - it resumes but I can see that it kept counting seconds while it was pause. I guess, that what I want is, that when I pause that it sends a zero signal to the pump which tells it to stop and the same with the timer. And when I start I want it to resume. Ya' follow me? 😉
I hope any of you guys, who have already been so helpful, can help!
Thank you
Theis
08-09-2011 08:12 AM
How are you hoping to pause the application? Your timer is still running. The next iteration of the true case will show this. I don't know that there is a way to pause this Express VI. You may have to use an FGV to store the elapsed time when "pause" is pressed. Then subtract this from time target, then you have the time remaining on your counter, which will be the new time once the operation has resumed. A bit more elaborate, but it should work. Rename your Stop2 as run/pause. Go into the boolean properties for the switch and rename the on state "run", off state "pause."