Circuit design for multiple UART connections

[Bill Porter] has a tip for designing circuits that have multiple connections to a single microcontroller UART. This stemmed from a review of a friend’s circuit design that used the UART in the project, but also called for an FTDI chip in order to reprogram via USB and a bootloader. Unlike the schematic above, the circuit called for straight connections without any resistors. With that design, a conflict will occur if two devices are connected and attempting to communicate at the same time.

The fix is easy. [Bill] discusses how to prioritize the connection by adding the pair of current limiting resistors seen above. This helps to ensure that damage will not occur, and that the FTDI chip will take precedence. Now the external hardware will not preclude the FTDI chip from accessing and programming via the bootloader. The tutorial is intended for those rolling their own boards out of an Arduino-based prototype, but it will work in any situation where you need multiple connections to a single set of UART pins.

Comments

  1. Jeremy says:

    Nice Tip.

  2. kubik says:

    I’d say that only the RX pin needs this trick, TX should be OK without the resistor.

  3. sneakypoo says:

    @kubik: But you will always manage to get the damn connections mixed up some time. It’s like USB-cables, impossible to plug in the right way on the first try ;)

  4. kubik says:

    @sneakypoo: I always do trial and error when connecting rx/tx from ATMega to my USB/RS232 adapter :)

  5. wernicke says:

    @sneakypoo: You have trouble plugging in USB cables? Really?

  6. kalleguld says:

    I’m with Sneakypoo here. I always need at least two tries to plug in USB plugs.

    @story: Is there a good way to detect collisions? Like hooking RXD to an ADC

  7. cpmike says:

    Nice tip to know, I actually have a use for this.

    @wernicke – have you ever tried plugging in a usb cable to find the connector is 180deg flipped? No?

  8. sneakypoo says:

    @wernicke: You don’t? I think you’re in the minority if you mean to tell me you’ve never managed to turn a USB connector the wrong way before trying to plug it in.

    I hereby give you a challenge! Grab the nearest USB cable, now, reach behind your computer and try to plug it in the right way on the first try. And no peeking! If you did it right grab another cable (or just drop the one you have randomly on the floor) and repeat. If you get it right 10 times in a row (without peeking!) I’ll be flabbergasted.

  9. Munch says:

    @sneakypoo – the trick to doing that right 10 times in a row is to be observant of the symbols on the connector. USB specs state that the USB logo is supposed to be facing upward towards greater human visibility when plugged in, so as long as you can ensure that orientation, you’ll nail it every time.

    @HAD:
    I would like to respond to this bit of the text in the article, though:

    “””With that design, a conflict will occur if two devices are connected and attempting to communicate at the same time.”””

    As stated, this is incorrect. You’ll get contention if you have two devices plugged in and *if even one* tries to communicate. RS-232 has no high-impedance state, and so as soon as one device tries to drive its start bit, the other device (which is assumed to be idle) will create dead short. (Hence the current limiters we see in the schematic.)

    As written, you imply that it’s safe for two devices to be plugged in, so long as only one communicates at a time. I can just smell the magic smoke now.

  10. matt says:

    Also works with the SPI pins. If you want to add an ISP programming header to your AVR system but you’re already using the SPI pins, stick some 1k resistors in series with the MOSI/MISO/SCK lines in the existing SPI bus. (The AVRISP manual actually recommends this.) That way, the programming signals always take priority, and you shouldn’t have bus contention issues.

  11. Bill says:

    @Munch You mean that logo that’s molded into the connector with no visual contrast, and not present at all on many flash drives? A quick survey of computers near me shows that one violates the spec and the others have the connectors mounted vertically so the logo faces to the side.

  12. Matt says:

    Here is another way to do it using two diodes and a resistor the RX pin is held high and the two TX pins can only pull the line low. With this design you can use a much larger resistor (100K) to reduce power consumption and still be able to operate at very high baud rates.

    VCC
    |
    .-.
    | |
    | |10K
    ‘-‘
    TX —–|<—-| |
    |——– RX
    TX —–|<—-|

  13. Alex says:

    RE USB Connectors:
    The “windowed” side (the one with open holes) always faces up, with respect to the jack it’s plugging into. For ports on the front of your machine and on laptops, that means the windowed side faces up, but on motherboard ports on the back of a tower, the windows face towards the greater majority of the machine, which is “up” relative to the motherboard.

    Laptops with ports turned 90 degrees can be confusing, as well as some other strange cases… But for the majority of machines, the “window side faces up” rule holds true.

  14. Jeremy says:

    @Alex This is not a universal rule. I have setup many Dell computers that have the ports 180deg flipped from normal. Front ports are notorious for being flipped upside down as well. I’d say your rule is about 65-75% accurate.

  15. scatterbrained says:

    the RX line could use a pullup so it doesn’t receive junk when nothing is connected… (maybe they have it turned on in the IO)

  16. wernicke says:

    @sneakypoo, @cpmike, @others:
    Wow… this is an easy bunch to steer off topic. (byw, it was meant jokingly. The sarcasm tag got filtered)
    OK.. I admit that for blind ports that I’m unfamiliar with I will line up a USB plug with a socket the wrong way close to half of the time. However, I never manage to plug it in the wrong way, like sneakypoo’s reply seemed to imply.
    As long as I’m OT, my bigger gripe is that some machines (my old dell D620 as an example) have their side ports set too deep for bulky USB plugs like memory sticks to work reliably.

  17. WH says:

    Great timing, I was just thinking to connect a bluetooth transciever to my arduino board but without having to disconnect the FTDI…

  18. Bob Spafford says:

    Face it, the USB “A” (flat) connector is a design by an inexperienced, rather stupid person. The mini “B” isn’t far behind. We all know that “blind” mating these connectors is very nearly impossible. Just plain dumb. In order to elevate the Stupid Competition, the HDMI connector was conceived; it wins easily. The thing that all these connectors share is the requirement of clear vision of the mating process. Given the nature of modern product design, connectors can be found in ANY orientation, ANY location, frequently dark as well.

    Clearly, not overly smart designers mate connectors at their well lit desks, hand holding them in the most optimal position for good vision. If they can mate them in this situation, the design is pronounced to be final and production begins. What a colossal disconnect from the real world!

    It’s pretty obvious that a good connector has a bit of “funnel” to get you in when you’re close. It is circular, scoop proof, and well keyed. That means that all you have to do is rotate until the “lock and key” align and mating occurs. You also need a quality detent that issues tactile feedback when mating is complete, and prevents unintentional disconnect from vibration. (Am I the only one having the detent free HDMI sporadically falling out of their laptop’s connector?) Come on guys, this isn’t rocket science!

    And if it’s really UNIVERSAL Serial Bus, why the plethora of sizes. Logic would suggest that the basic connector be “mini” sized and intelligent design used to create robustness.

    These hot shot engineers need to get out into the real world, and get their hands a bit dirty before they go dashing off designs that only look good in a computer CAD program. What is missing is the willingness to invest in prototype runs, tested in real world apps. AFTER the beta testers declare a design to be a good one, THEN make zillions of them. Ultimately, it’s about elimination of prototyping to improve the company’s economic profile on Wall Street. Maybe money really IS the root of all evil!

  19. Steve C says:

    As someone above mentioned, this method still introduces a contention.

    A much safer method is to use pull up resistors and sink diodes on the signals.

  20. John says:

    Personally, I like the L shaped SATA connector.

    Circular connectors should be burned at the stake. A circular connector gets jammed in at weird angles, pin holes get shredded, the ‘twist until it fits’ technique destroys connectors faster than feeding the stupid thing through a paper shredder.

  21. Munch says:

    I like the idea of a circular connector, actually. A 5 pin phono connector would work nicely (one ground, and two data pairs). The only problem I have with this kind of connector is the plug into which the connector fits into. Based on my experience with 1/8″ phono connectors on sound cards, the contacts wouldn’t last very long.

    Solve that problem, and the phono plug solution really would truly be ideal.

  22. Brian says:

    Or you could use a tri-state buffer and have a selection line…

  23. Brian says:
  24. Bill says:

    O man, When I saw my story had 20 something comments, I feared for the worse. Start reading in and it’s all about USB connections? You guys crack me up!!

    Other suggestions here are good and it just comes down to what people want. For a quick and easy way to allow for FTDI programming without unplugging other stuff, this way works. 5mA is not much power loss and I’m not two worried about holding a RX line, I don’t think many people will be running an AVR with a UART buffer enabled and nothing plugged in.

    And for the questions about two resistors; I suggest a resistor on both in case the ‘usually connected’ device is something other then a serial port, like general IO holding both lines low or high.

    Bill

  25. Bill says:

    BTW,

    @HAD

    You miss-spelled the ‘fdti’ tag. :)

  26. sneakypoo says:

    @Bill: Sorry about that. Didn’t think my little comment would explode like that.

  27. Bill says:

    @sneakypoo

    No worries, I’ll admit I have plugged 3 wire serial headers in backwards before.

  28. signal7 says:

    Here’s the real tip: Learn to read a schematic!

    The arduino has had this ‘solution’ for years now since it has an FTDI chip and available RX/TX lines on the header. All you really had to do was to find an open hardware example that was similar and just go look at the schematic to find the solution.

    Don’t waste time trying to reinvent the wheel. Use the resources that are already out there.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 91,851 other followers