Skip to the content.

Stage 1: active steel pan sticks

Part of deepPan: stage 1 builds the sticks, stage 2 adds sensors to a cardboard mock-up, and stage 3 is the 3D-printed pan. A PDF of this plan is in docs/plan.pdf.

3 Dec 2026 · Philip Lewis

The stick’s IMU does two location jobs: it identifies which note was hit and, ideally, where on that note’s pad it landed, so that different parts of a pad can trigger different effects.

Overview

Phase 1 builds one self-contained active stick: a Seeed XIAO nRF52840 Sense with its 6-axis IMU, mounted on a Percussion Plus PP458 tenor stick. It detects hits, estimates velocity and works out which note was struck from orientation, using a calibration done on a fixed drum mock-up. The output is BLE MIDI. Later phases add sensing on the drum and fuse the two signals.

  1. Phase 1, active sticks. Stand-alone firmware on the stick for hit detection, velocity, orientation and note location, calibrated by hitting known note positions on a mock-up. Start with the single XIAO you have now; the 3-pack arriving on 13 Dec gives the second stick and spares.
  2. Phase 2, sticks plus a sensed mock-up. Glue piezo hit sensors under the cardboard mock-up and learn a model that combines the two signals: the piezos give the struck zone and precise timing, and the stick gives which stick, the velocity and its own location estimate. The piezo labels also supply free ground truth for retraining the stick’s location model.
  3. Phase 3, the instrument. The deepPan 3D-printed tenor pan, with a hit sensor in each of its 29 note pads (the “pixels”), played with the active sticks and using the fusion model from phase 2. The printed pads already include sensor mounts: a 16 mm bore for a 14 mm sensor in each central and inner pad, and a 23.5 mm mounting cylinder under each outer pad.

Prior art. Commercial stick sensors already turn ordinary drumsticks into BLE MIDI controllers that play on any surface: Freedrum [R22] (gyro tracking on a Nordic nRF52) and Senstroke [R23] (aligned to each virtual drum at setup). A student project [R26] used a 9-axis IMU on 3D-printed sticks. deepPan differs in aiming at a real instrument’s 29 pads, in estimating where on a pad the stick lands, and in fusing the stick with sensors in the drum. References are listed in REFERENCES.md.

Phase 1 is designed to work alone: everything it needs to know about the drum comes from the calibration step, so it does not depend on phase 2 hardware.

Quick start (milestone M1). In the Arduino IDE, add the board URL https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json, install Seeed nRF52 Boards (not the mbed one), select Seeed XIAO nRF52840 Sense and upload firmware/m1_imu_stream/m1_imu_stream.ino. A blinking green LED means it’s streaming. Then run pip install pyserial numpy matplotlib and python host/m1_log.py, and tap the board a few times during the 60 s run. The script prints an M1 pass or fail.

Three-phase roadmap

Hardware and stick build

Mount the board rigidly on the butt end of the handle, with the battery along the shaft under the grip. The IMU has to move exactly as the stick moves: any foam or rubber between them will smear impacts and add wobble to the orientation estimate.

Stick assembly, side view

Part Qty Role Source
Seeed XIAO nRF52840 Sense 1 now, 3 more on 13 Dec MCU, BLE, LSM6DS3TR-C 6-axis IMU, PDM mic, charger Amazon, 30 Nov
Percussion Plus PP458 tenor pan sticks 1 pair Host stick: 18.8 cm hardwood shaft, rubber ring tip Amazon, 30 Nov
E-flite 150 mAh 1S LiPo (PH 1.25 plug) 2 Stick power, one per stick Amazon, 30 Nov
SPDT mini slide switches 80 Power switch in series with the battery’s positive lead Amazon, 30 Nov
Polyimide tape, 10 mm 1 roll Insulates the board’s underside and battery pads from each other Amazon, 30 Nov
Wilson Pro Overgrip 3 Final wrap over battery and wiring; restores grip Amazon, 30 Nov

Build steps (stick 1)

  1. Bench-test the bare board first: flash a sketch that streams IMU data over USB before soldering anything.
  2. Solder a lead to the board’s BAT+ and BAT− pads on the underside. The E-flite cells have a PH 1.25 plug and the XIAO has bare pads, so either fit a mating PH 1.25 socket lead or cut the plug off and solder directly. A socket lets you swap cells.
  3. Put the slide switch in the positive lead. Charging through USB-C only works with the switch on, so label the switch positions.
  4. Wrap the board’s underside and the battery in polyimide tape, then fix the board to the stick’s end with the IMU’s x-axis along the shaft. Use epoxy or a tight printed cap, not foam tape.
  5. Lay the battery along the handle, secure it with polyimide tape, and wrap with the overgrip. Leave the USB-C port and the switch exposed.
  6. Weigh the stick before and after, and play it to check that the balance still feels acceptable.

The board’s charger runs at 50 mA or 100 mA, selected in software (CircuitPython API). Either is within 1C for a 150 mAh cell, so use 100 mA.

XIAO nRF52840 Sense pinout and battery pads

Battery wiring

Phase 1 firmware architecture

The firmware is one fixed-rate loop. On each IMU sample it updates orientation; on each detected hit it extracts features and emits a note event. Arduino with the Seeed nRF52 (Bluefruit-based) core is the quickest route: it has BLE MIDI and UART services built in. Zephyr is the fallback if timing becomes a problem.

Per-sample pipeline

  1. Sample. Read the LSM6DS3TR-C through its FIFO at 833 Hz, or 1.66 kHz if impacts prove too short. Set accelerometer ±16 g and gyro ±2000 dps. Timestamp each sample from the nRF52 clock.
  2. Condition. Subtract the gyro bias measured at rest on power-up. Keep a 200 ms ring buffer of raw samples for the hit windows.
  3. Orientation. Run a 6-axis Mahony [R17] or Madgwick [R16] filter that outputs a quaternion. During motion it trusts the gyro; it corrects pitch and roll from gravity only while the stick is quiet.
  4. Hit detector. A small state machine: idle, downstroke, impact, rebound. Its inputs are gyro rate and high-passed accelerometer magnitude.
  5. On a hit. Freeze the orientation at impact, compute velocity, extract the location features, run the note classifier, and emit the event.
  6. Output. BLE MIDI note-on and note-off. In logging mode, also send each hit window and its features over BLE UART, or over USB serial when it’s plugged in.

Modes, switched from the host over BLE UART: play (MIDI only), log (MIDI plus hit windows), calibrate (guided capture, below) and stream (the raw IMU stream, over USB only).

Firmware pipeline

Hit detection, timing and velocity

A hit is a fast downstroke that stops abruptly. Detect it from two cues together, so that air swings and fast mutes don’t trigger notes.

The onboard PDM microphone is a cheap third cue: a sharp onset in the audio envelope confirms contact and refines the timing. Add it only if the IMU cues produce false triggers.

Thresholds are per stick and per player, so store them in flash and set them in the calibration session.

Hit detection signals

Orientation and drift

Yaw and pitch at impact

Pitch and roll are observable from gravity, but yaw (the stick’s heading around the drum) is not. Without a magnetometer, yaw drifts from the first second, so the design has to put up with drift rather than try to eliminate it.

A magnetometer breakout would make yaw observable, but there’s a lot of steel near a real pan. Leave it as a phase 3 option rather than a phase 1 dependency.

Yaw offset tracking

Location: which note, and where on it

Location works at two levels. Which note is a classification problem: for a seated player at a fixed drum, each note pad maps to a recognisable cluster of stick orientations at impact. Where on the note is a regression problem: map the same impact features to a continuous strike point (u, v) on the drum surface, with an uncertainty attached. Both are learned by hitting known positions on a fixed mock-up.

The mock-up

Mock-up layouts

Calibration procedure (host-guided, in calibrate mode)

Calibration session

  1. Hold still for 2 s to measure the gyro bias and gravity reference.
  2. Double tap the home note to set the yaw reference.
  3. The host prompts each note in turn, and you hit it 15–20 times at mixed strengths and from different preceding notes, because the approach direction changes the pose.
  4. Each hit is logged with its prompted label, its features and the raw window.
  5. The host fits the model, reports a held-out accuracy and a confusion matrix, and writes the parameters to the stick’s flash.

Features at impact: stick pitch and yaw (relative to the home anchor), roll, and the direction of the stroke in the last 30 ms (the angular velocity vector). Pitch and yaw do most of the work; the stroke direction separates neighbouring notes approached from different sides.

Model: one Gaussian per note over the feature vector, with the posterior over notes from Bayes’ rule:

p(n | x) ∝ p(n) · N(x; μ_n, Σ_n)

The posterior is cheap enough to run on the stick, gives a confidence for every hit (used for the yaw-offset update and for rejecting ambiguous hits), and leaves room for a musical prior p(n) later. If Gaussians underfit, try k-nearest neighbours on the same features before reaching for a neural net.

Run the classifier on the host for the first sessions, where it’s easy to iterate, then port the fitted parameters to the stick.

Note classification

Where on the note: strike position

Ideally each hit also gives a position within the pad, for example centre versus edge, to drive different effects. Treat it as regression onto the drum surface rather than more classes:

  1. Targets. Stick small dots on each pad: one at the centre and about 8 near the rim. Measure their (u, v) positions in cm from the drum centre. The note-level calibration then becomes “hit the dot”, so every calibration hit carries a known position, not just a note label.
  2. Model. A Gaussian process regression [R19] from the impact features (pitch, yaw relative to the anchor, roll, stroke direction) to (u, v). It interpolates smoothly between the dots and returns a predictive covariance for every hit, so you know when a position can be trusted.
  3. Note from position. The note is the pad that contains the predicted point. Its probability is the predictive Gaussian’s mass inside each pad’s outline, which replaces the per-note Gaussians once there are enough dots.
  4. Effects. Normalised radius within the pad, r/R from 0 at the centre to 1 at the rim, plus angle, become effect parameters: a MIDI CC (such as CC74 for brightness), per-note pressure, or switching between centre and edge samples. Apply an effect only when the predictive uncertainty is small compared with the pad. Otherwise play the note’s default.

Is it accurate enough? The strike point moves by lever length × angle error, so 1° at a 35 cm pivot-to-tip lever is about 6 mm. The deepPan pads set the bar. Conservative radii are about 36–51 mm for the outer ring, 19–27 mm for the central ring and 16–17 mm for the inner ring. With orientation good to 2° (12 mm), position within a pad is realistic on the outer ring and coarse at best on the central ring. The inner pads leave room for note identification only. The bigger unknown is the forearm and wrist translating between strokes, which orientation alone can’t see. If that dominates, strap a spare XIAO from the 3-pack to the wrist as a second IMU and model the arm as a two-link chain.

Strike position within a pad

Pad sizes against strike error

Output and host tools

The stick shows up as a standard BLE MIDI device [R20], so any DAW or soft synth can play it without custom drivers. A small Python host does everything else.

Phase 1 milestones and tests

Each milestone ends in a test with a pass mark. The targets are starting points, so tighten them once you have real numbers.

# Milestone Test Pass mark
M1 Bench IMU stream Stream accel and gyro over USB at 833 Hz; plot a hand-held tap No dropped samples over 60 s
M2 Stick 1 built Charge, power switch, battery life while streaming over BLE Runs a 1-hour session; balance acceptable
M3 Hit detection 200 hits on a practice pad plus 100 air swings and mutes; slow and fast rolls ≥ 99% of hits detected, ≤ 1% false triggers
M4 Velocity Soft, medium and loud blocks of 30 hits each The three blocks separate cleanly in MIDI velocity
M5 Drift measured Yaw logged for 5 min at rest and in motion Drift rate known; anchor interval set
M6 6-zone location Calibrate, then a 120-hit prompted test with yaw-offset tracking on ≥ 90% correct, no systematic confusions
M6b Strike position Hit centre and rim dots on 2 large pads, 20 hits each; held-out test Position RMSE reported; centre vs rim separable on large pads
M7 BLE MIDI play Play a DAW pan instrument; record the acoustic tap and the MIDI note together Hit-to-note latency ≤ 15 ms
M8 Second stick Build stick 2 from the 3-pack (from 13 Dec); play both at once Both pass M3 and M6 at the same time
M9 Full deepPan layout Repeat M6 on all 29 pads (1:1 from pan_geometry.py) Report accuracy per ring; decide what phase 2 needs to fix

Looking ahead, risks and open questions

Phase 2 (stage2_mockup): piezos under the cardboard mock-up, through multiplexers. Glue a piezo under each pad and read them all with a Raspberry Pi Pico 2 through analog multiplexers. Three 16:1 CD74HC4067 muxes, one per ring (outer, central, inner), use the Pico’s three ADC inputs (ADC0–ADC2) and share the 4 select lines S0–S3. Piezo pulses last only milliseconds, so give each pad a 3.3 V zener clamp (1N4728, protecting the mux and ADC from piezo spikes of tens of volts) followed by a simple peak-hold (series resistor, diode, 10 nF capacitor, 1 MΩ bleed). Piezo triggers read through a multiplexer are well-trodden ground in DIY e-drums (HelloDrum [R24], Edrumulus [R25]). Each channel then holds its peak for about 10 ms, and the scan reads strike strength without missing hits. The RP2350’s ADC is fast enough to sweep all 29 channels many times within that hold time. You already have 9 bare piezo discs (two sizes) and 2 Pico 2 boards; the 6 eBay shock modules are a fallback for timing-only pads.

Phase 2 multiplexer wiring

Fusion then works in three steps:

  1. Match stick hits to piezo hits by time. Sync the two clocks over BLE, or align them on the first few hits.
  2. Combine the likelihoods: the piezo pattern gives p(zone piezos), the stick gives p(note x), and the product resolves which stick hit which zone.
  3. Use the matched pairs as automatic labels, so the stick model recalibrates itself during normal playing with no prompted sessions.

Fusion of stick and piezo signals

The piezo amplitudes across neighbouring pads also carry position information, because a hit near a shared edge excites both pads. That gives phase 2 a second, independent estimate of strike position to check and retrain the IMU’s position model against.

Cardboard carries vibration between zones, so expect crosstalk. A ratio of piezo amplitudes beats a simple threshold.

Every sensor is a clue: joint inference, then self-calibration from the surface. No single signal is trusted. Piezos pick up crosstalk from neighbouring pads and from the other stick, the IMU drifts, and the timing between them jitters. Treat each as a likelihood over where the hit landed and combine them, as above. When the combined posterior is confident, the hit’s location is effectively known, and that known point can recalibrate the stick.

The constraint that makes this work is geometric. At impact, the stick tip has to lie on the drum surface. You know that surface in 3D: from the CAD model you print the phase 3 drum from, or for the cardboard prototype from measured pad outlines and the stand’s height and tilt. Model the tip position as

tip = pivot + R(q) · (L, 0, 0)

where R(q) is the stick’s orientation at impact, L the pivot-to-tip length, and the pivot the effective wrist point. Each confident hit says that the tip lies on a known patch of that surface. Update the calibration state (yaw offset, pivot position, L, and the IMU’s mounting angles on the stick) with an extended Kalman filter or a sliding-window least-squares fit. This is a data assimilation loop [R3]: the surface model is the prior, confident hits are the observations, and the calibration keeps tracking the player’s posture as it drifts during a session. Low-confidence hits update nothing, so crosstalk can’t pull the calibration off.

Self-calibration loop

Phase 3 (stage3_printed_pan): the 3D-printed drum with a sensor in each of the 29 printed pads. deepPan already prints each note as a separate, individually mounted pad, which helps isolate pads mechanically and reduces crosstalk at source. Reuse the phase 2 fusion model; the stage 3 pad meshes and pan_geometry.py are the surface model for self-calibration.

Risks and open questions

Code in this folder

Path What
firmware/m1_imu_stream/ M1 sketch: streams raw IMU data over USB at 833 Hz
host/m1_log.py M1 logger: records, checks for drops, saves CSV, plots
host/pan_geometry.py The 29 deepPan pads (centre, normal, radius, MIDI note) in a level frame
tools/make_figs.py Regenerates every diagram in docs/figs/
results/ Logged sessions, simulations and results as they come in

References (full list, and how each was used: REFERENCES.md)