How to Perform a Serial Loopback Test

Publish Date: Feb 03, 2020 | 428 Ratings | 4.39 out of 5 | Print | 25 Customer Reviews | Submit your review

Overview

This tutorial shows how to set up your National Instruments hardware and software to conduct a serial loopback test.

A loopback test can verify the operation of serial communication by sending and receiving data from the same serial port. It can show problems in the serial port, the cable, or the software generating the messages without having to connect to third party hardware. Loopback tests can be used for RS-232, RS-422, and RS-485 serial communication.

Table of Contents

  1. Prerequisites
  2. Connect Hardware
  3. Configure Software
  4. Test Communication
  5. Related Resources

1. Prerequisites

 

Back to Top

2. Connect Hardware

Refer to the sections below to properly connect your hardware. Identify what serial communication protocol you are using (RS-232 vs. RS-422/485) and the type of serial connector you have.  

Note: The pin diagrams provided for this tutorial are for the female connector. For more details on NI serial hardware pinouts, refer to the Serial Quick Reference Guide.

 

RS-232

On a RS-232 port, connect the transmit (TXD) signal to the receive (RXD) signal. Refer to the pins below based on your connector type. The connections are indicated in grey.

Connector Types

Pins

Diagrams

 

 

DB-9 (female)

 

 

Pin 3 to 2 (TXD to RXD)

 

 

 

 

DB-25 (female)

 

 

 

 

 

 

 

 

Pin 2 to 3 (TXD to RXD)

 

 

 

 

 

 

 

RJ-50

 

 

 

Not recommended*

 

*It is not recommended to use the RJ-50 connector by itself to perform a loopback test due to the small separation between pins. If you use a RJ-50 to DB-9 serial cable (Part Number 182845-XX), a loopback test can be performed using the pins for a DB-9 connector. 

 

RS-422/485 (4-Wire)

On a RS-422/485 port, connect the TXD+ signal to RXD+ signal, and the TXD- signal to the RXD- signal. Refer to the pins below based on your connector type. The positive connections are indicated in red and the negative connections are indicated in blue.

Connector Types

Pins

Diagrams

 

 

DB-9 (female)

Pin 4 to 8

(RXD+ to TXD+)

 

Pin 5 to 9

(RXD- to TXD-)

 

 

 

 

DB-25 (female)

 

 

Pin 5 to 20

(TXD+ to RXD+)

 

Pin 7 to 22

(RXD- to TXD-)

 

 

 

RJ-50

 

 

 

 

Not recommended*

 

 

*It is not recommended to use the RJ-50 connector by itself to perform a loopback test due to the small separation between pins. If you use a RJ-50 to DB-9 serial cable (Part Number 182845-XX), a loopback test can be performed using the pins for a DB-9 connector. 

 

RS-422/485 (2-Wire Auto)

For 2-wire configurations, you will need two RS-485 ports to achieve a set up similar to a traditional loopback test. 

  1. On each RS-485 port, place jumper wires between the TXD+ and RXD+ signals, and between TXD-and RXD- signals.
  2. From port 1 to port 2, wire the shorted positive signals together, and the shorted negative signals together. Wire the GND signals together. Refer to the pins below based on your connector type.

The positive connections are indicated in red, the negative connections are indicated in blue, and the GND connections are indicated in green.

DB-9 Connector (female)

Port 1 Pins

 

Port 2 Pins

Pin 1 (GND) Is connected to Pin 1 (GND)
Pins 4/8 (RXD+ to TXD+) Is connected to Pins 4/8 ((RXD+ to TXD+)
Pins 5/9 (RXD- to TXD-) Is connected to Pins 5/9 (RXD- to TXD-)

 

DB-25 Connector (female)

Port 1 Pins

 

Port 2 Pins

Pin 8 (GND) Is connected to Pin 8 (GND)
Pins 5/20 (RXD+ to TXD+) Is connected to Pins 5/20 ((RXD+ to TXD+)
Pins 7/22 (RXD- to TXD-) Is connected to Pins 7/22 (RXD- to TXD-)

 

It is not recommended to use the RJ-50 connector by itself to perform a loopback test due to the small separation between pins. If you use a RJ-50 to DB-9 serial cable (Part Number 182845-XX), a loopback test can be performed using the pins for a DB-9 connector. 

 

Back to Top

3. Configure Software

  1. Open Measurement and Automation Explorer (MAX) from the Start menu.
  2. Select the communications port of interest under Devices and Interfaces. If you are unable to see the port, refer to Serial COM Ports Missing in MAX or LabVIEW.
  3. Select the Port Settings tab at the bottom of the window. Make sure the proper settings are selected and select Validate. For more information on serial settings, refer to the Help topic.

 

  1. If you are using RS-485, select the Advanced tab and make sure the Transceiver Mode is set correctly.
  2. Select Save to save the settings.

 

Back to Top

4. Test Communication

Note: You can test communication in MAX VISA Test Panels or LabVIEW examples. Make sure not to have VISA Test Panels and LabVIEW simultaneously open, or VISA will throw an access resource error (error code -1073807246 hex:0xbfff0072).

 

Measurement and Automation Explorer

  1. In MAX, select the communications port of interest and select Open VISA Test Panel.
  2. Once the Test Panel window has opened, select Input/Output.
  3. In the Basic I/O tab, select Query to send the default *IDN?\n command.
  4. The display window will then outline the write and read operations. The Test Panel should successfully read the sent *IDN?\n command.

 

LabVIEW

For both RS-232 and RS-485 (4-wire), test communication with shipping example Simple Serial.vi.

  1. To locate the example, open LabVIEW and navigate to the Help tab >> Find Examples >> Hardware Input and Output >> Serial >> Simple Serial.vi.
  2. Ensure the proper VISA resource name is selected and the serial settings are correct.
  3. Run the VI.
  4. The Respond indicator should display the *IDN?\n command.

 

If you are using RS-485 (2-wire), test communication with the shipping example RS-485 Transceiver Control.vi.

  1. To locate the example, open LabVIEW and navigate to the Help tab >> Find Examples >> Hardware Input and Output >> Serial >> RS-485 Transceiver Control.vi.
  2. Ensure the proper VISA resource name is selected and the serial settings are correct.
  3. Specify the transceiver mode based on the one you want to use.
  4. Run the VI.
  5. The Respond indicator should display the *IDN?\n command.

 

Back to Top

5. Related Resources

Back to Top

Customer Reviews
25 Reviews | Submit your review

Testing software  - Oct 5, 2016

I've been trying to see the serial port log with plenty of methods. The one solution, which help me to make serial port test - http://www.eltima.com/rs232-testing-software/. A couple of simple steps and I see all serial activity on my monitor.

Good Tutorial  - Jul 28, 2011

The tutorial provides precise required information.

  - Dec 9, 2010

Error -1073807246 occurred at Property Node (arg 1) in VISA Configure Serial Port (Instr).vi->Basic Serial Write and Read.vi VISA: (Hex 0xBFFF0072) The resource is valid, but VISA cannot currently access it.

LabView submit the error  - Mar 20, 2010

Error -1073807343 occurred at Property Node (arg 1) in VISA Configure Serial Port (Instr).vi->Basic Serial Write and Read.vi Possible reason(s): VISA: (Hex 0xBFFF0011) Insufficient location information or the device or resource is not present in the system.

  - Jan 12, 2010

This is excellent, well-presented and very helpful information for me! I have just migrated a microcontroller app-dev from a PC to a COM-less Laptop and added a USB/Serial-adapter and now need to check it.

  - Nov 12, 2009

Excellent document for a starter

  - Nov 24, 2008

I need to send continous data in over a period of time from hyperterminal. The other end will be looped back? Is there a script or commands?

  - Oct 3, 2008

Thanks for the Tips. It works

  - Apr 6, 2008

thanks! I've read it and i've checked successfully!

  - Mar 13, 2008

very good document

  - Feb 3, 2008

Very useful technical information. K.N. Lakshmi Pathi Advanced Electronics Company Riyadh

  - Feb 2, 2008

Very useful technical information. K.N. Lakshmi Pathi Advanced Electronics Company Riyadh

  - Jan 10, 2008

Hi, I'm trying a different type of environment of loopback. The loopback suggested by you is done locally. Wondering how the below can be done :- Step 1 : Tx characters from modem A to Modem B using hyper term. Step 2 : modem B upon receiving the characters auto tx the characters received back to modem A. A summary of the enviorment is that whatever Modem A transmits, Modem B will do a auto loopback to modem A. Are there any AT commands that support this operation? Any advice is most appreciated. Regards, Zhiwei

  - Jan 7, 2008

thanks!

  - Nov 7, 2007

Thank you. This web site was a big help because I have been looking for a way to do this.

Simply Superb, But Need Further Details  - Jun 27, 2007

This type of tesing I have already done and its working really great for me. But the problem that am facing is, I use MSCOMM32.OCX to connect to the COM Port. I get message saying PORT ALREADY OPEN, When actually Port is closed and not used by other process and Vis Versa. Can any one put in some idea about why this happens. Thanks in Advance.

Thanks!  - Jun 8, 2007

thank you very much, it really helps. =)

Great!  - Apr 22, 2007

This helps out a lot, thanks!

Perfect, thanks  - Feb 12, 2007

Who would have thought I'd finally get some use out of that Quarterdeck loopback plug set all these years later? Thanks!

Great Document  - Jan 11, 2007

Exactly what I needed to sove a problem with a new Serial card.

Superb Article  - Sep 25, 2006

This is exactly the article I was looking for. Thanks a lot.

  - Apr 25, 2006

I am not clearly know that when I use modem connect mode, what type of the loopback connector I need, or modem connect mode can not be tested by loopback? Thanks!

Great document  - Jan 24, 2006

I was really looking to do some serial loopback tests, and this document also had the way to test them using HyperTerminal. Great document!

great technical document  - Oct 17, 2005

Thanks for this summary of testing serial ports!

Looking to test Serial Port via DOS in Interrupt mode!  - Apr 3, 2002

Looking to test Serial Port via DOS in Interrupt mode! Any quick examples I can "borrow"?

View more reviews

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit