RS-232 vs USB - Page 1
Forum section: electronics / projects

author: mojoe
author_rank: Frequent Contributor
timestamp: February 16, 2024, 07:09:37 pm
content: The below question is mainly focused on devices that have a TTL serial interface, like a GPS receiver.The BG7TBL GPSDO has a 9-pin RS-232 port on the front to let you talk to the GPS receiver inside. However, it is most likely that any of us would be using a serial to USB cable to connect to our computer (not counting an old computer that still has serial ports). Wouldn't it make more sense to eliminate the TTL serial to RS-232 to USB conversions, and go straight TTL serial to USB?I bring this up because this applies to many DIY projects. I'm even thinking about building one of the GPSDO's mentioned on this forum. Are there any advantages to keeping the RS-232 serial port? Is it more immune to ground loops, or being blown up by voltage differentials between equipment? Or how about static discharge? I know that I've blown a USB port this way at least once.One additional factor is that u-blox GPS receivers also have a built-in USB interface, which makes it even easier to use straight USB, eliminating the serial port entirely.

author: tggzzz
author_rank: Super Contributor
timestamp: February 16, 2024, 09:39:33 pm
content: USB requires a lot of software at each end.RS232 doesn't even require any electronics; it can use electromechanical teleprinters/teletypes. You know, the "tty" devices in Unix systemsSubsequently VDUs and other devices used TTL rather than mechanics.I could easily create an RS232 interface and comms from scratch. Life would be too short to consider creating a USB interface from scratchWhether that is an advantage is a separate issue, of course.

author: mojoe
author_rank: Frequent Contributor
timestamp: February 16, 2024, 09:54:34 pm
content: I'm not planning on writing my own USB stack. I'm talking about using an off the shelf TTL-USB adapter, then a standard USB cable to the PC. And, as I said above, u-blox receivers have USB built-in, in addition to the TTL serial. A few resistors and a connector should be enough to go straight USB, instead of the TTL serial interface.Ignoring how it's done, does RS-232 with a MAX 232 chip have any real advantage over a TTL-USB adapter, considering very few computers have serial ports any more, and the RS-232 port would need a serial-USB cable to the computer.It would be simpler to either go TTL serial to USB, or USB to USB, rather than TTL serial to RS-232 to RS-232 to USB to get to the computer. So, are there any downsides to eliminating the extra two RS-232 conversions in the middle?

author: magic
author_rank: Super Contributor
timestamp: February 16, 2024, 10:03:47 pm
content: RS232 has a standard connector, TTL UART does not and it's easier to screw up.I once blew a TTL level GPS receiver module by connecting to a USB UART and accidentally missing the ground connection. The module was powered by a separate wallwart, with some capacitive leakage from mains to its output ground (normal thing) and in absence of ground connection this current forced its way through the module's UART interface somehow.That being said, better protection in the module would have prevented this failure.

author: moffy
author_rank: Super Contributor
timestamp: February 16, 2024, 10:11:34 pm
content: Quote from: mojoe on February 16, 2024, 09:54:34 pmI think you might be misunderstanding the purpose of the RS-232 protocol. First, using the MAX chip would convert the TTL to a +/-12V protocol which is useful for distance communication in noisy environments because of the large voltage swings and noise immunity. Second, any serial TTL needs a protocol so that the data and control can be interpreted, in this case RS-232 is the protocol because it suits the use. If not RS-232, you would need say I2C or I2S, SPI etc. but they suit different requirements, RS-232 only needs a single wire apart from ground for Rx or Tx because it is self clocking. In the case of serial TTL some protocol is necessary and RS-232 is often chosen. Also RS-232 has USB drivers for pretty much all the OSs.

author: tooki
author_rank: Super Contributor
timestamp: February 16, 2024, 10:24:47 pm
content: Quote from: moffy on February 16, 2024, 10:11:34 pmI think it’s fair to assume that OP means UART when they say “TTL”. (And it’s probably whatyoumean when you talk about using RS-232 “protocol” on TTL.)Regardless, a USB-UART bridge chip like FT232, CP2102N, CH340, etc. appears the same to the host computer regardless of whether it’s used directly with TTL voltages or connected to an RS-232 transceiver.

author: langwadt
author_rank: Super Contributor
timestamp: February 16, 2024, 10:38:49 pm
content: Quote from: tooki on February 16, 2024, 10:24:47 pmI see little point in using a rs-232 transceiver these days, it's not the 1990's anymore

author: moffy
author_rank: Super Contributor
timestamp: February 16, 2024, 10:47:17 pm
content: Quote from: tooki on February 16, 2024, 10:24:47 pmSorry, I don't mean 'UART' because RS-232 vs TTL serial, which is undefined, has start bits, stop bits, parity bits and idle levels well defined baud rates with tolerances etc. it is more than just a UART it is a well defined protocol.

author: ejeffrey
author_rank: Super Contributor
timestamp: February 16, 2024, 11:07:48 pm
content: Quote from: magic on February 16, 2024, 10:03:47 pmThis. RS232 is a standard and if you don't know who or what is going to be connecting to your UART, better use RS232 signal levels and a standard transceiver. If you want someone to be able to just buy an off the shelf USB serial adapter and plug it in you want RS232.RS232 is also much better than TTL for operation across cables. They have specified drive strength and slew rate, good noise margin, and they have ESD protection.

author: tggzzz
author_rank: Super Contributor
timestamp: February 16, 2024, 11:28:27 pm
content: How far will the computer be from your equipment,when being used in anger?During development the two will be close, of course.When deployed, will it be within th length restrictions of USB? If not, how is it used?

author: mojoe
author_rank: Frequent Contributor
timestamp: February 16, 2024, 11:31:06 pm
content: Sorry I asked my questions. All I'm getting is off topic, esoteric, engineer nit picking. tooki seems to be the only one who gets it. Let's just forget it and not clutter up the forum with more replies to this topic.

author: tggzzz
author_rank: Super Contributor
timestamp: February 17, 2024, 12:20:00 am
content: Quote from: mojoe on February 16, 2024, 11:31:06 pmAlternatively it means your question was insufficiently constrained.Alternatively it means other people have thought of aspects you haven't considered/understood (yet).Either way, your response is unlikely to make.people want to try to help you in the future.

author: moffy
author_rank: Super Contributor
timestamp: February 17, 2024, 12:25:46 am
content: Quote from: tggzzz on February 17, 2024, 12:20:00 amJust what I was thinking but better stated than I could.

author: robert.rozee
author_rank: Frequent Contributor
timestamp: February 17, 2024, 12:37:22 am
content: mojoe: your question was perfectly valid, but unfortunately most of the responders siply failed to read and/or understand what you originally wrote!TTL-level serial (and indeed, 3v3 level too) is commonly used by many of us who tinker with microcontrollers. in this field, hardly anyone bothers with RS232 transceivers any more. the only thing lacking, however, is a standardized connector or pinouts.most folks will use a 4-pin berg connector that can plug into a 0.1" pin header, simply because these are ubiquitous and the 4th pin is useful for carrying power, but pin order is undefined and there is no polarization - blanking plugs for berg connectors seem to be as rare as hens teeth. i believe the designers of picaxe did try to standardize on 3.5mm stereo plugs/sockets, but this never took off.so what you say makes perfect sense, we just lack any standardizing of connector and pinout to follow.cheers,rob :-)

author: rsjsouza
author_rank: Super Contributor
timestamp: February 17, 2024, 12:52:05 am
content: Quote from: mojoe on February 16, 2024, 07:09:37 pmAn enclosed product being used in an unknown environment can only benefit from using a robust interface such as RS232 instead of fragile connections directly to the main processor (or perhaps via some TTL drivers). Sure, the convenience of the TTL signals is better, but any accidents or overvoltage can potentially cause much more damage.

author: soldar
author_rank: Super Contributor
timestamp: February 17, 2024, 01:19:07 am
content: I have designed and built RS232 interfaces and still use RS232 here and there for convenience and because it is simple and robust. I would not even think of doing the same with USB.

author: Nominal Animal
author_rank: Super Contributor
timestamp: February 17, 2024, 01:23:53 am
content: Quote from: mojoe on February 16, 2024, 07:09:37 pmFor most users, yes. However, it would cost money to redesign the product (even for such a simple change), and it might alienate existing users who buy them in larger quantities –– those that do product integration.The main issue is surprisingly isolation. While full-speed USB 2.0 (12 Mbit/s maximum, about 1Mbytes/sec in practice, sustained) isolators exist and are relatively cheap (see ADuM3160 and similar; even the $10 eBay cheapies are okay if you check their isolated DC-DC converter, because the signal side is trivial), UART/TTL isolators are even cheaper, and isolated RS-232-to-USB interfaces are available off the shelf.Check out myPublic Domain design of ISO6721 UART isolatorfor example: just the IC and two bypass capacitors.To add isolation to RS-232 or UART to USB dongle, you really only need a ISO6721 isolator (1.39€ in singles at Mouser, 0.633€ apiece for a full reel), some bypass capacitors, and optionally a low-power isolated DC-DC supply to power the RS-232 transceiver; say Murata NME1S0505SC, RECOM Power RFM-0505S, and so on (about 1.5€ in singles at Mouser). Full-speed USB 2.0 isolators start at about 9€ in singles, 5€ apiece for a full reel at Mouser. High-speed USB 2.0 isolators (ADuM3166, ISOUSB211, etc.) also require a 24 MHz crystal (or reference clock).When connected to a computer, if the external device is powered from a separate source, the signal grounds may not have the exact same potential, which can lead toground loops, and possibly even destroyed equipment. Isolation is often overlooked, but really useful to avoid problematic situations like that. The downside is that both sides of the isolator need separate supplies. If you have an UART with some 20mA available at the logic level VCC pin, that well suffices even for very high data rates (several Mbaud), otherwise you need an isolated DC-DC converter, which can cause some electromagnetic noise issues (itself being a switch-mode supply device with a high-frequency transformer in it).When the external device is powered by the computer, say from the USB 5V, there is obviously no need for isolation.A secondary reason is that USB is inherently asynchronous, with latencies on the order of a millisecond or more from the device to an userspace application when using USB 2.0 low or full speed (1 Mbit/s or 12 Mbit/s). UART and RS-232 (without hardware handshaking), on the other hand, is full duplex with the only delays being on the receiver side buffering (hardware and software).Quote from: mojoe on February 16, 2024, 07:09:37 pmI would use an USB-to-UART adapter or a CH552G microcontroller (cheap, programmable with open source tools, easy to use) to interface to USB, and remember that you will not be able to receive ahigh-precisionpulse train or even time via USB, because of the inherent latencies in low-speed/full-speed USB; even in the best case with kernel drivers you'll have jitter on the order of one millisecond (one USB low-speed/full-speed frame). With high-speed USB 2.0, that decreases to about 125µs (1/8000 of a second)Quote from: mojoe on February 16, 2024, 07:09:37 pmI only know about the software side, and know nothing about GPSDO per se, or about the signal grounding here.Even if USB-powered, it may be useful to isolate the analog side from the digital side. The isolated DC-DC controller can be chosen to boost the USB 5V to say 12V, which is then inverted and both positive and negative side regulated to produce the low-noise isolated analog rails. For a more complex device, you might even have multiple isolated power domains. There, knowing that isolating logic-level UART (2.5V to 5V) is cheap and easy even at several Mbaud, but isolating USB is much more expensive, is useful.One of my own projects is an analysis probe using a Teensy 4.0 microcontroller, with an isolated high-impedance sampling front-end that contains both low-samplerate 16+-bit ADC, and a high-samplerate 8-bit ADC, plus a pair of analog comparators with reference voltages driven from a DAC connected to an UART. The idea is that when I investigate an appliance (router, media box, etc. running some variant of Linux), I could probe running devices, with a program on my computer telling me the distribution of voltages on that pinandthe exact average voltage, and even autodetect UART settings.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: February 17, 2024, 03:47:22 am
content: Quote from: mojoe on February 16, 2024, 07:09:37 pmSimplicity and portability.(tho in 2024 you really mean TTL-RS-232)The GPS USB ports you mention are all done using USB bridge parts, so it is not a RS-232 'versus' USB question at all.The only real question is on-board or off-board USB Bridge. That decision is made for you, by the GPS module you select.eg Adafruit have new modules with USB on-boardhttps://www.adafruit.com/product/4279

author: Siwastaja
author_rank: Super Contributor
timestamp: February 17, 2024, 11:45:22 am
content: This whole topic is can of worms because of so much mixup in terminology it's not even funny.RS232 is signal level specification. Some people want to put it in volts. Don't be that guy. RS232 isnot+/-12V. It is... RS232. You don't want to copypaste the whole specification every time you talk about it. RS232 is its name. Like you know, if your neighbor's name is Bob Richardson, then your neighbor is Bob Richardson and not "that guy who makes a million per year" when he might not do that. Also if you then call your another neighbor, who is not Bob Richardson, also Bob Richardson, that would be like super confusing. Only call the actual Bob, Bob.Besides signal levels, RS232 standard specifies some other stuff like a few choices of recommended connectors, but in usual discussion the name is used in one of the two ways:1) incorrectly to mean really anything2) correctly to describe the signal levelsTTL is another signal level specification. 99.999% of "TTL serial" are not TTL and have absolutely nothing to do with TTL. Again, don't call your aunt Bob if she's actually Margaret. Don't say USB-TTL adapter when it's actually USB - serial with CMOS levels. Simple.RS232 signal levels are getting exceedingly rare. They offer only minor (maybe one order of magnitude) of signal integrity advantage over 3.3V or 5V CMOS. The transceiver chip offers built-in ESD protection, but ESD protection can be had separately with much less hassle, too. RS422 for physical layer makes more sense for truly long links. RS232 only adds extra components for little gain, and the problem is, it requires others to make their circuits more complicated, too. The standardized D-sub connector is "nice", but it's all but disappeared from everyday use, so actually interfacing using this obsolete connector means users have to build more adapters, which is more work. Logic level UART on pin headers is easier for everyone else except that one guy who happens to have a RS232 adapter with D-SUB connector in his pocket. Or a computer from 1990's.So it's not surprising to see that in 2020's, for simple serial interfaces, it's just 5V or 3.3V CMOS, possibly with some low-cost ESD protection components. This is fine for lab/debug use, and it's also fine for stuff that is permanently wired within enclosure. For something regularly connected and disconnected by users, possibly in harsh environment or long distances, consider RS422 over twisted pair instead, and let RS232 become history.

author: tooki
author_rank: Super Contributor
timestamp: February 17, 2024, 12:26:24 pm
content: Quote from: moffy on February 16, 2024, 10:47:17 pmBut that’s not the point here. OP’s question is why you would use a USB-RS232 adapter, only to then convert RS-232 signal levels to TTL signal levels internally, when you could skip the RS-232 level conversion using the TTL signals of the USB-serial bridge directly.To the host computer, it’s the same USB-serial bridge. It does not see what the voltage levels are and it doesn’t care. To it, it’s a serial port.

author: tooki
author_rank: Super Contributor
timestamp: February 17, 2024, 12:54:57 pm
content: Quote from: Siwastaja on February 17, 2024, 11:45:22 amTrue, but I think your own understanding of it is not quite right, either!Quote from: Siwastaja on February 17, 2024, 11:45:22 amWell no, it’s not just signal levels, though that’s arguably the most defining part of RS-232compared to related RS standards.Quote from: Siwastaja on February 17, 2024, 11:45:22 amIn all fairness it specifies a lot more than signal levels and connector pinouts. It also encompasses baud rates, timing, etc. In this regard ejeffrey is correct, that using RS-232 prevents a lot of configuration problems.Quote from: Siwastaja on February 17, 2024, 11:45:22 amTechnically correct, but we know it’s also very common usage to say “TTL” as shorthand for “5V logic levels of any kind” even though CMOS and TTL aren’t entirely compatible. Since practically everything these days is actually CMOS, this is more of a problem in theory than in practice.Quote from: Siwastaja on February 17, 2024, 11:45:22 amExceedingly rare? Uh, no, they’re still all over the place, even on new gear. RS-232 transceivers are readily available and widely used, as are the D-sub connectors used with them. They’re no longer common on the host PCs, but are common on servers and industrial PCs.Logic level UART on a header is great for tinkering and for connections between boards. But it’s not convenient for connecting standalone devices.You know whatisexceedingly rare, to the point of being essentially nonexistent nowadays? RS-422 signal levels. Why? Because RS-485 signal levels completely encompass RS-422 signal levels, so the transceiver manufacturers simply make the transceivers use RS-485 signal levels, sell them as being for RS-422/485 and leave it up to you to use them as RS-422 (which defines connectors, data rates, etc) or something else. (That is to say: some RS-422 signal levels are not compliant with RS-485 signal levels, but RS-485 signal levels arealwayscompliant with RS-422 signal levels. So you can always use an RS-485 transceiver in place of a true RS-422 transceiver, but not vice versa.)I’d rather see RS-485 used instead of RS-232 when a signal needs to go over longer distances than TTL/CMOS logic levels can handle reliably. But the inconsistent pinouts of RS-485 connectors are a significant handicap.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 17, 2024, 03:10:40 pm
content: Quote from: tooki on February 17, 2024, 12:54:57 pmThatcomparedthing was the whole point and assumed. When one compares UART over RS-232 to UART over other signalling standards, then RS232 adds just voltage level ranges.QuoteCompared to the increasingly usual logic level directly out/in of the very same microcontroller pins that would otherwise drive the transceivers, there is no difference whatsoever in configuration.QuoteThe best kind of correct. Mislabeling CMOS logic level as "TTL" in this context dates back to some Chinese adapter cables during last ten years. Natural everyday language being in constant change is one thing, but in technical context, I continue my quest to correct incorrect and misleading terminology, no matter how futile it may seem. Misuse of LDO is a very similar case. I can change my mind after the misuse has continued for over 50 years and all relevant Wikipedia articles have been rewritten to reflect the new meaning.QuoteI personally write "5V UART" or "3.3V UART" on my designs (documentation / pinouts / PCB/case silk screen). These are shorthand and everybody understand what they mean and them being correct (both technically and practically) does not hurt. Then I don't have to resort to random misused terminology like the sickening "RS232 TTL" which most people also understand but only because they would understand even "Adolf Hitler TX/RX" in that context - because they know the product has a serial port and it's probably this randomly named thing.QuoteYes. I have worked in several fields which do not cover everything, but have seen zero RS-232 ports in last decade or so in new designs. Automation and sensors use RS422/485, CAN, Ethernet, USB, whatever. RS232 was only widely used in different kind of data terminal equipment (computers and their peripherals), terminal interfaces for configuration / text interfaces, configuration interfaces of routers and industrial equipment. Most of this has gone WiFi, USB, Ethernet. Some CAN. Modbus over RS485 stays strong. Probably some modern-day router still has an RS-232 port for legacy convenience, but otherwise what's left is some low-cost / simple maintenance/debug/firmware update interfaces andthatis exactly the thing where I can clearly see the transition from RS232 to transceiver-less 3V3 UART.15 years ago you could see a DB9 on a freaking DVB TV set top box for firmware update no one would ever actually perform! Modern-day equivalent for this is pin headers (possibly unpopulated) on the PCB. I applaud this cost optimization. It was awkward to use when RS232, it's not any more awkward now.But I'm sure you are thinking about some niche what I'm completely missing where RS232 stays popular. Of course you would then use RS232 on that field to maintain compatibility. Then again if this was the case, OP would not be asking. Due to the fact that fewer and fewer people carry around RS232 UART to USB adapter cables, I have no reason to recommend it for new designs for any purpose. For those simple cheap-ass configuration interfaces, or modules which communicate with user microcontroller (like sensors connecting to single-board computers, this is not only for hobby stuff), just logic level UART. For more serious data rates, hot plugging, harsh conditions, or long wiring, then neither logic level UART nor RS232 UART, but something completely different, like Ethernet, CAN or RS422/485.

author: bk81
author_rank: Newbie
timestamp: February 18, 2024, 05:37:15 pm
content: Regarding the original question of whether USB is the way to go for hobby projects, I'd say yes in most cases. I've now done multiple projects that way as a hobbyist. Its very convenient to test/use the board because you can just plug it into your laptop and go. No RS232 dongle, no terminal application, no external power supply.There is a price to be paid though. The firmware complexity goes up a lot. And if you want to use something other than the CDC driver with a terminal application, a custom interface application might be needed as well. Finally, the power supply might be more complex in the case of a 5V supply or if you need a really low noise supply for analog circuits.