Channels ▼

Al Williams

Dr. Dobb's Bloggers

Fidgety USB

October 01, 2013

A few weeks ago I was lamenting how everything is built into my PC, so I don't get the chance to go shopping for goodies to plug into it as much as in the past. However, it is relatively easy to plug in USB devices, although it is somewhat less satisfying to my inner geek.

Linux-based boards like the Raspberry Pi or the Beagle Bone usually have some general-purpose I/O capability, but it is easy to forget they also sport USB ports. Adding a hub offers a wide range of expansion options. It wasn't long ago that I used a USB sound card and a Raspberry Pi to decode touch tones. That's a pretty obvious USB peripheral. There are more exotic ones, though.

A few years ago, I worked on a system for a museum that needed to identify different cast rubber livers. A patron would insert the liver into a mannequin's body cavity, and a face would appear along with audio describing if the liver was healthy or not. Imagine the character saying, "I drank too much and now I have cirrhosis."

The original system (that I inherited) used a strange and error-prone method to determine which liver was present. It relied on magnets, reed switches, and a cannibalized PC keyboard. My search for a better solution led me to a company called Phidgets. They make a wide range of USB sensors including some for load cells, pH, temperature, voltage, current, and many other quantities and functions. They are also fairly inexpensive as these sort of things go.

The one I was especially interested in was the RFID reader. Once connected to the PC and an RFID chip stuffed in each liver, detecting which one was inserted was a piece of cake. In this particular case, I was using a Windows-based PC but the RFID interface has example code for a variety of situations including Linux, Mac, LabView, Java, and even Flash.

I haven't tried any of these on a Raspberry Pi or Beagle, but there's no reason they shouldn't work like any other USB device will. If you crave something more custom (or otherwise unobtainable), an Arduino Leonardo would be another option to bring custom I/O into a USB port. It is easy to make these send keyboard or mouse input, which you can read very easily.

In the past, SPI or I2C have served to some degree as an embedded system bus. Larger systems rely on things like CAN. However, with the price of hardware falling and operating systems moving towards Linux and similar operating systems, maybe USB is the bus of choice for simple systems.

Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 


Video