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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

underflowing VISA Read Buffer

Hey all, 

I'm recently working with serial devices and now trying to do a bugfix. (LabView 2019)

 

My hardware:

Laptop/Win7

Nanotec C5-E-1-09 motorcontroller (CANopen/DS405) -> connected with USB

NEMA-23 stepper motor

 

Main programm is to drive the motor forward and backword on click. While the mouse button is pushed, the current position shoud be read and displayed in a XY-graph.

So far so good, everything works.

 

BUT suddenly the ReadPos.VI delivers less characters than it should be. I absolutely don't know why this is happening.

I tried to fix it by reading a second time to empty the buffer (usualy the second round gives me exactly the missing few characters) and in case the string is less than the expacted characters it will be discarded.

 

When it comes to less than 23 characters in the 'VISA read' the whole ReadPos.VI stuck for about 1-3sec and then works properly until it get stuck again.

 

I tried everything to solve this problem. 

Can pls someone help me out here?

(I uploades the VI in version 8.6)

 

Best

Markus

 

Download All
0 Kudos
Message 1 of 6
(2,159 Views)

How do you initialize the serial port? Do you happen to use the dreaded Bytes at Serial port property to determine how much data to read?

Sorry can't open your VIs at the moment as I don't have any LabVIEW version installed on the machine I'm working on right now, but I'm applauding you for back saving your VIs to an earlier version. Smiley Happy

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 6
(2,144 Views)

Hi Markus,

 

in the German LabVIEWForum we told you to explicitely use VISASerialPortConfig to DISABLE any TermChars - but you didn't follow our advice.

 

Can you please try to switch off any TermChars?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(2,139 Views)

Hey Gerd,

 

I tried this way with disabling the TermChar. (see Picture below)

The reading behaviour dosen't change

 

 

0 Kudos
Message 4 of 6
(2,109 Views)

@rolfk wrote:

How do you initialize the serial port? Do you happen to use the dreaded Bytes at Serial port property to determine how much data to read?

 

I define the Bytes to read at the VISA Read function


 

0 Kudos
Message 5 of 6
(2,107 Views)

For serial ports the TermChar Enable functionality is a little bit more involved than just this single property. Refer to this link to see an explanation.

Using the Initialize Serial Port.vi as recommended earlier takes care of all this for you and also makes sure the port uses the right baudrate and serial port settings instead of relaying on (user configurable) default values that can throw your application off.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 6
(2,090 Views)