Design and Optimization of a High-Performance Magnetic Switch Keyboard Using ARM Processor and Digital Signal Processing
Abstract
The evolution of high-performance input devices has led to the adoption of Hall Effect magnetic switches, enabling features like Rapid Trigger and adjustable actuation points. However, these systems face challenges regarding analog signal noise, non-linearity, and input latency. This paper presents a comprehensive introduction for a scalable magnetic keyboard using ARM microcontrollers. We propose a split-architecture employing a high-speed Serial Peripheral Interface (SPI) and Universal Asynchronous Receiver-Transmitter (UART) for chip-to-chip communication to handle massive data streams from sensor arrays. Furthermore, a Normalized Signal Processing algorithm with a look-up table is introduced to convert raw magnetic sensor data into linearized keypress signals, enhancing accuracy and responsiveness. The proposed design aims to optimize performance, reduce latency, and improve user experience in magnetic keyboard systems.
Introduction
In the realm of high-performance computing and competitive gaming, the demand for low-latency and customizable input devices has emerged. Unlike traditional mechanical switches, Hall Effect magnetic switches provide continuous analog output corresponding to the press distance[5]. Allowing for dynamic activation points and "Rapid Trigger" functionality, where keys could be reset immediately upon release[6]. However, the implementation of magnetic switches introduces significant challenges. The magnetic field strength does not change linearly with distance[5], and the analog signal is susceptible to environmental noise, power supply fluctuations, and mechanical stem wobble[5] [6]. To achieve high precision (0.005mm resolution), the system relies heavily on the Analog-to-Digital Converter (ADC) and robust processing algorithms[5]. This paper proposes a multi-MCU architecture using ARM microcontrollers to distribute and scale the processing load. The design incorporates high-speed SPI and UART communication protocols to manage the data flow from numerous Hall Effect sensors efficiently. Additionally, we introduce a Normalized Signal Processing algorithm that utilizes a look-up table to linearize the sensor outputs, thereby enhancing the accuracy and responsiveness of keypress detection.
System Architecture
Multi-MCU Master-Slave Configuration
The proposed keyboard architecture employs a distributed multi-microcontroller unit (MCU) topology to address the computational demands of real-time Hall Effect sensor processing across a full-size keyboard matrix. The system utilizes a master-slave configuration wherein a primary ARM-based MCU (master) coordinates multiple secondary processing units (slaves) to achieve scalable sensor array management and minimize latency.
Master Controller Unit
The master MCU serves as the central processing node, responsible for:
- USB host interface management and HID protocol implementation
- Global state synchronization and calibration parameter distribution
- Aggregation of processed keypress data from slave units
- Real-time decision making for activation point detection and Rapid Trigger logic
- Power management and system initialization
Slave Controller Units
Each slave MCU interfaces directly with a subset of Hall Effect sensors (typically 16-32 switches per slave), performing localized:
- High-frequency ADC sampling and oversampling operations
- Preliminary signal conditioning and noise filtering
- Look-up table-based linearization of magnetic field measurements
- Buffered data transmission to the master controller
Inter-MCU Communication Protocols
The architecture implements a dual-protocol communication strategy optimizing for both throughput and determinism:
UART Communication Channel
Universal Asynchronous Receiver-Transmitter (UART) links are established between the master and each slave MCU for:
- Command and control signaling (calibration triggers, mode switches)
- Configuration parameter updates (actuation points, sensitivity adjustments)
- Error reporting and diagnostic messaging
- Asynchronous event notifications
UART operates at baud rates of 921,600 bps or higher, providing sufficient bandwidth for low-latency control commands while maintaining simplicity in implementation. The asynchronous nature of UART allows for interrupt-driven processing without strict timing constraints[1][3].
SPI Communication Channel
Serial Peripheral Interface (SPI) connections facilitate high-throughput bulk data transfer:
- Continuous streaming of processed sensor readings from slaves to master
- Synchronous multi-slave polling in round-robin fashion
- DMA-enabled transfers to minimize CPU overhead
- Clock rates of 10-20 MHz enabling sub-millisecond update cycles
SPI's full-duplex capability allows the master to simultaneously request data while receiving processed samples, achieving aggregate bandwidths exceeding 2 MB/s across multiple slave units[1][3]. This ensures the 8000Hz polling rate can be sustained even with 100+ key matrices.
Hall Effect Sensor Hardware Design
Magnetic Sensing Principle
The Hall Effect sensor operates on the principle of the Lorentz force acting on charge carriers in a semiconductor material when subjected to a perpendicular magnetic field. The sensor IC contains a thin semiconductor plate with a constant current flowing through it. When a magnetic field B (generated by a permanent magnet attached to the keyswitch stem) passes perpendicular to the current direction, charge carriers experience a deflection, creating a measurable voltage VH proportional to the magnetic flux density:
Where:
- VH = Hall voltage output
- RH = Hall coefficient of the semiconductor material
- I = applied current through the sensor
- B = magnetic flux density
- t = thickness of the semiconductor plate
As the keyswitch is pressed, the magnet moves closer to the Hall sensor, increasing the magnetic flux density and consequently the Hall voltage. The non-linear relationship between distance and magnetic field strength follows an inverse cube law approximation for small magnets[5]:
where represents the distance between the magnet and sensor.
Sensor Signal Chain
The complete signal acquisition chain consists of:
-
Hall Effect IC: Typically a ratiometric linear sensor (e.g., A1324, SS49E) providing analog voltage output proportional to magnetic field strength.
-
Analog Conditioning: Operational amplifier stage for signal amplification and offset adjustment to maximize ADC input range utilization.
-
Anti-Aliasing Filter: Low-pass RC filter (fc ≈ 10-20 kHz) to attenuate high-frequency electromagnetic interference before ADC sampling.
-
ADC Interface: Differential input to the microcontroller's successive approximation register (SAR) ADC for digitization.
ADC Oversampling and Noise Reduction
To achieve sub-millimeter position resolution (0.005mm target) from inherently noisy magnetic measurements, the system employs oversampling and decimation techniques to increase effective ADC resolution from 12-bit to 14-bit.
Oversampling Theory
According to Nyquist sampling theorem and noise averaging principles, oversampling by a factor of provides an additional bits of resolution when the noise is sufficiently random and uncorrelated[2]. For a 2-bit improvement (12-bit to 14-bit), the required oversampling ratio (OSR) is:
Implementation
The ADC sampling process operates as follows:
-
Rapid Acquisition: The 12-bit SAR ADC samples each sensor 16 times consecutively at maximum conversion rate (typically 1-2 µs per sample).
-
Accumulation: The 16 samples are summed in a 16-bit accumulator register:
where is the accumulator and represents individual sample values.
- Decimation: The accumulated value is right-shifted by 2 bits (divided by 4) to produce a 14-bit result:
This technique effectively averages out white noise and quantization error, increasing signal-to-noise ratio (SNR) by approximately 6 dB per additional bit[2]. The resulting 14-bit resolution provides 4× finer position discrimination compared to native 12-bit sampling, critical for detecting minute keypress movements in Rapid Trigger applications.
Performance Trade-offs
While oversampling improves resolution, it introduces timing overhead. With a 16× OSR and 1 µs ADC conversion time, each sensor reading requires ~16 µs. For a 80-key keyboard matrix scanned at 8000 Hz (125 µs period), the distributed master-slave architecture with parallel processing across multiple MCUs ensures scan completion within the allotted time budget.
Signal Processing and Linearization
Normalized Signal Processing Algorithm
The raw ADC measurements from Hall Effect sensors exhibit severe non-linearity due to the inverse cubic relationship between magnetic field strength and distance. To convert these non-linear voltage readings into proportional displacement values suitable for keypress detection, we employ a lookup table (LUT) based normalization algorithm.
Normalization Methodology
The normalization process transforms the raw ADC value into a linearized analog output representing the physical keypress position. The algorithm operates as follows:
- Range Mapping: For each key, calibrated upper and lower bounds , define the full travel range. The normalized position coefficient is computed as:
This maps the sensor reading to a normalized range , where 0 represents the fully released position and 1 represents maximum depression.
- Lookup Table Indexing: The normalized coefficient is scaled to index into a pre-computed linearization table of length :
The lookup table contains pre-calculated correction factors derived empirically through physical measurement of magnetic field strength versus distance for the specific magnet and sensor geometry used in the keyboard.
- Output Scaling: The retrieved table value is scaled to the desired output range:
where is the output range and is the minimum output value.
Fixed-Point Optimization
For microcontrollers without hardware floating-point units, the implementation employs fixed-point arithmetic to maintain computational efficiency:
This integer-only formulation eliminates costly floating-point divisions while preserving accuracy through careful selection of table size (typically 64-256 entries) and integer scaling factors.
Boundary Handling
The algorithm incorporates saturation logic to handle edge cases:
- If (sensor reading exceeds upper bound), set
- If (key pressed beyond calibrated range), clamp to
This ensures graceful handling of mechanical overshoot and sensor drift without introducing discontinuities in the output signal.
Kalman Filtering for Noise Reduction
Despite ADC oversampling, residual noise from electromagnetic interference, mechanical vibrations, and thermal drift necessitates additional filtering. We implement a one-dimensional Kalman filter for each key to achieve optimal noise suppression while maintaining fast response to legitimate keypresses[2].
Filter Initialization and Adaptation
The Kalman filter parameters are adaptively initialized for each key through a calibration procedure:
- Noise Characterization: The system collects samples at the key's rest position, computing the sample mean and variance :
- Measurement Noise Estimation: The measurement noise covariance is estimated from the observed variance, with a minimum threshold to prevent filter instability:
- Filter Parameters: The Kalman filter is initialized with:
- Process noise covariance: (assumes slow thermal drift)
- Initial state covariance:
- Sampling period: where Hz
Kalman Filter Equations
The discrete-time Kalman filter operates in two phases per sampling cycle:
Prediction Step:
Update Step:
where:
- is the filtered state estimate (output position)
- is the measured value (from normalization stage)
- is the Kalman gain
- is the estimation error covariance
Filter Domain Selection
The Kalman filter can be applied in two domains:
-
Raw Domain Filtering: Applied directly to ADC readings before normalization. Advantages include consistent noise characteristics and simpler calibration.
-
Normalized Domain Filtering: Applied after LUT linearization. Provides more uniform noise statistics across the keypress range but requires recalibration when actuation points change.
Our implementation supports both modes through compile-time configuration, allowing optimization based on specific application requirements.
Combined Processing Pipeline
The complete signal processing chain for each key operates at 8000 Hz:
- 16× oversampled ADC acquisition → 14-bit raw value
- Kalman filter (optional, domain-configurable) → noise-reduced reading
- LUT-based normalization → linearized position
- Kalman filter (optional, normalized domain) → final output
- Actuation detection and Rapid Trigger logic → keypress events
This multi-stage processing achieves sub-0.005mm position resolution with noise floor below 0.001mm RMS, enabling reliable detection of minute keypress movements even in electrically noisy environments.
References
[1] Zibayiwa, M., & Chigwagwa, T. "A Review on The Inter-Processor Communication: I2C, UART, and SPI interfacing techniques," Department of Applied Physics and Telecommunications & Department of Metallurgical and Materials Engineering, Midlands State University. [2] Ma'arif, A., Iswanto, Nuryono, A. A., & Alfian, R. I. (2019). "Kalman Filter for Noise Reducer on Sensor Readings," Signal and Image Processing Letters, Vol. 1, No. 2, page 10-21. ISSN 2714-6677. [3] Pahlevi, R. R., Putrada, A. G., & Abdurohman, M. (2018). "Fast UART and SPI Protocol for Scalable IoT Platform," School of Computing, Telkom University, Bandung, Indonesia. [4] Shi, K., Wang, Z., Luo, F., & Gu, C. (2014). "Design and Realization of General Matrix Keyboard based on STM32," Institute of information science and engineering, East China University of Science and Technology, Shanghai, China. Technical Documentation [5] RAKKA Keyboards. (2022-2025). "Technology behind Hall effect keyboards," Knowledge Base. [6] RAKKA Keyboards. (2022-2025). "Debunking Common Misconceptions About Hall Effect keyboards — The True Meaning Behind Technical Specs," Knowledge Base.