Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
What is Developer Zone?
United States

Document TypeTutorial
NI Supported: Yes
Publish Date: Aug 03, 2011


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links -Products and Services

How to Do a Serial Loopback Test

412 Ratings | 4.42 out of 5
Read in  |  Print |  PDF

Overview

A loopback test allows you to send and receive data from the same serial port to verify that the port is operational. To perform this test, you need to temporarily connect the proper pins to allow signals to be sent and received on the same port.

Table of Contents

  1. Loopback Test
  2. Connectors
  3. Performing a Loopback Test in Hyperterminal
  4. Performing a Loopback test in Measurement & Automation Explorer
  5. Performing a Loopback test in LabVIEW

Loopback Test

A loopback test can be used to troubleshoot serial communications.  It can show problems in the serial port, the cable, or the software generating the messages without having to connect to third party hardware.  By connecting the proper wires, a loopback test can verify the operation of serial communication.  Loopback tests can be used for RS-232, RS-422, and RS-485 serial communication. 

For more information on RS-232, RS-422, and RS-485 see the Serial Communication Overview.  Note that not all serial devices, especially those with many connections on one card, allow hardware flow control on every serial output of the device. 

To perform a loopback test for RS-232, the TXD pin must be connected to the RXD pin.  This allows the data to flow from the transmit to the receive pins.  Since the communication is differential for RS-422 and RS-485, the TXD+ connects to the RXD+ and the TXD- connects to the RXD- pins. 

A more advanced loopback test that allows hardware flow control will need more pins connected to allow the flow control signals to be properly passed.  For RS-232, the CTS and RTS pins must be connected along with the DTR and DSR pins.  For RS-422 and RS-485, CTS+ should be connected to RTS+ and CTS- should be connected to RTS-.

For more information about National Instrument’s serial interfaces, visit ni.com/serial

 

Connectors

DE-9 (DB9) Connector

The DE-9 connector is the most common serial connector.  This connector is found on National Instrument’s one and two port serial interfaces.

Figure 1: Pinout diagram for DE-9 Connector

 To perform a loopback test with no hardware flow control, you will need to connect pins 2 and 3 for RS-232 and pins 4 to 8 and 5 to 9 for RS-422/485.  These connections can be seen in red below (figure 2 for RS-232 and figure 3 for RS-422/485). 

When using hardware flow control, you will need to connect pins 4 to 6 and 7 to 8 for RS-232.  Pins 7 and 8 are used for RTS/CTS hardware flow control where pins 4 and 6 are used for DTR/DSR hardware flow control.  For RS-422/485, you will need to connect pins 2 to 3 and 6 to 7.  Both of these connections are required for RTS/CTS hardware flow control since RS-422/485 have differential connections.  These connections can be seen in blue below (figure 2 for RS-232 and figure 3 for RS-422/485).

Figure 2: RS-232 female DE-9 plug with connections required for loopback test

Figure 3: RS-422/485 female DE-9 plug with connections required for loopback test

DB-25 Connector

This connector is not as common as the DE-9 connector.  This connector can still be used to perform a loopback test with a method similar to the one used for the DE-9 connector.

Figure 4: Pinout diagram for DB-25 Connector

Most of the pins on DB-25 connectors are not connected since only nine pins are used for RS-232, RS-422, and RS-485 communication. 

To perform a loopback test with no hardware flow control with a DB-25 connector, connect pins 2 to 3 for RS-232.  For RS-422/485 connect pins 5 to 20 and 7 to 22.  The required connections can be seen in red on figures 5 and 6.

For hardware flow control using RS-232, pins 4 and 5 must be connected along with pins 6 and 20. When using RS-422/485, pin 5 must connect to pin 20 and pin 7 must connect to pin 22.  This will allow the loopback test to use the proper flow control lines.  These connections can be seen in blue on figures 5 and 6.

Figure 5: RS-232 female DB-25 plug with connections required for loopback test

Figure 6: RS-422/485 female DB-25 plug with connections required for loopback test

10P10C (RJ50) Connector

This connector is most commonly found on National Instrument’s 4 port serial interfaces.  The National Instrument 4 port serial interfaces come with 4 10P10C to DE-9 male converter cables. 

Figure 7: Pinout diagram for RJ50 Connector

It is not recommended to use the 10P10C connector by itself to perform a loopback test due to the small separation between pins.  Using a 10P10C to DE-9 connector (Part Number 192190-01), a looback test can be performed using the methods described above. 

Performing a Loopback Test in Hyperterminal

1.  Create a new connection with any name and icon.

2. Select the communications port you would like to test

3.  Select the type of flow control you would like to use.  Note that Xon / Xoff is software flow control and will only require that the TXD and RXD pins to be connected.

4.  Type a message using the computer's keyboard.  Any data that shows in Hyperterminal is received from the device.

Performing a Loopback test in Measurement & Automation Explorer

1.  Open Measurement & Automation Explorer and select the communications port you would like to use.

2.  Ensure the proper settings are selected for flow control.

3.  Save the settings by selecting the Save button then select the Open VISA Test Panel button

4.  On the Write tab, type the message you would like to send (followed by a \n) then select Execute

5.  On the Read tab, select Execute and verify the message

Performing a Loopback test in LabVIEW

Note:  For a free evaluation copy of LabVIEW, visit ni.com/trylabview

1.  Start LabVIEW

2.  Select Help»Find Examples...

3.  Browse to Hardware Input and Output»Serial»Basic Serial Write and Read.vi

4.  Ensure the proper settings are selected, enter the string you would like to write in the "string to write" box, and then select the white run arrow on the toolbar.

412 Ratings | 4.42 out of 5
Read in  |  Print |  PDF

Reader Comments | Submit a comment »

Good Tutorial
The tutorial provides precise required information.
- Jul 28, 2011


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.
- Dec 09, 2010

LabView submit the error
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.
- FShimon@gmail.com - Mar 20, 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.
- peter.pollard@web.de - Jan 12, 2010


Excellent document for a starter
- Vijay Chavan,Vikim . cvijayin@gmail.com - Nov 12, 2009


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?
- dreherd@telus.net - Nov 24, 2008


Thanks for the Tips. It works
- Oct 03, 2008


thanks! I've read it and i've checked successfully!
- ,. - Apr 06, 2008


very good document
- siva prasad nandyala,wipro. siva.nandyala@wipro.com - Mar 13, 2008


Very useful technical information. K.N. Lakshmi Pathi Advanced Electronics Company Riyadh
- Kadaba Lakshmi Pathi,Advanced Electronics Company. knlpathi@hotmail.com - Feb 03, 2008


Very useful technical information. K.N. Lakshmi Pathi Advanced Electronics Company Riyadh
- Kadaba Lakshmi Pathi,Advanced Electronics Company. knlpathi@hotmail.com - Feb 02, 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
- Zhiwei,. chiopigwinner@hotmail.com - Jan 10, 2008


thanks!
- pham hung,DH Bach Khoa Ha Noi. pkh_1985@yahoo.com - Jan 07, 2008


Thank you. This web site was a big help because I have been looking for a way to do this.
- larry.harrison@ucps.k12.nc.us - Nov 07, 2007

Simply Superb, But Need Further Details
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.
- lakshmikanthkamath@gmail.com - Jun 27, 2007

Thanks!
thank you very much, it really helps. =)
- Jun 08, 2007

Great!
This helps out a lot, thanks!
- Apr 22, 2007

Perfect, thanks
Who would have thought I'd finally get some use out of that Quarterdeck loopback plug set all these years later? Thanks!
- Andrew,. andrew.rich@gmail.com - Feb 12, 2007

Great Document
Exactly what I needed to sove a problem with a new Serial card.
- Jake,. jatexas@camtel.net - Jan 11, 2007

Superb Article
This is exactly the article I was looking for. Thanks a lot.
- Susanta Mondal,. cse_susanta@rediffmail.com - Sep 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!
- When I use modem connection mode?,china. golden_ctbu@yahoo.com.cn - Apr 25, 2006

Great document
I was really looking to do some serial loopback tests, and this document also had the way to test them using HyperTerminal. Great document!
- Dustin Martínez,Electronics School, University of Cauca (Colombia). tbb_mb@yahoo.com - Jan 24, 2006

great technical document
Thanks for this summary of testing serial ports!
- Oct 17, 2005

Looking to test Serial Port via DOS in Interrupt mode!
Looking to test Serial Port via DOS in Interrupt mode! Any quick examples I can "borrow"?
- Roger Owens,Hamilton Sundstrand. roger.owens@hs.utc.com - Apr 03, 2002

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).