Device for tuning the servo positions of other Grumpenspiel instruments


Musical instruments need tuning. Grumpenspiel instruments heavily rely on servo motors for making noise. Servo Slam sends Midi SyxEx messages to configure the positions of those servos for best sound quality.

The most basic use case is a single percussion instrument, such as we have in Demonic Tapioca. One servo motor swinging one mallet to hit one block of wood.

There are three parameters the instrument needs to know:

  • Rest Position - servo position while waiting to play a note
  • Strike Position - servo position to hit the drum
  • Delay - how long to wait to return to rest position after striking

This pattern is repeated throughout nearly every component in Grumpenspiel. Servo Slam communicates via MIDI SysEx instructions. This lets me hook the device into Power Thru and have the ability to tune every single motor on every single device.


User Modes

Servo Slam is a versatile little tool that helps me configure several different situations. Press the Mode button to cycle through:

  1. Slam - a single tap triggered by pushbutton, sent over MIDI
  2. Loop - repeated tapping with variable tempo, sent over MIDI
  3. Spin - simple servo position instructions (no tapping), sent over MIDI
  4. Knob - simple servo position instructions, direct servo connection, no MIDI

The Device toggle selects the target Grumpenspiel device to address MIDI instructions to.

The Motor toggle selects the specific motor to address on the target device.

Finally, the Save button will direct the target device to save the settings. All other instructions are volatile, and only committed to EEPROM upon receipt of the Save message.

GitHub repository

Source code for the Arduino Nano firmware, Eagle schematic .sch file, and artwork for the control panel layout are stored in the GitHub repository.

Enclosure and Construction

A few days before starting Servo Slam construction, I was out walking the dog. Somebody down the street was moving out and discarded their home made bench by the curb. Nice big flat 2x12 lumber that just looked perfect for Servo Slam’s enclosure.

Used my normal technique of hollowing out pockets in an upper and lower half two piece construction. The sequence of steps was new for this. My previous pattern of cutting holes in the face before sealing left me with a heavy work load of filing dried sealer out of the holes to fit the components. Lets try an experiment and save the holes until later in the process. Not a simple process, nor a fast one, but I love the results. Beautiful finish, crisp text, and perfectly placed holes.

body construction progress
body construction progress
body construction progress
  1. Design layout in Inkscape
  2. Rough cut two pieces of 2x12 lumber on bandsaw
  3. Generate G Code for planer in Easel
  4. Plane four separate faces (top and bottom face, upper and lower body half)
  5. Rough sanding the touching/interior faces on sanding table
  6. Drill and countersink screw holes on drill press
  7. Mark the corresponding screw holes for easier realignment later
  8. Sand attached halves square on sanding table
  9. Finish sanding 100, 150, 220 by hand
  10. Stain conditioner
  11. Two coats stain with Varathane Special Walnut
  12. Dry overnight
  13. 3 coats Polycrylic
  14. Dry overnight
  15. Generate G Code for vcarve text/images in F-Engrave
  16. Apply oramask
  17. Vcarve text and images
  18. 2 coats Polycrylic on carves
  19. Dry overnight
  20. Enamel paint vcarves
  21. Dry overnight
  22. Peel mask
  23. 2 coats Polycrylic on whole thing
  24. Dry overnight (ended up sitting for 10 days, waiting for potentiometers on the slow boat)
  25. Generate G Code for holes using Easel
  26. Carve holes in front of face
  27. Generate G Code for interior pocket and exterior interface using Easel
  28. Carve interior pocket in upper half - use custom double-stick tape to secure the LCD pocket waste material that would otherwise fly and Murphy’s Law its way into some trouble.
  29. Carve exterior pockets in upper half
  30. Small amount of hand sanding/filing to fit each component in its spot
  31. Drill round holes in enclosure side (MIDI 5-pin DIN, 5.5mm barrel jack) using hand drill

In the end, I am very happy with how it came out. Substantially less hand filing required. Next time, pad the hole sizes by 0.1 mm and even less manual work will be required.

body construction progress
body construction progress
body construction progress

Adventures and Obstacles

This project was tons of fun, consistent with my experience on all the Grumpenspiel development. That said, none of these projects is without hiccups, Servo Slam had a few fun ones.

Metric vs Imperial

metric vs imperial

I was using my CNC to plane the 2x12 wood that forms the enclosure, shaving 0.5 mm at a time until the surface was entirely flat. With each successive iteration, more of the surface was in contact with the endmill bit and we’re getting closer to flat. As part of normal operation of the CNC, periodically pause to clean off the rails, belts, pulleys and v-wheels, so I began running a series of G Code commands manually.

All clean, return the CNC to G28 starting position. Start up the 0.5mm job only to see the router drive deep into the wood, straining the machine, screeching and grinding noise, heating up the bit and wood for some nice smoky burns. In the time I dove for the emergency stop, it got as far as you can see in the picture.

As it would turn out, I put the machine into G20 mode for imperial units during the cleaning operation. There’s a big difference between 0.5 mm and 0.5 inch, you think?

puppy dog nose covered in snow

Walk away, deep breaths, walk the dog, come back to the workshop in the morning. Recalibrate the machine.

Instead of going simply until the surface is flat, need to carve off 13 mm to make up for the big old .5 inch oopsie. Luckily the design was oversized to begin with, and the smaller piece still allows plenty of space for the electronic components destined to live inside.

False Advertising

disconnected rails and rows

Putting together a permanent prototype circuit on a perfboard is a risky step in projects. Lots of details, lots of tiny parts, lots of opportunity for human error. I go slow, focus on extreme attention to detail. Triple, quadruple, decituple (?) check for short circuits, since that’s the obvious killer. Satisfied, apply the power and look/listen/smell/feel for sizzling melting smoke puffing.

In this case, I applied power and….nothing. Those worry me because one reason could be the hidden short that killed it instantly. Unplug quickly. Feel for heat. Nothing. Smell for burning. Nothing.

Start diagnosing with the multimeter. And there’s no connectivity. Between anything. At all. Head scratch.

Yeah, the permanent prototype boards that advertised connected power rails and rows. She’s got no connections, just individual isolated holes. So nothing is connected to anything else.

Solder jumpers galore and we’re in business.

File complaint with the seller, get refund, get to keep the remaining boards. Nice because they are fine quality double side plated thru hole boards, but really wanted the connected rails and rows.

Split Wood

split wood in the vice
split wood on the table
split wood glue drying

I really need to get a forstner bit in the size of 5 pin DIN connectors for MIDI jack. Spade bits just apply too much force for the thin walls featured on my enclosures. With only a few fibers left to cut through, the spade bit caught the edge and blew the wood out. Luckily it was a clean break and some wood glue solves the problem nicely.

In addition to a better drill bit, also need to:

  • Design thicker walls where the DIN connector goes. Will resist splitting better.
  • Screw the halves together before drilling. Provides additional strength.

Disconnected Programmer

disconnected programmer wire

I couldn’t get the camera to focus on the spot I wanted through that jungle of wires, but the picture gets the point across.

Servo Slam firmware is uploaded to the device using ICSP rather than the Arduino bootloader. I didn’t want to expose the USB connection to the exterior of the enclosure, and I also don’t want to wait the few seconds to boot when I’m out in the field tuning my instruments. HC ISP ECHO is the programmer of choice.

Upload a few iterations of firmware, walking through each push button, toggle and potentiometer to test out the hook up. Quickly get the dreaded avrdude.exe error that the target circuit cannot enter programming mode. This brings back nightmares from Cow Baby Drum Set who suffered a similar fate the day before heading out to give the device away as a gift.

Why is programming so error prone, and how many times will I have to rebuild these boards?

Walk away from the robot lab and call it a night, sleep on it and return in the morning with a cool head.

Crack her open, ready to rebuild the whole circuit.

Beautiful glorious low hanging fruit. A plainly obvious disconnected wire on the ICSP programming header, victim of a poor crimping job. Human error strikes again. Crimp on a nice new terminal, only to have another one of the wires pop out while reinserting the headers.

Glad I caught it now.

Disconnected Potentiometer

Sometimes you need to walk away from the workshop and reconnect with the important things in life. No sense getting stressed over your hobby. Pet the belly and find your inner Zen.

puppy dog belly
puppy dog belly
puppy dog belly

Things were working nicely and I was on to writing the firmware. Looking at potentiometer values and converting them to servo positions and delay timings, I’ve got some drifting values.

The 10-bit ADC on ATMEGA328P should be pretty reliable. Sure, readings might vary by 1 or 2 between iterations, well within acceptable error margins. But I’m seeing values drift over time, by 10, 20, 30, and eventually things are really bad with all 4 pots maxing out in the 700’s, rather than the clean 1023 they should reach at 5v.

Crack her open again, start tracing connectivity. Discover a feeble solder joint on the PCB giving an intermittent connection for one of the pot wiper pins. If only the perfboard had connected rails of holes, I wouldn’t have needed to make this jumper connection, but a bad robot maker blames his tools. Take responsibility for your craftsmanship.

Heat her up, apply some fresh solder, noice! We’re back in business.

Schematic and Circuit

Eagle .sch schematic file.

servo slam schematic
circuit closeup
circuit closeup

I went with crimped connectors instead of direct solder this time. Made for much easier soldering job without having to slowly creep closer and tighter as the peripheral components solder deeper and deeper together. Even a medium sized project like this involves a whole lot of crimping.

circuit closeup
circuit closeup
circuit closeup


Servo Slam needs to know some information about all the other Grumpenspiel instruments. To this end, she stores a whole lot of info about devices and motors in EEPROM.

Storage format

EEPROM for Servo Slam config starts at address 20.

BlockSize (bytes)ValueDescription
Device Data Size 1 D_SIZE the number of bytes the device data uses, including this size byte
Device ID 1 Device ID the device ID. assignments can be found in the MIDI SysEx doc.
Model ID 1 Model ID the model ID. as of this writing, no model IDs are assigned, all devices have a single model with id 0x00, but the data is here for future compatibility.
Instrument Name Size 1 N_SIZE the number of bytes the instrument name uses, including this size byte
Instrument Name N_SIZE <= 16 string the name of the instrument, 16 characters available on the LCD screen

Then, for each motor in the instrument.

BlockSize (bytes)ValueDescription
Motor Data Size 1 M_SIZE the number of bytes this motor data uses, including this size byte
Motor ID 1 Motor ID a unique ID for each motor in the device. typically starts with 0 and increments, used to map the EEPROM address space of the target device for saving the config info with SysEx 0x12
Motor Name Size 1 MN_SIZE the number of bytes the motor name uses, including this size byte
Motor Name MN_SIZE <= 16 string the name of the motor, 16 characters available on the LCD screen

Uploading new config

I created a utility Java application to manage this data. Simple XML file containing device and motor information. Run the utility on your desktop PC and she spits out an Intel HEX EEPROM image file. Run avrdude to upload to Servo Slam.

Really need to decide where to keep the source code for the application. Does it live in the Servo Slam repository, or does it live in a centralized repo for all the little helper applications Grumpenspiel makes use of?