3

I am trying to understand how an Arduino Uno communicates with a PC and why it does so.

As far as I understand, an Arduino can be programmed to communicate with a PC only via a COM interface. At the same time, an Arduino Uno uses a physical USB interface to connect to a PC and it has a USB-serial converter onboard. So data sent from the board is converted from COM to USB to be transferred to the PC where USB data is converted to COM by a device driver to be read by a COM-port listener.

Why does this COM-related stuff is needed if the Arduino already uses the USB stack for connection? And is the Arduino able to emulate a keyboard and mouse if it has to use interrupts for this, so it has to act like USB device without using COM?

2
  • 1
    You seem to have multiple Arduino products jumbled up together in your mind. Commented Nov 2, 2017 at 19:27
  • @IgnacioVazquez-Abrams can you please provide detailed answer and point me where i am wrong? Commented Nov 2, 2017 at 19:40

1 Answer 1

5

The problem with your understanding is with what "COM" is.

"COMx" is not a physical serial port - it is merely a concept. It is a "serial device" in Windows.

That Serial Device is implemented as a CDC/ACM protocol on USB. It's not "converted" - "COMx" is just the visible interface to the PC's end of the CDC/ACM connection.

The ATMega328P chip (and the ATMega2560) can't talk USB directly. They talk UART. So UART data is sent to another chip that can talk both USB and UART to bridge the two technologies.

So from the PC perspective the chain is:

CDC/ACM Driver ("COMx") => USB => ATMega16U2 => UART => ATMega328P

Boards with an ATMega32U4 chip on them, like the Leonardo, can talk USB directly - so the sequence is much shorter:

CDC/ACM Driver ("COMx") => USB -> ATMega32U4

Again there is no conversion from "COMx" to "USB" since "COM" is just the name given to the exposed end of the CDC/ACM driver.

It can be said that CDC/ACM emulates a serial port over USB. It forms a channel between the CDC/ACM driver ("COMx") and a pair of bulk endpoints in the chip at the other end of the connection.

3
  • Is using ATMega16U2 a real need or just workaround for ATMega328P talking USB? I wonder why Uno has more complex and costly (in my opinion) two chips solution instead of 1 chip like Leonardo. Commented Nov 2, 2017 at 20:58
  • Because it does. That is what the designers designed it to be. If you don't want to use it then don't use it. There is this little thing called "choice". The great thing with the Uno is you can remove the MCU from the board and embed it in your own circuit and still communicate with it (UART is simple, USB is complex). You can't do that with a Leonardo.
    – Majenko
    Commented Nov 2, 2017 at 21:36
  • Of course you can make your own board with the Leonardo's ATmege32u4 or any of the many other USB-enabled MCUs. But they're generally only available in 20-year old surface mount packages, not 40-year old DIPs, so you have to be willing to use moderately modern fabrication methods. Commented Nov 3, 2017 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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