4
\$\begingroup\$

I was trying to figure out the real reasons why USB signals are converted to RS232 serial. I came to understand that(if I am not wrong) USB is faster and synchronous, whereas the chips are using UART which needs RS232 protocol.

Are all the chips designed for TTL(RS232) serial data communication? Is that the reason USB is never directly used for data communication with integrated circuits?

And one more thing related. When we are uploading sketch(code) to the Arduino micro-controller, we configure the baudrate first i.e. 9600. I think this is the data transfer speed from USB to Arduino. If USB is converted to RS 232 before reaching to the UART of the ATMEGA what is changing? Voltage level? Baudrate? Is the baudrate still 9600 at the UART?

\$\endgroup\$
  • 2
    \$\begingroup\$ Something noone has mentioned in the answers: RS-232 allows far greater distances. \$\endgroup\$ – Simon Richter May 7 '12 at 8:20
5
\$\begingroup\$

TTL and RS232 are mutually exclusive (although you can easily convert from one to the other). I think you are switching around UART and RS232. UART is timings, bit order, numbers of bits, etc., but not voltages. RS232 adds voltages, connectors and pinouts, etc on top of UART. It is one of many physical manifestations of UART communication. TTL is another physical manifestation of the UART protocol, and is often used chip to chip. (There is technically nothing RS232 on the Arduino - I don't think I've ever heard of a micro that actually works with RS232 levels) There are several reasons for using a USB-UART or USB-RS232 chipsets/circuits:

  1. Legacy hardware and entrenched design preferences: Industrial automation and other types of ruggedized electronics like to use RS232 and other tried-and-tested communications methods, especially when speed is often not a serious limitation. RS232/UART are also much easier to electrically isolate than USB for safety when working with line voltage devices.

  2. Direct USB is more involved to implement as a device, and much more involved to implement as a host. If I design an RS232 device, anyone else can design something that works with it quite easily. This is true of both PC hosts and micro-based hosts. RS232 is much simpler in both cases.

  3. You can communicate to some VERY small micros using UART, but the smaller 50% (give or take) of micros don't have USB support. Also, you can hit pause on your debugger while using UART without Windows killing communication on your device :)

As for the Arduino baud rate, it is confusing. This has no effect on the communication between the computer and the USB-UART chip (FTDI, etc). This is not UART communication, but a USB-CDC class to emulate an RS232 (or other UART) serial port over USB. The baud rate takes effect between this chip and the micro, which is actual 5V (TTL/CMOS) UART communication.

| improve this answer | |
\$\endgroup\$
7
\$\begingroup\$

You have found some misinformation out there. You make it sound like USB is always converted to RS-232, and that's USB's only reason for existance. That is completely untrue. USB is a deliberately designed well thought out hardware and low level protocol interface intended for connecting common devices to a general purpose computer.

Before USB, there was serial (RS-232), parallel (Centronic printer), and plugging boards into a bus on the motherboard. All of these had their problems, and USB was motivated in part by their shortcoming.

As the number of RS-232 devices dwindled as USB gain popularity, the number of RS-232 ports was reduced on many computers and dropped altogether on some. Sometimes you still need RS-232 for special devices or circumstances. One way to address this is with a USB to RS-232 converter. You plug it in, and now your computer has a "COM" port it wasn't originally built with.

Most USB instances communicate with devices that do USB directly. There are microcontrollers that come with USB interface hardware built in. You only need to connect the two data lines straight to two pins and the device can communicate over the USB with the right firmware. For example, see PIC 18F2550 and some newer ones too.

So no, not all chips are designed for RS-232. Many microcontrollers have UARTS because these are simple and still useful in embedded applications, but ordinary end user devices hardly ever do RS-232 anymore, with many being USB.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ how would you read or write to the USB port directly? Do uPs come with software for this, or you'd have to figure out the C programming that would do this. (maybe matlab?) \$\endgroup\$ – CyberMen May 7 '12 at 13:28
  • \$\begingroup\$ You don't write to a USB port directly, unless you are at the bottom of the USB protocol stacvk. Yes, you'd have to put that software into the uC, but you will likely use a vendor-provided library instead of figuring it out for yourself. I don't see the relevance of Matlab in thsi context. \$\endgroup\$ – Wouter van Ooijen May 7 '12 at 14:35
2
\$\begingroup\$

I was trying to figure out the real reasons why USB signals are converted to RS232 serial. I came to understand that(if I am not wrong) USB is faster and synchronous, whereas the chips are using UART which needs RS232 protocol.

RS232 is an extremely old standard developed in the (relatively) early days of computing. It has been extended to do many things that it was not intended for and had "extra bits" added to it. While RS232 is properly the standard related to the interface and levels the term has in common use been extended to cover most aspects of the interface, data rate, basic communications protocol, connectors and more.

USB is a much more modern standard. It provides a mans of transferring data over short distances at much higher speeds than RS232 is intended to do.

The main reasons for USB to RS232 converters existing are

  • At one stage almost all "PC's" had a seriel interface - essentially an RS232 interface. Most modern "PCs" no longer RS232 interfaces. Older euqipment with an RS232 interface can often but not always be connected to a PC via an RS232 to USB converter.

  • The processing & complexity overhead in maintaining a "USB stack" - the software interface to a USB port, is substantial and not easily handled by either entry level programmers or by very bottom end equipment. The interface requirements for RS232 are very modest both in code complexity and code size. They are "easy enough" to program for and easily enough accommodated in he most bottom end of processors with even very minimal hardware resources. Even processors which even Olin or Wouter could not implement USB on can happily handle asynchronous serial communications, which is the heart of RS232.

Are all the chips designed for TTL(RS232) serial data communication? Is that the reason USB is never directly used for data communication with integrated circuits?

That question is slightly confused. RS232 is a serial interface by default. Usually levels of logical 1 ~= - 12 volts and logical 0 ~= +12 volts were used. Some variants use logic 1 = +5V and logic 0 = 0 Volts (ie nomonally (only) TTL levels). This makes it easier to use standard logic ICs operating on 5V. Very simple converters can be used to interface with a true RS232 interface in may bu not all cases. This is a marginal method of operation when working with a "true" RS232 interface and needs care and understanding to work well - and may not work at all in some cases. TTL to TTL works well enough for most purposes.

And one more thing related. When we are uploading sketch(code) to the Arduino micro-controller, we configure the baudrate first i.e. 9600. I think this is the data transfer speed from USB to Arduino.

9600 baud was a very standard data rate historically. It is used mainly because it i a compromise between as fast as possible to be useful and slow enough to work most of the time. Much slower (eg 300 bauds) and somewhat faster (115,200 baud [Are you feeling lucky, Punk?)) can be used. Usually data rates scale up or down by factors of 2 eg 300, 600, 1200, 2400, 4800, 9600, ... . The fact that 115,200 is used in some cases and is NOT a power of 2 multiplier tells you something about how lucky you may need to be.

If USB is converted to RS 232 before reaching to the UART of the ATMEGA what is changing? Voltage level? Baudrate? Is the baudrate still 9600 at the UART?

Everything is changing :-).

  • RS232 is an unbalanced voltage feed system relative to ground. +/- 12V or 5/- V or ... .
    USB is a differential voltage system of +/-%V nominally around a 2.5V centre voltage but that is not part of the signalling system.

  • USB is multidrop. RS232 is nominally between 2 items of equipment but this has been extended in some of the non standard standards.

  • RS232 is as dumb as they come. The only control information in the basic standard relates to asynchronous timing, bit length and number of start and stop bits and perhaps parity.
    USB has a wealth (or a scourge) of control information as part of the standard.

  • RS232 data rate is what you set it at. Usually 300, 1200, 8600, ... BUT it could be 237.4 baud if you wished.

    Baud rate is not meaningful at a data transfer level for USB. Data rates are increasing as the standard transmogrifies - initially about 12 Mbps with USB1 and now over 1 GB/s in latest version.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ USB isn't multidrop -- you need a dedicated hub to distribute the bus. \$\endgroup\$ – Simon Richter May 7 '12 at 7:12
  • \$\begingroup\$ For short runs, 115,200 poses no problem if the embedded device's UART can handle it. For some reason, a lot of devices require that when used with a clock at rate F, the baud rate must be evenly divisible into F/16, F/32, F/192, or some other annoying number, so some devices can't produce a very accurate 115,200. Annoying, since there are many ways for simple circuitry to accommodate a full range of baud rates, but even new chip designs often have limited baud rate choices. \$\endgroup\$ – supercat May 7 '12 at 22:25
1
\$\begingroup\$

One consideration is not only that a UART takes less silicon real estate than a USB controller, but it is easier to program.

Your embedded firmware can print something to a serial console very easily just by polling some status register for the availability of space in the FIFO, and storing the byte into the transmit register.

There is no driver required; just a handful of machine instructions.

USB requires a protocol stack just to get to Hello, World.

So, a serial port is definitely nice to have for embedded work.

If you have a chip with a UART on it, then it takes very little board space to expose it. Just a header with a couple of pins (as few as two, if you don't need hardware handshaking) will do.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.