# Analog Potentiometer Output to USB Serial [closed]

I‘m working on a project which has several switches and potentiometers that will be used to control parameters in software via (e.g.) MIDI and would like to know how to get the pots set up without using an Arduino.

The path I started down was to use a (following the MIDI example) 7-bit Flash ADC IC to convert to a digital signal, but am unsure how I could convert this to serial to be sent over USB. Is there some microcontroller which could be programmed to send out MIDI information based on the values received from the ADC?

I‘d like to cut out the Arduino to save space, be able to make a more customised device, and would also like to learn more about how this works. If there‘s a different path (such as using a different type of ADC other than Flash) I should look towards, please point me in the right direction.

• There are plenty of MCU's with both ADCs and USB interfaces, and a lot of good long term reasons for moving away from the Arduino approach; however you might find it simplest to either use a small form factor Arduino or use something like a Teensy-LC which can be programmed in a similar manner. Even some of those ATtiny85 kludges might work, at least to the degree you trust their software USB. – Chris Stratton Jan 2 '19 at 19:36
• That's a weird criterion: without using an Arduino? What if you use an MCU that uses the same chip as an Arduino? What's so exclusive about an Arduino that you can't use something that isn't branded as an Arduino but behaves almost exactly the same? – KingDuken Jan 2 '19 at 19:36
• @KingDuken it‘s not necessarily that I have an issue with Arduino, but rather that I‘d like to know what the Arduino is doing to accomplish this. I‘m guessing I could just use one of the ATMega2560 chips, but how is it converting the information from the ADC to something which can be sent over USB? – som3oneMw Jan 2 '19 at 19:55
• In the arduino there is a microcontroller with a serial port, and a serial to USB translator chip. Microcontrollers which do have on-chip USB do not need a translator chip, but if you program them you have to be aware of USB which is a bit more complex than just Serial. – peufeu Jan 2 '19 at 19:59
• how small do you need? – Jasen Jan 3 '19 at 1:00

The FTDI FT240X is a USB to 8-bit parallel FIFO IC, so you should be able to connect that directly to an 8-bit parallel ADC (other products are available, just search the web for USB GPIO).

This won't appear automatically as a MIDI device when you plug it in to a PC, you will have to do some programming at the PC end to read the data and do what you want to do with it. Also if you want to read multiple pots, you'll either need to add some sort of multiplexing circuit on the parallel side (and more software on the PC end to drive that) or to connect multiple USB-parallel devices using a USB hub (which defeats your object of small size, although you could implement the hub on your own board using a hub IC).

If you want to build something that will appear to the host PC as a MIDI controller then I don't think you can avoid using some sort of micro, and I would guess that the Arduino platform probably has more support than any other (try a web search for arduino USB MIDI). As mentioned in the comments on your question, if size is an issue then you can build your own circuit using an Arduino-compatible micro rather than having to use an existing Arduino board, although some of those are pretty small.

I'm sure that using one micro to implement the USB interface, and connecting that to multiple ADCs if necessary (if you can't just use built-in ADC pins) will be simpler than trying to interface multiple micros to one USB-serial interface. Note that while original Arduinos used a separate USB-serial chip, later designs use a microcontroller with built-in USB support.

A good place to look at are the Microchip microcontroller. You can go from the PIC18 to PIC25 or PIC32 range depending how many pots you need.

The PIC32MK can have up to 42, 12-bit ADC input, so you could connect 42 pots directly on a single 5-10\$ chip.

Then they natively supports USB and Microchip have what they call the Harmony stack which makes it "simple" to configure the USB through a (bit buggy) visual configuration that generates the code for you.

Microchip provides the stack, have cheap programmer and are fairly easy to use, but you will find similar MCU in a lot of other manufacturer.

It's never easy to start from scratch though and be ready to scratch your head quite a bit to get it working, but once you pass the first wall it becomes very valuable knowledge.

You can use the USB Device mode, which is better than serial because you can directly bind the computer side software to the usb PID and VID, and not mess around with COM port settings that changes all the time.

I do not think USB supports natively MIDI format, so you would need to have a computer side software that takes the data from the USB device and transform them into MIDI and forward it where needed.

• There is a USB MIDI device class. It's not clear whether the questioner needs their device to appear as a MIDI controller when connected to a computer though, or if they're OK with it being a serial port, which is probably less work on the microcontroller side. – nekomatic Jan 3 '19 at 16:02
• i‘m going to take a good look at this and probably at least end up experimenting with it, thank you – som3oneMw Jan 4 '19 at 6:46
• You can integrate the pic as MIDI if the class exist, but not sure it's directly supported by the framework and may need some coding. – Damien Jan 4 '19 at 7:21