LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loop Problem

Solved!
Go to solution

No it doesnt work.. the event only can work with the changes from the operator from the front panel not with automatic change. 

 

Otherwise no need to queue if it was working I will put all my work inside an event structure and a case.. 

 

But anyways I tried it and it didn't work.. qany idea about how to initialiase the incrementor of a for loop?

0 Kudos
Message 31 of 37
(2,415 Views)

Have you looked at what I posted?

 

A Loop will always start with i = 0.  If you want another number, then add that number to i and use that.  That answers your last question, but isn't the real solution to your problem.

0 Kudos
Message 32 of 37
(2,405 Views)

Did you check the snippet i added?

-Whenever user changes diResist value, the event will be triggered first.

-Then inside event it'll be checked for whether number is either 16,26 or 36

-If it is true then the enqueue will enqueue message "True"

-In another loop the "True" case will execute.

-If you enter any other number then false case will be executed.

-Attached code in LV2014 version.

Loop_Update.png

Thanks
uday
0 Kudos
Message 33 of 37
(2,396 Views)

UDKA I am not changing the variable of diresist. Diresist change programmatically, so the event loop will not consider these changement.. 

I tried your solution it's not working 🙂

0 Kudos
Message 34 of 37
(2,375 Views)

@ravensfan:  A while loop will always start by 0. a For loop no. 

you can take a VI, create a for loop and see. In the beginning it start with 0. but if you stop and run again it will start from the last number where it stopped and add..  

 

I find a solution to initializate via the invoke node... 

Last question please, if I stop a while loop via some condition.. and then I want to restard again without restarting the whole VI. I mean I just need to restard the queue.. is it possible ? 

 

Because my program will at first measure the cold resistance (the loop will stop after measuring), then run the motor till thermal stability, stop the motor, measure the hot resistance (the loop need to restart) 

 

Ideas  how to restart a loop?

0 Kudos
Message 35 of 37
(2,366 Views)
Solution
Accepted by topic author marwah1

@marwah1 wrote:

@RavensFan:  A while loop will always start by 0. a For loop no. 

you can take a VI, create a for loop and see. In the beginning it start with 0. but if you stop and run again it will start from the last number where it stopped and add..  

NO.  The i value of both loops always start at zero.  Why do you think that is not true?

 

I find a solution to initialize via the invoke node... 

I'd have to see that code.  Maybe it works for you.  But initializing an invoke node means changing the value of a control back to its default.  You were just talking about the i iteration terminal.  Two different things.  If it works, then it is because you are actually talking about something different than what you are describing.

 

Last question please, if I stop a while loop via some condition.. and then I want to restard again without restarting the whole VI. I mean I just need to restard the queue.. is it possible ? 

You are talking about while loops vs. queues vs. whole VI.  I can't picture what you are talking about without seeing the latest code.  You should never need to restart the queue.  Perhaps you send a "restart" command through the queue which can do several things like restart the motor, or clear the array of boolean flags back to all Falses.

 

Because my program will at first measure the cold resistance (the loop will stop after measuring), then run the motor till thermal stability, stop the motor, measure the hot resistance (the loop need to restart) 

 

Ideas  how to restart a loop?

Put another while loop outside of it.

 

The activities you are describing, and especially now that you are talking about more activities than where this thread started which was just looking for 3 conditions, means you really need to architect your code into a state machine.  Search the forums, search the example finder, and look for the state machine template under the New VI.... menu choice.  Once you read up on it.  Then sit down away from the PC and with a pencil and paper and draw a flowchart.  Figure out all the states or conditions in you program.  What activity leads to what.  Under what condition does it move on to the next.  When does it need to go back to a previous state.  Once you have that document, you'll be in a much better position to build your state machine.


 

Message 36 of 37
(2,360 Views)

thanks everybody for your help the program is working perfectly now 

😄 

0 Kudos
Message 37 of 37
(2,352 Views)