Tag Archives: toys

New Toys: Bus Pirate and Digipots

That’s right, I’m now the proud new owner of a Dangerous Prototypes’ Bus Pirate.  I’ve been looking at these things for awhile, and finally decided that I should stop being such a cheapskate and just get one.  Yea, I know I can always rig up one of my AVRs to do serial communications, but this is just so much more convenient.  And at $30 (I got mine from SparkFun), it’s a pretty sweet deal.

Bus Pirate Closeup

So what did I get for my three Hamiltons?  Well, check this out (courtesy SFE):

  • Supported protocols:
    • 1-Wire
    • I2C
    • SPI
    • JTAG
    • Asynchronous serial
    • MIDI
    • PC keyboard
    • HD44780 LCD
    • 2- and 3-wire libraries with bitwise pin control
    • Scriptable binary bitbang, 1-Wire, I2C, SPI, and UART modes
  • 0-5.5volt tolerant pins
  • 0-6volt measurement probe
  • 1Hz – 40MHz frequency measurement
  • 1kHz – 4MHz pulse-width modulator, frequency generator
  • On-board multi-voltage pull-up resistors
  • On-board 3.3volt and 5volt power supplies with software reset
  • Macros for common operations
  • Bus traffic sniffers (SPI, I2C)
  • A bootloader for easy firmware updates
  • Transparent USB->serial mode
  • 10Hz – 1MHz low-speed logic analyzer
  • Scriptable from Perl, Python, etc. (aka everything)
  • Translations (currently Spanish and Italian)
  • Enumerates as a virtual COM port over USB
  • Can operate as AVR STK v2 clone programmer
  • Access to PIC24FJ64 ICSP programming port

Needless to say, the Bus Pirate’s capabilities are extensive.  And open source.

Thus far I’ve tested out its UART and SPI modes, and have been sufficiently impressed.  Which leads me to my next new toy, an SPI digital potentiometer, the MCP42010:

MCP42010 Digital Potentiometer

This particular part comes in a 14-DIP package, contains two 10k potentiometers with 8-bit resolution, and can be had for just $2.40 from Digi-Key.  I’m thinking of using it in an audio compressor / volume control prototype, but it may come in handy elsewhere.

Controlling this digipot is just ridiculously easy when using the Bus Pirate.  Once connected and in SPI mode, I simply issue the command “[0b11011111, x]” (without the quotes), where x is a value from 0-255 representing the potentiometers’ wiper positions.  The two least significant bits (11 above) of the first byte tell the chip which of its potentiometers to adjust.  You can set one at a time, or both simultaneously.  Bits 4 and 5 of the first byte (01 above) allow you to either write data to the wiper registers or put the digipot into a high-impedance shutdown mode (which could be great for reducing power consumption).  The same effect can be achieved by pulling pin 12 low.  Want to reset the potentiometer to its 50% position (this also happens automatically on power-up)?  Pin 11 will do just that when pulled low.  For all the gory details, take a look at this datasheet.

Bus Pirate and Digipot Test Setup

This little chip is pretty impressive.  It’s also available in 50k and 100k versions.  The only thing it really can’t do is handle much current (wiper current should be kept under ±1mA).  But just toss in some buffer op-amps and you’ll be all set.  That’s my plan anyways.