LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loop Problem

Solved!
Go to solution

 Please use the below snippet and modify code according to your requirements.

Thanks
uday
0 Kudos
Message 21 of 37
(2,373 Views)

Move your lost terminals closer to your actual code.  You have miles of white space making that image much larger than it needs to be.

 

Did you read my message earlier about why your code is running twice with relation to how your stop button is being read in the loop?

 

You are probably queuing up mulitple operations in your queue when the number hits a value rather than just a single time because your producer loop runs infinitely fast.

0 Kudos
Message 22 of 37
(2,372 Views)

Dear Ravens, 

I read your message and the programe is stopping now with the conditions that I added. 

But the problem is that if I run again the problem inside the for loop is going to be equal to the number of value set so he is going to stop and doesnt make the measurement again.. 

I'll join you the program because I used control+U and I couldn't find the terminals 😛

 

0 Kudos
Message 23 of 37
(2,365 Views)

The VI you attached isn't doing anything with the queue.  You never enqueue anything in it.

Your producer loop has nothing in the False case, not even the queue wires.  Which means you are going to lose the reference to your queue as soon as one of those conditions becomes false.

 

When you start your VI, isn't that diresist value going to be something besides 26, 36, or 16?  Be different than it was when you VI last ran?

 

You can keep an array that tracks which values you have been run.  Anytime you get a new value check to see if it exists in the array.  If it doesn't, then queue it up.  If it does, you won't.  If you detect that all 3 values have happened, then you can queue up a stop command to tell the consumer loop to stop when it is done.  When your VI starts, you queue up an empty array to the shift register so that when it restarts, it starts from scratch and will forget that it is still sitting at the last value it was at when it last ran.

0 Kudos
Message 24 of 37
(2,358 Views)

Dear RavensFan,

The starting of the program is working weel. Everytime I am getting 36, 26 or 16, the program is queuing. But as you said, as soon as one of the stopping condition become true the program is not running anymore. (Even if I run from new the whole program)

So how can I initialize my second loop everytime? 

  "When your VI starts, you queue up an empty array to the shift register so that when it restarts, it starts from scratch and will forget that it is still sitting at the last value it was at when it last ran." 

I didnt understand could you please send me the VI or a scrrenshot of what you mean? 

 

What I exactly need is to initialize the " i " of the for loop. It should always start from zero everytime I queue.. any Ideas?

0 Kudos
Message 25 of 37
(2,325 Views)

Did you check with the snippet i provided?

http://forums.ni.com/ni/attachments/ni/170/975665/1/loop_Update_mod.png

Thanks
uday
0 Kudos
Message 26 of 37
(2,311 Views)

the sniipp is 2015 could you please send as a Vi and convert it to 2014?

 

0 Kudos
Message 27 of 37
(2,304 Views)

Only stop once you've detected all 3 of those things have happened.  Only queue up the event when you detect a particular number has occurred, but has not happened before.

 

Attached is a VI for an example how to do this.

0 Kudos
Message 28 of 37
(2,299 Views)

Ravens you didnt really understood the problem I think. So I explain you again

I always need to make measurement everytime I got 26 36 16. Once I detect one of those Value, I enqueue and send commands to my instrument to measure values of resistance. The measurement are done via a for loop as in the VI that you received yesterday. Once we achieve the number of measurement written by the operator the VI should stop. 

 

The VI is now doing all this, but he's not initializing, so for exemple, if I runned already the program with a number of measurement = 3. The program run for the first time. I stop the program then and run again, the program will not run.. why? 

Because in my for loop i=3 which is one of the stopping conditions so he is not enqueuing. The question now is how can I initialize my second loop ? 

 

 

 I don't need to put it in a table or to wait for the 3 values together to stop.. I need to stop once my measurements are achived so the number of i in my for loop is equal to the number written by the operator.. 

0 Kudos
Message 29 of 37
(2,287 Views)
Please check the implementation in the snippet
Thanks
uday
0 Kudos
Message 30 of 37
(2,273 Views)