What are TX and RX relative to?

It might be easier to understand, if we quickly review how the RS-232 standard was originally used.

Note: All pin numbers below refer to the original 25-pin D connector; the numbering changed on the 9-pin connector used on later PCs.

Background

DTE = Data Terminal Equipment - in the old days, this would usually be a terminal or a printer, or equipment emulating those.

DCE = Data Communications Equipment - in the old days, this would usually be a modem or other WAN interface.

Pin 2 on the original 25-pin D connector (described in the standard as "Transmitted Data", "Circuit BA", "V24. number 103") should be data from the DTE to the DCE.

Pin 3 on the original 25-pin D connector (described in the standard as "Received Data", "Circuit BB", "V24. number 104") should be data from the DCE to the DTE.

This meant that the cable linking a terminal and a modem was "straight through" - pin 2 on a terminal (DTE) at one end of the cable where data originated, was connected to pin 2 on a modem (or similar) at the other end of the cable (DCE) where that data was received. The modem then sent that data out using the communications link, to whatever equipment was on the other end of that link.

Pin 3 "Received Data" was the data signal in the opposite direction - transmitted by the modem (DCE) on pin 3, and received by the terminal (DTE) on pin 3.

Therefore you can see that the labelling of what was Transmitted and what was Received, was from the point of view of the DTE (i.e. the terminal). This all made sense when the typical connections were between a DCE and a DTE.

However the pieces of equipment we are using these days (even when they don't use RS-232 and are instead using a TTL or other voltage UART protocol interface) are usually all effectively DTE (with one exception being modems). Connecting pin 2 (which is an output) on one piece of DTE, to pin 2 (another output) on another piece of equipment configured as DTE, makes no sense (and when using logic level signals, could even cause hardware damage). This is where the use of "crossed" or "null modem" (i.e. no modem) cables comes in.

Your question

I have been working with a device that uses RS232 communication to a PC. There has been some confusion as they have defined their TX and RX pins relative to the device. In their definitions they use to mean TX being the pin that sends data from the device. In my mind this should be labeled RX because it is the pin the computer receives on.

How should the pins be defined? Are they relative to each device or relative to the "controller"?

From the above background info, you can see that their labelling is correct if their device is acting as DTE (which most are, unless it's a modem or other WAN interface). On a piece of DTE, the pin labelled "Transmitted Data" (pin 2 on the 25 pin connector) does send data. (And, as explained above, on a piece of DCE (e.g. a modem) the pin known as "Transmitted Data" (pin 2 on its 25 pin connector) is actually an input, which receives the signal from the DTE.)

The PC's serial port will also be configured as DTE (unless it has a very unusual serial port - that won't apply here, as you would know if it did apply).

Therefore you are connecting DTE device (this device you've mentioned) to DTE device (the PC) i.e. there is no DCE in "RS-232 terminology, i.e. no modem, and the "null modem" or "crossed" RS-232 wiring will be needed. Whichever pin is RS-232 "Transmitted Data" (probably the one you mention they have labelled as TX) on this DTE device, which will be an output, will need to be connected to the RS-232 "Received Data" pin on your PC (also a DTE device), which is an input (and obviously vice versa for data transfer in the other direction).

Although this doesn't seem to apply to you, I'll just add: To make life more complicated, some manufacturers try to "help" by effectively labelling their DTE equipment as if it was a piece of DCE. They mark their data input pin as Tx so that user just connects "Tx" from the external device (which, if it's DTE, will be the data output from there) to the pin marked "Tx" on their equipment (which they know is an input). Thereby allowing them to say "just connect Tx on your device to Tx on our equipment". They think they are trying to help, but such labelling often just adds to the confusion.

As Dan Mills mentioned in a comment, many of us who grew up with RS-232, spent happy hours having to connect various equipment with slightly different RS-232 implementations, using the "breakout boxes" which he described. These breakout boxes have LEDs, which show which signals are being actively driven (this quickly allows you to see if the equipment is configured as DTE or DCE: Is pin 2 driven on that equipment? Yes = it's DTE) and have places where short jumper cables can be used to link the various connector pins.


Unlike many bus-like configurations, which use signal name, the serial communication traditionally uses function name for pins. So, if the device transmits on some pin, it is marked Tx. If it receives, it is marked Rx. Obviously you connect Tx of one device with RX of the other and vice versa.

To put it into perspective, the device you are talking about also has a "computer" in it, which is what MCU basically is. Why should one computer dictate the names of the other computer's pins, especially considering bi-directional asynchronous nature of communication?

The special case is when the device in question is pass-through kind, like an old modem or modern FT232 converter. They are not using Tx/Rx pins to communicate with computer, they use them to pass computer's communication further down the line. For this reason their pins are named after the signals coming through.

UPDATE: Here are couple examples to illustrate the point.

Probably millions of people are using Arduinos nowadays, some even without having slightest idea how it works. They connect Tx to Rx, Rx to Tx, Gnd to Gnd and they are good to go. What they often don't realize, is that they are technically creating null-modem, which allows two MCUs talk to each other.

Now, the same people sometimes want to add USB connectivity to their Arduinos. They connect TX to TX and RX to RX on the adapter or converter chip. Note that those often named "TX-IN" and "RX-OUT" to avoid confusion. Again, what seems to be obvious but rarely thought about, is that technically this USB adapter is a pass-through device. What it "says" on RX pin is not coming from adapter itself, it is coming from the device on the other side of the line. And guess what? It is connected to TX pin somewhere.


They're usually relative to the device, since RS232 devices don't have a "master/slave" or "client/server" relationship. The SPI protocol has a master/slave architecture, so they're labeled "MISO" (Master In Slave Out) and "MOSI" (left as an exercise to the student). That's at the device level; I can't speak to what individual circuit designers might choose as net names.

Tags:

Rs232