LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loop, proceed on click

Hi,

 

I am looking to place a loop condition in my Vi,that proceeds to the next iteration ( repeats inside the loop) again when a boolean clicked, for a set number of loops, any suggestions?

BD looks likes this....

 

Labview.jpg

 

Cheers 

Peter

 

0 Kudos
Message 1 of 18
(3,903 Views)

Your image is very small, so it is hard for me to see what is displayed there, sorry if I have missed to notice something. But, if I see it correct:

1. why are you using a local variable in the same structure instead of simply wiring the value directly?

2. couldn't all that part of mathematics to be replaced by a simple constant? It seems that all those values in the calculation are static, so why do you need to recalculate that in every cycle.

 

If you need to fire the loop when some kind of event occurs (a boolean is pressed), you can use Event Structure for that. The number of iterations can be adjusted by using a control/constant to prescribe such limit (for a "For" loop) or while checking if the number of iterations has reached the desired maximum of iterations and then stopping the execution of the loop structure (for a "While" loop).

Message Edited by Giedrius.S on 02-14-2010 02:38 AM
Message Edited by Giedrius.S on 02-14-2010 02:38 AM
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
0 Kudos
Message 2 of 18
(3,898 Views)

Hi,

 

Cheers for the tip... it now looks somethin glike this... i put n an event structure as below... but i can't conncet a boolean... what parameters does the event structure require?

 

i want to repeat the counter loop (all inside the while loop) , for approx 12 times, by the click of a boolean on a front panel??

 

Labview2.jpg

0 Kudos
Message 3 of 18
(3,890 Views)

You can right-click on the Event Structure and select "Add Event Case...". This code belongs to the event "Boolean is pressed" right? Not the timeout event 🙂 When you will choose the option to add an event, you will see a window that will ask you to select which event should be handled. You will see the list of available controls to be handled. Select desirable control (this time it is boolean) and select the action which should be done with the control to active the event structure (like mouse down, etc., this goes for you to decide).

 

If you don't want to lock your front panel during the execution (this means you won't be able to acces the front panel controls for that time) of your code of the event, uncheck the "Lock front panel..." option at the bottom of the previously mentioned window during the event setup.

 

P.S. One more tip: if you wish to improve the readabilty of your code, try to avoidbackwards wires. I aim this for the "Counter Output" indicator. According to the LV etiquette, wires should dock indicators from the left and they should [un]dock controls/constants from the right.You can see those little white arrows indicating those directions on the icons.

 

And why do you need two Case Structures? You could put your code in the same Case Structure but just move it to the other case.


 

 

Message Edited by Giedrius.S on 02-14-2010 03:01 AM
Message Edited by Giedrius.S on 02-14-2010 03:03 AM
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
0 Kudos
Message 4 of 18
(3,886 Views)

I add in that case, but its still throwing up errors... could you have a look at it please?

 

Cheers

0 Kudos
Message 5 of 18
(3,877 Views)

I won't be able to run your code, because you use some SubVIs that you have not attached and also I lack of DAQ VIs. Sorry. I believe somebody will be able to debug your code in the morning (well, at least in the morning of my location :)).

 

To improve the facilities for that, I suggest you copying the error message (if you get any) to the forum.

---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
0 Kudos
Message 6 of 18
(3,873 Views)

You have an event case 0 with no event associated with it.  It has a while loop inside of it.

 

In general, loops do not belong inside of event structures.  Event structures belong inside of loops.

0 Kudos
Message 7 of 18
(3,867 Views)
i dont know how to wire the terminals for the event structure, or if i even if i have the correct one. I want to repeat the inside loop N number of times, (from front panel), and to advanced to the next iteration on the click of a boolea (front panel)?
0 Kudos
Message 8 of 18
(3,848 Views)

I'm not sure what you mean by "wire terminals for event structure".

 

 

See the attached VI.  Here I modified the while loops and changed the one to a For loop so it will run the N times when you click the button.

0 Kudos
Message 9 of 18
(3,814 Views)

Cheers thats a great help. The application this is for is a panoramic camera head, the number of iterations is the number of pictures to be taken, so it needs to stop after each iteration, and not proceed until the picture is taken, i.e. a boolean is clicked, to the next iteration, and continue until reached the number of iterations? Any ideas? its for a final uni project...

 

Regards

 

Peter

0 Kudos
Message 10 of 18
(3,810 Views)