RS-232 Interface

MartinM57

Moderator
Without careful study, it looks like a variation on the fairly standard circuit for 3.3v<->5v conversion.

Note that it seems to rely on pin 7 being at a +ve voltage - I don't know how often the 'other end' equipment would do this and whether it's always +ve (with a name like Request To Send it sounds like it can be on or off)...and a lot of RS232 cables only connect pins 2, 3 and 5, so that might turn out to be a bit of a stumbling block.
 

Dippy

Moderator
Ditto without careful study/testing it looks OK.

If you have some MOSFETs kicking around then give it a go.

I use a variation with cheaper bipolars which has worked with every PC--PIC (UART) I've tried.
Sadly, I can't upload any image, so I'll try TinyPIC.com



ooh, it seems to have worked :)
 

hippy

Ex-Staff (retired)
In the majority of cases level conversion or buffering shouldn't be necessary; the 22K current limiting resistor on the input pin and direct drive from output pin ( via optional 180R ) is entirely suitable.

Inversion is mainly necessary for taking 'idle high' UART's to 'idle low' inputs of PC's and the like, and for the X1's the ability to invert UART output is on-chip, for X2's both input and output inversion capability is on-chip ( see HSERSETUP command ).

It should also be borne in mind that most MAX232 substitute circuits do not generate fully RS232C compatible outputs and aren't RS232C compliant. Most, IMO, don't offer anything more than the 22K resistor does.

My personal opinion is to use the 22K and direct output connection and a MAX232 or similar where genuine RS232C compatibility is required.
 

moxhamj

New Member
My personal opinion is to use the 22K and direct output connection and a MAX232 or similar where genuine RS232C compatibility is required.

Yes, I'll second that.

Proper RS232 is >3V or <-3V and voltages like 0V are not valid. In the real world, you can get away with 3V and 0V as most RS232 receiver circuits will accept that. Real RS232 might rest at -12V and the data pulse is +12V. But you can get away with resting at 0V and the data pulse is 3V to 5V. So you can output from a picaxe directly and call it RS232. Or 'pseudo RS232' for the purists.

But I'd at least add the 22k current limit resistor and the 180R resistor as hippy says.

For all my circuits I use a D9 and a max232. I have many boards with all sorts of micros on them and I know that anything can connect to anything. Max232s cost 50c and the caps cost 5c each. The main tests I want to apply to true RS232 are:

1) No parasitic powering via the data lines if the chip/board is not powered up.
2) Ability to short any data wire.
3) Ability to connect two outputs together.
4) Ability to put any voltage from -20V to +20V on any data wire and not cause any damage.
5) Ability to wire up a D9 plug with wires in any random way and not do any damage.

I'm not 100% sure, but I think hippy's 22K and 180R passes all these tests. (The one I'm not sure about is the parasitic powering test) So you can do this with two resistors if you like.

Incidentally, the picaxe programming circuit with a 22k and 10k resistor will also work as an input to any 74HC or 74HCT gate.
 

hippy

Ex-Staff (retired)
I'm not 100% sure, but I think hippy's 22K and 180R passes all these tests

Not 100% - The output shorted to 0V would draw 28mA, above official rating for most pins, if shorted to +20V, 111mA, to -20V, 139mA which are both well over. Also a short on an output could drive the port over its rating when adding the current used for other pins. Running the PICAXE other than at 5V will increase / decrease short-circuit currents in fault conditions.

For the Serial Out pin ( at 5V operation ) that 28mA shouldn't be a problem as the output would not be permanently high, just pulsed, and the PICAXE is fairly robust and seems conservatively rated as has been observed. The 180R can probably be increased to 220R or higher if desired.

The interface suggested is used to simplify the circuit and reduce cost, is assumed to be used only when wired correctly, offers reasonable protection against common mistakes ( shorting output to between +V and 0V ) and limited protection against bigger mistakes.

MAX232 and their ilk are designed to be more robust to fault conditions which is one reason they cost more. I have no idea how most MAX232 substitute circuits stand up to fault conditions. You'd have to work that out, ask the designer, or test it - The circuit in Post #1 probably wouldn't stand up to a voltage applied to pin 2, the FET would short that voltage to 0V.
 
Last edited:

Dippy

Moderator
I agree with the above about the simple PICAXE version and the limitations shown. I gave my circuit as an alternative idea.
Though the poster is referring to 5V ...?

To be honest, and without careful selection, I'm not sure how a MOSFET based circuit would behave at 3V.
I ALWAYS take Internet example circuits with a pinch of salt (including my own :) ).

Max232 (and 3V derivatives) give a much more robust proper RS232, however on a low power board they are too hungry without clever switching. I would only ever use them nowadays on high spec boards.

It's horses for courses and my own circuit works on everything thrown at it. Obviously some numpty doing soemthing stupid could break it, so it needs a little common sense, but not a fault or burning PIC reported to date.
 

womai

Senior Member
One problem with the MAX232 I found is that their internal charge pump creates a lot of switching noise that leaks out and can mess up your circuit's noise floor. That can be an issue e.g. whenever you want to take analog readings with the ADC. E.g. my Picaxe scope showed about 2-3 LSBs additional noise (1 LSB @ 8 bit resolution and Vcc=5V corresponds to ~20mV) with the MAX232 compared to the resistor interface.
 

BeanieBots

Moderator
Agree with womai about the noise issue. They are a nightmare when used with analogue signals even if good decoupling is observed.

@Dippy, your posted diagram works on this PC but not on an IT regulated works machine. Probably got a ban on tinypic.com:mad: Just see an icon.
Worth noting for all those that browse during work time on company machines!
 

tjetson

Senior Member
Well, I'd like to thank everyone for their replies. I think I'd be more inclined to use a Max232 chip anyway. This is due mostly to my lack of knowledge about transistors. I liked the look of this circuit because of its low part count, but I think I will just use a Max 232. Thank you again
 
Top