Close

Major timing improvement

A project log for Christmas Orchestra

Taking stepper music to absurd levels, with a dash of Christmas cheer

Jeremy WeatherfordJeremy Weatherford 12/10/2014 at 14:420 Comments

The weak point in the playback chain for this project and the music box has always been the PC (or RPi) sending note data to the Arduino. Most of the time it worked great, but occasionally a timer wouldn't get called in a timely fashion and the playback would glitch. That's not a huge problem for a one-off project, but this time I'm planning to record the audio and video tracks separately and then sync them, music-video style, so I need the performance to be as repeatable as possible.

So yesterday I finally dug into the docs and figured out how to put the 10kbytes of note data into PROGMEM instead of RAM so the Arduino could hold the entire song without needing an external source of note data. By the way, I think it's criminal that the Arduino IDE can't detect when you're allocating too much SRAM for variables -- the sketch just silently fails to boot. Or is that fixed in newer bootloaders now? I was worried about the flash access being slow, but it's fast enough to index through the note data every 0.4msec. Playback is now bulletproof and doesn't require an external laptop.

To add the finishing touch and make the rig completely self-contained, I now have it triggering playback when a floppy disk is inserted in the top drive, and stopping when it's ejected. :) I'm also planning to have it re-home the motors to the start position when the disk is ejected, so that I don't have to do that manually every time (since that does require a laptop connection at the moment).

If all goes according to plan (and how likely is that, really?) we should be recording tomorrow.

Discussions