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: 

Trouble communicating in RS232

Solved!
Go to solution

Hello everyone,

 

I recently changed the computer (from windows 7 to windows 10) that is communicating with a bunch of instrument, especially one in RS232.

Since I switched computer, I had trouble establishing a communication with that instrument, either through NIMax or via LabVIEW.

 

More specifically, I have trouble from reading instruction from the port: it work perfectly or not at all from one day to another, for a reason that I cannot understand.

The instructions that I write on the port are always taken into account by the instrument, meaning that the communication is established, but I sometimes can't Read at all instructions from the instrument (leads to timeout).

 

The port configuration (baud rate, stop bit, parity, buffer size ...) are correct, and I write the instruction in the good way (term char, line feed etc.).

So, I can't figure out why it sometimes work, and why it sometimes does not work:

-Is it linked to this new computer's port configurations ?

-Are there errors stuck in the instrument register ?

 

More information are probably needed, I am not an expert in the field.

Thanks in advance for your ideas !

 

Sam

 

0 Kudos
Message 1 of 6
(1,059 Views)

I would need to see code and have more information on the instrument to verify, but my guess is that you are sending things too quickly.  This is a common thing when you use a new computer (computer is faster and so you suddenly run into race conditions).  So you may need to add some delays.


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 2 of 6
(1,043 Views)

Thank you for four reply. So when the initialization is done with LabVIEW, the Write function is used the send a bunch of commands to reset registers on the instruments (these commands works). Then the read function is used to verify register's state. The "Bytes at port" property node always return zero when the read function is not working.

Why would it be a "race conditions" ? The code procedure is always the same, it sometimes works and it sometimes ends on timeout loops.

Download All
0 Kudos
Message 3 of 6
(1,037 Views)

I'm not understanding why you are sending 1 byte at a time.  The Serial Write can just do the whole string at once.  Furthermore, I highly recommend you transition to use VISA for your communications.  VISA can handle a lot of your code for you.  For instance, you can enable the termination character and then tell the VISA Read to read more bytes than you should ever get in a message and it will just return the message (the read ends when the termination character is read).


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 6
(1,028 Views)
Solution
Accepted by topic author Samdub19

You wrote that you changed the computer.. so the cable& connectors were mechanically stressed

Since it work in one direction

Sometimes just a failed contact broken cable .. loose contacts are always a nice source of errors BTDT 😄

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 5 of 6
(912 Views)

Hi,

 

Sorry for not updating this topic earlier.

As you mentioned it, I realised some weeks ago it was a hardware problem: the Rx wire inside the DB9 port wasn't brazed anymore due to mechanical stress. Contact was still maintained, explaining why the communication worked from time to time. It is now resolved as I re-brazed the Rx wire 😄

 

Thank you,

 

Sam.

 

0 Kudos
Message 6 of 6
(905 Views)