From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Nothing received in VISA serial port buffer

Solved!
Go to solution


Hi all,

 

I want to make a VI to read temperature data packages from a serial port. The data is sent from a monitor automatically in a fixed period, so the VI is only required to read data from the serial port.

 

I have made a VI, which can show the number of bytes at serial port and read all the data once a button is pressed. The problem is that the number of bytes at serial port is always zero no matter how long I have wait before reading. Consequently, no data is read.

 

Could anyone help me? Thanks a lot!

 

More information:

1. This VI can work properly when I send data from a virtual serial port created by VSPD software.

2. The serial port seems right in Windows Device Manager. What's more, other software can read data successfully (but I need to process data in LabVIEW).

3. NI-VISA is installed and serial port is configured properly. No error occurs during operation except no data received.

4. My PC is connecting to the monitor via a standard RS-232 interface directly, and no USB-to-RS232 adapter is used.

5. I have study the signal by an oscilloscope and find it is right. (Other software's working properly can also demonstrate this.)

The button is activated only once although it may be pressed for a while.The button is activated only once although it may be pressed for a while.The while-loop do nothing when button is unpressed.The while-loop do nothing when button is unpressed.

Other software can receive data.Other software can receive data.

0 Kudos
Message 1 of 7
(3,451 Views)

Do you have a manual for the instrument (preferably in English)?  There are a few issues that we need information about the instrument in order to fix.

 

1. You need to verify your port settings (baud rate, parity, handshaking, number of bits per byte, etc).  Your main symptoms point to a wrong setting somewhere.

2. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Your instrument obviously has a messaging protocol.  You need to use that when reading the data in order to make sure you get complete messages and therefore valid data.


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
Message 2 of 7
(3,428 Views)

@crossrulz  已写:

Do you have a manual for the instrument (preferably in English)?  There are a few issues that we need information about the instrument in order to fix.

 

1. You need to verify your port settings (baud rate, parity, handshaking, number of bits per byte, etc).  Your main symptoms point to a wrong setting somewhere.

2. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Your instrument obviously has a messaging protocol.  You need to use that when reading the data in order to make sure you get complete messages and therefore valid data.


The manual provides only little information about the interface, including port settings and data packet formats. I'm asking the manufactor for more documents. Maybe they have some example VIs. 

Serial port settingsSerial port settings

 

 

Data packet formatData packet format

 

 

 

 

 

 

 

 

 

 

1. According to the manual, I have set the right baud rate, parity, data bits, stop bits , but it doesn't mention other settings like handshaking, etc. I think there may be something wrong in setting as well.

2. The instrument has been configured to sent a data packet every 0.1 seconds. What the VI needs to do is just open the port, wait and read data. The data can be explained only after reading it. However, there is no data can be read. If I specify 1 byte to be read, the VISA-Read will return a timeout error.

 

I have done more tests and fond more clues.
1. The same problem occurs in Matlab. There is no data can be read in buffer, either.
Matlab Instrument Control Toolbox provides a exsisting APP to read serial port, so there shouldn't be any mistakes in the Matlab APP. Up to now, only two APPs can read data. One is the offical software from the manufactor, and the other is a serial port utility.
2. When I send some messages to the serial port, the same messages are received. This will happen when using either Matlab APP or "Continuous Serial Write and Read.vi"(a LabVIEW example)

0 Kudos
Message 3 of 7
(3,418 Views)

If you receive the same data as you send it can be because there is a short in your cable (send and receive connected, or that the command is echoed by the instrument.

It is probably an echo.

If other software can read and write It has to be your own software including the initialization in LabVIEW but no cabling problem.

Looking at the manual it seems that a binary format is sent. So I would display the hex representation of the bytes as I see that in the vi, so that is correct.

I have removed the set buffer size vi because this is the default.

Maybe you have to send a cr/lf command to begin data transmission.

I've seen that before.

But you also could explain the name of the instrument.

 

I still kept the bytes on port. just to make it easy to test but moved the display to look at it without having to press the key.

If the instrument is indeed sending it should increment the data size 10 times per second.

 

 

greetings from the Netherlands
0 Kudos
Message 4 of 7
(3,403 Views)

@Albert.Geven  已写:

 

 

If the instrument is indeed sending it should increment the data size 10 times per second.


I don't think there is any mistake in your VI, but the data size still maintains zero all the time.

 

I've tried three different third-party Serial Port Utility APPs. All of them can read data properly. Is there any difference between the utilities and LabVIEW/MATLAB ?

 

The instrument is a Photrix Infrared Thermometer from LumaSense Technologis.

0 Kudos
Message 5 of 7
(3,391 Views)

The only thing I can think of is that LabVIEW issues a BREAK on the serial line during init. This can stop the sending device.

 

MAtlab I don't use.

greetings from the Netherlands
Message 6 of 7
(3,380 Views)
Solution
Accepted by topic author YanGroup

@YanGroup  已写:

I've tried three different third-party Serial Port Utility APPs. All of them can read data properly. Is there any difference between the utilities and LabVIEW/MATLAB ?


I've studied the waveform at each pin in detail with an oscilloscope. The cause of this problem is that LabVIEW or MATLAB sets the RTS Line to high level in defult at the initialization. This will interrupt the transfer of data. So I inserted a step to set RTS state to 0 after the VISA Configure Serial Port function. Then LabVIEW can send and receive data properly.

 

The VI attached is used to read data.

0 Kudos
Message 7 of 7
(3,337 Views)