34
\$\begingroup\$

How does one go about building an interface for a USB device that allows interfacing pots, linear/log tapers, and momentary/toggle switches to a computer?

If someone could give me a high-level description, I would appreciate it. I can read spec sheets, so understanding details is not a problem as long as I know where to find the sheets.

\$\endgroup\$
1
  • \$\begingroup\$ If anyone still uses this thread, other encoders include "Zero Delay Encoder" (no analog axis), and boards sold by Leo Bodnar and Desktop Aviator. \$\endgroup\$ – Galaxy May 26 '20 at 21:13

10 Answers 10

30
\$\begingroup\$

I'd use one of the Teensy boards. These are Arduino-like microcontroller boards which have USB support. Unlike the Arduino, they can appear to a PC as any sort of USB device. This means that you can create your own custom USB keyboard, joystick, MIDI device, etc and have the PC use standard drivers.

The Teensy supports the Arduino IDE, or you can program in C and use LUFA (for USB support) directly.

Here are some project links to help.

\$\endgroup\$
2
  • 10
    \$\begingroup\$ For this type of application I would suggest pretending to be a HID. Drivers already written, you just emulate a mouse or a similar device. \$\endgroup\$ – Kortuk Mar 19 '10 at 18:04
  • 1
    \$\begingroup\$ +1 for joystick, you don't even need to build a mcu board, the board recovered from a borken joystick with analog axes will work just as well... \$\endgroup\$ – bobflux Oct 14 '17 at 16:30
6
\$\begingroup\$

I would use a microcontroller board like an Arduino. You read the ADC and digital I/O and send ASCII characters to the PC using the UART->USB connection.

How much external hardware you need depends on the accuracy you require. I would think for most applications the hardware internal to the microcontroller would be sufficient. I would debounce the switches in hardware.

For the USB interface just write a simply parser so that you can query the readings. For example if the PC sent the string "A00?" the uC could send back the reading on analog channel 0. "D00?" the uC could send back the state of digital input 0. To change a digital output maybe something like "D00=1" or "D00=0". These are short strings in a fixed length. Should be very easy to parse.

\$\endgroup\$
4
\$\begingroup\$

I like using Arduinos, they're simple to program and you can easily send data to your computer from the various inputs via the onboard USB connection. The data can be sent to the Arduino programming environments Serial Monitor - which is useful for debugging.

I then use a program like Pure Data (PD) or Max MSP to receive the serial data. Data can be sent out from these programs in all kinds of useful formats. Cuz it's simple enough to do any kind of log curves or scaling in the software - you don't have to worry about buying expensive log pots or using hard to find values - just buy a job-lot of the same value and worry about the specifics later (1K or 10K is normally easy to get).

This one's free: http://puredata.info/

This one is the payed for swanky version, but it has a good demo: http://cycling74.com/downloads/

\$\endgroup\$
4
\$\begingroup\$

Get an Arduino

Get a DangerShield.

Write code to send DangerShield sensor data to PC via RS-232 over USB connection.

Write custom app in like VB.NET or something to translate data into something useful on PC, like Win32 window messages or something.

\$\endgroup\$
3
\$\begingroup\$

I would suggest using PoKeys. Very easy adding 55 digital I/O, 7 analog inputs (12-bit), PWM outputs and more. It can even be combined with something like this.

\$\endgroup\$
2
\$\begingroup\$

I would go with an Arduino or a Sanguino as most folks suggested. Just google for them. They are extremely easy to use and you can be up and running in a few hours once you have all the necessary components.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ "Just google for them" is not accepted as an answer around here. Give details here. \$\endgroup\$ – stevenvh May 24 '12 at 11:38
2
\$\begingroup\$

An alternative which may or may not suit is to buy commercially available analogue joysticks / joypads (from $fckall on ebay china, or from the games store) and replace their analogue input components with your own, or just rip the main PCB out and transplant into your hardware.

You'll need to match some of the electrical characteristics, but the hard work of coding/USB comms etc. is done for you and usually the comms protocols / input mapping is well known.

Chinese knock-offs of PlayStation-style USB controllers etc. can be had for a few bucks, which is well below the price of hobbyist *duino IO boards etc. and cheap enough to be disposable when you blow the first one or two up.

\$\endgroup\$
1
\$\begingroup\$

Take a look at ObDev V-USB AVR based projects: http://www.obdev.at/products/vusb/prjhid.html. I think that this one might be just what you are looking for: http://www.fredrikolofsson.com/pages/hardware.html.

\$\endgroup\$
1
  • \$\begingroup\$ Fredrik Olofsson has some really interesting stuff. \$\endgroup\$ – Robert Harvey Oct 23 '17 at 18:35
1
\$\begingroup\$

If you just need knobs, check out YoctoKnob: http://www.yoctopuce.com/EN/products/yocto-knob

\$\endgroup\$
0
\$\begingroup\$

The GamepadBlock makes use of an ATmega32U2 together with LUFA to implement a full speed USB HID device to poll several original game controllers. The ATmega has a hardware USB interface and getting started was easy since LUFA provides several demo projects.

\$\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.