LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with receiving data from a Zebra Miniscanner in LabVIEW.

Solved!
Go to solution

Hello, I've been banging my head against the wall on a project for some time now. I have been trying to create a serial port reader for a Zebra Mini Scanner completely within LabVIEW. I know what port the barcode scanner is on and the proper settings to receive data from it. It works with third party RS-232 programs, however all my attempts to get it to send information to LabVIEW have ended in failure. I have attached both an image of the settings I have been using to get this to work on third party software as well as a VI containing my attempt to pull the data from serial port. Any help would be greatly appreciated.

Download All
0 Kudos
Message 1 of 17
(2,041 Views)

Just an update on a few things I tried. NI I/O Trace only detects the use of the COM port when I access it via NI MAX. Not when I use Termie or Termite. Attempting to query through NI MAX only leads to a timeout error and attempting to send anything via Termite's terminal just results in a gibberish response. As far as I can tell, the barcode scanner is turned on by an external button press. Physically on the table, not on the computer. Which indicates a green light when it has scanned a barcode. This sends the correct information to Termie or Termite when reading the connected port, but not LabVIEW or NI I/O Trace.

0 Kudos
Message 2 of 17
(2,012 Views)

Yes, as you've found NI I/O Trace only works with NI software unfortunately. There are other serial port monitors out there, but if you're sending data to Termite successfully then it's not a serial port issue.

 

Can you use Save for Previous to an earlier version of LabVIEW? I don't have 2021 installed.

 

Also, the "NI MAX Query" function only works with SCPI instruments. I very much doubt that your scanner is SCPI compatible so I wouldn't even try those commands.

 

It would also be helpful to post some more info about your communication protocol, perhaps from a manual.

 

It sounds right now though that your scanner sends a burst of data when you push the Scan button and it reads something. Hopefully it has a termination character, so you can just set up LabVIEW to use that termchar. Do a VISA Read with a fairly short timeout (0.25 or 0.5 seconds). If nothing came in (i.e., you get a timeout error), clear the error and try to read again. If you get something, then you know the scanner sent something.

 

The only reason not to make your timeout super long is that, once called, VISA Read will block until you timeout, read the requested number of bytes, or receive a termchar. If you set the timeout to 5 minutes and decided to stop listening on that port, you'd have to wait 5 minutes before VISA Read returns.

 

(Note: you may be able to call VISA Close in parallel to "abort" the read. I haven't done that before but it'd be easier to just call Read in a loop.)

0 Kudos
Message 3 of 17
(1,971 Views)

Here is an 8.5 version of the vi. It's a simple wait for the port to have something on it and read VI. While I know the scanner is an MS-954 model I can't find anything in the documentation about a termchar. Only that it uses a 9 pin serial cable and a propriety board to convert it's SSI data to rs232. In the current version of the larger program I have Termite write the data to a log file and have LabVIEW read the log to get the barcode. Unfortunately my client does not want any extra software in the solution.

 

Is there perhaps a way to create a RS232 terminal in LabVIEW? From what I can see it's not a matter of the data not being sent, but LabVIEW being unable to receive it via it's native functions.

0 Kudos
Message 4 of 17
(1,939 Views)

If LabVIEW can't read it you may not have NI VISA installed properly. Anything Termite can do, LabVIEW can do.

 

Let me get this straight though- you open a terminal in Termite, then when you scan a barcode, some data shows up. Right? If so, what you have in LV should work. If you're not getting anything at all then you either have a VISA driver problem or an issue with your code.

 

What exactly does your code do or not do? If it's getting a timeout error, then your While loop is reporting that there ARE more than zero bytes at the port. That means it's getting *something* in the buffer. When you try to read that many bytes, it should return them immediately.

 

BTW, one small issue is that, by default, VISA Open defaults to "True" for Termchar. Try setting that to False. Also, you basically never need to use Bytes at Port.

 

Give this a shot. Run it and click the buttons to scan stuff. It should display something.

 

barcode example.png

0 Kudos
Message 5 of 17
(1,921 Views)

Unfortunately this didn't work for me, I've tried updating the NI VISA driver, then reinstalling it. Neither case has given me anything. No barcode or even gibberish to indicate that LabVIEW is receiving at least some data. I'm still getting clean responses from Termite so I know it's not an issue with the COM port.

Edit: I know that LabVIEW is connecting to the right COM port as it does lock me out of it when I try to connect with other programs at the same time.

0 Kudos
Message 6 of 17
(1,911 Views)

Another interesting find. It seems to be a problem with the barcode scanner working with LabVIEW. I've written a short test program with Arduino which writes a looping Serial.print() message which works just fine on all platforms. Termite, your LabVIEW program, my LabVIEW program, it's not having any issue.

0 Kudos
Message 7 of 17
(1,899 Views)

@samuelm91 wrote:

Another interesting find. It seems to be a problem with the barcode scanner working with LabVIEW. I've written a short test program with Arduino which writes a looping Serial.print() message which works just fine on all platforms. Termite, your LabVIEW program, my LabVIEW program, it's not having any issue.


That makes no sense.

0 Kudos
Message 8 of 17
(1,891 Views)

Then that indeed is very weird. Sounds like whatever the driver is for your serial device isn't VISA compatible. Could you try to update the drivers there? I've had very odd errors with older Silicon Labs chips (IIRC) that would work with (again IIRC) Teraterm but not LabVIEW or Termite. I could be remembering wrong though, and I don't recall the fix either. See if you can find a USB VID/PID in Device Manager, and it'll tell you what the USB to Serial device is (assuming you're connecting via USB).

 

Still though- earlier you said you were getting timeout errors. Based on the code you showed, you'd only ever get a timeout error if the While loop exited, which only happened if there was an error (which you wouldn't see with just a Bytes at Port node) or the Bytes at Port node returned a number other than 0. What was it returning? And are you sure it wasn't just returning non-printable characters or something?

 

If the transmission happened to include erroneous termchars in it then your string indicator wouldn't show any data since the default termchar is a non-printing character.

0 Kudos
Message 9 of 17
(1,871 Views)

I was never able to get it to return any data and the timeouts were before I added to loop to force it to constantly check for data at the port. I'm finding a Prolific USB to Serial Comm Port. I've tried installing the latest driver from Prolific's website, but it didn't help. As you said it might be that an incompatibility with VISA. Do you know a work around within LabVIEW? 

0 Kudos
Message 10 of 17
(1,855 Views)