Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Random Serial Communication Error

I am currently trying to program a PCB.

 

This works by sending serial commands to the board at 115200 baud rate.

 

Currently, the VI works most of the time but after a couple hundred loops, the board will reset itself resulting in the "read" result not matching the "desired" result and therefore not exiting the loop (until an error occurs). 

 

I figure that I'm missing a small thing in the code that is causing this to happen. I know that the buffer is not overflowing as I have previously had an indicator showing the buffer amount.  

 

Does anyone have any idea what is going wrong? I've captured trace data and there is nothing within that which is out of the ordinary before the board is reset. 

 

Thanks,

 

Scot07

Download All
0 Kudos
Message 1 of 9
(3,708 Views)

You probably know how many bytes you want to receive and I hope you also chose an end character for your message. If you have an end character use that instead of bytes at serial port to make your communication stable.

Select the end char at init visa and enable it.

If you have no end char but a fixed number of bytes, use that after finding out where the data starts before the loop.

greetings from the Netherlands
0 Kudos
Message 2 of 9
(3,612 Views)

The written and read messages both end 0A so that is why I left the rest of the init VISA settings as default (0x0A & True). 

 

The communication is stable for several hundred loops. The board resetting appears to occur at random. 

 

Note: the board is grounded appropriately as well. 

0 Kudos
Message 3 of 9
(3,573 Views)

@Scot07 wrote:

The written and read messages both end 0A so that is why I left the rest of the init VISA settings as default (0x0A & True).


In that case...

DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis)

 

Just tell the VISA Read to read more bytes than you ever expect in a message and it will end when the 0x0A is read.  By using the Bytes At Port to tell it how many bytes to read, you are causing potentially very weird race conditions.  That is likely the error you are having (ie, you are getting lucky most of the time).


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 4 of 9
(3,536 Views)

I have removed the bytes at port and still getting this error. 

0 Kudos
Message 5 of 9
(3,532 Views)

But now you have two cases:

message corruption or

timeout

 

corrupt messages (btw how long is your cable?*) cause a not equal and request a new action ...

if only one true message is send AND that message can get corrupted you have to rethink your solution.

(common method: checksum and ACK)

Using the 'is exactly equal' to stop a loop  is prone to such errors.

 

*)serial COM at this baudrate can create errors is someone turn the ligth off 😉

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 6 of 9
(3,513 Views)

What is happening is that the correct message is being sent and the correct responses are being returned, even when the board is resetting itself, the response prior is correct. As far as I can tell, there is no reason for this to happen. There is no timeout (the board reset happens 100ms after part of the response is returned) and the message to the board is read correctly and the correct action is taken (definitely not sending a corrupt message). 

 

The fact this always happens after several hundred loops would lead me to think it was something similar to a full buffer but I don't believe that's the case. 

 

The cable is 5m long. 

0 Kudos
Message 7 of 9
(3,475 Views)

Have you compared the messages on a bit level? Set the string indicators to HEX 😉

What looks like a space could be something else...

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 8 of 9
(3,445 Views)

I have checked in hex. Everything is good up until the board reset.

0 Kudos
Message 9 of 9
(3,437 Views)