From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bar Code Scanner information not displaying automatically

Solved!
Go to solution

Hello All:

 

I have an issue with a bar code scanner, specifically Unitech AS-10U.

 

Now my problem is this, I'm trying to create a sub.vi that takes the input from a bar code scanner as if its input from the keyboard, verify that the information is the right length and move on to the next step in the sequence. When I use "Bar Code Scanner.vi" (see attached vi) as a standalone vi it works fine no problem, however when I embed this sub.vi into my main.vi it stops working (even if I paste the entire contents of the sub.vi into the main.vi). I have found that using the "Highlight Execution" button in the block diagram and probing the input string magically makes it show up, however without doing this the input string remains blank (this works in all cases).

 

So I tried hitting the forums and I came accross "Prompt User for Input" and it worked beautifully, only down side was that now I have to click the okay button to get it to accept the Serial Number I'm trying to input, so I modified it to measure the length of the string and use that as the acceptence criteria for terminating the while loop (see attached vi). Then bam same problem, now it wont work unless I probe it.

 

Can someone help me and tell me what I'm doing wrong, I've tried looking on the forums and havent been able to find someone who had the same issue I did.

 

Thanks for taking the time to read my post, I appreciate it.

Download All
0 Kudos
Message 1 of 9
(3,350 Views)

remove your "reinit to default, they are useless. it should fix your problem.

0 Kudos
Message 2 of 9
(3,322 Views)

Thanks 1abvi3w for the reply I tried what you suggested and it didn't work.

 

I still have the same problem unless I move away from the front panel by either going into the block diagram or probing something nothing shows up, and if I have my probes set up before I click run, then the outputs show up as blank until I move away from the front panel.

0 Kudos
Message 3 of 9
(3,244 Views)

Throggdor,

 

Can you give us more information about how you are calling the sub vi Barcode Scanner? For example, do you have the sub vi in a loop? 

 

Also, did you remove all instances of "reint to default"? 

0 Kudos
Message 4 of 9
(3,222 Views)

I'll add that you don't need those flat sequence structures so remove the entire thing. You also do not need the While Loop, either. Get rid of it.

0 Kudos
Message 5 of 9
(3,214 Views)
Solution
Accepted by Throggdor

Capture.PNG

That will solve most of the trouble,  Then STOP Polling! use a Value Change Event and exit if the string length is 6-9 characters long. (Disable wrapping too).


"Should be" isn't "Is" -Jay
Message 6 of 9
(3,196 Views)

Thanks everyone for your help, I made the changes suggested by Jeff, and it works beautifully now. Thanks a bunch.

0 Kudos
Message 7 of 9
(3,150 Views)

@Throggdor wrote:

Thanks everyone for your help, I made the changes suggested by Jeff, and it works beautifully now. Thanks a bunch.


Happy to have been of help.

 

For completness for others.  Most bar code scanners read the code and add a "Return" to the end.  just as if someone typed the data from the bar code and hit return.  The "Return" triggers a value update(AKA Value Changed) IF the "limit to single line flag" is set on a string controlSmiley Very Happy

 

By taking advantage of the Value Change Event triggered by the scanner's added "Return" a lot of CPU usage can be freed up from the code and, it works with much less effort on the LabVIEW Coder's part.

 

Some of those "Unique" string control properties, like "Limit to single Line" and "Update value while typing" are fairly intuitive in English-  I don't know about other languages- HOWEVER, you have to know they exist to use them!  

 

Kudos to anyone that finds a shipping example that showcases String Control Behaviors.


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 9
(3,117 Views)

On top of Jeff's response, getting rid of the sequence structures and the While Loop will help your code too and not confuse the next person that comes along & has to "read your code."

0 Kudos
Message 9 of 9
(3,090 Views)