USB General Guidelines

Thread Starter

giovannelucas_

Joined Jan 5, 2023
38
Hello everyone,

Id like to request some help on how to implement USB onto a project. I am currently working on a project that sends analog signals to a computer using a headphone jack and plots it into a graph. Id like to do the same but using a USB port instead as it is standard and easier to use. However, I have no idea of where to start or to look to learn the USB basics. Like how to send analog and digital signals, how to read them and how to use D+ and D- as those signals oscilate between positive and negative values. As well as how to draw it on kicad schematic.

I appreciate any help.

Thank you,

Giovanne Lucas
 

MrChips

Joined Oct 2, 2009
30,518
There are two approaches to using USB,

1) true USB to USB communications
2) UART-to-USB bridge

1) This is not exactly easy and requires an MCU with OTG (on the go) or client or host USB capabilities.

2) This is easier to implement and only requires an MCU with a UART port.
Basically, you send data over the UART port which you connect to a UART-to-USB bridge, such as Silicon Labs CP2102. These modules are readily available.

1688945284914.jpeg

When you plug the adapter into a USB port on a PC, it will register as a COM port which you can identify by going to the Device Manager. You will need to install the device driver from Silicon Labs.

Once the hardware link has been established, you will need software on the PC side to send and receive commands and data.
 

crutschow

Joined Mar 14, 2008
34,073
Since the data is analog, you will also need an A/D converter that can interface to the UART input.

Alternately I would look for an audio or A/D USB interface module or a USB data acquisition module (example).

I don't think you want to try to build a USB interface from scratch.
 
Last edited:

geekoftheweek

Joined Oct 6, 2013
1,183
You only need USB OTG if you are attempting to create a USB host. If you just want something to plug into a computer and communicate with it there are several microcontrollers with USB capabilities built in and basic templates to start from.

USB to UART, USB to I2C, or USB to SPI bridges can flatten the learning curve considerably and get you up and running much quicker (relative to programming a microcontroller). Most chips and modules offer additional I/O pins.
-FT232R (USB to UART) has three digital I/O and well as one digital out only.
-MCP2221 (USB to UART/I2C) has four additional I/O. Three can be set up as analog to digital converters as well as a couple other functions. I have not yet used the ADC feature, but I can say their ADCs in the PIC microcontrollers are fairly accurate and expect the ADC pins of this chip to be similar.
-MCP2210 (USB to SPI) has eight digital I/O available as well as one digital in only.

If you are using Windows there are drivers readily available to download and use to get started. If using Linux the MCP22xx takes a little work due to incomplete drivers and/or drivers not being included with the distribution. I don't know about the FT232R and Linux.

The USB data acquisition modules linked above look interesting to some extent other than digital I/O adds to the cost quickly.

As far as manipulating the D+ and D- directly it can't be done if that is what you were asking.

Edit:
Another consideration... normally audio is sampled at a 44100 times a second and at regular intervals, but your are limited to "audio" signals. Connecting to an external ADC in most cases will be slower as the ADC itself may be slower as well as the timing between samples will be irregular as you are depending on the USB subsystem for communication to start the conversion and retrieve the data. There are several layers of programming for data to pass through. A microcontroller can operate on a fixed interval and store the data to be retrieved. You will have to work out the point in which the microcontroller is working faster than the USB can keep up with. The USB data acquisition modules linked above can help with the timing issues, but that will depend on how much you want to spend.
 
Last edited:

Ian0

Joined Aug 7, 2020
9,531
Hello everyone,

Id like to request some help on how to implement USB onto a project. I am currently working on a project that sends analog signals to a computer using a headphone jack and plots it into a graph. Id like to do the same but using a USB port instead as it is standard and easier to use. However, I have no idea of where to start or to look to learn the USB basics. Like how to send analog and digital signals, how to read them and how to use D+ and D- as those signals oscilate between positive and negative values. As well as how to draw it on kicad schematic.

I appreciate any help.

Thank you,

Giovanne Lucas
Will PCM2904, PCM2906 do the job?
https://www.ti.com/product/PCM2904
 

Ya’akov

Joined Jan 27, 2019
8,975
Welcome to AAC.

Your thread has been moved to Homework Help. THe rules of AAC limit the help that can be provided with coursework related questions to guidance in finding your own solution. Because of this, all such posts must be posted to the Homework Help forum to make their nature clear.

Happy to have you join us here, and good luck with school.

[Moderation]
 

Thread Starter

giovannelucas_

Joined Jan 5, 2023
38
Hi Everyone, I would like to thank everyone for the response. I was able to test UART using a raspberry pi and an arduino, and it worked great, just as I needed it to. Again, thanks for the support. I'll use it in my project before thinking about something more permanent as with the IC suggested above.
 
Top