LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Barcode Scanner

Hello,

I am trying to make a program which will read data from a 1-D Barcode through a Zebra/Symbol/Motorola handheld scanner.I want to save the data from the Barcode in my SQL database as "SAP Code" to identify the lot ,a data/time for sorting and it's unique id.The scanner was programmed through the "123Scan" software,it can collect data from the code,and it's linked to the PC through a Serial COM port.But I don't know from where to start,on how to acquire the data from the scanner ,save it as a string in my database,I've tried using VISA but it's documentation on what I want to do with it is scarce.

 

This code must be running 24/7 as the factory's working shifts include nights shifts as well.Right now I only need to know from where to start from because I can't seem to make a VISA variable work like I want it to.

 

Felix

 

 

0 Kudos
Message 1 of 20
(5,885 Views)

@Lopimank wrote:

,on how to acquire the data from the scanner


VISA is definitely the way to go. You'll probably better study some of the examples. Most of what you'd want to know should be in the manual of the scanner though.

 

Make sure you've got the serial settings right. If you can set them, set them to 9600, no parity, 1 stop bits, no flow control. If you can't find out what the settings should be. If you get it wrong, you'll get either garbage, or nothing.

 

You'll need to find out if the device sends things on it's own, or that you need to send something first. My guess would be that it sends something every time a scan is made.

 


@Lopimank wrote:

save it as a string in my database,


This is something completely different, and unrelated.

 

What database? MySQL, SQLServer, Access, Postgres? You can even make an ODBC connection to a text file database...

 

Sometimes even files on disk are called 'database' (by customers), so it's really hard to give solid advice on this.

0 Kudos
Message 2 of 20
(5,867 Views)

I have a database made in "MySQL Workbench" ,i have made an UDL link to the database ,tested it's connectivity and save capabilities,but now I want to use the scanner to read a 1-D Code,the scanner manual doesn't have all the data I need ,but it works mostly on how I want it to,but I want the VI to run indefinitely.For example I want to send to my database the barcode that was scanned and the time of the scan,only other thing I need to do is to do in my SQL database to allocate that barcode from this table to the last 48/60/63(depending on the size of the lot) products from another table.But I don't know on how to make the vi send data only once when the scan was done.Like what can I use as a trigger for the visa and make a while loop or something else run only once save the data from the barcode and save the current time as well.

0 Kudos
Message 3 of 20
(5,861 Views)

Running a VI parallel to the rest can be done by simply putting the VI next to the rest of the code (or by dynamically starting it, as most would suggest).

 

The next problem is how to communicate between the loops. There so much options here. Queues, User Events, FGV, DVRs, Notifiers… And those are just the obvious ones.

 

Sounds to me you want to look a bit into code architecture. (Queued) State Machines, Producer\Consumer, Actor Framework, maybe even Object Oriented Programming, although not really an architecture.

0 Kudos
Message 4 of 20
(5,850 Views)

Barcode scanners that I have used are USB powered and they are essentially a keyboard.  If your cursor is in a text field when a scan is initiated, the scanner will type out the contents of the barcode into the text field, which can be monitored for a value change and actions performed.

 

In your case with a serial scanner, the scanned data is stored in the device and you have to poll the device.  If you are scanning once, maybe you put a button on the screen to start polling the device repeatedly (in a loop) for an allotted amount of time.  If no scan is detected, go back into wait mode looking for another button press.  If a scan is detected, write the data to SQL database and then go back into wait mode.  As Weibe says, a good architecture will make this easy for you.  I would suggest a state machine since by my understanding of your problem, there are well-defined states that need to be executed (idle, poll device, write, etc).

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

When one of these bar code scanners is set to read and responds as a keyboard, the programming guides for these bar code scanners can be set to add a character like a tab or line feed.  This can allow you to read the scanner contents and move to the next field in an automated fashion.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 6 of 20
(5,816 Views)

@Lopimank wrote:

and it's linked to the PC through a Serial COM port.But I don't know from where to start,


Not a keyboard encoding barcode scanner...

0 Kudos
Message 7 of 20
(5,812 Views)

 


wiebe@CARYA wrote:

@Lopimank wrote:

and it's linked to the PC through a Serial COM port.But I don't know from where to start,


Not a keyboard encoding barcode scanner...


If you open notepad or some other data entry program and scan a code, it can read and save as text just like a keyboard.  I am using the SYMBOL handheld unit in that fashion.

Bar Code Scanner.png

 

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
Message 8 of 20
(5,806 Views)

If you still need a simple test program in LV, search the Example Finder for serial and choose Continuous Serial Write and Read.vi

 

Here you can configure the serial port parameters and display all the characters coming in the port.  Just set the Read Count to 1.  All codes scanned should display in the Response window on separate lines if the scanner sends a CR/LF.

Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.0, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
Message 9 of 20
(5,793 Views)

Sorry for not answering but I have been able to figure it out with all of you guys' help.

 

But now I have another problem,I have a case structure with multiple variables.

In the first while loop I read a DMC code with a unique identifier,this part works and the data is sent to the next while loop,in the second while loop I have different types of production problems like scratched battery,poles too high,too low,oxidized,with holes,mass too big or small,and want to see if I read any of the codes from the case structure to send that problem,then in the next while loop to see which shift was working when the problem occured.In the next while loop there's a "Confirmation"("confirmare" in my case) which will save data in the SQL Database,and a reject("refuz" in my case)which will make the VI rerun from the begining(this while loop isn't finished yet).

 

I want the string from the bar code scanner to be sent to be verified then send the string of the barcode to the next while loop,but the local variable I am using is sending data with a /r or enter key and is never entering any of the other frames from the case structure,just the "False",default frame,from which I want to redo the scanning until it is succesful.

 

If you have any idea how to use the case structures and the local variables in a more efficient way,or any other way for me to change the VI to work like I want it to.

 

PS If you need any kind of clarification on what any part of the VI does ask me.

0 Kudos
Message 10 of 20
(5,736 Views)