Skip to content

CapSense Feasibility

The shift register approach gives us rock-solid on/off detection for all 151 key contacts — but MIDI is capable of much more. Velocity, continuous key position, aftertouch, even proximity detection before a key is pressed. Acoustic pianos achieve velocity by measuring the time between two switch closures per key. The 555’s single-contact keys don’t offer that luxury directly.

Capacitive sensing could fill the gap. As a finger approaches and depresses a key, the change in capacitance near the contact mechanism provides a continuous analog signal that tracks key motion — not just the binary moment of contact.

We have a pile of Cypress PSoC chips with CapSense hardware:

ChipPackageFlash / RAMCapSense ChannelsKey Characteristics
CY8C20236A16-pin QFN8 KB / 1 KBUp to 10 buttonsDedicated CapSense controller, SmartSense auto-tuning, I2C slave, 1.8–5.5 V
CY8C29466-24SXI28-pin SOIC32 KB / 2 KB~20 via CSD user moduleFull PSoC1 — programmable analog/digital blocks, SPI/UART, 14-bit ADC, 5 V only
CY8C2644328-pin SSOP16 KB / 256 B~20 via CSD user moduleSmaller PSoC1, same architecture as CY8C29466, SPI/UART, 5 V only

What CapSense Would “See” at the Contact Rails

Section titled “What CapSense Would “See” at the Contact Rails”

The 555’s key contacts are not passive switches sitting at ground potential. They carry 0–12 V square waves at the note frequency — 27 Hz at the bottom of the pedalboard up through ~4 kHz at the top of the upper manual, plus harmonics from the TOD divider chain’s fast edges. This is the signal that the shift registers read as simple on/off.

CapSense works by measuring charge and discharge time on a sensing electrode — the CSD method uses a sigma-delta modulator clocked at tens to hundreds of kilohertz. That AC signal on the contact rails is right in the danger zone: audio-frequency square waves couple capacitively into any nearby sensing electrode and directly modulate the charge/discharge measurement. The sensor can’t distinguish “finger approaching” from “divider signal coupling.”

This means you can’t simply stick a CapSense electrode on or near the existing contact rails and expect clean readings while the organ is powered. The sensing electrode needs to be physically isolated from the rail signals, or the measurement approach has to account for (or exploit) those signals.

Two approaches emerge from this constraint — one fights the interference, the other embraces it.

Before diving into the approaches, it’s worth understanding the interference landscape. The divider-keyer ICs produce steep-edged square waves with significant harmonic content. A 440 Hz A4 note doesn’t just produce 440 Hz — the square wave harmonics extend well above the PSoC’s CSD measurement frequency.

The coupling paths include:

  • Direct capacitive coupling between contact rail and sensor electrode (dominant when they’re close)
  • Radiated EMI from the long bus wires running under the keybed acting as antennas
  • Ground loop injection through shared power or ground planes

Mitigation strategies for traditional CapSense (Approach A) include shielded sensor traces with active driven shields (the PSoC’s CMOD/shield pin drives a guard electrode at the same potential as the sensor), isolated PCB layers with a grounded copper pour between sensor and rail, and physical separation — mounting the sensor strip on the opposite side of the key mechanism from the contact rails.

Cypress’s own AN85951 covers shielding and noise immunity in detail. Silicon Labs’ AN447 addresses PCB layout for capacitive sensors in electrically noisy environments.

The proven path. Mount dedicated sensor pads on a thin flexible PCB strip positioned under each key, isolated from the contact rail. Each pad detects the proximity and position of the key above it as the key descends.

A narrow FR4 or polyimide strip runs the length of each manual, with individual copper pads (roughly 8–12 mm square) centered under each key’s travel path. The pads face upward toward the underside of the key, while the contact rails sit to the side or below — maximizing the distance between sensor and interference source. A ground plane on the back side of the strip provides a shield.

The CY8C20236A is the natural fit here. It’s a dedicated CapSense controller with SmartSense auto-tuning and an I2C slave interface — exactly what you’d want for a distributed sensor network. Each chip handles up to 10 sensor pads.

ManualKeysCY8C20236A ChipsI2C Addresses
Upper (Swell)4450x00–0x04
Lower (Great)4450x05–0x09
Pedalboard1320x0A–0x0B
Orbit III2530x0C–0x0E
Total12615

Alternatively, the CY8C29466 handles ~20 channels per chip via direct pin connection (8 needed for 151 keys), though external muxing can increase this substantially — see Analog Block Multiplexing. It requires more firmware effort — the CSD user module needs manual configuration, calibration, and the communication interface (SPI or UART) requires custom protocol design.

The CY8C20236A speaks I2C natively. Fifteen chips on a single I2C bus (at 400 kHz Fast Mode) could report all 151 channels in under 2 ms — well within MIDI’s timing budget. The ESP32-S3 has two I2C controllers, so the sensor bus can run independently from any other I2C peripherals.

graph LR
    subgraph UPPER["Upper Manual"]
        UP1["CY8C20236A<br/>keys 1–10"]
        UP2["CY8C20236A<br/>keys 11–20"]
        UP3["CY8C20236A<br/>keys 21–30"]
        UP4["CY8C20236A<br/>keys 31–40"]
        UP5["CY8C20236A<br/>keys 41–44"]
    end
    subgraph LOWER["Lower Manual"]
        LP1["CY8C20236A<br/>keys 1–10"]
        LP2["CY8C20236A<br/>keys 11–20"]
        LP3["CY8C20236A<br/>keys 21–30"]
        LP4["CY8C20236A<br/>keys 31–40"]
        LP5["CY8C20236A<br/>keys 41–44"]
    end

    UP1 & UP2 & UP3 & UP4 & UP5 --> I2C["I2C Bus<br/>400 kHz"]
    LP1 & LP2 & LP3 & LP4 & LP5 --> I2C

    I2C --> ESP["ESP32-S3"]
    ESP --> MIDI["MIDI Output<br/>USB / BLE / DIN-5"]

    style ESP fill:#78350f,color:#fef3c7,stroke:#d97706
    style MIDI fill:#065f46,color:#d1fae5,stroke:#10b981
    style I2C fill:#1e3a5f,color:#bfdbfe,stroke:#3b82f6

Andrew McPherson’s TouchKeys project (2012, NIME) demonstrated capacitive sensing overlaid on a standard piano keyboard. The sensor strips detect not just key press but lateral finger position and contact area — mapping to vibrato, pitch bend, and timbral control. The Snyderphonics Manta takes the concept further with a 48-sensor hexagonal grid. Both prove the underlying physics works at musical performance speeds.

This is the clever one — and it’s specific to organs with tone divider architecture.

Instead of fighting the 0–12 V square wave on the contact rails, treat it as an excitation signal. As a key descends toward its contact rail, the capacitive coupling between the key mechanism (or a nearby pickup electrode) and the rail increases. The amplitude of the coupled signal rises proportionally to the inverse of the air gap distance. The organ’s own divider output becomes a per-key excitation source at a known, unique frequency.

Each key in the 555 produces a different frequency from the TOD chain. That means each key’s coupled signal occupies a distinct frequency band — natural frequency-division multiplexing, built into the instrument’s architecture. A pickup electrode near a group of contact rails would receive a superposition of all nearby keys’ signals, but simple bandpass filtering (or DFT) can separate them.

graph TD
    DIV["TOD Divider Chain<br/>0–12 V square wave<br/>per note frequency"] --> RAIL["Contact Rail<br/>(existing)"]

    RAIL --> |"capacitive coupling<br/>(varies with key position)"| GAP["Air Gap"]
    GAP --> PICKUP["Pickup Electrode<br/>(thin wire or PCB trace<br/>near contact rail)"]

    PICKUP --> BPF["Bandpass Filter<br/>(tuned to note frequency)"]
    BPF --> ENV["Envelope Detector<br/>(peak amplitude)"]
    ENV --> ADC["PSoC 14-bit ADC<br/>or ESP32 ADC"]
    ADC --> ESP["ESP32-S3<br/>position → MIDI"]

    style DIV fill:#92400e,color:#fef3c7,stroke:#d97706
    style RAIL fill:#92400e,color:#fef3c7,stroke:#d97706
    style GAP fill:#374151,color:#f3f4f6,stroke:#9ca3af
    style PICKUP fill:#1e3a5f,color:#bfdbfe,stroke:#3b82f6
    style BPF fill:#1e3a5f,color:#bfdbfe,stroke:#3b82f6
    style ENV fill:#1e3a5f,color:#bfdbfe,stroke:#3b82f6
    style ADC fill:#78350f,color:#fef3c7,stroke:#d97706
    style ESP fill:#78350f,color:#fef3c7,stroke:#d97706

The AC signal coupling concept builds on a lineage of keyboard sensing research — from IKOR’s 1967 AC-coupled keyboards through Giulio Moro’s 2020 PhD thesis on continuous key position sensing with the Hammond organ. Moro’s work provides the hard design targets that constrain our approach: ≥ 1 kHz scan rate, < 5 ms action-to-MIDI latency, and a minimum of 3 virtual contacts per key travel for perceptually useful expression. His five-state key lifecycle model (Partial Press → Press in Progress → Key Down → Release → Post-Release) maps directly to our ESP32 firmware design.

The full research survey and quantitative findings are covered in Prior Art & Thesis Research.

Several properties of the Wurlitzer 555’s architecture make this approach particularly attractive:

  1. The excitation signal already exists — the TOD chain provides a continuous square wave at every note frequency, present on the contact rail whether or not the key is pressed. No additional signal injection needed.

  2. Each key has a unique frequency — natural multiplexing. A single pickup electrode near a group of rails could detect multiple keys simultaneously via frequency analysis.

  3. The PSoC1’s analog blocks are built for this — the CY8C29466’s programmable analog blocks can implement bandpass filters and envelope detectors in hardware, reconfigurable at runtime to multiplex across all keys (see Analog Block Architecture). Its 14-bit ADC provides sufficient dynamic range to resolve the small coupling changes.

  4. No custom sensor PCB required — a pickup wire or thin PCB trace routed near the existing contact rail is the only new hardware. Compare this to Approach A’s 151-pad sensor strip.

  5. The coupling is inherently proportional — capacitive coupling between a rail and pickup electrode follows a roughly 1/d relationship (inverse distance), providing a smooth continuous signal as the key descends.

The CY8C29466’s 12 programmable analog blocks can be reconfigured at runtime — rewriting center frequency registers in under a microsecond to time-division multiplex a single bandpass filter chain across all keys assigned to one chip. Combined with adaptive sensing modes (comparator mode for idle keys, full ADC measurement for active keys), external analog multiplexers, and real-time drift compensation tracking the 555’s analog master oscillator, this architecture makes a 2–3 chip solution realistic for all 151 keys.

The full analog block analysis — including settling time constraints, external mux expansion with CD74HC4067 parts, and the CY8C20236A’s potential as an AC amplitude detector — is covered in Analog Block Architecture.

Either approach (or a combination) opens up expressive dimensions that on/off contacts can’t provide:

CapabilityMechanismMIDI Mapping
VelocityRate of capacitance/coupling change during key descentNote On velocity (0–127)
Continuous positionAbsolute key depth proportional to coupling amplitudeCC (key-specific or zone)
Anticipatory triggeringDetect key approaching before mechanical contactNote On with pre-trigger timing
AftertouchPost-contact pressure changes coupling geometry slightlyChannel Pressure or Poly Aftertouch
Proximity detectionHand hovering above keys changes ambient couplingCC for zone-based expression
Per-key frequency taggingNatural multiplexing from TOD architecture (Approach B)Simplifies signal routing

The critical design principle: the CapSense/AC coupling layer is purely additive. The 74HC165 shift register chain remains the primary key detection system. If the capacitive sensing turns out to be too noisy, too expensive to calibrate, or not worth the added complexity — nothing is lost.

graph TD
    KEYS["Key Contacts<br/>151 digital"] --> SR["74HC165 x19<br/>Shift Registers"]
    SR --> |"SPI"| ESP{ESP32-S3}

    KEYS --> |"capacitive coupling<br/>or sensor overlay"| CAP["CapSense / AC Coupling<br/>PSoC Chips"]
    CAP --> |"I2C or SPI"| ESP

    PEDAL["Expression Pedal<br/>2 analog"] --> |"ADC"| ESP

    ESP --> |"Layer 1: note on/off"| MIDI["MIDI Output<br/>USB / BLE / DIN-5"]
    ESP --> |"Layer 2: velocity, position,<br/>aftertouch, proximity"| MIDI

    style KEYS fill:#92400e,color:#fef3c7,stroke:#d97706
    style SR fill:#1e3a5f,color:#bfdbfe,stroke:#3b82f6
    style CAP fill:#164e63,color:#cffafe,stroke:#06b6d4
    style ESP fill:#78350f,color:#fef3c7,stroke:#d97706
    style PEDAL fill:#92400e,color:#fef3c7,stroke:#d97706
    style MIDI fill:#065f46,color:#d1fae5,stroke:#10b981

The ESP32-S3 fuses both data streams: shift registers provide the definitive note-on/note-off events, while the CapSense or AC coupling layer provides the continuous expression data that MIDI velocity, aftertouch, and CC messages carry. If a CapSense reading disagrees with the shift register, the shift register wins — it’s the ground truth.

  1. AC coupling bench test (simplest — no custom PCB needed)

    Solder a single insulated pickup wire near one contact rail on the lower manual. Connect to an oscilloscope probe (high-Z, AC coupled). Power the organ and press the corresponding key slowly. Observe whether the coupled signal amplitude changes measurably as the key descends toward the rail. If a clean amplitude ramp is visible: connect the pickup to a CY8C29466 ADC input and log readings versus key position.

  2. CapSense baseline test (needs a small sensor PCB)

    Build a single-octave (12-key) test strip with CY8C20236A or CY8C29466. Mount it under one octave of the lower manual. Test with the organ powered OFF to establish the baseline noise floor and verify that finger/key proximity produces clean capacitance changes. Then power the organ ON and quantify the EMI impact. Add shielding (ground plane, driven shield) and measure the improvement.

  3. Integration prototype

    Whichever approach (or combination) proves viable, integrate a single-octave prototype with the ESP32 shift register chain. Map CapSense/coupling data to MIDI velocity on Note On events and to CC messages for continuous position. Evaluate latency, resolution, and noise in a real playing scenario.

  4. Per-key calibration (from Moro’s workflow)

    Each key’s sensor response is nonlinear and mechanically unique. Moro’s three-point calibration: measure sensor reading at fully up, half-press, and fully down positions for each key, then fit a linearization curve. Store the per-key coefficients in ESP32 flash (NVS partition). This calibration must hit the design targets: ≥ 1 kHz scan rate sustained during calibrated reads, < 5 ms total action-to-MIDI latency including the linearization lookup. Recalibration should be triggerable via a maintenance mode (e.g., holding a key combination on power-up).

  • Andrew McPherson — TouchKeys (2012, NIME) — Capacitive sensor overlays for continuous key position and lateral touch. nime.org
  • Snyderphonics Manta — 48-sensor hexagonal capacitive controller for continuous pitch, pressure, and position. snyderphonics.com
  • IKOR AC-coupled keyboards (1967) — First known AC-coupled keyboard sensing using emitter/receiver pad coupling modulated by key position. telcontar.net
  • Pye Electro-Devices (1960s) — Finger-touch detection via 1 pF coupling to 100 kHz oscillator. telcontar.net
  • Silicon Labs AN447 — PCB design guidelines for capacitive sensors in electrically noisy environments.

Additional references — including Moro’s thesis, Hammond organ research, optical key position sensing, and Cypress/Infineon application notes — are organized with their respective topics in Prior Art & Thesis Research and Analog Block Architecture.