Tx to Tx, is UART open collector?

hi,

I need to route two Tx lines, from two MCU’s, to one Rx input on a third MCU.

Normally I use an opto-isolator when connecting Tx to Rx. Now I want to add another Tx line (Tx-B) directly to the Rx input. The two Tx lines will never transmit data simultaneously. Would the attached schematic work?

thanks

UART-Tx-to-Tx-Axiom25.jpg

The TX signal is a solid and strong 0V or 5V, or 3.3V (that depends on the device that outputs the TX). You can combine them by converting them both to a open collector signal and create a pullup signal. Therefor you must use resistors or optocouplers or perhaps diodes or a logic gate or a transistor to combine them.

That optocoupler inverts the TX-A signal.

Peter_n: That optocoupler inverts the TX-A signal.

nope. When the Cathode of the LED (Tx line) is high the NPN transistor is closed, so the level on Rx is also high, and vise-verse Tx-A low = Rx low.

So as far as I see it, it's either the NPN in the Opto-coupler than can pull Rx low or the Tx-B line, i.e. when Tx-B is Logic 1 it conducts from Vcc through R1 and R3 to ground, thereby Rx see's a low which is Logic 1 (UART is inverted logic). Unless I'm missing something.

p.s. perhaps it would be good idea to add a diode between R3 and Tx-B: R3 - anode - cathode - Tx-B, so that when the NPN is open, Tx-B will not source power to ground, but I'm not sure, maybe this is not a problem and a diode is not necessary.

You must specify the "idle" state of the link.

The circuit you give is missing important parts, so one cannot say much about it until the full details are specified.

You need to explain why you are using an opto-coupler.

Paul__B: You must specify the "idle" state of the link.

You mean what level Tx-A has when no data is transmitted? If so then it's high.

I have the opto-coupler in the circuit because MIDI equipment uses them on inputs.

The UART output, when in use, is connected to an otherwise normal I/O pin, so it is not open collector.

OK, it took me a while to verify that the idle state of MIDI is in fact, OFF.

So you have R1 of about 4k7 to pull the Rx input HIGH. You want a diode instead where you illustrate R3, cathode to the Tx-B so that it definitively pulls the line LOW when Tx-B goes LOW.

I am not sure where you got R2 from, it presumably sets a sensitivity threshold for the opto-coupler.

Paul__B: OK, it took me a while to verify that the idle state of MIDI is in fact, OFF.

hmm, I guess I don't understand what idle state means. I thought it means when there is no data being transmitted, which afaik is when Tx is constantly high, i.e. after a stop and before a start bit.

So you have R1 of about 4k7 to pull the Rx input HIGH. You want a diode instead where you illustrate R3, cathode to the Tx-B so that it definitively pulls the line LOW when Tx-B goes LOW.

Good, so I had the right idea.

I am not sure where you got R2 from, it presumably sets a sensitivity threshold for the opto-coupler.

R2 is there to improve the fall time of the photo transistor. MIDI devices usually use 6n138/6n139 opto-couplers, the 4n25/4n35 are slower and don't produce very good wave forms at MIDI baud 31250.

So I guess multiple Tx lines can be connected to an Rx input through diodes, as long as only one Tx line is active at any given time?

You could OR the two inputs if you don't want to short them together. (with diodes). Why do you want to do this ?

raschemmel: Why do you want to do this ?

I need it for some device hacking, a MIDI keyboard in my case.

I think there are some other options available to you for the arduino. I’m MIDI challenged so I won’t be any help to you but there are many people who have done stuff with MIDI who might have some advice for you.
I would change your post title in your original post to decribe your MIDI application to attract the MIDI experienced members.

I would change your post title in your original post to decribe your MIDI application to attract the MIDI experienced members.

oh, there in need for that anymore, I have the solution, a diode as described a few topics above.