Electrical – Serial line switching through a transistor

arduinomicrocontrollerserialswitchingtransistors

I want to switch my RS-232 TX pin.For this I am using NPN transistor in between the TX line in such a way that the collector terminal is connected to controller side and Emitter to external side. The base is connected to a digital pin.

So, when the digital pin is high, the NPN transistor should close and TX line should send data from controller to external circuitry. But, in this case it was not sending data.

when I connect the serial line directly (without a NPN transistor), it was sending data properly.

I have also make sure that the NPN transistor is not faulty.

So, Why serial line is not switching by a transistor? Or is it not possible to switch a serial line like that?

enter image description here

Best Answer

The circuit configuration as shown won't work. But why?

Note that for a forward biased NPN transistor, the emitter voltage will be equal to the base voltage - 0.6V. That means the emitter voltage won't toggle when the transistor is on or off since it's effectively locked to the base. Even a MOSFET would not work here without some additional non-trivial circuitry.

I would normally suggest that a switch is unnecessary as the UART won't toggle when there is no data to send. But let's assume you really do want to be able to disable the UART output. I'm also going to assume that the signals are 0-VCC UART levels NOT bipolar RS-232 signals.

If you really do need to be able to disable it, here is another way: a different idea

When the base control voltage is high, the transistor turns on which pulls the output signal to GND. In this state no pulses make it out.

When the base voltage is low, the transistor is off and has no effect on the signal. Both R1 and R2 are mandatory.