Wednesday, July 4, 2012

After a long hiatus, I'm back!

(In which I give a big shout-out to PJRC, designers of the Teensy)

I got inspired to do more work on my Gordophone project when I saw that the Teensy 2.0 had native support for USB MIDI. If you're unfamiliar with Teensy, it's a dynamite little ATMega-based microcontroller that is extremely compatible with Arduino, but also allows you to turn it into a USB device.

I've always been bummed out that, in order for my instruments to drive software synthesizers on my Mac, my designs needed a MIDI shield bolted to the Arduino, and a MIDI interface connected to the Mac, using those 1980s DIN-5 connectors - very unwieldy.

There is a standard for transporting MIDI messages over USB, and any modern music device you get these days will allow you to attach it to your computer via USB. So if, say, you go to your local music store and buy a keyboard, it'll have a USB connector. Plug it into your Mac, start up Garage Band, and you can control the softsynths.

Since Teensy 2.0 has USB-MIDI support built in, this means that the Gordophone can shed all those MIDI cables and interfaces, and work directly over the USB cable that connects the Teensy to the computer.

Also, Teensy is, well, teensy. It's barely bigger than a U.S. Quarter, yet has all the I/O I need to build the Gordophone, and if I need more I/O pins, I can use the Teensy 2.0 ++ (the big brother to the Teensy, which, while being a larger sibling, is still pretty damn small). I'm hoping to be able to embed the controller directly into the instrument in future designs.

PJRC is the company that sells the Teensy. I placed an order with them via the web, received a prompt acknowledgement of my order, and received my order a couple of days later (I'm on the US west coast, so shipping time from Oregon is fast). The Teensy is well-supported with plenty of downloadable sample code.

My first milestone was to put together a simple instrument - a single button that sends a random MIDI node on event when pressed, and sends a note off event when the button is released. Following the help files on the PJRC website, I had my simple instrument running in less than 30 minutes, and the code worked the first time (that *never* happens at my day gig).

My next milestone was to port my old Arduino-based Gordophone sketch to the Teensy.

First, I had to solder up an adapter that would plug into the DB-25 connector on the Gordophone and bring out the individual wires so I could plug them into a breadboard and wire them up to the Teensy:

And then it was a matter of digging up my project docs to remember which of the Gordophone sensors were connected to which input pins on the Arduino. The pins on the Teensy are different, but PJRC thoughtfully provides a reference card that maps the Arduino pin numbers to the Teensy pin numbers. Looking at that, I was able to patch the DB-25 to the Teensy:

Also, I should mention, PJRC has done a fabulous job of integrating the Teensy into the Arduino IDE, via the Teensyduino package. Apart from requiring that you press the Teensy's reset button once, the developer experience is exactly the same as using an Arduino.

Since I have been inactive for a while, getting things running on the Teensy also required porting some code to Arduino 1.0, which required a few code changes since I developed everything on Arduino-22, but within 2 hours, I had everything working.

Kudos to Paul and Robin at PJRC for making such an excellent controller and providing such top-notch support for it. Thank you!

No comments:

Post a Comment