I want to mux a connector pin that can be RS232 (+- 15V) or ttl data (3.3V) depending on hardware on the other side of the connector. Data speeds up to low MHZ. I hope this diagram helps.
Ah, interesting. And this must be electronically switched for some reason? (The most likely use-case I would think: the hardware interface varies with, well, the hardware, so a hardware solution should be more than sufficient: a switch or jumper. Or just not wiring them to the same connector at all.)
There is a more expedient solution, I think:
RS-232 drivers with disable are available. So you can trivially shut that off by just not enabling it. Good, got that done.
If you had a 3.3V output driver with wide voltage range when disabled, you'd be set, just wire them together and be done.
But how would you do that?
Well, you could construct your own by making a tristate / bus driver gate, using diodes in series with the pull-up and pull-down transistors so that, when off, the transistor body diodes don't clamp the voltage to VDD/GND.
But if we had a device with these already integrated, wouldn't that be handy?
Consider the RS-485 bus driver. Yes, it's a differential pair, but we don't
need to use it that way. Fundamentally, each output is a TTL driver with tri-state and wide output voltage range (the same series-diodes gimmick, or equivalent). It's differential when we use both outputs. But we could use just one, and leave the other open circuit. And we can ignore the receiver if it's a transceiver type chip.
You'll want to check between 3.3 and 5V rated types, and see which ones have suitable outputs. Possibly among the 3.3V ones, there are high-level drivers where instead of a series PN diode, it's back-to-back MOSFETs, so it's actually switching it as such,
Bonus, or liability as the case may be: the drive strength is huge, 100mA+. If this is uncomfortably high, simply put a resistor in series with it. Otherwise... maybe strong drive is useful even? Will certainly drive a long line a hell of a lot harder than RS-232 can. Not that a long line will have anywhere near the noise immunity needed for reliable use...
Thanks Tim. The bilateral switch like 74HC4066 is almost perfect but cant block higher than VCC (6V). Is there another device like bilateral switches that can handle up to 15V? MOSFET transmission gates look right for the job but Im only just learning more about them, hence this post.
There are 15-30V parts, like the DG4xx series, and relatives. e.g.
https://www.digikey.com/short/1hzqz82tNotice these need supplies exceeding the signal range, and you can either provide a +/-15V supply externally, or leech off the charge pump in the RS232 chip most likely -- check the internal diagram, but usually there's +V and -V pins, which normally just have a bypass cap and absolutely nothing else on them, but in fact they're just the not-so-internal supply rails of the device('s output drivers), and as long as you aren't using much, you can tap off some of this just fine. The datasheet may say not to draw current from these pins, which is a concern (you're on your own at that point*), but it's probably fine, for just a switch (very little load current).
*This just means, it'll probably work, but the manufacturer may decide to change the design at some later date, and maybe it's really unhappy with current drawn from these pins, and now your design fails when made with new parts. Or that that's an unsupported configuration and if you ever go to them for support, they'll likely just say "well there's your problem" and not elaborate any further until you "fix" that discrepancy. If you don't care about either of these, and like it's a one-off or whatever, yeah, it doesn't matter.
Alternately, use a super-old-school (ancient, really) driver like SN75155, which requires said supplies (no onboard charge pump), with the analog switch.
There is the matter of transient protection. Since you say it's going to a connector, it's probably liable to ESD discharge, or errant screwdrivers, or cable-discharge events, or etc. You should probably get an analog switch rated for ESD, or add clamping or TVS diodes to the connector and some series resistance between diode and switch to further limit surge current into the switch.
With the alternate en/dis-abled RS-232/485 drivers from above, you should be fine as long as both devices are rated to desired/required ESD levels (usually 8/15kV per IEC 61000-4-2). Possibly a disabled RS-232 driver doesn't appreciate being back-driven by something else; check that it's truly tri-state (allowed voltages while disabled includes the 485 driver's range).
Oh, probably choose a 485 driver with fairly slow slew rate limiting, or controlled by pin and set it nice and slow. Comparable to the 232 driver will be good, to keep EMI down. Don't want a balls-out 50Mbps driver spewing trash across your bench, or cables or wherever this thing is going.
Anyway, using proper devices -- interfaces, or switches, and TVS or other protection as needed -- keeps things consistent and simple and reliable, and means you don't have to solve awkward questions about exceeding Vgs due to transient conditions on the cable, or all the level shifting, that you'd need for the bare MOSFET analog switch circuit. (The most obvious problem with your diagram as shown: the logic is only, say, 5V or whatever, so it can only enhance an N-MOS to about 3V, and above that, it doesn't conduct. And for say -15V on the line, Vgs is now at the maximum 20V with no headroom for transient protection at all, and that thing is toast as soon as someone zaps it. There are many ways we can address that -- which are interesting analog design questions themselves -- but those questions will not help you get a switched driver any time soon, and are better explored for their own curiosity.)
Tim