RS232 Nullmodem 3.3V - Page 1
Forum section: electronics / projects

author: luca0074
author_rank: Contributor
timestamp: May 25, 2021, 12:07:42 pm
content: Hello allI am currently designing a handheld-device that communicates via RS232 with different target systems.Both a straight and a crossed connection must be possible. (Nullmodem) Handshake is not required.The current solution is to switch the TX&RX lines with a relay.However, due to batterylife and reliability considerations, I would like to have an integrated solution.I have already looked at various ICs from Maxim Integrated.TheMAX214is exactly the driver I want, but unfortunately it is not available with 3.3V.TheMaxim Integratet Appnotes 654suggest the use of DCE/DTE ICs.I have looked at theMAX3170andMAX13173E, but I am not sure if I understand the data sheets correctly.Can i use the MAX13173E like so?:Pin MAX13173EConfiguration 1Configuration 2M211M111M000DCE/DTE01T2INTX MicroprocessorTX MicroprocessorT2OUTATX DeviceRX DeviceR2OUTRX MicroprocessorRX MicroprocessorR2INARX DeviceTX Device(i dont think this will work)Are there any ICs that can simply cross out the two lines and run at 3.3V?Should i integrate a 5V step-up driver, so that i can use the MAX214?Can you think of any other solutions to my problem?Thanks in advance for your answers!Best regards, Luca

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 25, 2021, 12:44:26 pm
content: A latching relay can save on power consumption, though may still be vulnerable to shock/vibration.How about using something like this,https://www.ti.com/lit/ds/symlink/sn65c3223e.pdfwith the outputs cross connected, enabling one at a time?Analog switches aren't a great idea on com lines that may have transient as well as elevated voltages. I mean, you can put in a +/-15V supply just to run a mux, and you can get analog switches with comparable ESD ratings, but, what a pain...Maybe there's a more clever solution with discrete switches (including depletion MOS or JFETs?), or maybe ICs are okay anyway (just let the body diodes backfeed the supplies, let them float up?), I'd have to think about it.There's also SSRs, but that's no better than a regular relay as the LED requires continuous current to keep switched on.Tim

author: NiHaoMike
author_rank: Super Contributor
timestamp: May 25, 2021, 01:53:18 pm
content: The receive side is easy, just put a receiver on each one and mux the low level signal, possibly inside the microcontroller if it supports flexible pin mapping like many do nowadays. The transmit side is harder, perhaps you could have a single transmitter connected to both lines through resistors (the value would then be a compromise between power consumption and speed) or separate transmitters that can be tristated to only enable the one you want.

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 25, 2021, 04:45:24 pm
content: I'd use two transceivers, say MAX3221's (with explicit enable/poweroff pins), with their outputs cross-connected. Only one of the transceivers is enabled at any time (by code on the MCU):Blue are the RS-232 RX/TX lines, green are outputs from the microcontroller, and yellowish-khaki are inputs to the microcontroller. The caps are according to the datasheet application recommendation for 3.3V operation.According to thedatasheet, when disabled, the current draw should be ~ 2µA total; max. 20µA total if automatic power down is used. Automatic power down should allow you to detect when the device is connected to something, and possibly which pin order is used, as the other side should pull its TX high; then, only one of the MAX3221's should pull its /INVALID line high (indicating valid RS-232 idle detected). That might need a large-ish resistor to ground from the RS-232 RX/TX lines, though; maybe a couple of hundred k, so that when nothing is connected, the RS-232 RX/TX lines would be close to 0V.Note: I am not an EE, just an uncle bumblefuck hobbyist. I am hoping that one of the experienced members here would comment whether this looks sane; Ithinkit should work, but I haven't checked this in practice.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 25, 2021, 09:30:18 pm
content: Ah yep, sounds like the 3223 I posted earlier. Or, probably, the off-by-two is just variants in a family, YMMV, and the MAX and SN65C are just alternate sources of a functionally identical part.I'd have to think about the FORCEON/OFF/INVALID logic a bit, it might not be something you can leave alone by itself. The detect function monitors line input voltages; if both are looking at each other, they'll simply be a latch, detecting each other once triggered, or neither when disconnected and shorted out.It should be fine to leave them both disabled by default, and poll one then the other to check if the line's gone active -- breaking the loop, at the expense of a little busy work by the MCU.Tim

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 25, 2021, 11:05:05 pm
content: Quote from: T3sl4co1l on May 25, 2021, 09:30:18 pmAlmost: the 3223 has two receivers and two transmitters, whereas the 3221 has just one of each. (Agreed wrt. MAX and SN65C.)When /OFF is low, DOUT is high impedance. Regardless of the /OFF, /EN, or ON states, /INVALID is low if RIN is floating, says the datasheet.So, if one has /OFF1=/OFF2=ON1=ON2=low, /EN1=/EN2=high, each chip consumes 1µA to 10µA. /INVALID1 and /INVALID2 are both high when nothing is connected to the RS-232 lines; the correct one of them to be used should have /INVALID low when a device is connected.For active operation, either /OFF1=/EN2=high and /OFF2=/EN1=low (to enable the first transceiver), or /OFF1=/EN2=low and /OFF1=/EN1=high (to enable the second transceiver).So, the microcontroller really only needs 8 pins (3 inputs and 5 outputs): RX, /INVALID1, /INVALID2, TX, /EN1, /EN2, /OFF1, and /OFF2, with ON1 and ON2 tied to ground.There are only three useful states:/EN1 /EN2 /OFF1 /OFF2 StateHigh High Low Low Powered offLow High High Low First '3221 in useHigh Low Low High Second '3221 in useBecause the transceiver outputs are crossed, /INVALID1 and /INVALID2 are only meaningful in the powered off state.Then, /INVALID1 is high if RIN1 is between -0.3V and +0.3V or is floating, low if RIN1 is below -2.7V or above +2.7V. Similarly for /INVALID2 and RIN2.

author: NiHaoMike
author_rank: Super Contributor
timestamp: May 26, 2021, 12:08:59 am
content: What about connect each transmitter to each line through small MOSFETs? Would then need a small level shifter to drive those MOSFETs, but maybe some clever circuit can derive it from the signal itself.

author: luca0074
author_rank: Contributor
timestamp: May 26, 2021, 03:31:18 pm
content: first of all:thank you all for your time!!!Quote from: T3sl4co1l on May 25, 2021, 12:44:26 pmIt already is a latching relais. the shock/vibration/reliability issues are more in focus.Quote from: T3sl4co1l on May 25, 2021, 12:44:26 pmi think i found withMAX14777a part who could be used, as it generates its +/-15V supply by itself.A1/A3: MCU_TXA2/A4: MCU_RXB1/B4: Target_RXTXB2/B3: Target_TXRXBut as you said, it has only +-2kV ESD protection...i also foundMaxim Integrated Appnote 588where they are muxing RS232.COMA: MCU_TXCOMB: MCU_RXNO1A/NO2B: Target_RXTXNO1B/NO2A: Target_TXRXbut i dont know how this should work, as in the Datasheet from theMAX399is stated:Analog Signal Range= V- / V+. But when driving the MAX399 from the MAX3221, this would only be +-5.5V?Quote from: Nominal Animal on May 25, 2021, 11:05:05 pmas i dont need the powered off state, i think i can use just one pin from the mcu for the mode (with an inverter).i will try if this will work.

author: madires
author_rank: Super Contributor
timestamp: May 26, 2021, 03:55:54 pm
content: What about a classic sliding switch? Some old Ethernet switches used this for the uplink port.

author: luca0074
author_rank: Contributor
timestamp: May 26, 2021, 04:03:55 pm
content: Quote from: madires on May 26, 2021, 03:55:54 pmI would like to load the RS232 configuration automatically (user putting the device-id via softkeypad in) so that no further intervention by the user is necessary.also it is a waterproof casing.

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 26, 2021, 04:17:22 pm
content: Quote from: luca0074 on May 26, 2021, 03:31:18 pmI'm worried about the transition; I'd personally use two pins and two inverters (/OFF1=!/EN1, /OFF2=!/EN2, via sayNexperia 74LVC2G04), and always switch through the both-off state. Aside from that, I used theTI MAX3221 datasheetfor the info.(As I was looking at Mouser for typical chips to suggest, I did encounterONSemi NL7SZ57multifunction logic gates which seem pretty darn nifty for circuits where one needs oddball logic for a single pin here and there; allowing for a simpler BOM. I didn't know such chips existed; that's how hobbyist I am.)I'd be very interested to know whether the two-'3221 configuration can autodetect the RXTX orientation; I guess it depends on whether RS-232 receivers pull the RX above +2.7V or below -2.7V. I believe not, but have no proof/reason for that. If they do leave RX near ground, then adding the two input pins for detecting the correct orientation would make a LOT of sense to me. Then, the two '3221s could be in powered off state (also saving power, consuming only ~ 20µA total) whenever data is not being transmitted; and the two /INVALID inputs would tell if/how an RS-232 is connected. If both are high, nothing is connected; if both are low, something is connected but the RX/TX orientation is unknown; and when only one is low, that one is the correct orientation (that '3221 should be used). As an user, I'd like the ability to let the software do the right thing – as long as I could override it, if it doesn't work right. So, in software: "Off, RX/TX, TX/RX, Autodetect", with Autodetect complaining if both /INVALID lines are low. That way you need minimal user interaction for most cases.

author: bingo600
author_rank: Super Contributor
timestamp: May 26, 2021, 08:12:59 pm
content: I'm quite sure i have Seen Atmel use a 74HC153 for "Mux'ing" several RS232 sources to the Uart/Bingo

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 26, 2021, 08:20:34 pm
content: Quote from: luca0074 on May 26, 2021, 03:31:18 pmPretty slick, if you don't mind adding the ESD protection. A couple diode arrays and resistors will do the job. But that's still added parts, not the simplest possible solution.Also if you don't mind the Maxim effect: who knows how long they'll keep it in production...QuoteYes-- also, the supply can be tapped off the 232 chip itself, as the V+/V- pins have those boosted voltages available. As long as you don't draw much current from them (a couple mA should be fine -- more than enough for a mux).Trick is, it only works for TX, which unless it's been cross-connected (which, heh, well...), is just that. RX could be anything, up to whatever the allowed maximum is for RS-232, I forget exactly -- I think +/-15V is the normal level, and allowable is somewhat more than that, not counting transients?So, for proper compatibility with any compliant transmitter, you'd have to have much higher supplies on the receiver mux. So it's kind of a non-starter, alas. (But the other one would still be okay, with its +/-15V internal rails.)In contrast, 3 to 5V is the nominal minimum, which is why all these transmitters get away with so little (i.e., a doubler charge pump from 3.3V supply --> ~6V output). As long as you don't need it over a huge distance, it's good enough.Tim