Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Vision builder does not responding after calling a "VI" that contains a while loop

Solved!
Go to solution

Vision builder stop responding/hangs after calling a "vi" that contains a while loop and a event structure inside. The event structure has a timeout of 130ms and an event handler of "Value change" which is connected from an string control, what i'm trying to do is to prevent that the user can introduce a password with the keyboard. He can only scan the password via a usb scanner. The VI runs properly if I run it inside the Labview environment, but when I try to call it from Vision Builder, it hangs and does not respond to anything. Some advise to solve this issue?. Thanks in advance!

 

 

0 Kudos
Message 1 of 11
(3,486 Views)

Is it possible to share the code here?

 

Also, does the front panel of the VI come up when you run it from Vision Builder?

 

I bet that it has something to do with that event structure, either not timing out and potentially not being supported being called from the Vision Builder environment.

C. Weeks
Product Support Engineer
NI
0 Kudos
Message 2 of 11
(3,410 Views)

Hi, cweeks12,

 

in fact, i found the code here in the forum:

https://forums.ni.com/t5/LabVIEW/Disable-Keyboard-Input-Allow-USB-Barcode-Scanner-Input/td-p/2145330...

 

What i'm trying to do is that the user can only introduce the password using the scanner and not the keyboard.

 

By the way, I'm new in VIsion Builder, and have some little experience with Labview..

 

Thanks.

 

Jose M.

 

 

 

0 Kudos
Message 3 of 11
(3,394 Views)

I would be interested to see if any errors come up when running it from VBAI. Can you display the error if there is one coming off of the property node, potentially with a Simple Error Handler VI?

 

Also, do you see the front panel when this step runs? Or does it not appear?

C. Weeks
Product Support Engineer
NI
0 Kudos
Message 4 of 11
(3,368 Views)

The way Vision Builder AI runs VIs expects the VI always return, so instead of putting your code in a while loop, I made a sample VI to illustrate how you might accomplish the same thing in VBAI by using the transitions of VBAI state diagram to loop on the VI instead of a While Loop inside the VI. I would also recommend you use the User Input step in VBAI for this type of application, so I included a sample of how to do this in the inspection as well. Just press the Run Once button in VBAI at the top after loading the attached inspection and notice it doesn't let you continue with inspection states until you enter a valid password. You can obviously change this behavior, but I thought this would illustrate something useful for you.

 

Hope this helps,

Brad

0 Kudos
Message 5 of 11
(3,359 Views)

I attached a video showing the behavior of VBAI when I try ti run the VI that contains the while loop. As you can see, when I press the Test button VBAI stop responding, even I cannot see the textbox to introduce the password, I mean I cannot see the front panel, see the image of the front panel below.

front-panel.PNG

 

Please see the video below:

0 Kudos
Message 6 of 11
(3,348 Views)

Hi, Brad,

 

Thanks very much for your suggestion and for your sample.

 

I will try it later, so now I'm a little busy and let you know the results, but I think it is going to work for what I need. Thanks again.

 

Jose

0 Kudos
Message 7 of 11
(3,343 Views)

As I mentioned in my previous post, you shouldn't have VBAI call a VI that doesn't return. Try my example and see if that helps. If you really wanted your example to work, you'd need to add an invoke node to show the front panel when the VI is called (see my example VI attached in the previous post for how to accomplish this). I think you will want to use the User Input step in VBAI though as my previous post illustrates.

 

Hope this helps,

Brad

0 Kudos
Message 8 of 11
(3,341 Views)

Hi, Brad,

 

Your sample is working well, also the User Input step works fine. But what I want to accomplish is that the user cannot use the keyboard to introduce the password, instead he should use an usb scanner. Do not know if I explain well what I'm trying to do. Now I understand what you said about that calling a VI from VBAI that contains the While Loop. 

 

Thanks and regards,

Joemen.

 

0 Kudos
Message 9 of 11
(3,327 Views)
Solution
Accepted by topic author JOEMEN

Just replace my example's simple string control with VIs to read a string from a scanner so you can compare that string against expected values. Just make sure you aren't calling it in a loop that may never end.

0 Kudos
Message 10 of 11
(3,318 Views)