Design and Optimization of a High-Performance Magnetic Switch Keyboard Using ARM Processor and Digital Signal Processing

Authors: Mihal Dimo ([email protected]) — Mai ([email protected])
Published: December 15, 2025

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:

VH=RH×I×BtVH = \frac{RH \times I \times B}{t}

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

B∝1d3B \propto \frac{1}{d^3}

where dd represents the distance between the magnet and sensor.

Sensor Signal Chain

The complete signal acquisition chain consists of:

  1. Hall Effect IC: Typically a ratiometric linear sensor (e.g., A1324, SS49E) providing analog voltage output proportional to magnetic field strength.

  2. Analog Conditioning: Operational amplifier stage for signal amplification and offset adjustment to maximize ADC input range utilization.

  3. Anti-Aliasing Filter: Low-pass RC filter (fc ≈ 10-20 kHz) to attenuate high-frequency electromagnetic interference before ADC sampling.

  4. 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 4n4^n provides an additional nn 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:

OSR=42=16 samples\text{OSR} = 4^2 = 16 \text{ samples}

Implementation

The ADC sampling process operates as follows:

  1. Rapid Acquisition: The 12-bit SAR ADC samples each sensor 16 times consecutively at maximum conversion rate (typically 1-2 µs per sample).

  2. Accumulation: The 16 samples are summed in a 16-bit accumulator register:

A=∑i=116SiA = \sum_{i=1}^{16} S_i

where AA is the accumulator and SiS_i represents individual sample values.

  1. Decimation: The accumulated value is right-shifted by 2 bits (divided by 4) to produce a 14-bit result:

Output14bit=⌊A4⌋\text{Output}_{14\text{bit}} = \left\lfloor \frac{A}{4} \right\rfloor

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 VrawV_{\text{raw}} into a linearized analog output VanalogV_{\text{analog}} representing the physical keypress position. The algorithm operates as follows:

  1. Range Mapping: For each key, calibrated upper and lower bounds (Vupper(V_{\text{upper}}, Vlower)V_{\text{lower}}) define the full travel range. The normalized position coefficient xx is computed as:

x=Vupper−VrawVupper−Vlowerx = \frac{V_{\text{upper}} - V_{\text{raw}}}{V_{\text{upper}} - V_{\text{lower}}}

This maps the sensor reading to a normalized range [0,1][0, 1], where 0 represents the fully released position and 1 represents maximum depression.

  1. Lookup Table Indexing: The normalized coefficient xx is scaled to index into a pre-computed linearization table of length NN:

index=⌊x⋅N⌋\text{index} = \lfloor x \cdot N \rfloor

The lookup table contains NN 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.

  1. Output Scaling: The retrieved table value T[index]T[\text{index}] is scaled to the desired output range:

Vanalog=T[index]⋅R+VminV_{\text{analog}} = T[\text{index}] \cdot R + V_{\text{min}}

where RR is the output range and VminV_{\text{min}} 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:

index=(Vupper−Vraw)⋅NVupper−Vlower\text{index} = \frac{(V_{\text{upper}} - V_{\text{raw}}) \cdot N}{V_{\text{upper}} - V_{\text{lower}}}

This integer-only formulation eliminates costly floating-point divisions while preserving accuracy through careful selection of table size NN (typically 64-256 entries) and integer scaling factors.

Boundary Handling

The algorithm incorporates saturation logic to handle edge cases:

  • If x<0x < 0 (sensor reading exceeds upper bound), set x=0x = 0
  • If index≥N\text{index} \geq N (key pressed beyond calibrated range), clamp to index=N−1\text{index} = N - 1

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:

  1. Noise Characterization: The system collects M=128M = 128 samples at the key's rest position, computing the sample mean μ\mu and variance σ2\sigma^2:

μ=1M∑i=1MVi\mu = \frac{1}{M} \sum_{i=1}^{M} V_i

σ2=1M∑i=1MVi2−μ2\sigma^2 = \frac{1}{M} \sum_{i=1}^{M} V_i^2 - \mu^2

  1. Measurement Noise Estimation: The measurement noise covariance RR is estimated from the observed variance, with a minimum threshold to prevent filter instability:

R=max⁡(σ2,0.5)R = \max(\sigma^2, 0.5)

  1. Filter Parameters: The Kalman filter is initialized with:
    • Process noise covariance: Q=0.01Q = 0.01 (assumes slow thermal drift)
    • Initial state covariance: P0=0.1P_0 = 0.1
    • Sampling period: Δt=1fpoll\Delta t = \frac{1}{f_{\text{poll}}} where fpoll=8000f_{\text{poll}} = 8000 Hz

Kalman Filter Equations

The discrete-time Kalman filter operates in two phases per sampling cycle:

Prediction Step:

x^k∣k−1=x^k−1∣k−1\hat{x}_{k|k-1} = \hat{x}_{k-1|k-1}

Pk∣k−1=Pk−1∣k−1+QP_{k|k-1} = P_{k-1|k-1} + Q

Update Step:

Kk=Pk∣k−1Pk∣k−1+RK_k = \frac{P_{k|k-1}}{P_{k|k-1} + R}

x^k∣k=x^k∣k−1+Kk(zk−x^k∣k−1)\hat{x}_{k|k} = \hat{x}_{k|k-1} + K_k(z_k - \hat{x}_{k|k-1})

Pk∣k=(1−Kk)Pk∣k−1P_{k|k} = (1 - K_k)P_{k|k-1}

where:

  • x^k∣k\hat{x}_{k|k} is the filtered state estimate (output position)
  • zkz_k is the measured value (from normalization stage)
  • KkK_k is the Kalman gain
  • Pk∣kP_{k|k} is the estimation error covariance

Filter Domain Selection

The Kalman filter can be applied in two domains:

  1. Raw Domain Filtering: Applied directly to ADC readings before normalization. Advantages include consistent noise characteristics and simpler calibration.

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

  1. 16× oversampled ADC acquisition → 14-bit raw value
  2. Kalman filter (optional, domain-configurable) → noise-reduced reading
  3. LUT-based normalization → linearized position
  4. Kalman filter (optional, normalized domain) → final output
  5. 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.