3
\$\begingroup\$

I'm in the process of designing a USB to RS-232 converter for communication with some existing boards, and I ran into two problems.

First Question

I need a way to programmatically reverse the TXD and RXD lines, as there are some boards that are incorrectly wired and need a crossover Serial cable to work.
(instead of pin 2 and pin 3 being RX and TX respectively, the board is wired the other way around)

Since the voltage level of RS-232 is ±3-15V, I was planning to use a DPDT relay and control it using an MCU in order to switch the RX and TX lines.

Question 1: I was wondering if what I'm looking for can be achieved without using relays/SSRS, using passive components. If so, can you please help me with the schematics?  

schematic

simulate this circuit – Schematic created using CircuitLab

Second Question

An existing USB to RS-232 cable I was using (which had a PL2303TA chip) was fried, when it was connected to these existing boards (since both of the TXD lines were connected to each other). It can still receive data, but the transmit doesn't work anymore.

Question: Is there a way I can prevent the board I'm designing from such a failure?
I feel like in the worst case scenario, one side would output a +15V voltage, while the other one would output a -15V voltage, which would cause driver contention, and is very bad!

Is there a mechanism in order to avoid my chip from being damaged, and prevent the other board's chip from being damaged as well?

schematic

simulate this circuit

Additional Info

As I checked, the manufactured boards have a MAX232 chip on them. I'm also basing my design on a MAX232 chip, if that helps.

I appreciate any tips and general advice!

Update

Thank you for all the good advice, the investigation with the PL2303TA chip, explanation of DPDT switching, the idea of multiplexing without a relay, and the use of two chips with separate enable pins! I'm going to use most of the ideas in my design.

I'm also now more confident regarding the issue 2, as the RS-232 specification specifically mentions this wouldn't harm a chip that meets the requirements.

\$\endgroup\$
9
  • 2
    \$\begingroup\$ It is very unlikely that just connecting two transmits together would cause device damage. The max232 for example is designed to survive a short to ground indefinitely and the output is current limited to a few mA. Also the output is a maximum of +/- 10V. It never drives as much as 15V. \$\endgroup\$ Commented Feb 4, 2022 at 0:41
  • \$\begingroup\$ It's also suggested here that a compliant device would tolerate a short between -25V to +25V, so maybe the PL2303TA chip wasn't compliant? I'm planning to use a MAX232 instead \$\endgroup\$ Commented Feb 4, 2022 at 0:54
  • 1
    \$\begingroup\$ I suspect that your damaged PL2303 interface was for "TTL Levels" (bare UART), rather than RS232. There are some USB<->Serial cables like that for connection directly to a microcontroller that does not have a MAX232 or equivalent TTL<->RS232 level converter. \$\endgroup\$ Commented Feb 4, 2022 at 6:19
  • 1
    \$\begingroup\$ @mkeith The device I'm interfacing with actually use a MAX232 chip, which is RS-232 level. Would connecting two TXDs from different MAX232 chips be safe? \$\endgroup\$ Commented Feb 9, 2022 at 16:42
  • 1
    \$\begingroup\$ The MAX232 chips will definitely not be damaged if you connect two outputs together (TX to TX). RS232 was specifically designed so that it could be connected wrong without damage. The MAX232 is a fully compliant and high quality implementation of RS232. People connect serial ports wrong all the time, as I am sure you realize based on your question. \$\endgroup\$
    – user57037
    Commented Feb 9, 2022 at 17:44

4 Answers 4

8
\$\begingroup\$
  1. The switching cannot happen with passive components. A relay or analog mux chip are active. A latching relay only needs a pulse to go to correct state and stays at that state without power. Another option is to use a DPDT switch and a servo, but it is also an active component.

  2. By specification, RS-232 interfaces are required to handle short circuits. The MAX232 RS-232 level translator is no exception, but it's old and slow and supports 5V logic levels only, it won't work with 3.3V logic levels. Chips capable of faster communication with smaller charge pump capacitors and 3.3V logic support do exist.

Also you mention about fried PL2303 chip, but that's not an RS-232 interface chip, that's a USB to logic level UART adapter chip. It has no RS-232 or RS-485 or any other interface built-in, which means it is not directly compatible with RS-232 voltage levels and and can't handle them without frying up. Don't connect RS-232 voltages to logic level chips.

\$\endgroup\$
4
  • \$\begingroup\$ Thank you for the answer, I wonder why the PL2303TA chip was directly wired to a RS-232 DB9 connector, maybe as a cost reduction measure by the manufacturer. Can you please also mention some of the newer chips with 3V3 support, for the sake of completeness? I appreciate it \$\endgroup\$ Commented Feb 4, 2022 at 13:58
  • 1
    \$\begingroup\$ I would not know, but having a TTL UART directly on DE-9 makes no sense as it would not be compatible with anything else that has DE-9 with RS-232 levels, the data pin polarity is inverted, nobody could use it for anything. Perhaps it was some cable for some special use? And asking and recommending parts is against site rules so I won't recommend any, besides it will be easy to find RS-232 transceivers. \$\endgroup\$
    – Justme
    Commented Feb 4, 2022 at 14:10
  • \$\begingroup\$ Ah, thanks for the info! I'll be looking into MAX3232, hopefully it's be a good alternative for this task. Thanks again! \$\endgroup\$ Commented Feb 4, 2022 at 15:35
  • \$\begingroup\$ This answer has been accepted as both points were explained (I actually ordered some latching DPDT 5V SMD relays, and it works perfectly). However, I'm going to implement this, as instead of swapping the RX/TX pins, two chips with enable pins could be used. \$\endgroup\$ Commented Feb 16, 2022 at 1:39
3
+50
\$\begingroup\$

For your first question: "I need a way to programmatically reverse the TXD and RXD lines, as there are some boards that are incorrectly wired and need a crossover serial cable to work".

You can use two RS232C bus transceivers with a shutdown control, /SHDN. There are plenty of suitable parts on the market for you that you can select from yourself.

'sel' selects the direction.

Some ICs tri-state their receiver's digital output when /SHDN is asserted, others may drive it HIGH. If you select a part with tri-state outputs, you will not need R1, D1 and D2.

You can drive each /SHDN straight directly from its own MCU GPIO pin, if you have the two GPIO free and are confident of your software reliability. That would remove the inverter.

Note that this circuit puts two RS232C receiver loads on the other board's transmitter. This should not be a problem, as the transmitters are typically capable of driving multiple single loads (see datasheet), but may reduce the very highest speeds that can be reached.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
3
  • 1
    \$\begingroup\$ This is indeed a great idea! I think it's the best design for my requirements \$\endgroup\$ Commented Feb 8, 2022 at 12:13
  • 1
    \$\begingroup\$ MAX3234 seems to be a good candidate for this, I'll look into the datasheet for more details. Once again, I appreciate your solution! \$\endgroup\$ Commented Feb 8, 2022 at 12:32
  • 1
    \$\begingroup\$ + 1 While the 'accepted answer' answered both my questions, I'm actually going to implement your anwer, so once again thank you for the good solution! Also, the bounty goes to this answer - as this is the solution that I'm going for. \$\endgroup\$ Commented Feb 16, 2022 at 1:37
2
\$\begingroup\$

I need a way to programmatically reverse the TXD and RXD lines, as there are some boards that are incorrectly wired and need a crossover Serial cable to work.

I'd consider using multiplexers for this job and, as an example of where this has been proposed elsewhere, the MAX399 is of interest: -

enter image description here

And Maxim even give an application of multiplexing RS232 that can be found here using the MAX399: -

enter image description here

However, as pointed out in comments, the devices above won't handle the full RS-232 range of voltages so, choose a similar multiplexer like the ADG5434: -

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ The appnote circuit might work only because both sides of the mux uses MAX3221, which guarantee that data and supply voltages are below abs max +/-7V. In general case, the mux handles up to +/-8V supplies and muxed signals should be within that range. As RS-232 data voltages might be up to +/- 15V, the mux might not handle it well. \$\endgroup\$
    – Justme
    Commented Feb 14, 2022 at 13:56
  • \$\begingroup\$ @Justme yes, it's a little light on the full RS232 spec but, generally you can get multiplexers that will work up to the full voltage. I only proposed this as an idea of using multiplexers. That is the message to be taken home in my answer. I'll make that clearer. \$\endgroup\$
    – Andy aka
    Commented Feb 14, 2022 at 14:08
  • \$\begingroup\$ + 1 This is the only answer (in my opinion) that actually deals with RS-232 level voltages, also bonus points for highlighting the relative parts of the datasheet (relay replacement, voltage, resistance, and communication) \$\endgroup\$ Commented Feb 16, 2022 at 1:34
2
\$\begingroup\$

The PL2303 datasheet from Prolific Technology Inc. is NOT very prolific about the RS-232 interface analog specs. It is a CMOS chip (thus sensitive to SCR latching with overvoltage) They suggest using 5V to create +/-9V required without any details.

I would presume any voltage exceeding this could fry the chip with a few mA DC drive outside the ESD Schottky protection diodes intended for transients.

Prolific Tech. only mention this on their "RS-232 Like interface"

9.0 USB to RS-232 Application Example
Following is an example of using the PL2303TA as a USB to RS232 converter where a RS232 transceiver (Sipex SP213EHCA) is used to convert the TTL levels serial interface of the PL2303TA to RS232 levels as well as converting the +5V nominal VCC to the ±9V required by RS232.

Recommendations:

Be sure that whatever you design does not exceed the interface specs.
e.g. The MAX3232 is rated for +/-25V input.

I can imagine micro relays should be OK.
It seems to be a common commercial solution.

enter image description here

Image source: NCD - RS-232 4-Channel DPDT Relay Controller with Terminal Block Interface

As always, when in doubt how to design something, work on expanding your interface design specs and budget then flag any discrepancies, otherwise, you are good to go. Then verify prototype against specs for a perfect design. Include all environmental concerns.

CMOS SPDT MUX switches are certainly viable options.

The only questions are ESD latchup and if your environment is well known or unknown and thus your Design Specs. enter image description here

If your environment is well known, then you can quantize the ESD potential value, RS232 Vcc levels and thus IC ESD ratings for 3kV, 6kV etc. and choose Vdd/Vss to exceed Vcc.

For ESD it's harder to predict, but if you have neoprene shoes on an old nylon carpet, you can expect well over > 6kV.

Notice the ESD rating uses the Human Body Model (HBM) and most CMOS manufacturers use a circuit like above to yield a 2 stage attenuation of the initial charge voltage. Give then substrate SCR-mode trigger threshold for latchup and the Not to Exceed table thresholds of 0.3V outside the rails. Will the IC design and the system and worst-case environment result in a failure when tested for ESD. This is what is done during Design Validation Tests (DVT) to test against your chosen Design Specs. Looking at my simulation above, there is a clear probability that a latchup may occur (but not a certainty of failure) as the result exceeds the 0.3V table of max limits. So what will you choose? Hope the tests pass? or design for more margin. Tests are usually 50 ~100 random zaps with a Schaeffer ESD gun to the DUT. enter image description here ref

\$\endgroup\$
1
  • \$\begingroup\$ + 1 Very useful, thank you for checking the PL2303TA as I'm still perplexed as to how this chip actually worked with RS-232 previously. Also, thank you for the tips on designing and then verifying the prototype, much appreciated! \$\endgroup\$ Commented Feb 16, 2022 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.