Two TX to one RX - Page 1
Forum section: electronics / general

author: Rick Law
author_rank: Super Contributor
timestamp: February 09, 2015, 07:16:16 am
content: Two TX to one RX - connected full time but only one TX in use at a timeMy goal is to connect another RS232-TTL device (such as a Bluetooth or say CH340) to an Arduino UNO (16U2) or NANO (FT232RL) without having to rewrite the program. They won’t be both transmitting at the same time, but they are wired-in full time.One TX to two RX is no problem, having two TTL-RXD inputs listening to a single TTL-TXD output works in theory and in practice. So both the second RS232 device (CH340 or Bluetooth or FT232RL) AND the build-in (16U2 or FT232RL) should be able to listen.What I am not sure is the RXD. In this case, I have two TTL-TXD outputs into one RXD input to the ATMEGA328.I know that if the TXD output goes hi-impedance when not transmitting, the other device's TXD can transmit and it should works in theory as well as in practice. But I can't find any info on either FT232RL's datasheet or 16U2's datasheet on if TXD are tri-state or not.Since this info is not in either datasheet, I am thinking it may be part of a common practice or perhaps a standard that TXD be tri-state (or not). But I don’t know what it is…Anyone has info on that?By the way, I know I can wire up my FT232RL-TTL as the foreign RS232 and try. But, I want to make sure it is suppose work in theory - instead of just luck and happen to work in this particular combination of fiddling.Thanks for your inputRick

author: Paul Moir
author_rank: Frequent Contributor
timestamp: February 09, 2015, 07:43:22 am
content: Normally they stay on line. There are a few drivers that can shut down, which will tristate their outputs but they're rare.Some discussion here:https://www.eevblog.com/forum/beginners/rs232-switch-looking-for-the-right-search-term/(Note that's in the beginner's forum. There's a lot of unworkable stuff by the OP. Just skim over that.)

author: jmsc_02
author_rank: Regular Contributor
timestamp: February 09, 2015, 07:51:48 am
content: the datasheetvof tye ft232r comments that txd are tri-stated when the chip is in reset status.

author: langwadt
author_rank: Super Contributor
timestamp: February 09, 2015, 09:03:21 am
content: looks like there a 1K resistors on the arduiono so just add a diode to the extra Tx so it can only pull down

author: SL4P
author_rank: Super Contributor
timestamp: February 09, 2015, 09:52:55 am
content: I've done this in the past for infrastructure grade projects - using multiple modems in a polled arrangement - so only one 'replying' at any given time. Tx outbound was 'paralleled' to all destinations, but only the correctly addressed remote site would talk back...Solution was passive, simple and extremely reliable.Schottky diodes (low LossVF) used as steering/isolation on the RX lines. multiple 'in', single 'out'.

author: suicidaleggroll
author_rank: Super Contributor
timestamp: February 09, 2015, 06:23:15 pm
content: You could also stick a couple of tri-state buffers on the lines. That way both devices can talk at the same time without interference/corruption, and you just choose which one you want to listen to.

author: Rick Law
author_rank: Super Contributor
timestamp: February 10, 2015, 12:21:17 am
content: Quote from: SL4P on February 09, 2015, 09:52:55 amQuote from: suicidaleggroll on February 09, 2015, 06:23:15 pmMy original thought was to implement this project using a pre-made Arduino UNO or Nano. Taking that approach, I would not be able insert anything between the 16U2 (or the FT232RL) to the ATMEGA.I will fiddle a little to see if I can get that to work with diode.Thanks for all the advice and suggestions!Rick

author: dannyf
author_rank: Super Contributor
timestamp: February 10, 2015, 01:23:12 am
content: I would implement some kind of usage signaling so a pending transmitter knows if the bus is being utilized by someone else.One way to do it is to use a pull-up resistor. Any transmitter would test if that node is low (=being used). If it is not low, it would pull it down and then start transmission; Upon the end of the transmission, that node is released.That's not exactly 100% collision free but will cut it down significantly.To further cut it down, you can listen to the bus for a period of time before transmission; if the bus was indeed being used, you wait a random period of time before re-testing it.

author: tggzzz
author_rank: Super Contributor
timestamp: February 10, 2015, 10:28:08 am
content: If we assume that you can physically connect two tx outputs without destroying them, you still have at least two other issues that will need to be solved at a higher level. And that may conflict with "...without having to rewrite the program".The first is how does the rx know which tx has sent a message. There are many pre-existing solutions ranging from different forms of polling/handshaking to encoding the source within the message.The second is how to ensure the two tx don't try to transmit simultaneously. There are many pre-existing solutions ranging from ensuring the two tx have a common time to some form of collision detection (think ethernet).

author: Rick Law
author_rank: Super Contributor
timestamp: February 12, 2015, 06:17:52 am
content: Ensuring just one TX transmit is not a problem the way I had envisioned this design to operate. But I think I was just goofy in thinking to hook up two TX to one RX...I finally freed up my FT232RL and do a check and experiment. The TX do stay HIGH even while not transmitting. If I am to use stock Arduino UNO or NANO, unless I cut a trace or something, hooking two TTL out to a single TTL in doesn't look workable.I will have to rethink this...Thanks for the input!

author: SL4P
author_rank: Super Contributor
timestamp: February 12, 2015, 06:51:38 am
content: Quote from: Rick Law on February 12, 2015, 06:17:52 amYou don't like the diode steering proposal...? It worked for Telstra.

author: David_AVD
author_rank: Super Contributor
timestamp: February 12, 2015, 08:07:46 am
content: I've used the diode (one for each slave transmitter) & resistor (as a pullup on the master receive) trick on a product that had lots of slave micros that needed to reply back to the master micro. Worked well and super simple to implement.

author: Rick Law
author_rank: Super Contributor
timestamp: February 12, 2015, 09:13:23 am
content: Quote from: SL4P on February 12, 2015, 06:51:38 amQuote from: David_AVD on February 12, 2015, 08:07:46 amMay be I misunderstood.The diode would be required byboth Tx senders, right? That would require cutting a trace on a stock Arduino Uno's 16U2 or the Nano's FT232RL/CH340G, so that the on-board Tx and my add-on Tx can both have a diode. Otherwise, the add-on Tx would be trying to pull the Rx low while the on-board Tx stays high and try to pull the same Rx high. I don't think that would work if my add-on Tx alone has the diode.I see that for both Nano and Uno schematic that there is a 1K resistor for the Tx from USB. I am thinking I may just try to overwhelm it by connecting the add-on Tx with a lower resistor or no resistor at all. Here the diode may make the difference. But I am not sure if that is a reliable way of doing it.I know this would be easily accomplished if I don't use a stock Uno or Nano. It would be rather easy to put an ATMEGA328p and have it act like an UNO. I have two like that. But that would not accomplish my goal.I have a reason for basing it on a stock Uno/Nano- it is intended to be a gift to someone drive his/her interest; butI expect (hope) that it would be taken apart and convertedto something else. That parts used for this would really be - shall we say "seeding the initial part-stock". I want to use minimal part to show how easy it is. A home-grown "Uno" would not accomplish the same thing. It would be far less likely to be disassembled and modified.(I don't want to disclose whom (or relationship) or even he or she in case he/she stumbles into this via Google search or something. This whole idea that may not fly.)

author: David_AVD
author_rank: Super Contributor
timestamp: February 12, 2015, 11:06:42 am
content: Yes, you need to add the diode in series with each transmit line. Whether that involves cutting tracks I've leave up to you.

author: dannyf
author_rank: Super Contributor
timestamp: February 12, 2015, 11:59:36 am
content: QuoteThose diodes form a crude OR gate.Most (all?) decent usart modules have the pins in open drain, so they are naturally "ORed" when you connect them directly.

author: langwadt
author_rank: Super Contributor
timestamp: February 12, 2015, 03:30:30 pm
content: Quote from: dannyf on February 12, 2015, 11:59:36 amcan you name a few modules that have open drain Tx? I've never seen any

author: langwadt
author_rank: Super Contributor
timestamp: February 12, 2015, 03:39:16 pm
content: Quote from: Rick Law on February 12, 2015, 09:13:23 amthe 1k resistor means you can do it with one diode and no cuttingwhen the add-on is idle(tx = high) the diode is reverse biased so everything works like normalwhen the on-board is idle (tx = high) the 1K resistor works as a pull up and the add-on can pull low via the diode

author: David_AVD
author_rank: Super Contributor
timestamp: February 12, 2015, 08:40:19 pm
content: Quote from: dannyf on February 12, 2015, 11:59:36 amSome micros may have the capability of running the TX pin as open drain, but as far as I know none of them do that by default. If they did most regular applications wouldn't work correctly.You'd have to check the datasheet for the micro you're using to see if it really can do open drain on the TX pin when assigned to the USART.

author: Rick Law
author_rank: Super Contributor
timestamp: February 13, 2015, 02:40:08 am
content: Quote from: David_AVD on February 12, 2015, 08:40:19 pmQuote from: langwadt on February 12, 2015, 03:39:16 pmGreat to hear an "acceptable" approach. As something to drive interest for a kid, I hate to do something way to "patch-together-ish". And as a gift, I sure hate to cut the board trace making the recipient less likely to treat is as a board ready for experimenting.Also, I want to do it more by-the-book with this one. Normally, I would just tinker and tinker to make it work; this one, I want the techniques/solutions to be more conventional.Thanks guys - I have many great advice/idea to follow up on to solve this.Rick