04-13-2021 12:15 PM
Hello,
I am working on a project using Visa serial communication. I have to read the scanner output and print information in the report. I have successfully read the barcode and also able to print it in the Excel sheet. But I am facing a problem of synchronization of data from the scanner and printing it to Excel sheet. sometimes I don't print data and sometimes two, three data in a single cell.
Please find the enclosed vi.
Regards.
G.Matharoo
04-13-2021 12:34 PM
04-13-2021 12:59 PM
Looks like you are doing intermittent/sporadic ASCII communications. So....
1. Do not tell the VISA Read how many bytes to read with the Bytes At Port. Instead, read more bytes than you ever expect to get in a single line.
2. Your wait should be in the FALSE case of your structure. In other words, you only wait if there is no data to read.
04-13-2021 02:09 PM
Hi Crossrulz,
Thanks for replying my message. I am using default settings.
Do you see any property that I can use to control the reading operation.
What value should I provide at byte count of Read vi. Data byte length is not fixed for reading barcodes. I also used 1000 byte counts that I read from NI forum. That didn't work properly.
Regards
Matharoo
04-13-2021 02:54 PM
I tend to use 100, since I very rarely see a message that is longer than that. In the case of your bar code scanner, you need to figure out if the scanner sends a Carriage Return and/or a Line Feed to state the end of the message or if it relies on the barcode to do that. Since we are stating it is ASCII data, we need something, typically a Termination Character, to tell us when the message is over.
04-14-2021 06:42 AM
Hi Crossrulz,
I have carefully checked the manual. It describes that that Maximum no of bytes per packet are 257. Also scanner uses ACK/NAK handshaking for communication. The host serial response timeout is 2 sec.
Could you please let me know what changes I have to made in my code.
Regards.
GMatharoo
04-14-2021 07:23 AM
Hi Crossrulz,
Forgot to mention that ACK/NAK handshaking is with SSI interface. NI Visa support SSI or RS232 ? I have no idea.
Regards.
GMatharoo
04-14-2021 08:11 AM
Could you point me to documentation on your scanner?
04-14-2021 08:20 AM
Hi Crossrulz,
Please find the enclosed manual.
04-14-2021 10:58 AM
On Page 7-4 you can see the RS-232 suffix is a CR (carriage return) for most terminal types. Try that (0xD) instead of line feed (0xA) as your termination character.