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.
- 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.
- 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.
- 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.

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.

| 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)
- Bench-test the bare board first: flash a sketch that streams IMU data over USB before soldering anything.
- 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.
- Put the slide switch in the positive lead. Charging through USB-C only works with the switch on, so label the switch positions.
- 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.
- 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.
- 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.


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
- 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.
- Condition. Subtract the gyro bias measured at rest on power-up. Keep a 200 ms ring buffer of raw samples for the hit windows.
- 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.
- Hit detector. A small state machine: idle, downstroke, impact, rebound. Its inputs are gyro rate and high-passed accelerometer magnitude.
- On a hit. Freeze the orientation at impact, compute velocity, extract the location features, run the note classifier, and emit the event.
- 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).

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.
- Downstroke. The gyro rate about the stroke axis (perpendicular to the shaft, in the swing plane) goes above an arming threshold.
- Impact. Within a few milliseconds of the armed state, the high-passed accelerometer magnitude spikes above an impact threshold and the stroke-axis gyro rate collapses or reverses (the rebound). The impact time is the first sample over the accelerometer threshold.
- Refractory window. Ignore new impacts for about 25 ms after a hit, then re-arm. Tune this down so rolls still register.
- Velocity. Use the peak stroke-axis gyro rate in the 30 ms before impact, which is the angular speed of the tip. Map it to MIDI 1–127 through a curve fitted from soft, medium and loud test hits. The size of the accelerometer spike is a cross-check, but it depends on where the stick lands.
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.

Orientation and drift

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.
- Don’t track position by double integration. Position from integrated acceleration drifts by centimetres within a fraction of a second, so it is no use for locating notes. Use orientation at impact instead.
- Treat yaw offset as a state to estimate. Model the heading at impact as the true heading plus a slowly varying offset. Each confident note classification gives a measurement of that offset, so update it with a scalar Kalman filter [R18] (random-walk process noise). Playing keeps the stick calibrated.
- Re-anchor explicitly as well. A double tap on a designated home note, or a held still pose at the start, resets the yaw offset directly.
- Measure the drift first. Before designing the filter, log yaw while the stick is at rest and while it’s waved around for 5 minutes. That gives the process noise and shows how often an anchor is needed.
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.

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
- A cardboard disc, about the diameter of a tenor pan, on a fixed stand at playing height and tilt. Mark a fixed stool position so the player’s geometry repeats between sessions.
- Draw the note areas on it. Start with 6 large zones to prove the method, then move to the real deepPan layout once 6 zones work: 29 pads named O0–O11 (outer, octave 4), C0–C11 (central, octave 5) and I0–I4 (inner, octave 6).
host/pan_geometry.pyloads every pad’s centre, normal and size from stage 3’s data in a level frame, so the cardboard can be marked out at 1:1 and the same coordinates serve as the surface model. - Use the same cardboard disc in phase 2, with piezos glued underneath, so the phase 1 calibration data stays valid.

Calibration procedure (host-guided, in calibrate mode)

- Hold still for 2 s to measure the gyro bias and gravity reference.
- Double tap the home note to set the yaw reference.
- 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.
- Each hit is logged with its prompted label, its features and the raw window.
- 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.

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:
- 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.
- 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.
- 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.
- 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.


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.
- Play path. BLE MIDI note-on with the classified note and velocity, then note-off after a fixed gate time. Map notes to a steel pan sample instrument in the DAW. For two sticks, give each its own MIDI channel.
- Host tool (Python with
bleak): pairs over BLE UART, switches modes, runs the guided calibration, saves every hit (label, features, raw window) as Parquet or CSV, fits and evaluates the model, and writes the parameters back to the stick. - Live view. A simple plot of the orientation at impact over the drawn note zones, so misclassifications show up as you play.
- Data. Keep every session file, because phase 2 retrains on the same data with piezo labels added.
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.

Fusion then works in three steps:
- Match stick hits to piezo hits by time. Sync the two clocks over BLE, or align them on the first few hits.
-
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. - Use the matched pairs as automatic labels, so the stick model recalibrates itself during normal playing with no prompted sessions.

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.

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
- Gyro saturation. Fast wrist strokes may exceed ±2000 dps. Check in M1 and M3; if it happens, estimate the peak from the samples either side.
- Mount and balance. The board and battery at the butt end change how the stick feels. If it’s unplayable, move the battery towards the middle or use a lighter cell.
- Wooden shaft vibration. Impact ringing in the shaft may blur the accelerometer spike. Check the hit window plots in M3.
- BLE latency with two sticks. The connection interval sets the floor. Measure it in M7 and M8 before committing to BLE MIDI over a USB dongle receiver.
- Strike position resolution. Forearm translation may limit within-pad position more than orientation error does. Measure it in M6b; the fix is a wrist IMU.
- Clamp leakage. The 1N4728 zener sits before the peak-hold’s rectifier, so its leakage can’t drain the hold capacitor, but it may soften the quietest hits. Check in stage 2 milestone P1; the alternative is a BAT54S Schottky clamp.
- Mux channel crosstalk and settling. After switching channels, allow settling time or discard the first ADC sample; check with one pad hit and the others quiet.
- Geometry between sessions. If the player or the mock-up moves, the calibration shifts. Anchoring on the home note covers yaw; larger moves need a quick recalibration.
- Open: sound source. Is it a DAW on the laptop, or should the stick or the drum play samples itself? The DFPlayer Mini in the Pi Hut order could make the drum self-contained.
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)
- Seeed XIAO nRF52840 series wiki
- Zephyr: XIAO BLE (Sense) board docs
- CircuitPython XIAO nRF52840 API (IMU, charge current)
- Percussion Plus PP458 product page (shaft length, tip)
- deepPan stage 3 data:
stage3_printed_pan/data/notepads/notepad_properties.json,data/quarters/section_properties.json(levelling rotation), andgenerate_notepad.py(sensor mount sizes) - Your Amazon orders 203-8335099-7485953 and 203-5756503-9156310 (30 Nov 2026); The Pi Hut order #1474830; eBay order 15-14110-14707