LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan barecode and read the value without enter

I have a string control where i scan a barecode.After i scan the code i want the value to be read (without pressing any key) and to be empty in order to scan another barecode as soon as possible.

 

Thank you,

BV.

 

 

0 Kudos
Message 1 of 9
(5,826 Views)

If you right click the string control you will see an option to "Limit to Single Line"

 

Check it.  The Return the scanner adds at the end of read then just triggers the value change event.


"Should be" isn't "Is" -Jay
Message 2 of 9
(5,802 Views)

Right-click the string control and enable "Update while typing" then use a Value change event to read the string until your bar code is verified and complete. Then clear the string.

 

Lather rinse repeat.

 

Ben

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

@Ben wrote:

Right-click the string control and enable "Update while typing" then use a Value change event to read the string until your bar code is verified and complete. Then clear the string.

 

Lather rinse repeat.

 

Ben


Don't do that, you get a VC event for each char not for each scan


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 9
(5,797 Views)

@JÞB wrote:

@Ben wrote:

Right-click the string control and enable "Update while typing" then use a Value change event to read the string until your bar code is verified and complete. Then clear the string.

 

Lather rinse repeat.

 

Ben


Don't do that, you get a VC event for each char not for each scan


Look at what I posted again please.

 

Ben

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

How do you know that you've finished entering the barcode? Usually a barcode scanner is configured to act like a keyboard. LabVIEW doesn't know the difference between a barcode scan, and someone typing into the string control. Most scanners optionally allow you to append a character (such as enter or tab) after each successful read, so that you know the scan is complete.

 

You probably want to use an Event structure, but how you use it depends on exactly how you want your application to work. If you're looking for a fixed number of characters rather than an end-of-scan character, you could set the string control to "Update value while typing" and then catch Value Change events for the string control until you reach the desired number of characters. Another approach is time-based - a barcode scanner acting like a keyboard enters characters very quickly, so if some small amount of time passes without a Key Down event, then the scan is probably complete and you can read the value, then clear the control.

 

Another option, which I once used, is to skip the string control entirely, and catch Key Down events on the entire front panel. In my case, the barcode scanner was the only input to the application, and the scanner was used for other purposes on the same machine so I couldn't change its configuration. Each time the front panel received a key down event I'd add that character to a string (stored in a shift register) and validate that the value of the accumulated string was at least the beginning of a valid barcode. If it was an entire valid barcode I processed it and cleared the shift register. If some amount of time passed without a key down event, then I also cleared the shift register.

 

Finally, many barcode scanners can be configured as a serial port instead of a keyboard, and that's often a more reliable approach in LabVIEW since it doesn't rely on the user clicking on the string control first to give it focus, and there's no chance of the user entering values from the keyboard that would mess up a barcode read.

 

That's probably a longer answer than you wanted, but there are a lot of options. If you describe exactly what you want your application to do and which barcode scanner you're using, it will be easier to give you specific advice.

Message 6 of 9
(5,791 Views)

OK, and the return from the scanner is ignored how?, or do you capture the \r in the VC Event case or some other event?

 

I missed something there (I think)

 

along these lines:

Example_VI.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 9
(5,789 Views)

@JÞB wrote:

OK, and the return from the scanner is ignored how?, or do you capture the \r in the VC Event case or some other event?

 

I missed something there (I think)


That is a " depends" question.

 

Depends on what the bar code scanner is providing, and the nature of the barcode that was read. If the bar code scanner terminates with a new line, then that triggers the end of the code and move on.

 

Ben

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

@nathand wrote:

 LabVIEW doesn't know the difference between a barcode scan, and someone typing into the string control.

 


Mine does but only because I configure the scanner to send a Ctrl+G at the begging of the scan.  The key down filter event looks for a PlatMods.Ctrl and a G and discards them and what follows is the scan itself.  The scan is configured with an Enter keypress at the end of the scan so that the string control is updated and the Value Change event is fired.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 9 of 9
(5,750 Views)