RS232 SMD Shifter Board

What is the chip used in the RS232 SMD Shifter Board, i.e. the NPN/PNP pair, by look at the image looks like its a SOT-23 package, looks neat and would be useful when including the “dirty” translator on-board.

Cheers

Jay

Total agree with the dirty statement - it’s an RS232 trick that works amazingly well.

Digikey : XN04312

Shall I post loose ones on the SFE site?

-Nathan

Thanks Nathan.

Shall I post loose ones on the SFE site?

I for one would definetly use it, but if more folks become aware the ‘dirty’ method, I am sure they would choose this over a MAX3232 variant

Cheers

Jay

Not being much of an analog guy the circuit for this level shifter is a bit confusing… But so it works just fine? Any chance you could try to explain how/why it works?

looks like:

D1 and C1 steal a negative voltage from the rs232 port. The two transistors are just acting as switches, so that when RX is less than Vcc, its transistor turns on and RS-out is pulled towards Vcc; the rest of the time, R2 pulls it towards the negative voltage stored on C1. The other half is doing the same thing in reverse: when the computer brings RS-in positive, it turns on the right-hand transistor, which pulls TX down to ground. The rest of the time, its resistor (R1) is pulling it up to Vcc. The resistors inside U1 keep too much current from flowing through the transistors’ bases, which would happen if those resistors weren’t there.

This makes more sense when you remember that RS232 uses voltage levels which are reversed from usual logic levels — a ‘1’ (MARK) is negative, and a ‘0’ (SPACE) is positive.

I’ve wired up circuits like this out of discretes on a breadboard many times :slight_smile:

I have also tried to understand several versions of such RS232 tricks lately. I find that understanding such seemingly simple analogue circuits is very useful to gain basic analogue skills. The last post summerized it well, but the naming of TX and RX confused me at first.

According to RS232 the pin 2 on the DB-9 connector in this schematic is “Received Data”. So “RS-Out” in this schematic is an output, for data to your PC. This implies that the serial output on your uC must be connected to the RX pin in this circuit. That confused me. Anyway, the left PNP transistor is switched on/off whenever your uC clear/set the RX pin in this circuit.

The neat part of this circuit is the “stealing” of negative voltage from the computers RS232 port. To understand this I dug up the following, partly also mentioned by previous poster.

  • Logic voltages on RS-232 (pin 2 and 3) are inverted. Logic “1” is aprox -2.5V to -15V, and logic “0” is +2.5V to +15V.

  • 0 volt is usually interpreted as negative voltage, or logic “1” by your computer

  • After power-up and in idle state an RS232 line is in its lower voltage state, hence 0V or negative voltage

So, after power-up and before/between transmissions the “Transmit Data” on the DB-9 connector (RS-In) will be negativ, or -15V. This voltage will transfer to C1 through D1 since positive side of C1 is connected to earth. Negative voltage on “RS-In” also keeps the right NPN transistor off, so TX signal is pulled to VCC by default.

Now, one of two things can happen. The PC sends data or the uC sends data.

When PC sends data:

When PC sends logic “0” then “RS-In” is set to high voltage +15V. Because of D1 this does not affect the negative voltage kept on C1. But it turns on the right NPN transistor, and the TX signal is pulled to ground. Since the RX pin on your uC is connected to this TX signal, your uC will correctly read a logic “0”

When the PC sends logic “1” then “RS-In” is set to low voltage -15V. Besides recharging C1 to -15V this turns off the right NPN transistor and the TX signal will be pulled to VCC. Again, since the TX signal is connected to the RX pin on your uC the latter will correctly read a logic 1 (VCC).

When uC sends data:

Now your PC is idle, so the “RS-In” pin is negative, keeping C1 at -15V.

When your uC sends a logic “1” on its TX pin, the RX signal in this circuit becomes VCC, which turns off the left PNP transistor. So “RS-out” is pulled to the negative voltage on C1 (-15V) through R2. This is correctly interpreted as logic “1” by your PC.

When your uC sends logic “0” the RX signal in this circuit is 0V. The left PNP transistor turns on and pulls “RS-Out” to VCC. This is read as logic “0” by your computer.

R2 reduces current when “RS-Out” is pulled to VCC by left transistor. A current of (15+VCC)/10k will flow through R2. With VCC=5V this would only be aprox 2mA. Note that although C1 delivers current through R2 it will continously be recharged from “RS-In” via D1.

One cavaet of this design that doesn’t affect your traditional MAX232 circuit is that the shifter board apparently must be powered by the same power supply that supplies the PIC. I tried using my breadboard’s 5v power supply, like I do in the MAX232 circuit, and for the life of me I couldn’t figure out why it wasn’t working (my PIC is powered by a regulator on it’s PCB.) Finally I jerry-rigged a power connection to my PCB’s regulated supply voltage and presto, it worked!

Ray

I was thinking about how to test out the shifter board with a PIC dev board having an ICSP connector…hmmm…the ICSP connector has power, ground and connections to a couple port pins…and the shifter board needs power, ground and connections to a couple of port pins. Could it be that easy?

Indeed it was. The pins are in the same order, so soldering on a single row socket strip lets me add an RS-232 port by plugging the adapter to the ICSP connector!

Great design, whether planned or not.

Hey Rackley - yea, you have to power the Shifter board with the same voltage as the logic you are connected to. Otherwise the transistors will never fully bias and nothing will work.

Glad the Plug and Go layout worked for you Jon!

Just cause I promised to post the IC on the shifter board - here it is:

http://www.sparkfun.com/commerce/produc … cts_id=588

-Nathan

Are the pinouts for the RS232 shifter schematic avaialble? I fear I’ll likely invert them or something silly :frowning:

-marc

Here is the schematic:-

http://www.sparkfun.com/datasheets/Prot … er-SMD.pdf

I was looking for the pin assignments – I’ve seen the schematic…just wanted to make sure I don’t mess up which pin is which from the transistor pictures.

-marc

The datasheet is on the IC page - sparky posted a link:

http://www.sparkfun.com/datasheets/Comp … N04312.pdf

There is an old TI Application Note slaa096b.pdf about their Bootstrap Loader. The hardware includes a bag of tricks that may be useful elsewhere:

a) Get needed operating power from the RS232 port of a PC (or any Data Terminal Equipment). Specifically, steal +10V from DTR and RTS, -10V from TXD.

b) Use 74AHC14 to convert from RS232 to CMOS logic level.

c) Use low power Op Amp to convert from CMOS to RS232 level. They recommend TL062D, but I cannot find such part and tried a Linear Technology Op Amp instead. It works fine at 9600 b/s.

d) Not only the RS232 conversions are self-powered, there is enough power there to operate the uC (MSP430F in their case) and even to program the Flash.

e) In case the uC already has power, they use an Op Amp to match the voltage of 74AHC14 (and thus its CMOS output level) to the voltage of the uC.