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.
Note: If you are using a third-party serial interface, use this article based on your hardware pinout.
RS-232
On an 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 an 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-485 (2-Wire Auto)
For 2-wire configurations, you will need two RS-485 ports to achieve a setup similar to a traditional loopback test.
- On each RS-485 port, place jumper wires between the TXD+ and RXD+ signals, and between TXD- and RXD- signals.
- 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.
Configure Software
- Open Measurement and Automation Explorer (MAX) from the Start menu.
- 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.
- 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.
- If you are using RS-485, select the Advanced tab and make sure the Transceiver Mode is set correctly.
- Select Save to save the settings.
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
- In MAX, select the communications port of interest and select Open VISA Test Panel.
- Once the Test Panel window has opened, select Input/Output.
- In the Basic I/O tab, select Query to send the default *IDN?\n command.
- 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.
- To locate the example, open LabVIEW and navigate to the Help tab >> Find Examples >> Hardware Input and Output >> Serial >> Simple Serial.vi.
- Ensure the proper VISA resource name is selected and the serial settings are correct.
- Run the VI.
- 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.
- To locate the example, open LabVIEW and navigate to the Help tab >> Find Examples >> Hardware Input and Output >> Serial >> RS-485 Transceiver Control.vi.
- Ensure the proper VISA resource name is selected and the serial settings are correct.
- Specify the transceiver mode based on the one you want to use.
- Run the VI.
- The Respond indicator should display the *IDN?\n command.