LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication synchronisation with Reporting Toolkit Issue

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

0 Kudos
Message 1 of 28
(448 Views)
Hi Matharoo,
I'd guess that's because of the way you are reading from your serial device. I would save a copy of this VI, then strip out everything dealing with file I/O (report generation) and just leave the code that talks to the scanner. Now make an indicator on the scanner output, and watch what happens when you scan barcodes.

In general you should read up to the termination character if possible. You have yours set to 0xA (line feed), is that what you want for your scanner? If yes, just use the read function with a large number of bytes to read as the input, it will stop at the line feed. But the fact that you sometimes read 3 barcodes at once, tells me that your scanner is probably not outputting line feeds, maybe carriage returns (0xD). You can set the timeout to something short, and if the read times out you don't update your indicator / file. This way you will not need to use the bytes at port property.

Generally, bytes at port should only be used if your device does not use a termination character, meaning it has a poor serial interface.
0 Kudos
Message 2 of 28
(430 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 28
(411 Views)

Hi Crossrulz,

Thanks for replying my message. I am using default settings. 

Matharoo_2-1618340550116.png

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

 

 

 

 

0 Kudos
Message 4 of 28
(396 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 28
(385 Views)

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 

0 Kudos
Message 6 of 28
(357 Views)

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

0 Kudos
Message 7 of 28
(349 Views)

Could you point me to documentation on your scanner?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 28
(343 Views)

Hi Crossrulz,

 

Please find the enclosed manual.

0 Kudos
Message 9 of 28
(334 Views)

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.

0 Kudos
Message 10 of 28
(312 Views)