đš Piano Player â Mechatronics Design Project
đŻ Project Objective
Design and build a fullârange electromechanical pianoâplaying system capable of actuating all 88 keys of a standard acoustic piano using MIDI performance data.
The project began as a fully remote collaboration, with mechanical, electrical, and firmware development performed in Taiwan. Over time, it evolved into a longâterm embedded systems and realâtime control R&D platform, serving as a vehicle for learning, architectural experimentation, and scalable mechatronic design.
đ§Š System Overview
The system is built around a modular actuator architecture consisting of two identical 44âkey subsystems, each responsible for half of the keyboard. This modularity supports:
- Incremental mechanical assembly
- Independent subsystem testing
- Easier debugging and refinement
- Remote collaboration and partial builds
The architecture cleanly separates:
- Realâtime actuator control (embedded controller)
- Highâlevel sequencing, playback, and user interaction (host system)
This separation ensures direct actuation while enabling flexible external control, observability, and experimentation.
đ§Š Early Design Constraints & Rationale
Initial design discussions established several constraints that shaped the first prototype:
- The system needed to use an Arduinoâclass microcontroller for accessibility and ease of replacement and institutional knowledge at the partnerâs request.
- Hobby servos were selected for availability, simplicity, and lowâcost experimentation.
- The system had to be modular and serviceable, supporting partial builds and rapid iteration.
- Musical performance data would be supplied via standard MIDI, originating from a PC or Raspberry Pi.
- The mechanical structure needed to be lowâcost, easy to fabricate, and modifiable without specialized tools.
These constraints strongly influenced the early mechanical layout, electronics partitioning, and firmware structure.
âď¸ Mechanical Design
Mechanical design was carried out in Autodesk Fusion 360, with emphasis on:
- Rapid iteration
- Lowâcost fabrication
- Easy disassembly and modification
Due to limited workshop access and budget constraints, the prototype frame was built from laserâcut plywood and perspex, assembled using mechanical fasteners rather than adhesives. This allowed fast design revisions and mechanical experimentation during early testing.
Design artifacts:
⥠Electronics
Original Architecture (ArduinoâBased)
The first-generation system required independent control of 88 servo motors, one per piano key. To support this:
- Two Arduino Mega boards were used, each controlling 44 keys
- A hardware selector switch assigned each board to its note range
- A custom interface PCB handled:
- Servo signal routing
- Power distribution
- External MIDI input
- Boardâtoâboard interconnects and test access
All schematics and PCB layouts were created in KiCad, with fabrication performed by JLCPCB.
PCB documentation:
- Controller PCB Design
- Controller PCB Top Layer
- Controller PCB Bottom Layer
- Populated PCB â View 1
- Populated PCB â View 2
While functional, this architecture revealed limitations:
- Servo timing jitter due to MCU timer constraints
- Power distribution challenges during dense chord play
- Increasing firmware complexity as features grew
- Difficulty scaling beyond the monolithic control loop
These limitations motivated a full system redesign.
đž Embedded Software
Initial Firmware (Arduino)
The original firmware:
- Parsed standard MIDI input
- Mapped MIDI notes to actuators
- Controlled servo position and motion timing
- Coordinated multiâkey actuation for chords
- Included diagnostic and test modes
Although successful, the monolithic structure struggled with timing problems as the Arduino was severely underpowered for the job.
đ§ System Redesign & Modern Architecture
The system is now being reâarchitected as a modern embedded control platform focused on determinism, scalability, and robustness.
Hardware & Control Evolution
- Migration from direct MCUâdriven servo outputs to I²Câbased PWM driver boards (PCA9685âclass)
- Improved electrical load distribution and powerâdomain separation
- Cleaner signal routing and reduced ISR load
Firmware Architecture (Zephyr RTOS)
The embedded control layer has been ported to Zephyr RTOS running on an STM32WB55, introducing:
- A multiâthreaded architecture separating:
- MIDI input parsing
- Event scheduling
- Actuator motion execution
- Explicit timing determinism and task prioritization
- Robust interâthread communication
- Improved fault isolation and system resilience
This architecture cleanly decouples realâtime actuation from nonâdeterministic external inputs.
đ Host Control & Web Interface
To support remote testing and flexible playback, a hostâside control layer provides:
- MIDI file browsing and selection
- Playlist management
- Playback control (play, pause, stop, next)
- Realâtime system observation
Evolution of the Host System
The webserver originally ran on a Raspberry Pi 2B, but under heavy load (multiple clients, large MIDI files, realâtime updates) the Pi became CPUâbound. To improve responsiveness and reliability, the system was migrated to a more powerful openSUSE Linux workstation, resulting in:
- Faster page loads
- Lower latency in control commands
- More stable longâduration playback sessions
- Headroom for future features (e.g., video streaming, analytics)
This migration reflects the systemâs evolution from a simple test interface to a robust orchestration layer.
đ¸ Media
Arduino Prototype
STM32 / Zephyr Prototype (Current)
Note: Only one 44âkey subsystem is shown. The second subsystem was provided to a collaborator for independent testing, and the architecture is validated on a halfâkeyboard before full 88âkey reintegration.
đ§ Current Status & Next Steps
Completed
- Modular mechanical and electrical platform
- Reliable 44âkey realâtime actuation
- MIDIâdriven embedded control
- Hostâbased playback and monitoring interface
- Migration of host system from RPi2B to openSUSE workstation
In Progress
- BLEâMIDI transport integration
- Debugging and performance improvements
- Refinement of actuator motion profiles
Planned Enhancements
- Mechanical completion of the full 88âkey system
- Perâactuator temperature monitoring and protection
- Powerâaware scheduling for dense chord passages
- Further optimization of realâtime control algorithms