
The Phidgets toolkit takes a plug'n'play approach to adding physical sensors and actuators to your applications: just connect one of the supplied Phidgets to a USB jack on your computer or to an input connector on the InterfaceKit, drag the corresponding software widget into your C#/VB/.. form, and everything should run. But what if you want to add a different device to your setup, one that did not come in the Phidgets box?
Adding external devices requires a larger toolbox of concepts, techniques, and &emdash; tools. You don't have to be an expert in EE or ME though - a combination of googling and hands-on trial and error will be sufficent for the kind of rough-and-ready prototypes we are building in class. Topics worth familiarizing yourself with include basic electronics (more), machine shop techniques (visit Stanford's product realization lab), and places to order electrical/mechanical parts from. Stanford's product design program has a large list of suppliers - Jameco (in Belmont) and Digikey are the main sources for electronics, but if you're in a hurry and want to stay local, you can get many parts at Fry's and Radio Shack in Palo Alto. McMaster-Carr has every conceivable part of hardware you will ever need, but making your own at PRL may be cheaper and faster. Useful general references are the Physical Computing book by O'Sullivan and Igoe and their web sites.
Let's first look at how to deal with new sensors such as foot switches, rotary encoders, or IR distance sensors. The Phidgets site has a documentation page that describes how to connect sensors with variable resistance/voltage output to the analog inputs of the Phidgets InterfaceKit. In many cases, you may be able to get away with simply connecting Phidgets' "analog input" cable to the appropriate pins of your sensor. The actual lead assignment for the Phidget cables can be found on this page. Unless you can find the right kind of connector at a local electronics shop I would suggest just cutting one of the supplied analog input cables in half, stripping some isolation off the cut end of the wire and soldering or otherwise connecting the wires to your sensor. An example: The Sharp GP2D12 IR distance ranger requires a 5V input and a connection to ground. Depending on the proximity of the closest objects in it's field, it outputs 0-5V on a third pin. The Phidget analog cables have leads for 5V supply voltage, ground, and "Vout" - the voltage coming back from the sensor. I simply soldered a cut Phidgets connector wire to the short cables supplied with the sensor, making sure to match ground to ground, etc. If you're not familiar/comfortable with soldering, take a look at this detailed beginner's guide (check out the photo gallery on soldering). I don't know of any publicly accessible labs with soldering irons though - maybe in the ME buildings? To prevent short circuits from dangling bare wires it is a good idea to cover your connections with electrical tape or heat shrink tubing.


Let us now try to connect a new output device to Phidgets - a motor. You can pick up cheap DC motors like the ones found in RC toy cars from surplus stores like allelectronics.com. Wendy supplied me with a 3V vibrating motor (this is a normal motors with an off-center mass attached to the rotating axis). Most motors draw more current than the InterfaceKit can provide/sink, so you will need a secondary power source (think 2xAA batteries) and some sort of switch that uses the signal from one of the InterfaceKit digital outs to switch the larger motor current. A power transistor (again supplied to me by Wendy) will do the job. Pick a "NPN" type: it will switch on the load (motor) when the chip output is high (boolean true in the Phidgets API). This corresponds to a "normally open" switch, i.e., the motor is off unless you flip the switch/put voltage on the transistor's base. A "PNP" transistor works the other way around - analogous to a "normally closed" switch. You will also need a "snubber diode" (which only lets electricity pass in one direction) to prevent blowback voltage from the motors damaging your other components. Don't worry about the details, simply following the recipies on the last link should get you there. Here is a diagram of how your circuit should look like:
To build simple circuits you probably want to get a solderless breadboard (Pololu | allelectronics) and a jumper wire kit.

Bill Verplank's breadboard sketch from the music250 website
The Phidgets website has a page on Using DC motors with the PhidgetInterfaceKit 0/16/16. Some of this information can be reused for the 8/8/8 kit we have but note that the 0/16/16 Kit has high voltage outputs, which our InterfaceKit does not. Don't connect the motor directly to your board!
Posted by Bjoern Hartmann at February 10, 2005 9:54 AM