Arduino and USB, how it works?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
After purchasing an Arduino board (UNO) I decided not to use Arduino IDE as it lacked some features and all libraries are written in C++. I am coding with C. One thing that I really do miss is a serial interface that allowed my Arduino to talk to PC it is connected to.
So far I am familiar with SPI protocol, and thought to use USB-SPI converter chips, but since I already have USB implemented on the board I decided to seek information about how it is done and what USB consist of.
So far I found that it is UART that talks to a chip on Arduino board, and that chip is responsible for communication with PC.
But can somebody explain to me what actually happens on that board? And point me in the right direction please.
arduino usb uart
add a comment |Â
up vote
1
down vote
favorite
After purchasing an Arduino board (UNO) I decided not to use Arduino IDE as it lacked some features and all libraries are written in C++. I am coding with C. One thing that I really do miss is a serial interface that allowed my Arduino to talk to PC it is connected to.
So far I am familiar with SPI protocol, and thought to use USB-SPI converter chips, but since I already have USB implemented on the board I decided to seek information about how it is done and what USB consist of.
So far I found that it is UART that talks to a chip on Arduino board, and that chip is responsible for communication with PC.
But can somebody explain to me what actually happens on that board? And point me in the right direction please.
arduino usb uart
@ScottSeidman Yeah, I got that on the second read through and deleted my comment asking which one.
â Jack B
1 hour ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
After purchasing an Arduino board (UNO) I decided not to use Arduino IDE as it lacked some features and all libraries are written in C++. I am coding with C. One thing that I really do miss is a serial interface that allowed my Arduino to talk to PC it is connected to.
So far I am familiar with SPI protocol, and thought to use USB-SPI converter chips, but since I already have USB implemented on the board I decided to seek information about how it is done and what USB consist of.
So far I found that it is UART that talks to a chip on Arduino board, and that chip is responsible for communication with PC.
But can somebody explain to me what actually happens on that board? And point me in the right direction please.
arduino usb uart
After purchasing an Arduino board (UNO) I decided not to use Arduino IDE as it lacked some features and all libraries are written in C++. I am coding with C. One thing that I really do miss is a serial interface that allowed my Arduino to talk to PC it is connected to.
So far I am familiar with SPI protocol, and thought to use USB-SPI converter chips, but since I already have USB implemented on the board I decided to seek information about how it is done and what USB consist of.
So far I found that it is UART that talks to a chip on Arduino board, and that chip is responsible for communication with PC.
But can somebody explain to me what actually happens on that board? And point me in the right direction please.
arduino usb uart
arduino usb uart
edited 1 hour ago
Michel Keijzers
5,30362357
5,30362357
asked 2 hours ago
Anton Stafeyev
475
475
@ScottSeidman Yeah, I got that on the second read through and deleted my comment asking which one.
â Jack B
1 hour ago
add a comment |Â
@ScottSeidman Yeah, I got that on the second read through and deleted my comment asking which one.
â Jack B
1 hour ago
@ScottSeidman Yeah, I got that on the second read through and deleted my comment asking which one.
â Jack B
1 hour ago
@ScottSeidman Yeah, I got that on the second read through and deleted my comment asking which one.
â Jack B
1 hour ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
On "ordinary" Arduino boards like the Uno, the AVR microcontroller's serial UART is used to communicate with a PC.
Because modern PC's no longer tend to have serial ports, the 9-pin serial connector and level translators found on the earliest Arduino boards have long since been replaced with an on-board USB<>Serial bridge chip. Originally this was an FT2232, but from the Uno it has been a different Atmel MCU such as the ATmega8u2 or 16u2 running a firmware which provides similar functionality.
Essentially, the Arduino's main processor needs to have its hardware UART configured to output debug messages or program data at a chosen baud rate, using logic level asynchronous serial signaling. If the USB port is connected to a computer running appropriate CDC ACM drivers, the USB bridge chip will be commanded to batch the data received and forward it to the host computer, where it can be claimed from serial APIs just as if it came from a traditional serial port.
To communicate in the other direction, a program on the PC sends data through serial APIs, this is batched into USB packets and sent to the bridge chip, which turns it into asynchronous serial data and sends it to the main MCU. A program running on the Arduino itself would need to be written to collect this data form the UART, typically using interrupts (or optionally frequent polling) and then interpret it.
The bootloader used on the Arduino performs both of these operations on its own behalf while running - briefly after each reset, longer if it sees traffic related to a bootloader. But that capability is irrelevant to the main program (aka "sketch") which must re-implement the logic to interact with the UART itself. Worth noting that you can use the Arduino bootloader without using the IDE or writing Arduino-style programs.
If you look around online, you'll probably find many code examples for using the ATmega UART in a C program, vs. a C++ or Arduino one.
Some other Arduino boards work differently; for example the Leonardo uses an ATmega32u4 chip as its main processor, which can directly speak USB. In that case there is no extra bridge needed. But instead of simple UART configuration, the program on the main MCU must now include much more complex logic for dealing with the USB hardware itself, including interrupts that must run fairly frequently. This is much harder to implement in a from-scratch project, though it does mean a lower parts count and a little more flexibility since the USB port can be used for purposes beyond channeling a virtual serial stream.
1
Not FT2232, but FT232R.
â CrossRoads
1 hour ago
add a comment |Â
up vote
1
down vote
As pointed out in another answer, there is a USB to serial port conversion going on on the UNO board.
There is also a bootloader program installed on the microcontroller. The ability to program the UNO microcontroller through the serial port is 100% dependent on a bootloader. If during the programming development, something happens to that bootloader, you need to reload the bootloader on to the chip. This is done with an in circuit serial programmer (ICSP), which plugs in to one of the .1" header connectors on the UNO.
If you're going to develop in the way you describe, I would recommend purchasing and using an ICSP for programming, and just programming the serial port communications directly. The serial to USB conversion will be transparently handled by the on-board hardware.
So your suggestion is: In order not to harm boot-loader program on Arduino i better use another device (aka programmer) to do my serial stuff ?
â Anton Stafeyev
15 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
On "ordinary" Arduino boards like the Uno, the AVR microcontroller's serial UART is used to communicate with a PC.
Because modern PC's no longer tend to have serial ports, the 9-pin serial connector and level translators found on the earliest Arduino boards have long since been replaced with an on-board USB<>Serial bridge chip. Originally this was an FT2232, but from the Uno it has been a different Atmel MCU such as the ATmega8u2 or 16u2 running a firmware which provides similar functionality.
Essentially, the Arduino's main processor needs to have its hardware UART configured to output debug messages or program data at a chosen baud rate, using logic level asynchronous serial signaling. If the USB port is connected to a computer running appropriate CDC ACM drivers, the USB bridge chip will be commanded to batch the data received and forward it to the host computer, where it can be claimed from serial APIs just as if it came from a traditional serial port.
To communicate in the other direction, a program on the PC sends data through serial APIs, this is batched into USB packets and sent to the bridge chip, which turns it into asynchronous serial data and sends it to the main MCU. A program running on the Arduino itself would need to be written to collect this data form the UART, typically using interrupts (or optionally frequent polling) and then interpret it.
The bootloader used on the Arduino performs both of these operations on its own behalf while running - briefly after each reset, longer if it sees traffic related to a bootloader. But that capability is irrelevant to the main program (aka "sketch") which must re-implement the logic to interact with the UART itself. Worth noting that you can use the Arduino bootloader without using the IDE or writing Arduino-style programs.
If you look around online, you'll probably find many code examples for using the ATmega UART in a C program, vs. a C++ or Arduino one.
Some other Arduino boards work differently; for example the Leonardo uses an ATmega32u4 chip as its main processor, which can directly speak USB. In that case there is no extra bridge needed. But instead of simple UART configuration, the program on the main MCU must now include much more complex logic for dealing with the USB hardware itself, including interrupts that must run fairly frequently. This is much harder to implement in a from-scratch project, though it does mean a lower parts count and a little more flexibility since the USB port can be used for purposes beyond channeling a virtual serial stream.
1
Not FT2232, but FT232R.
â CrossRoads
1 hour ago
add a comment |Â
up vote
3
down vote
accepted
On "ordinary" Arduino boards like the Uno, the AVR microcontroller's serial UART is used to communicate with a PC.
Because modern PC's no longer tend to have serial ports, the 9-pin serial connector and level translators found on the earliest Arduino boards have long since been replaced with an on-board USB<>Serial bridge chip. Originally this was an FT2232, but from the Uno it has been a different Atmel MCU such as the ATmega8u2 or 16u2 running a firmware which provides similar functionality.
Essentially, the Arduino's main processor needs to have its hardware UART configured to output debug messages or program data at a chosen baud rate, using logic level asynchronous serial signaling. If the USB port is connected to a computer running appropriate CDC ACM drivers, the USB bridge chip will be commanded to batch the data received and forward it to the host computer, where it can be claimed from serial APIs just as if it came from a traditional serial port.
To communicate in the other direction, a program on the PC sends data through serial APIs, this is batched into USB packets and sent to the bridge chip, which turns it into asynchronous serial data and sends it to the main MCU. A program running on the Arduino itself would need to be written to collect this data form the UART, typically using interrupts (or optionally frequent polling) and then interpret it.
The bootloader used on the Arduino performs both of these operations on its own behalf while running - briefly after each reset, longer if it sees traffic related to a bootloader. But that capability is irrelevant to the main program (aka "sketch") which must re-implement the logic to interact with the UART itself. Worth noting that you can use the Arduino bootloader without using the IDE or writing Arduino-style programs.
If you look around online, you'll probably find many code examples for using the ATmega UART in a C program, vs. a C++ or Arduino one.
Some other Arduino boards work differently; for example the Leonardo uses an ATmega32u4 chip as its main processor, which can directly speak USB. In that case there is no extra bridge needed. But instead of simple UART configuration, the program on the main MCU must now include much more complex logic for dealing with the USB hardware itself, including interrupts that must run fairly frequently. This is much harder to implement in a from-scratch project, though it does mean a lower parts count and a little more flexibility since the USB port can be used for purposes beyond channeling a virtual serial stream.
1
Not FT2232, but FT232R.
â CrossRoads
1 hour ago
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
On "ordinary" Arduino boards like the Uno, the AVR microcontroller's serial UART is used to communicate with a PC.
Because modern PC's no longer tend to have serial ports, the 9-pin serial connector and level translators found on the earliest Arduino boards have long since been replaced with an on-board USB<>Serial bridge chip. Originally this was an FT2232, but from the Uno it has been a different Atmel MCU such as the ATmega8u2 or 16u2 running a firmware which provides similar functionality.
Essentially, the Arduino's main processor needs to have its hardware UART configured to output debug messages or program data at a chosen baud rate, using logic level asynchronous serial signaling. If the USB port is connected to a computer running appropriate CDC ACM drivers, the USB bridge chip will be commanded to batch the data received and forward it to the host computer, where it can be claimed from serial APIs just as if it came from a traditional serial port.
To communicate in the other direction, a program on the PC sends data through serial APIs, this is batched into USB packets and sent to the bridge chip, which turns it into asynchronous serial data and sends it to the main MCU. A program running on the Arduino itself would need to be written to collect this data form the UART, typically using interrupts (or optionally frequent polling) and then interpret it.
The bootloader used on the Arduino performs both of these operations on its own behalf while running - briefly after each reset, longer if it sees traffic related to a bootloader. But that capability is irrelevant to the main program (aka "sketch") which must re-implement the logic to interact with the UART itself. Worth noting that you can use the Arduino bootloader without using the IDE or writing Arduino-style programs.
If you look around online, you'll probably find many code examples for using the ATmega UART in a C program, vs. a C++ or Arduino one.
Some other Arduino boards work differently; for example the Leonardo uses an ATmega32u4 chip as its main processor, which can directly speak USB. In that case there is no extra bridge needed. But instead of simple UART configuration, the program on the main MCU must now include much more complex logic for dealing with the USB hardware itself, including interrupts that must run fairly frequently. This is much harder to implement in a from-scratch project, though it does mean a lower parts count and a little more flexibility since the USB port can be used for purposes beyond channeling a virtual serial stream.
On "ordinary" Arduino boards like the Uno, the AVR microcontroller's serial UART is used to communicate with a PC.
Because modern PC's no longer tend to have serial ports, the 9-pin serial connector and level translators found on the earliest Arduino boards have long since been replaced with an on-board USB<>Serial bridge chip. Originally this was an FT2232, but from the Uno it has been a different Atmel MCU such as the ATmega8u2 or 16u2 running a firmware which provides similar functionality.
Essentially, the Arduino's main processor needs to have its hardware UART configured to output debug messages or program data at a chosen baud rate, using logic level asynchronous serial signaling. If the USB port is connected to a computer running appropriate CDC ACM drivers, the USB bridge chip will be commanded to batch the data received and forward it to the host computer, where it can be claimed from serial APIs just as if it came from a traditional serial port.
To communicate in the other direction, a program on the PC sends data through serial APIs, this is batched into USB packets and sent to the bridge chip, which turns it into asynchronous serial data and sends it to the main MCU. A program running on the Arduino itself would need to be written to collect this data form the UART, typically using interrupts (or optionally frequent polling) and then interpret it.
The bootloader used on the Arduino performs both of these operations on its own behalf while running - briefly after each reset, longer if it sees traffic related to a bootloader. But that capability is irrelevant to the main program (aka "sketch") which must re-implement the logic to interact with the UART itself. Worth noting that you can use the Arduino bootloader without using the IDE or writing Arduino-style programs.
If you look around online, you'll probably find many code examples for using the ATmega UART in a C program, vs. a C++ or Arduino one.
Some other Arduino boards work differently; for example the Leonardo uses an ATmega32u4 chip as its main processor, which can directly speak USB. In that case there is no extra bridge needed. But instead of simple UART configuration, the program on the main MCU must now include much more complex logic for dealing with the USB hardware itself, including interrupts that must run fairly frequently. This is much harder to implement in a from-scratch project, though it does mean a lower parts count and a little more flexibility since the USB port can be used for purposes beyond channeling a virtual serial stream.
answered 1 hour ago
Chris Stratton
21.6k22662
21.6k22662
1
Not FT2232, but FT232R.
â CrossRoads
1 hour ago
add a comment |Â
1
Not FT2232, but FT232R.
â CrossRoads
1 hour ago
1
1
Not FT2232, but FT232R.
â CrossRoads
1 hour ago
Not FT2232, but FT232R.
â CrossRoads
1 hour ago
add a comment |Â
up vote
1
down vote
As pointed out in another answer, there is a USB to serial port conversion going on on the UNO board.
There is also a bootloader program installed on the microcontroller. The ability to program the UNO microcontroller through the serial port is 100% dependent on a bootloader. If during the programming development, something happens to that bootloader, you need to reload the bootloader on to the chip. This is done with an in circuit serial programmer (ICSP), which plugs in to one of the .1" header connectors on the UNO.
If you're going to develop in the way you describe, I would recommend purchasing and using an ICSP for programming, and just programming the serial port communications directly. The serial to USB conversion will be transparently handled by the on-board hardware.
So your suggestion is: In order not to harm boot-loader program on Arduino i better use another device (aka programmer) to do my serial stuff ?
â Anton Stafeyev
15 mins ago
add a comment |Â
up vote
1
down vote
As pointed out in another answer, there is a USB to serial port conversion going on on the UNO board.
There is also a bootloader program installed on the microcontroller. The ability to program the UNO microcontroller through the serial port is 100% dependent on a bootloader. If during the programming development, something happens to that bootloader, you need to reload the bootloader on to the chip. This is done with an in circuit serial programmer (ICSP), which plugs in to one of the .1" header connectors on the UNO.
If you're going to develop in the way you describe, I would recommend purchasing and using an ICSP for programming, and just programming the serial port communications directly. The serial to USB conversion will be transparently handled by the on-board hardware.
So your suggestion is: In order not to harm boot-loader program on Arduino i better use another device (aka programmer) to do my serial stuff ?
â Anton Stafeyev
15 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
As pointed out in another answer, there is a USB to serial port conversion going on on the UNO board.
There is also a bootloader program installed on the microcontroller. The ability to program the UNO microcontroller through the serial port is 100% dependent on a bootloader. If during the programming development, something happens to that bootloader, you need to reload the bootloader on to the chip. This is done with an in circuit serial programmer (ICSP), which plugs in to one of the .1" header connectors on the UNO.
If you're going to develop in the way you describe, I would recommend purchasing and using an ICSP for programming, and just programming the serial port communications directly. The serial to USB conversion will be transparently handled by the on-board hardware.
As pointed out in another answer, there is a USB to serial port conversion going on on the UNO board.
There is also a bootloader program installed on the microcontroller. The ability to program the UNO microcontroller through the serial port is 100% dependent on a bootloader. If during the programming development, something happens to that bootloader, you need to reload the bootloader on to the chip. This is done with an in circuit serial programmer (ICSP), which plugs in to one of the .1" header connectors on the UNO.
If you're going to develop in the way you describe, I would recommend purchasing and using an ICSP for programming, and just programming the serial port communications directly. The serial to USB conversion will be transparently handled by the on-board hardware.
answered 53 mins ago
Scott Seidman
21.9k43283
21.9k43283
So your suggestion is: In order not to harm boot-loader program on Arduino i better use another device (aka programmer) to do my serial stuff ?
â Anton Stafeyev
15 mins ago
add a comment |Â
So your suggestion is: In order not to harm boot-loader program on Arduino i better use another device (aka programmer) to do my serial stuff ?
â Anton Stafeyev
15 mins ago
So your suggestion is: In order not to harm boot-loader program on Arduino i better use another device (aka programmer) to do my serial stuff ?
â Anton Stafeyev
15 mins ago
So your suggestion is: In order not to harm boot-loader program on Arduino i better use another device (aka programmer) to do my serial stuff ?
â Anton Stafeyev
15 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f403374%2farduino-and-usb-how-it-works%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
@ScottSeidman Yeah, I got that on the second read through and deleted my comment asking which one.
â Jack B
1 hour ago