LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Barcode scanner string doesnt update

Hello everyone, 

I am trying to make a code that uses a barcode scanner that reads in a string. I then want to compare that string to another string. However my problem is is that when the string is read in, labview for some reason doesnt register or read in that change. What I mean is that my case structure will always return true, even though I used the barcode scanner to read in code.  Any help would be appreciated.

0 Kudos
Message 1 of 9
(3,040 Views)

If you simply scan a barcode into a String control, focus is still on that string control. As far as the code is concerned, you are still in the process of changing the value.

Configure your barcode scanner to add a TAB character to the end of the barcode.  This will trigger a "Value Change" event for the string control.

 

Also remember than string comparisons are case sensitive.  If you still don't get a match, check for leading/trailing spaces.

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

Is it possible to fix this without changing the barcode scanner, I just want to use Labview? 

Thanks

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

I'm confused.  Where/how are you reading the BarCode?  When I did this, I programmed a VISA Serial Device (COM4, into which the BarCode Reader was plugged).  In the VISA Open, I specified the Serial parameters, especially the Termination Character.  I then had a loop that ran every 100 msec -- if there was data at the Serial Port, it read it and then passed it into a State Machine that said "Oh, a new value from the Bar Code Reader, let's process this ...".

 

I'm not sure where you are reading the BarCode, but it seems to be before the code snippet you attached takes place.  I'm not sure what this is supposed to be doing.

 

Bob Schor

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

I don't have any code for the barcode scanner. The Barcode scanner will automatically scan in the string and display it onto the screen, it doesn't require any drivers It will automatically displays on the screen where the User clicks. I made Key focus true so the barcode scanner will automatically display on the string control as soon as the user scans it in. The problem is that, the local variable I made of that string doesnt recognize the change.

0 Kudos
Message 5 of 9
(3,015 Views)

@Rayzab wrote:

I don't have any code for the barcode scanner. The Barcode scanner will automatically scan in the string and display it onto the screen, it doesn't require any drivers It will automatically displays on the screen where the User clicks. I made Key focus true so the barcode scanner will automatically display on the string control as soon as the user scans it in. The problem is that, the local variable I made of that string doesnt recognize the change.


That's weird -- how does it know where to put it?  Never mind, I'll accept that somehow this works.  Here is a Good Rule for LabVIEW Beginners -- Never Use a Local Variable, they are Evil!  Note that this Rule is not True, but especially when you are starting out, obeying this Rule will work in your favor more often than not.

 

Let's assume the Bar Code Reader is magically able to put its value into a Keyboard Control called "Bar Code".  What happens when it does this?  Why, the value of Bar Code changes (provided the Reader knows about termination characters and that sort of thing).  This means that you should be able to Fire a Value Change Event when the Control "Bar Code" changes.  Do you know about Event Structures/Loops and Value Change Events?

 

Bob Schor

0 Kudos
Message 6 of 9
(2,998 Views)

Most USB barcode scanners have their drivers automatically installed by Windows upon connection.  They simply function as a keyboard input.  Virtually all scanner manufacturers set them up with configuration options.  this is most commonly done by scanning barcodes which they themselves provide in the manual.  Google search your barcode scanner model for the manual.

0 Kudos
Message 7 of 9
(2,991 Views)

I have used both types of bar code scanners and the ones that act like wedge just act like a keyboard.

 

Try changing the string control to "update while typing".

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 9
(2,986 Views)

By default a string control doesn't send a value change event until it's "done", usually meaning that you click on a different control.

 

Try right-clicking on the control and toggling "Update Value while typing" on (it will probably be the 4th option from the bottom of the right-click menu or so).  Depending on the timing of your bar code scanner you might get a bunch of events all in a row that add one character each or one event that types in all the characters at one time.

0 Kudos
Message 9 of 9
(2,979 Views)