LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Events & Booleans

I have a problem with booleans. I am using an event structure within a while loop. This while loop has image acquistion going on. The event structure has two events which are triggered by value changed event using boolean controls. The first of the events gets executed fine when I use the boolean. but after the first is done the second event does not recognize the change in the value of the boolean. If I stop the program and directly press the button for the second event then the event runs. I would like to know what is causing this problem
0 Kudos
Message 1 of 10
(3,348 Views)
would you mind post your code here?

Joe
0 Kudos
Message 2 of 10
(3,348 Views)
Here is my code. the events I am talking about are learning and tracking. The learning button works fine and does what I want but if I press tracking button after learning it does not work and then if i stop the vi and run it and press tracking it works.

can u please identify the problem. I am new to event structures and might me making some mistakes there.

thanks
Hema
0 Kudos
Message 3 of 10
(3,348 Views)
Since the subvis are not available, I could not run it. But the problem I spotted is in the tracking event, which has a endless while loop (False was wired to the Exit condition, but the condition is set to "Stop if True", since it never becomes true, this loops never exits). This is probably why all other events didn't occur after clicking the track boolean.

One suggestion, if you do not need to re-initialize the iamge acqusition device every time, then move it outside the while loop. Initializing hardware always takes some time.

Joe
0 Kudos
Message 4 of 10
(3,348 Views)
Thanks for ur reply. The reason I wired the stop to a constant is because if I put a control on the front panel it doesnt seem to work. and secondly it is the tracking event that does not work after the learning event runs. If I run the vi and immediately start the tracking event it works alright.

Hema
0 Kudos
Message 5 of 10
(3,348 Views)
Ok, the problem is with the "Tracking" latch function, it is set as "Latch when Pressed". Try to change it to "Latch when Released". If you need to use "Latch when pressed", then wired the "New value" in the event to to the while loop instead of the "Tracking" control itself.

Joe
0 Kudos
Message 6 of 10
(3,348 Views)
I tried to do what u said but that doesnt work either. No matter what mechanical action I try it doesnt work. But the moment I stop the vi and rerun and then press the tracking button it runs. Does that mean that the start of this event is being prevented by something other event. But the only other events are the learning and the stop events. And I do not see either of them running when I press the execution highlighting

Hema
0 Kudos
Message 7 of 10
(3,348 Views)
Check the following image, notice the "new value" at the left border of the event case is wired to the while loop. It works on my machine. When the "Tracking" control wired to the while loop, I exprienced the same problem you had, but with the new method, it wored flawlessly. I even changed the boolean constant to a control just to test the "learning", "tracking", "stop tracking" events many times.


Joe
0 Kudos
Message 8 of 10
(3,348 Views)
I think you might have a problem in one of the subVIs in the Learning event. Since you didn't attach the subVIs, I deleted them from the main program and ran it. It did the learning event and then went to the tracking event when I clicked that button. Is there a while loop in one of the subVIs that isn't exitting? At some point you're also going to have to fix the while loop in the tracking event as well. The way you've got it, there's no way to stop the program except with the abort button and that's usually not a good idea.
0 Kudos
Message 9 of 10
(3,348 Views)
Thank you for the replies. I did check what Joe said and for some reason it still does not work with the sub vis. Also there are no while loops in the subvi's in the learning event. So what I did was I deleted the subvis and checked again. What I find is that the learning button once pressed remains true even after the code inside is executed.How can I set the learning button to false automatically. From what I understand about event structures if the learning button value remains true no other event can be executed right.
0 Kudos
Message 10 of 10
(3,348 Views)