10-21-2015 10:55 AM
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
Solved! Go to Solution.
10-21-2015 11:58 AM
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…
10-27-2015 12:04 PM
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
10-29-2015 12:29 PM
HI,
What do you mean by arbitrary big constant?
10-29-2015 12:31 PM
Hi Jones,
Can you share your final code.
10-29-2015 12:37 PM