LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Serial Read missing data in between

Solved!
Go to solution

Hi,

 

I am communicating with a motor controller from PCB motors over an emulated COM Port from Windows 7. LabVIEW Version 2013.

COM Port Settings:

   19200 Baud

   8 data bits

   1 stop bit

   no flow control

   no parity

 

Most of the time the serial communication works just fine, but randomly some data gets missing. Playing with delays at different sections in the code did not help.

 

More accurately: I send the command "RD4,RD6,R10,RD12,R31,R32,R42,R43" to the controller to read values from the register and continously read until the ">>" symbol signals the end of the data (that's what the while loop does). Sometimes part of the reply of the controller goes missing.

 

Normal situation: The controller answers with the accepted command and the data asked for:

 

RD4,RD6,R10,RD12,R31,R32,R42,R43

Memory# 4(+1): 20
Memory# 6(+1): 9999
Memory# 10: 255
Memory# 12(+1): 9999
Memory# 31: 100
Memory# 32: 100
Memory# 42: 100
Memory# 43: 100

 

But sometimes the first line of the data is missing ("Memory# 4(+1): 20"😞

 

RD4,RD6,R10,RD12,R31,R32,R42,R43

Memory# 6(+1): 9999
Memory# 10: 255
Memory# 12(+1): 9999
Memory# 31: 100
Memory# 32: 100
Memory# 42: 100
Memory# 43: 100

 

I would understand data missing at the beginning or end, but inbetween?

 

When using Termite 2.6 this problem does not seem to occur.

 

Any ideas?

Jonas

Download All
0 Kudos
Message 1 of 6
(3,871 Views)
Solution
Accepted by topic author jonasze

Hi Jonas,

 

don't use BytesAtPort! Don't use VISAClear!

 

- Enable TermChar(s): you use it at VISAWrite and your images indicate you also can use a TermChar at VISARead!

- Use an arbitrary big constant instead of BytesAtPort, VISARead will return as soon as it receives the TermChar.

- Your while loop stops when it doesn't find ">>": it should stop when it finds those chars!

- You don't need to Init the port each call. You don't need to close the port each call.

- You don't need to clear the buffer each call. It might delete already received data…

Best regards,
GerdW


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

Hi Gerd,

 

thanks for your quick reply!

Indeed VISAClear generates some problems, replacing it with a simple VISA read to clear out the buffer worked well.

 

Cheers

Jonas

0 Kudos
Message 3 of 6
(3,774 Views)

HI,

 

What do you mean by arbitrary big constant?

0 Kudos
Message 4 of 6
(3,725 Views)

Hi Jones,

 

Can you share your final code.

0 Kudos
Message 5 of 6
(3,723 Views)

Hi AKSHK,

 

with "arbitrary big number" I want to say: use a constant with a value bigger than the longest expected message length…

Best regards,
GerdW


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