Archive for 'Tutorial'

Updating the MP3 Trigger Firmware

by

The MP3 Trigger is now shipping from SparkFun, and I’ve already been asked about support for different baud rates on the serial port. As shipped, the unit supports 38.4Kbps and is not user configurable. I chose this relatively high data rate because I needed to send updates as quickly as possible to avoid clicking and distortion when dynamically altering the volume – many small changes are better than a few big ones. I understand that not everyone needs this feature, and some may want to control the MP3 Trigger from devices that don’t support such a high baud rate.

For the time being, I’ve built alternate versions of the v1.01 firmware (the version that SparkFun is shipping at this date) for 2400 and 9600 baud.  Please do not ask SparkFun to modify the firmware before shipping – they are simply not able to do this on a case-by-case basis.

You can download the hex files here:

MP3 Trigger v1.01 38.4K baud firmware (as shipped)
MP3 Trigger v1.01 9600 baud firmware
MP3 Trigger v1.01 2400 baud firmware

In order to make use of the above hex files, you’ll need a way to utilize the in-circuit programming connector on the MP3 Trigger. The easiest solution is to get a Cypress MiniProg for around $25. Since there is no header installed for this on the MP3 Trigger, a 5-pin male header can be used for temporary connection.  The following picture shows the MiniProg and appropriate header.

MP3Prog001

The next picture shows the header inserted into the female connector of the MiniProg, then inserted into the connector on the under side of the MP3 Trigger and properly oriented.

MP3Prog002

I’ve created a forum dedicated to discussion and questions about the MP3 Trigger. If and when you get to the point of reprogramming your firmware and have questions, that’s a good place to go and it will help me get the forums going. You can also leave comments/questions here.  And I’ll do my best to monitor the SparkFun forum as well.

-Jamie

6

Why MIDI is so useful for physical computing

by

I was talking recently with my nephew, an undergraduate in the Computer Engineering department at Ohio State, and someone who generally likes to build stuff. He mentioned how he’d always wanted to do one of those choreographed Christmas light displays but couldn’t imagine the amount of work involved. I started to explain that all one needs is a bunch of MIDI controlled switches and some MIDI sequencing software, and quickly realized that he understood MIDI only in terms of general MIDI synths and cheesy sounding music.

This realization was reinforced several weeks later when I spoke to the Ohio State Open Source Club. As part of that talk, I rigged up a simple microcontroller (Cypress PSoC) with a MIDI input, a hobby servo with a long wand and an LED at the end. (It was a big lecture hall and I needed something that could be seen from the back of the room.) I programmed the microcontroller to assign a MIDI note to the LED and a MIDI controller to the servo. Pretty basic stuff.

During the talk, I opened up Cakewalk Sonar and loaded music into an audio track, armed a MIDI track, hit record, and then proceeded to make the wand wave and the LED blink in time to the music by turning a knob and playing a key on my little M-Audio Oxygen8 keyboard. Stop, rewind, play… and you’d have thought that I pulled a rabbit out of a hat.

So, with apologies to those who already know this, here’s a brief review.

 

Simple MIDI input for the Arduino

Simple MIDI input for the Arduino

MIDI is a physical serial communications specification and a byte-oriented message protocol. That’s it. The physical component is a 20mA current loop, one for each direction, with 8-bit asynchronous data transfers at 31.250kbaud, easily implemented with a UART. The message protocol was originally designed to support real-time music performance data from input devices (keyboards, wind controllers, etc) to output devices that produce musical sounds. Most MIDI messages are 3 bytes in length, consisting of an address and command byte, a note or controller number and a data byte. There are exceptions and ways to handle bulk data transfers, but it’s all very well documented.

The key point is that MIDI, specifically the serial communications specification, has become an industry standard, supported by all manner of useful hardware and software. Furthermore, there’s nothing to prevent you from taking advantage of all this useful hardware and software by using MIDI for things other than intended, i.e. other than musical sounds.

Case in point: Years ago at Walt Disney Imagineering we were experimenting with air-launched fireworks, and built a series of microprocessor controlled roman candle guns. We added MIDI input capability to the guns and were thus able to very quickly create a compelling show using off-the-shelf MIDI software to fire the guns in time to a recorded music track.

Here are 4 reasons why MIDI is so useful in embedded control projects:

1) MIDI is easy to implement on a microcontroller

MIDI is asynchronous serial data, 8-bit, 1-start bit, 1-stop bit, no-parity at 31.25kbaud. Most microcontrollers have a built-in serial transmitter, receiver or UART that can do this, and usually the only challenge is programming the correct baud rate. The 20mA current loop input can be implement using 2 resistors, a diode and a 6N138 optoisolator. The output can be any logic output pin that can handle 20mA, sometimes buffered, sometime not.

I plan to do an article in the near future on how to easily add MIDI I/O to an Arduino.

2) MIDI is easy to get into and out of a PC

Let’s face it. Once you build something, you’ll probably want to be able to talk to it with a computer. MIDI interfaces that plug into a USB port are cheap, and class-compliant interfaces require no drivers for the Mac OS or Windows. Once installed, there’s a standard API for sending and receiving MIDI comments, so programming your own communications, if you’re into that sort of thing, is a snap.

3) There are a ton of creative products that produce MIDI

The list is simply too long to provide here, but suffice to say that browsing the web or going to Guitar Center will reveal all manner of products whose sole purpose is to convert input controllers to MIDI data, which can be used to control your MIDI enabled device. Imagine using a guitar to control all those LEDs…

4) There’s lots of software to record, manipulate and play back MIDI

Want a way to easily communicate with your device without writing any code? MIDI-OX lets you type in outgoing MIDI messages and display incoming MIDI messages. Want to record control information for your device, perhaps in time to music or audio? Pretty much any MIDI sequencer or DAW (digital audio workstation) software will do that out of the box. Want to create your own control application? Max will let you do that and more.

Nuff said for now. Hopefully, I’ve provided some evidence that MIDI is way more than bad-sounding banjo sounds. Let me know if you have some cool non-standard way to leverage MIDI that I didn’t mention.

0