Magnetic axis keyboard control method
By combining multi-frequency magnetic excitation to drive giant magnetoresistance with tunnel magnetoresistive array, sparse compression, and Bayesian correction, the problem that traditional keyboards cannot detect XY lateral micro-movements is solved, realizing high-precision, low-power three-dimensional displacement detection of magnetic axis keyboards in complex human-computer interaction.
Patent Information
- Application Number
- CN202510886778.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-11-18
AI Technical Summary
Traditional mechanical or membrane keyboards cannot sense lateral micro-movements and tilt angles within the XY horizontal plane, resulting in limited functionality in multimodal input, force feedback, and gesture interaction scenarios. Existing magnetic axis keyboard solutions suffer from problems such as complex kilohertz sampling, difficulty in noise suppression, and significant temperature drift.
A multi-frequency magnetic excitation is used to drive a giant magnetoresistive and tunneling magnetoresistive array. Through sparse compression, iterative reconstruction and Bayesian correction, combined with pulse time difference coding and pulse graph convolutional network, real-time detection and feedback of triaxial magnetic vectors are achieved.
It achieves three-dimensional displacement detection with microsecond-level closed-loop, micrometer-level accuracy, and milliwatt-level power consumption, reducing the impact of long-term drift and enhancing the application depth of keyboards in complex human-computer interactions.
Smart Images

Figure CN120973243A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent magnetic sensor fusion technology, and in particular to a magnetic axis keyboard control method. Background Technology
[0002] Traditional mechanical or membrane keyboards can only move along the Z-axis (vertical direction perpendicular to the keyboard plane) for each key. The control logic relies on metal spring closure, optical blocking, or linear Hall effect elements to determine only the travel depth and trigger threshold. This type of structure cannot sense lateral micro-movements and tilt angles in the XY horizontal plane, thus limiting its functionality in multimodal input, force feedback, and gesture interaction scenarios.
[0003] like Figures 1-2 As shown, magnetic axis keyboards, by arranging permanent magnets and multi-directional magnetic sensitive elements within the key cavity, allow each key to independently detect changes in the magnetic field from weak to strong in the X, Y, and Z planes: the Z-plane signal replaces traditional travel detection; the X and Y plane signals (aligned with the keyboard's horizontal plane) are unique to magnetic axes and can capture complex operations such as tilting and rotation. However, existing magnetic axis solutions mostly use single-linear Hall elements with amplitude comparison—sensing only the Z-axis; the displacement-voltage curve has a narrow linear region, requiring operational amplifiers to stretch the dynamic range; and it uses low-speed I... 2 The C / USB polling reporting mechanism makes it difficult to achieve kilohertz sampling, composite gesture recognition, and adaptive noise suppression. Furthermore, the lack of an online learning mechanism makes it susceptible to temperature drift and component tolerances, requiring manual calibration for long-term drift. These shortcomings limit the application depth of magnetic axis keyboards in e-sports and complex human-computer interaction. Summary of the Invention
[0004] To address the numerous problems existing in the prior art, this invention provides a magnetic axis keyboard control method. This invention employs multi-frequency magnetic excitation to drive a giant magnetoresistive array and a tunneling magnetoresistive array, acquiring three-axis magnetic vectors in the same frame. Zero drift is eliminated through sparse compression, iterative reconstruction, and Bayesian correction. Then, pulse time difference encoding is input into a two-layer pulse graph convolutional network to output three-dimensional displacement in real time. When the value function is below a threshold, the readout weights are fine-tuned based on pulse time-dependent plasticity, and the piezoelectric vibration associated with the displacement amplitude and the corresponding LED luminous efficacy in the displacement direction are output synchronously, achieving microsecond-level closed-loop control, micrometer-level accuracy, and milliwatt-level power consumption.
[0005] A magnetic axis keyboard control method includes the following steps: A multi-frequency excitation magnetic field is generated, and under the action of the excitation magnetic field, the following are simultaneously acquired: impedance parameters of a giant magnetoresistive sensor; induced voltage of a first-direction magnetic sensor; induced voltage of a second-direction magnetic sensor orthogonal to the first direction; and packaged into a single-frame measurement vector according to a unified time reference. The measurement vector is multiplied by a preset sparse matrix to generate a compressed observation vector. The weighted least norm iterative reconstruction algorithm is used to obtain the reconstructed vector. Bayesian estimation is performed based on the covariance prior of the previous frame to obtain the corrected triaxial magnetic vector and the corresponding posterior parameters. The corrected triaxial magnetic vector is quantized at a fixed point and converted into a pulse time difference signal. The pulse time difference signal is input into a pulse neural network, and the network weights are adjusted using the posterior parameters to obtain an instantaneous displacement vector. The value function is calculated based on the instantaneous displacement vector and the preset evaluation index. The quantization step size is determined, the instantaneous displacement vector is encapsulated, and sent through the communication interface. When the value function is lower than the threshold, the readout weights of the spiking neural network are updated according to the pulse timing dependence plasticity rule, and the piezoelectric driving signal corresponding to the displacement amplitude and the light-emitting diode driving signal corresponding to the displacement direction are output respectively.
[0006] Preferably, the multi-frequency excitation magnetic field is synthesized by synchronizing at least three sinusoidal signals that are not integer multiples of each other. The amplitude and frequency of each sinusoidal signal are kept constant to reduce intermodulation interference and stabilize the magnetic field amplitude.
[0007] Preferably, the single-frame measurement vector is timestamped under a shared clock reference, written to a circular buffer immediately after encapsulation, and an interrupt is triggered at the end of the sampling period to start the compressed observation vector generation step.
[0008] Preferably, the positions of the non-zero elements of the preset sparse matrix are determined by a pseudo-random sequence output by a linear feedback shift register. The pseudo-random sequence is reinitialized after a preset number of frames to increase the probability that the compressed observation vector satisfies the sparse reconstruction condition.
[0009] Preferably, the weighted least norm iterative reconstruction algorithm updates the weights in each iteration according to the reciprocal of the magnitude of the current reconstructed vector, and terminates the iteration when the Euclidean distance between the reconstructed vectors obtained in two adjacent iterations is lower than the threshold.
[0010] Preferably, Bayesian estimation obtains the corrected three-axis magnetic vector and posterior parameters by linearly fusing the covariance prior of the previous frame with the covariance of the reconstructed vector of the current frame, and writes the posterior parameters back as the covariance prior of the next frame.
[0011] Preferably, fixed-point quantization uses a fixed-length format to separately encode the sign bit and amplitude bit of the correction triaxial magnetic vector, and the quantization ratio is applied when the system is powered on and remains constant during operation.
[0012] Preferably, the spiking neural network consists of two spiking graph convolutional layers. Each layer establishes an adjacency matrix by calculating the cosine similarity of the node embedding vectors, and adjusts the regularization intensity of the convolution weights in real time according to the posterior parameters during inference.
[0013] Preferably, the value function takes the distance between the instantaneous displacement vector and the prediction vector of the previous frame, as well as the power consumption integral, as input, and outputs a single scalar result for determining the adaptive quantization step size.
[0014] Preferably, when the value function is below the threshold, the readout weights of the spiking neural network are updated according to the pulse timing-dependent plasticity rule. The increase or decrease of the weights is exponentially related to the pulse arrival time difference. After the weight update is completed, the piezoelectric driving signal corresponding to the displacement amplitude and the light-emitting diode driving signal corresponding to the displacement direction are output respectively.
[0015] Compared with the prior art, the advantages and beneficial effects of the present invention are as follows: By combining multi-frequency magnetic excitation with giant magnetoresistance-tunneling magnetoresistive hybrid sensing, three-axis magnetic vectors are acquired synchronously in a single operation, avoiding timing errors from multiple chips. Dimensionality reduction, noise reduction, and zero-drift compensation are achieved within a frame period through sparse compression, weighted least-norm reconstruction, and Bayesian estimation, achieving sub-micron resolution. Real-time displacement is output within 5µs with milliwatt-level power consumption via fixed-point quantization, pulse time difference encoding, and pulse graph convolutional networks. The temporal plasticity of value function gating allows for self-learning only in high-confidence frames, reducing long-term drift by 40%. Real-time dual-modal feedback of displacement amplitude and direction is provided through piezoelectric vibration and LED hue mapping. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the external structure of the keyboard in this invention; Figure 2 This is a schematic diagram of the internal structure of the keyboard in this invention; Figure 3 This is a flowchart illustrating the method of the present invention. Detailed Implementation
[0017] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation.
[0018] like Figure 3 As shown, a magnetic axis keyboard control method includes the following steps: A multi-frequency excitation magnetic field is generated, and under the action of the excitation magnetic field, the following are simultaneously acquired: impedance parameters of a giant magnetoresistive sensor; induced voltage of a first-direction magnetic sensor; induced voltage of a second-direction magnetic sensor orthogonal to the first direction; and packaged into a single-frame measurement vector according to a unified time reference. This invention proposes a multi-frequency excitation-three-directional magnetic sensing collaborative acquisition mechanism for magnetic axis keyboards, used to generate single-frame measurement vectors that can directly serve three-dimensional displacement inversion. The overall principle can be divided into three parts: magnetic field excitation, vector sensing, and time encapsulation. Each part differs from existing linear Hall effect schemes in its implementation details, resulting in higher resolution and stronger anti-interference performance.
[0019] The magnetic field excitation is handled by a miniature Helmholtz coil. The coil is driven according to a waveform lookup table, simultaneously outputting three non-integer multiples of each other, denoted as . , , The three sets of signals are combined by the on-chip power stage to form a spatial magnetic field, creating a nearly uniform area at the center of the key. When the permanent magnet inside the keycap undergoes a micro-displacement, the magnetic flux density fluctuates within the millitalas range. Because... , , With frequencies being coprime, the inductive reactance responses at each frequency remain separated in the spectral domain, eliminating intermodulation distortion and widening the dynamic range of sensible displacement. The coprime frequency design also simplifies electromagnetic compatibility filtering because there are no overlapping components in the harmonic space, avoiding interference to adjacent button RF modules.
[0020] The vector sensing section employs a heterogeneous three-sensor combination. The first sensor is a giant magnetoresistive (GMR) sensor, whose core is a soft magnetic alloy microwire with a diameter of approximately 50 micrometers and copper-plated on the surface to reduce external parasitic impedance. After radio frequency biasing, the sensor's real and imaginary impedance parts are exponentially sensitive to changes in the external magnetic field. This invention uses resistance, inductance, and impedance phase as impedance parameters. The second and third sensors are tunneling magnetoresistive bridges, respectively positioned in two orthogonal directions on the keyboard plane. The second sensor outputs a differential voltage along the X-direction, and the third sensor outputs a differential voltage along the Y-direction. The GMR sensor is responsible for high-resolution amplitude detection in the Z-direction, and the two tunneling magnetoresistive bridges provide signals in two orthogonal directions within the plane. These three sets of data constitute a minimal complete set of three-dimensional magnetic vectors. This avoids the complex calibration required to simultaneously compensate for temperature drift using three linear Hall effect sensors and fully utilizes the high sensitivity of GMR in the low magnetic field range.
[0021] The timing encapsulation section relies on a unified time base. All analog-to-digital conversion channels are driven by the system clock obtained by dividing a 24-bit phase accumulator, ensuring that each sample has a unique time index and avoiding phase jitter caused by asynchronous sampling. The encapsulation logic sequentially writes six physical quantities: giant magnetoresistance resistance, giant magnetoresistance inductance, giant magnetoresistance phase, X-direction induced voltage, Y-direction induced voltage, and frame synchronization flag, forming a single-frame measurement vector. In subsequent core algorithms, this vector serves as the sole entry point and will not be further split. All three excitation signals (6 dimensions) are encapsulated with a 25-microsecond cycle, allowing direct input to the compressed sensing and Bayesian correction link.
[0022] Through the above design, the present invention achieves the following technical effects: The multi-frequency excitation magnetic field allows the same travel event to produce separable responses at three frequency points, improving the signal-to-noise ratio of the magnetic signal at low amplitude displacements; the frequency coprime characteristics avoid harmonic overlap, so that the electromagnetic compatibility requirements can be met without complex filtering networks during system maintenance.
[0023] The exponential sensitivity of the giant magnetoresistive sensor to the change in magnetic flux density in the Z direction is complementary to the linear response of the tunnel magnetoresistive bridge in the X and Y planes, enabling the coverage of three dimensions of information with only three devices, without the need for an additional compensation bridge.
[0024] The unified time base of the single-frame measurement vector ensures that the subsequent sparse reconstruction runs at a fixed frame length, and the system does not introduce error accumulation due to the time base difference of each channel.
[0025] The following example illustrates the workflow and effects of this invention. The keycap is slightly moved 50 micrometers vertically, 30 micrometers along the X-axis, and maintains zero displacement in the Y-axis. Under the action of three excitations, the increase in the giant magnetoresistance is approximately 0.03, the increase in the induced voltage in the X-axis is approximately 0.02 of the full scale, and the induced voltage in the Y-axis remains at the baseline. The corresponding single-frame measurement vector enters the compressed observation process: a sparse matrix with 64 rows and 256 columns is preset, and a compressed observation vector is generated through multiplication. Weighted least norm iterative reconstruction is used, and the reconstructed vector is obtained after 4 iterations; then, Bayesian estimation is performed by combining the covariance prior of the previous frame, and the corrected three-axis magnetic vector and posterior parameters are output. After fixed-point quantization, pulse time difference encoding, and pulse graph convolution inference, the final inversion yields a vertical displacement of 49.8 micrometers, an X-axis displacement of 29.4 micrometers, and a Y-axis displacement of 0.5 micrometers, with all three-dimensional errors less than 1 micrometer.
[0026] This invention combines innovative designs from three directions: multi-frequency excitation, giant magnetoresistance-tunnel magnetoresistance hybrid sensing, and unified time base packaging. It achieves a dual improvement in resolution, stability, and anti-interference capability of magnetic axis keyboards in three-dimensional displacement detection by using a closed-loop processing link of compressed sensing-Bayesian-pulse network with strictly synchronized single-frame measurement vector input.
[0027] Preferably, the multi-frequency excitation magnetic field is synthesized by synchronizing at least three sinusoidal signals that are not integer multiples of each other. The amplitude and frequency of each sinusoidal signal are kept constant to reduce intermodulation interference and stabilize the magnetic field amplitude.
[0028] The multi-frequency excitation magnetic field is the signal source for the keyboard detection link of this invention. Its physical essence is the simultaneous superposition of three or more sinusoidal currents on a miniature Helmholtz coil. The frequency of each current... The frequency of each channel is not an integer multiple of the frequency of any other channel; the amplitude of each channel... With phase It remains constant throughout the execution cycle. Therefore, the resulting magnetic flux density at the center of the coil can be expressed by the formula:
[0029] in The time-varying composite magnetic induction intensity For the sine path, For the first Road width value, For the first Road frequency, For the first Initial phase of the path. Due to Coprime means that no cross terms appear at integer multiples of the frequency after the formula is expanded, thus avoiding intermodulation components falling into the sensor bandwidth and interfering with demodulation.
[0030] At the principle level, the micro-displacement of the permanent magnet beneath the keycap in three directions modulates the amplitude and phase of different frequency components. The giant magnetoresistive sensor, due to its near-exponential relationship between impedance and magnetic flux density, can respond sensitively to amplitude disturbances in the composite field in the vertical direction. Two tunnel magnetoresistive bridges differentially detect the modulated components in the X and Y directions within the keyboard plane. Phase synchronization means that during system startup, a phase-locked loop is used to correct the reference zero point of the three waveforms, ensuring that the three magnetic fluxes are spatially superimposed in the same direction. Micro-displacement of the permanent magnet will not transform three-dimensional disturbances into spurious vector changes due to phase drift. Constant amplitude ensures that baseline drift is not caused by power amplifier temperature drift during long-term operation, simplifying the workload of subsequent Bayesian correction.
[0031] In terms of implementation details, the waveform lookup table is stored in read-only memory, and its contents are the waveforms within one cycle. , , Amplitude sampling is performed. The digital-to-analog converter drives the power amplifier with a common clock, ensuring that the three data streams at any sampling point have strictly identical time signatures. The power amplifier output is band-limited by a T-shaped impedance network before being fed into the coil to suppress higher harmonics. The coil geometry employs a double-layer trapezoidal winding, with the inner and outer layers in opposite directions, which cancels out the radiated magnetic field gradient and eliminates crosstalk between adjacent keyways.
[0032] The effect verification was performed using an actual keyboard prototype. Prototype settings. The amplitudes were all 0.5 mT. The test was conducted by repeatedly pressing the designated key in a constant temperature environment of 25℃. Compared with the single-frequency excitation scheme, the multi-frequency excitation reduced the variance of the 3D reconstruction error by about 35%. Further temperature cycling within the range of 10℃ to 60℃, the multi-frequency field with constant amplitude suppressed the vertical zero-point drift to within 1µT, while the single-frequency field drifted to 4µT under the same conditions.
[0033] Example: The keycap is driven by a precision displacement stage, with a vertical step of 40µm, an X-axis sinusoidal sweep of 20µm, and the Y-axis remaining in place. The output impedance amplitude of the giant magnetoresistive channel increases by 2.8%, the differential voltage amplitude of the tunnel magnetoresistive bridge X-channel increases by 1.5%, and there is no significant change in the Y-channel. After subsequent sparse reconstruction and Bayesian correction, the inversion displacement errors are 0.8µm, 0.9µm, and 0.5µm, respectively. If the coprime frequencies are replaced with a set of tests that have an integer multiple relationship, an intermodulation distortion peak can be observed under the same displacement, and the reconstruction error increases to over 3µm, verifying the necessity of the coprime design.
[0034] Preferably, the single-frame measurement vector is timestamped under a shared clock reference, written to a circular buffer immediately after encapsulation, and an interrupt is triggered at the end of the sampling period to start the compressed observation vector generation step.
[0035] The time encapsulation mechanism of single-frame measurement vectors connects front-end sampling and subsequent compressed observations, forming the temporal foundation for ensuring the accuracy of 3D displacement calculations in this invention. The core idea of this mechanism is to assign a unique time identifier to each synchronous sample and strictly control the order of writing and triggering at the hardware level, thereby eliminating data misalignment caused by channel phase inconsistencies and cache read / write contention. The complete process consists of three stages: time base generation, vector encapsulation writing, and interrupt triggering.
[0036] Time base generation. The system uses a 24-bit phase accumulator to divide the crystal oscillator output by an integer to obtain a 160MHz master clock. The master clock is further divided by a programmable counter to generate a 40kHz sampling clock and a 40kHz frame clock, both of which are phase-aligned. The sampling clock drives three analog-to-digital conversion channels, ensuring that the giant magnetoresistance impedance parameters and the two tunnel magnetoresistive differential voltages are digitized at the same sampling point. The rising edge of the frame clock represents the end of a complete sampling cycle, and the falling edge is used for write confirmation and interrupt triggering. The clock tree corrects the duty cycle through a phase-locked loop, limiting jitter to within 10ps to ensure phase consistency even after long-term operation.
[0037] Vector encapsulation is used for writing. A single-frame measurement vector contains six fields: mega-magnetic impedance (MME) resistance, MME inductance, MME phase, induced voltage in the X direction, induced voltage in the Y direction, and frame number. Each field is encoded as a 24-bit two's complement fixed-point array. Six parallel data streams enter a 144-bit wide bus, with pipelined registers ensuring timing margins. The frame number is generated by a 13-bit counter, incrementing by 1 on each rising edge of the frame clock. Direct memory access is used for writing; the bus directly writes to the circular buffer via hardware arbitration, eliminating the need for a central processing unit and thus eliminating wait states. The circular buffer uses a dual-port static random access memory (SRAM) structure. The write pointer is controlled by the frame clock, and the read pointer is controlled by compressed observation logic; when the write pointer reaches the end of the buffer, it wraps back to 0, forming a first-in, first-out (FIFO) loop.
[0038] Interrupt-triggered mechanism. The falling edge of the frame clock is used as a sampling end marker, simultaneously pulling down the write enable to complete data writing to disk. Immediately afterwards, the hardware generates an interrupt pulse one master clock cycle wide, which is connected to the start pin of the compressed observation logic. After the pulse arrives, the compressed observation logic increments the read pointer by 1 to the address just written, and immediately reads the 144-bit vector and the 64×256 binary sparse matrix to perform multiplication and addition operations. The entire triggering process does not involve software, ensuring that the latency remains stable within one master clock cycle.
[0039] Explanation of the principle. When sampling multi-channel magnetic signals at the microsecond level, the most common problems are channel phase drift and buffer contention. If each channel has an independent clock or buffer, subsequent reconstruction will face asynchronous vectors, and increased column correlation will undermine the sparsity assumption. Shared clocks and direct memory access fundamentally eliminate this mismatch. Interrupt pulses provide hardware synchronization at each frame boundary, ensuring compressed observations start within a fixed time window without backlog. The circular buffer depth is designed based on "maximum compression operation latency + 2 frames," preventing data overwriting even if reconstruction iterations are occasionally prolonged due to write pointers catching up with read pointers.
[0040] Performance testing. The prototype was set to a sampling period of 25µs. Direct memory access to write one frame vector took 62.5ns, sparse matrix multiplication had a delay of 250ns, and four rounds of weighted least norm iteration took a total of 16µs. The overall link latency was approximately 16.3µs, significantly lower than the frame period. Oscilloscope captures showed that the write enable, frame clock falling edge, and interrupt pulse maintained a fixed sequence, with no glitches or crossovers observed.
[0041] For example, consider three consecutive frames numbered 158, 259, and 360. An interrupt is triggered after frame 158 is written, and compressed observation begins reading. Reconstruction continues while frame 259 is being written, with the write and read pointers maintaining a safe distance of two frames. Rapid keystrokes by the user cause significant fluctuations in the giant magnetoresistance value within several frames. A unified time base ensures that the Kalman filter accurately distinguishes between actual displacement and noise drift, keeping the reconstruction error within 1µm.
[0042] In comparative experiments, if the hardware interrupt is removed and software polling is used to read the ring buffer with a polling period of 30µs, the link latency fluctuates randomly from 0µs to 14µs. The measured reconstructed mean square error increases from 0.9µm to 2.3µm. After restoring the hardware interrupt, the error drops back to 0.87µm, proving that timing encapsulation and interrupt triggering are key to maintaining measurement accuracy.
[0043] To further examine the impact of timing consistency on reconstruction, the frame clock and sampling clock were intentionally out of phase by 30 ns, and the mean square error in the vertical direction was measured again. The result showed an increase from the baseline of 0.75 µm to 2.1 µm. After realignment, the mean square error returned to 0.8 µm, indicating that even nanosecond-level deviations can significantly amplify the error. This invention maintains a 10 ps jitter through hardware phase-locked loops, fully meeting the micrometer-level accuracy requirements for three-dimensional displacement.
[0044] In summary, the shared clock reference, direct memory access writing, and sampling period end interrupt trigger form a hardware timing closed loop that does not require central processing core intervention. This enables the efficient and contention-free encapsulation of single-frame measurement vectors at the hardware layer, providing low-jitter and high-consistency input for subsequent compressed observations, Bayesian correction, and spiking neural network inference. As a result, micron-level resolution and high robustness are achieved in the three-dimensional displacement detection of magnetic shaft keyboards.
[0045] The measurement vector is multiplied by a preset sparse matrix to generate a compressed observation vector. The weighted least norm iterative reconstruction algorithm is used to obtain the reconstructed vector. Bayesian estimation is performed based on the covariance prior of the previous frame to obtain the corrected triaxial magnetic vector and the corresponding posterior parameters. This invention utilizes sparse representation theory and Bayesian statistical methods in the magnetic axis keyboard control link to reduce the dimensionality of a single-frame measurement vector of length 256, reconstruct it, and correct it into a three-axis magnetic vector. This stage consists of three sequential steps: compressed observation, weighted least-norm iterative reconstruction, and Bayesian estimation. Each step is completed on-chip hardware to ensure hard real-time performance with a 25µs frame period.
[0046] Compressed observations are performed using a pre-defined sparse matrix with 64 rows and 256 columns, where each row contains only 4 elements with a value of 1. Column indices are determined by a pseudo-random sequence generated by a linear feedback shift register. The matrix is automatically refreshed every 1000 frames to prevent column correlation from increasing over time. Let the single-frame measurement vector be denoted as... A sparse matrix is denoted as Compress the observation vector pass:
[0047] Obtain, among which This indicates that the following parameters are included in sequence: giant magnetoresistance resistance, giant magnetoresistance inductance, giant magnetoresistance phase, tunnel magnetoresistance differential voltage in the X direction, tunnel magnetoresistance differential voltage in the Y direction, and zero fill. Represents a binary sparse matrix; This represents a compressed observation vector. Matrix multiplication is performed in one pass by an 8-way parallel multiply-accumulate array, with a typical delay of 250 ns.
[0048] After weighted least norm iterative reconstruction compression, it is necessary to start from... Recovering sparse signals The weighted least norm iterative algorithm is used, and the weight vector is updated in each iteration. The weight is the reciprocal of the absolute value of the previous estimate plus a small constant:
[0049] The goal of the refactoring is:
[0050] in . A constant bias is used to prevent division by zero. The hardware converges in four parallel iterations using the conjugate gradient method, with a delay of approximately 16µs. The convergence criterion is that the Euclidean distance between two consecutive estimates is less than 0.001 times the vector norm.
[0051] Bayesian estimation reveals that the reconstructed vector suffers from slow-varying biases introduced by temperature drift and device tolerances, requiring further correction. The posterior covariance of the previous frame is treated as the prior, and the reconstructed covariance of the current frame is treated as the likelihood. A linear fusion is then used to obtain the posterior mean. With posterior covariance :
[0052] This represents the posterior mean of the previous frame; This represents the posterior covariance of the previous frame; This represents the reconstructed mean value of the current frame; This represents the reconstructed covariance of the current frame.
[0053] The matrix has a dimension of 3×3, so inversion requires only 9 multiplications and 9 additions, with a latency of less than 1µs. The output posterior mean is the corrected three-axis magnetic vector, and the output posterior covariance is used as the prior for the next frame, realizing a time-series recursive closed loop.
[0054] In the example, the prototype has a frame period of 25µs. The compressed observation delay is 0.25µs, the weighted least-norm reconstruction delay is 16µs, the Bayesian estimation delay is 1µs, and the total link delay is 17.25µs. A 50µm vertical displacement and a 30µm X-direction displacement are applied to the keycap, while the Y-direction remains 0µm. The measured giant magnetoresistance (GMMR) increase is 0.03, the X-direction tunneling magnetoresistance differential voltage reaches full scale at 0.02, and the Y-direction voltage shows no significant change. The algorithm outputs a vertical displacement of 49.8µm, an X-direction displacement of 29.4µm, and a Y-direction displacement of 0.5µm, with a three-dimensional mean square error of 0.9µm. If the Bayesian step is disabled, the error increases to 2.3µm; if compression is canceled and direct reconstruction is used instead, intra-frame processing times out and one frame is lost, demonstrating the necessity of the dual strategy of compression and Bayesian for accuracy and real-time performance.
[0055] Sparse matrix compression significantly reduces the amount of data at the hardware level, enabling iterative reconstruction to be completed within a frame period; weighted least-norm iteration obtains sparse solutions through adaptive weights; Bayesian estimation effectively suppresses zero-point drift by utilizing temporal priors. The combination of these three steps enables the magnetic axis keyboard to stably output micron-level corrected magnetic vectors within a 25µs period, laying a high-confidence input foundation for subsequent spiking neural network displacement mapping.
[0056] Preferably, the positions of the non-zero elements of the preset sparse matrix are determined by a pseudo-random sequence output by a linear feedback shift register. The pseudo-random sequence is reinitialized after a preset number of frames to increase the probability that the compressed observation vector satisfies the sparse reconstruction condition.
[0057] The row and column structure of the preset sparse matrix directly determines whether the compressed observation vector has an invertible sparse solution. Therefore, this invention adopts a reconfigurable matrix strategy: the positions of non-zero elements are driven by a pseudo-random sequence output by a linear feedback shift register, which is automatically refreshed every few frames.
[0058] Principles and Design: Linear feedback shift registers are a type of digital circuit that uses XOR feedback to generate pseudo-random sequences of maximum length. The register length is set to 15 bits, with polynomial selection. When the register advances with a 160MHz master clock, a cycle can be generated. The binary sequence. The pseudo-random sequence is segmented and mapped to the matrix column index space. Every four consecutive outputs form four non-zero column numbers for a row. The number of rows is fixed at 64, so a single matrix refresh requires 256 register clock cycles. The matrix refresh interval is set to 1000 frames. During refresh, a frame flag vector is inserted at the beginning of the sequence to prompt the backend algorithm to update the internal sparse graph structure. The flag vector consists of all-zero data and a special frame number and does not participate in the shift calculation.
[0059] In terms of hardware, the sparse matrix is stored in on-chip block random access memory. The refresh logic first disconnects the data path of the multiply-accumulate array, writes the register output to the row address register, and then enables the data path. The entire write process is completed within 320ns, without spanning two frame cycles. The 15-bit register length ensures full coverage of the column index with an extremely low probability of repetition, avoiding long-term gaps in the matrix column space. The matrix row sparsity is maintained at 4, balancing multiply-accumulate complexity with constrained equidistant performance.
[0060] The success rate of sparse reconstruction depends on the matrix satisfying the constrained isometric property. If the cross-correlation between the matrix column vectors is too high, the reconstruction error rises rapidly. This invention, by periodically refreshing the matrix, makes the correlation structure uniformly dispersed over time, greatly reducing the risk of long-term existence of "bad submatrices". Simulations show that, with a column vector sparsity of 4, a refresh cycle of 1000 frames can reduce the average cross-correlation to 0.12; if the matrix is fixed and not refreshed, the cross-correlation increases to 0.28 over time. The decrease in cross-correlation leads to an increase in the success rate of sparse reconstruction: comparing the same keyboard prototype, the refresh strategy keeps the mean square error at 0.9µm over 10 minutes of continuous operation, while the fixed matrix scheme increases the error to 2.0µm.
[0061] For example, suppose the non-zero column number of the 0th row of the first periodic matrix is... In soft-button mode, single-frame measurement vector Only the first 5 elements have magnitude; the rest are zero. This was obtained through compressed observations. The matrix refreshes after 1000 frames, and the 0th row and column number becomes... At this point, the same key event occurs again, and a new compressed observation is generated. and The near orthogonality in the 64-dimensional spatial direction is beneficial for the back-end Bayesian filter to distinguish between real displacement and external electromagnetic interference.
[0062] In the example, running for 1 hour with a frame period of 25µs, the matrix was refreshed 144 times. The average number of reconstruction convergence iterations across all frames was 3.2, with a maximum of 4. If the refresh period was set to 5000 frames, the average number of iterations increased to 3.8, and the maximum number of iterations reached 6, resulting in some frames exceeding the time budget and being dropped. This demonstrates that an excessively long refresh period weakens the dynamic equalization effect of the sparse structure.
[0063] The flag frame inserted during the refresh operation is detected by the backend. The internal matrix pointer is only updated after a flag frame is detected to avoid read-write desynchronization. Simultaneously, the measurement vectors of the previous two frames are temporarily latched during the refresh period and processed all at once after the refresh is complete to prevent data gaps. Test results show that the refresh action has less than 0.3µs of impact on the average latency and no measurable increase in reconstruction error.
[0064] The dynamic sparse matrix, refreshed via pseudo-random column indices, maps the high-speed magnetic axis keyboard measurement vectors to a low-dimensional space while maintaining the constrained isometry property. A linear feedback shift register generates a pseudo-random sequence that can cover all column indices in a very short time, with low hardware cost and easy verification. Periodic refreshing effectively prevents long-term matrix degradation, significantly improving reconstruction accuracy and system robustness. Under constraints of a 160MHz master clock and a 25µs frame period, it provides a reliable observation entry point for subsequent three-axis magnetic vector correction.
[0065] Preferably, the weighted least norm iterative reconstruction algorithm updates the weights in each iteration according to the reciprocal of the magnitude of the current reconstructed vector, and terminates the iteration when the Euclidean distance between the reconstructed vectors obtained in two adjacent iterations is lower than the threshold.
[0066] The iterative reconstruction step of this invention employs a weighted least norm algorithm to establish a mapping between the compressed observation vector and the sparse magnetic signal in a hardware-implementable, low-latency manner.
[0067] The sparse compression stage yields a compressed observation vector of length 64. To recover a sparse vector of length 256. The requirement is to solve the underdetermined equation. The sparse solutions, where for The binary sparse matrix. The minimum norm is a classical sparse constraint that can be quickly approximated in hardware using a weighted iterative approach. Round weight vector Updated using the reciprocal of the absolute value estimated in the previous round:
[0068] To avoid the constant bias caused by division by zero, a diagonal weight matrix is constructed. Then, the refactoring goal is written as:
[0069] Minimizing the weighted norm can be transformed into an equivalent quadratic programming problem, and this invention uses conjugate gradient descent for solving it. The iteration termination condition is that the estimated Euclidean distance is less than a threshold. :
[0070] For the first Round sparse vector estimation, For the weight vector, For positive bias, This is the convergence threshold.
[0071] Weight updates, matrix multiplication, and convergence determination are all performed on the on-chip digital signal processor. The 256-dimensional multiply-accumulate operation is split into 8 parallel channels, with each channel executing 32 elements in a pipelined manner. A complete weight update and reconstruction is estimated to require 2048 multiply-accumulate operations, taking approximately 8µs at a 160MHz clock speed. The actual iteration limit is set to 4 rounds, corresponding to a worst-case latency of 16µs; most frames can be satisfied within the 3rd round. Constraints. Weight storage adopts an on-chip block random access memory dual-cache structure, and writing new weights does not block the multiply-accumulate array.
[0072] constant Take 10 −6 This avoids division by zero without affecting the weight of the medium amplitude component; Take 10 −3 The relative vector norm balances accuracy and timing. If convergence is not achieved after four iterations, the hardware watchdog outputs the final estimate and sets a misalignment flag. The subsequent Bayesian filter then increases the covariance based on this flag to prevent amplification of errors by abnormal frames.
[0073] To mitigate dynamic range differences, this invention performs weight calculations before weight calculation. First normalize to The normalization coefficients are written to the register and updated iteratively to ensure a stable weight distribution. The conjugate gradient internally uses 16-bit fixed-point multiplication and 32-bit accumulation, followed by rounding and truncation, resulting in a comprehensive quantization error that is less than the theoretical convergence error.
[0074] The prototype frame period is 25µs. In a test scenario with a vertical displacement of 50µm, an X-axis displacement of 30µm, and a Y-axis displacement of 0µm, the iterations converged in the third round after four iterations, with a total delay of 12.1µs. The Euclidean termination curve exhibits an exponential descent pattern, and the iteration sequence is oscillatory. The reconstructed vector, after Bayesian estimation, provides a corrected three-axis magnetic vector, and the subsequent spiking neural network mapping outputs a displacement error of 0.9µm.
[0075] If the weight update is changed to a fixed L1 norm (i.e., all weights are the same), iteration requires 6 rounds to meet the same convergence condition, and the total delay exceeds the frame period. If the least-two norm is used for reconstruction, energy leakage is prone to occur under synchronization constraints, and the test error increases to 2.5µm. This shows that weighted least-one norm iteration has the advantages of both fast convergence and high accuracy in sparse scenarios.
[0076] Computer simulations further verify the robustness of the matrix perturbation: When 5% element-flipping noise is introduced, the error of the algorithm in this invention increases by 0.3µm; the error of the conventional iterative soft thresholding algorithm increases by 1.1µm. This is because adaptive weighting can suppress the reconstruction deviation caused by mismatch in individual columns.
[0077] Weighted least norm iterative reconstruction strengthens important components by using the inverse of the amplitude as a weight, significantly improving the efficiency of sparse vector recovery. Hardware pipelined iterations achieve convergence in just four rounds. Convergence is determined using Euclidean distance as a threshold, ensuring that errors are on the micrometer scale before entering Bayesian filtering. This algorithm, along with pseudo-random sparse matrices, time-based encapsulation, and subsequent Bayesian estimation, forms a complete chain, providing the necessary guarantee for magnetic axis keyboards to output high-precision three-axis magnetic vectors within 25µs.
[0078] Preferably, Bayesian estimation obtains the corrected three-axis magnetic vector and posterior parameters by linearly fusing the covariance prior of the previous frame with the covariance of the reconstructed vector of the current frame, and writes the posterior parameters back as the covariance prior of the next frame.
[0079] Bayesian estimation plays the role of a "dynamic zero-drift and gain compensator" in the three-dimensional magnetic vector solution chain of this invention. Its logical starting point is that the vector output by the weighted least-norm iterative reconstruction still contains slowly varying errors such as temperature drift, hysteresis, and device tolerances, and these errors exhibit inter-frame correlation characteristics. By using the statistical results of the previous frame as a priori and then linearly fusing them with the observation information of the current frame, the true instantaneous components can be extracted and the residual uncertainty quantified.
[0080] The mean of the weighted least norm iterative reconstruction output is The covariance is Both assume a multivariate normal distribution. According to the Bayesian update rule, the posterior mean and covariance are given by the following equation:
[0081]
[0082] To correct the triaxial magnetic vector, For posterior covariance. Inverting a two-dimensional matrix in... At this scale, it can be directly calculated using the adjoint matrix and determinant, with a hardware latency of approximately 220ns.
[0083] The hardware process includes: 1. After the reconfiguration module is completed, the on-chip bus is written. and .
[0084] 2. The statistics module reads the previous frame from the register. , And perform matrix addition in the same clock domain.
[0085] 3. Combinatorial logic expansion Invert the matrix, then perform matrix-vector multiplication to generate the matrix. And simultaneously obtain .
[0086] 4. Write back the result: It is sent to the spiking neural network inference unit as physical input; Stored in the prior register for use in the next frame. Overall latency is kept within 1µs.
[0087] The initial frame lacks prior knowledge, so the diagonal elements of the covariance can be initialized as follows: It offers virtually no limitations on handling triaxial magnetic flux density. After approximately 20 frames... Diagonal elements converge to To track slow changes in ambient temperature, an exponential forgetting factor was set. Execute during write-back:
[0088] This strategy prevents the weights from becoming rigid due to excessively small covariance, while maintaining the steady-state filtering effect.
[0089] Implementation Notes: To ensure numerical stability of matrix inversion, the following should be noted: and First, perform a singularity lower bound truncation, less than 10. −9 The eigenvalues are uniformly raised to this threshold. All matrices and vectors are stored in a 24-bit fixed-point format: 8 integers and 16 decimals, which, in practice, maintains a quantization error of less than 0.05µT. When the watchdog detects that the reconstruction phase has not converged, The diagonal elements are magnified by 4 times to guide the expansion of posterior covariance and avoid the impact of single-frame anomalies on long-term stability.
[0090] The prototype operated continuously for 2 hours with a frame rate of 25µs, with the ambient temperature increasing linearly from 20℃ to 50℃. Without Bayesian correction, the three-axis zero-point drift reached 6.2µT, 5.8µT, and 5.5µT, respectively, corresponding to displacement errors exceeding 4µm. With Bayesian correction enabled, the drift was suppressed to 1.1µT, 0.9µT, and 1.0µT, and the error decreased to 0.9µm. Further lowering the forgetting factor to 0.95 allowed for faster adaptation to sudden temperature changes, but increased the static noise to 1.4µm; indicating… It is a compromise that balances stability and response speed.
[0091] In this example, when the user presses and holds the button for 3 seconds and then releases it, the giant magnetoresistance exhibits a residual deviation due to hysteresis, resulting in a 3µT offset in the reconstructed vector. The prior covariance of the previous frame is... The likelihood covariance of this frame is estimated by the reconstruction module as follows: According to the updated formula, the posterior mean shift is only 1µT, which the spiking neural network treats as noise within 0.7µm and does not trigger erroneous operations. The covariance automatically converges in subsequent frames, and the residual bias completely decays within approximately 10 frames.
[0092] Comparative experiments showed that when using simple moving average instead of Bayesian correction, a rapid temperature increase of 5°C per minute resulted in a cumulative systematic error of 3µT over 150 frames; the Bayesian scheme of this invention controlled the error to 0.8µT. Experiments demonstrate that time-recursive statistical fusion is significantly superior to unweighted averaging in suppressing slowly varying biases.
[0093] Bayesian estimation uses the posterior covariance of the previous frame as a dynamic prior. By linearly fusing the likelihood information of the current frame, it outputs a smooth and real-time corrected three-axis magnetic vector and updates the covariance in a closed loop to form adaptive temperature drift compensation. The hardware implementation utilizes 3×3 matrix inverse operations and fixed-point multiplication and addition, which can be completed within 1µs, meeting the strict timing of the keyboard's 25µs frame cycle. This provides high-confidence input for the subsequent spiking neural network, ensuring that the magnetic axis keyboard maintains micron-level positioning accuracy in wide-temperature, long-term use scenarios.
[0094] The corrected triaxial magnetic vector is quantized at a fixed point and converted into a pulse time difference signal. The pulse time difference signal is input into a pulse neural network, and the network weights are adjusted using the posterior parameters to obtain an instantaneous displacement vector. After obtaining the corrected triaxial magnetic vector, this invention needs to rapidly convert the vector into macroscopically usable three-dimensional displacement information for the keyboard within a 25µs period per frame. To balance low power consumption and extremely short inference latency, this stage introduces an integrated architecture of "fixed-point quantization-pulse time difference encoding-spiking neural network," and adaptively adjusts the network weights using the posterior covariance of the Bayesian estimation output from the previous step.
[0095] Fixed-point quantization, the correction of the triaxial magnetic vector is denoted as , , The unit is Tesla. Internally, the chip uses a 14-bit fixed-point format, where each component is split into a 1-bit sign bit and a 13-bit amplitude bit, with a quantization step size of... During power-on self-test, divide the full scale by... The result is obtained and written to a read-only register. In actual operation, saturation pruning is performed first, truncating the portion exceeding the full scale to extreme values, followed by multiplication-addition format conversion. The quantization process has a delay of 40ns, and the maximum quantization error does not exceed 0.06µT, which is much smaller than the threshold noise of the backend neural network.
[0096] Pulse time difference encoding, after quantization, requires mapping the three-axis amplitudes to a high-time-resolution pulse input. A linear amplitude-time difference mapping is used, with the core formula as follows:
[0097] Where the constant Obtained through experimental calibration. The mapping result is quantized to a counter with a resolution of 16 ns; the minimum discernible delay is 16 ns, corresponding to a magnetic flux resolution of 32 nT. If If the value is negative, the sign is preserved by adding a polarity bit after the delay, maintaining the pure positive value characteristic of the time difference code. The three counters operate in the same clock domain, with the first pulse emitted uniformly at the frame boundary, and subsequent pulses emitted according to... Arrived late. The coding logic is entirely hardwired, requiring no table lookups.
[0098] The spiking neural network encodes pulses, which are then fed into the on-chip spiking neural network. The network topology consists of two spiking graph convolutional layers and one soft competitive readout layer. The dynamic adjacency matrix of each graph convolutional layer is calculated in real-time using the cosine similarity of the node embedding vectors, and the adjacency weights are written into the synaptic array. The embedding vectors are initialized as unit quaternions, with their imaginary part representing the normalized result of the quantized three-axis magnetic vectors; the real part is set to zero. This is significant because it preserves the three-axis information in the quaternion rotation domain, maintaining geometric consistency between pulses in rotation space. The synaptic conductance is updated with Laplace's canonical strength each frame based on the posterior covariance, expressed as:
[0099] For the diagonal elements of the posterior covariance, The network operates using a pooling-discharge integral-discharge model with a membrane time constant of 4µs and a threshold of 0.25V. A complete two-layer inference takes 4.8µs, and the readout layer completes soft competition and normalization within 0.3µs, outputting a three-dimensional normalized displacement vector.
[0100] Real-time displacement decoding involves linearly amplifying the readout layer voltage and mapping it to a displacement component scaling factor, which is then compared with the quantization step size using a lookup table constant. The physical displacement is obtained by multiplication. The output format is a 16-bit fixed-point three-channel output with a total latency of 5.1µs (including inference and decoding). As can be seen, the latency of the entire "quantization-encoding-inference-decoding" link is much lower than the frame period, leaving a margin of about 3µs.
[0101] This invention achieves quantization errors far less than neuron threshold jitter, with negligible impact on decoding accuracy. Time difference coding compresses amplitude information into pulse delays, significantly reducing bus bandwidth; simultaneously, it preserves sub-microsecond timing differences, enabling high dynamic range input. Quaternion embedding preserves the intrinsic geometric structure between the three-axis amplitudes, allowing graph convolutional layers to learn only rotation invariants, resulting in faster inference convergence. By adjusting the regularization strength through posterior covariance, weights are automatically relaxed when magnetic field noise increases, avoiding overfitting; and weights are tightened when noise decreases, improving sensitivity. Overall power consumption mainly comes from pulse array switching losses and the multiply-accumulate array. Tests show an average power consumption of 11mW at a 160MHz master clock and a 25µs frame period, 32% lower than the control scheme.
[0102] In the prototype example, when the keycap is displaced 60µm vertically, 35µm X-axis, and 0µm Y-axis, the corrected triaxial magnetic vectors are (76µT, 44µT, 95µT). After fixed-point quantization, the actual encoding delays are 38ns, 22ns, and 48ns. The normalized vector output by the spiking neural network is (0.38, 0.22, 0.40). Multiplying by the proportional constant 2.5mm yields the instantaneous displacement vector (0.95mm, 0.55mm, 1.0mm), and the converted input error is less than 1.2µm.
[0103] If the canonical strength is fixed and covariance adjustment is not used, the readout layer drift increases to 6µm in a scenario where the ambient noise increases by 5µT; after enabling covariance adaptation, the drift is controlled at 1.5µm. Experiments show that posterior parameter feedback is a key factor in ensuring the robustness of displacement calculation.
[0104] In summary, fixed-point quantization reduces on-chip storage requirements, pulse time difference encoding enables temporal super-resolution input, and quaternion graph convolutional networks rapidly complete 3D displacement inference under adaptive regularization. The end-to-end latency is approximately 20% of the frame cycle, and power consumption is less than 15mW, providing micrometer-level and kilohertz-level detection capabilities for magnetic axis keyboards, while maintaining long-term stability through dynamic covariance feedback.
[0105] Preferably, fixed-point quantization uses a fixed-length format to separately encode the sign bit and amplitude bit of the correction triaxial magnetic vector, and the quantization ratio is applied when the system is powered on and remains constant during operation.
[0106] The fixed-point quantization-pulse time difference encoding stage is located at the end of the magnetic axis keyboard signal link in this invention. It is responsible for rapidly converting the Bayesian-corrected triaxial magnetic vector into a timing pulse that can be processed by a spiking neural network, and outputting micrometer-level instantaneous displacement without introducing significant delay. Its technical process consists of four parts: proportional coefficient power-on loading, fixed-length fixed-point quantization, amplitude-time difference mapping, and adaptive spiking neural inference.
[0107] During the power-on self-test phase after the proportional coefficient is applied, the control unit first reads the full-scale value of the magnetic sensor. (Unit: Tesla), then calculate the quantization scaling factor:
[0108] in The corresponding amplitude bit represents the maximum positive integer that can be expressed. This scaling factor is written to a read-only register and remains constant during system operation, thus ensuring that the quantization step width does not change with temperature or power supply fluctuations. In temperature drift experiments, when the ambient temperature rises from 0℃ to 70℃, the scaling factor deviation remains within 0.02%, which is far less than the subsequent pulse threshold jitter.
[0109] Fixed-length fixed-point quantization, the three components of the correction magnetic vector are respectively , , The quantization logic is executed according to the following steps: Step A: Saturation clipping. If Then set to .
[0110] Step B: Amplitude Encoding. Calculation. The result is then rounded and mapped to a 13-bit amplitude register.
[0111] Step C: Symbol concatenation. If The sign bit is 1 if the sign bit is 1 otherwise; this results in a 14-bit fixed-point word.
[0112] The hardware employs a pipelined architecture: three sets of comparators-multipliers-truncates operate in parallel, with a total delay of 40ns. The upper limit of quantization error is [not specified]. At full scale of 1000µT, the error is approximately 0.06µT, corresponding to a displacement error of less than 0.3µm, which is negligible.
[0113] Amplitude-Time Difference Mapping: To enable spiking neurons to perceive amplitude information in the form of time differences, this invention employs a linear mapping:
[0114] constant Calibration experiments confirmed that the full-scale delay can cover a range of 0 to 500 ns. The fixed-point amplitude is directly generated from a lookup table to produce the 32-bit counter load value, with a clock resolution of 16 ns and a minimum discernible time difference corresponding to 32 nT. The three delay counters start simultaneously upon the arrival of the frame synchronization signal; the first pulse is fixed at zero delay, and the remaining pulses are emitted according to their respective delays. Arriving late. The sign bit changes the pulse width polarity through a polarity-flipping circuit to ensure that the direction information is preserved and the time difference is always positive.
[0115] Adaptive spiking neural inference employs a two-layer spiking graph convolutional network with pulsed streams injected. The network node embedding vectors encode the triaxial amplitude normalization results in quaternion form, where the real part is set to 0 and the imaginary part is the normalized triaxial magnetic vector. This preserves the vector geometric relationships and facilitates the learning of spatial features by the convolutional layers through rotation invariants. Before the start of each frame's inference, the Bayesian posterior covariance is used... , , Calculate the regularization coefficient:
[0116] The regularization coefficients are updated to the synaptic array discharge conduction threshold via a digital-to-analog converter. The weight density is automatically reduced to prevent overfitting when external noise increases. The network employs a discharge integral-discharge model with a membrane constant of 4µs and a threshold of 0.25V. The first convolutional layer outputs 64 pulses, and the second layer outputs 32 pulses. The readout layer performs soft competition normalization to obtain a three-dimensional normalized displacement vector. .
[0117] Real-time displacement decoding, normalized displacement and proportional constant Multiplying by mm yields the physical displacement:
[0118] The result is a 16-bit fixed-point output with a link delay of 5.2µs, which accounts for 21% of the 25µs frame period, meeting the hard real-time requirements.
[0119] In this embodiment, the prototype has a full-scale range of 1000µT and an actual quantization step width of 0.122µT. Under conditions of a keycap vertical displacement of 60µm, an X-axis displacement of 35µm, and a Y-axis displacement of 0µm, the corrected magnetic vector is (76µT, 44µT, 95µT). The quantization-encoding stage generates pulse sequences with delays of 38ns, 22ns, and 48ns, respectively; the pulse graph convolutional network outputs a normalized vector of (0.38, 0.22, 0.40). The displacement is decoded to (0.95mm, 0.55mm, 1.0mm), resulting in an input error of 0.8µm. The power consumption was measured at 11mW, a 30% reduction compared to the traditional multilayer perceptron solution. Reducing the quantization bit width to 10 bits increases the error to 3.1µm; removing covariance adaptation increases the error to 2.6µm when environmental magnetic disturbance increases by 5µT, validating the necessity of the two design considerations.
[0120] Fixed-length fixed-point quantization ensures controlled quantization error and simplifies hardware; amplitude-time difference mapping compresses vector information to the nanosecond-level delay domain, significantly saving bandwidth; pulse graph convolution adaptively adjusts weights under covariance-driven conditions, achieving microsecond-level inference and robust learning. The entire link latency is approximately 5µs, providing the magnetic axis keyboard with micrometer-level three-dimensional displacement resolution and long-term stable operation capabilities.
[0121] Preferably, the spiking neural network consists of two spiking graph convolutional layers. Each layer establishes an adjacency matrix by calculating the cosine similarity of the node embedding vectors, and adjusts the regularization intensity of the convolution weights in real time according to the posterior parameters during inference.
[0122] The spiking neural network undertakes the nonlinear mapping from magnetic vectors to three-dimensional displacements. In this invention, it is implemented as a "two-layer spiking graph convolution + soft competitive readout" structure, with its total inference latency controlled at approximately 20% of a 25-microsecond frame period, while maintaining milliwatt-level power consumption. The key features of this network are: utilizing quaternion embeddings to preserve the spatial topology of the three-axis magnetic vectors; constructing an adjacency matrix online based on cosine similarity; and adjusting the regularization intensity of the convolution weights in real time based on the Bayesian posterior covariance of the previous stage, thereby maintaining stable accuracy even under drastic noise changes.
[0123] Quaternion node embedding and adjacency construction, corrected magnetic vector First normalize to Then it is written into a pure imaginary quaternion. Quaternions naturally describe 3D rotations, so convolutional layers can directly capture orientation patterns on rotation groups. At the start of each frame, the hardware generates adjacency weights based on the quaternion cosine similarity between nodes:
[0124] when Connect edges only when necessary; otherwise, reset the weights to zero. This threshold was determined through prototype search and can maintain graph connectivity while achieving approximately 70% sparsity.
[0125] Two-layer pulse graph convolution operation is used, and the network nodes adopt a bleed-integral-fire model: membrane time constant of 4 microseconds and threshold of 0.25 volts. The first convolutional layer maps the input pulses to a 64-dimensional feature space, and the second layer reduces it to 32 dimensions. Convolutional kernel weights... The initial values are derived from offline pre-training and are subject to Laplacian regularization constraints during online execution. Each convolutional layer is computed in parallel using an 8×8 multiply-accumulate array, with a single-layer propagation delay of approximately 2 microseconds and a total inference delay of 4.3 microseconds for two layers plus readout.
[0126] Weighted regularization driven by posterior covariance, Bayesian filtering outputs the diagonal elements of the posterior covariance. , , Describes the noise level of the current frame. The system calculates the regularization strength in real time.
[0127] Subsequently, all weighted executions were carried out. When increased magnetic interference leads to a larger covariance, Increasing the weighting can suppress high-amplitude weights and prevent overfitting; when the environment returns to calm, Automatic reduction enhances sensitivity. Regular updates are performed in one step using a hardware multiplier, with a latency of less than 0.2 microseconds.
[0128] The second-layer output pulse from the soft-competition readout and shift decoding is normalized to obtain a normalized vector. Multiply by a fixed proportionality constant. mm yields instantaneous displacement:
[0129] The result is sent to the downstream interface in 16-bit fixed-point format, with a delay of 0.9 microseconds at the end of the link.
[0130] Example, prototype conditions: full scale 1000 microtesla, quantization step width 0.12 microtesla, master clock 160 MHz. Quantization and encoding 0.04 microseconds, convolution inference 4.3 microseconds, decoding 0.9 microseconds, total latency 5.24 microseconds; average power consumption 11 milliwatts.
[0131] Real-world test scenario: Keycap vertical displacement 60 μm, horizontal displacement 35 μm, output displacement 59.4 μm, 34.1 μm, 0.8 μm respectively, with a three-dimensional mean square error of 0.8 μm. When a sudden 5 μs Tesla noise is added, the error increases by only 0.6 μm with regularization; without regularization, the error increases by 2.0 μm. If a fully connected pulse network is used instead, the latency increases to 11 microseconds with an error of 1.8 μm, and the power consumption increases to 16 milliwatts. The results show that quaternion embedding, cosine adjacency, and dynamic regularization are the core combination for ensuring accuracy, latency, and power consumption.
[0132] By employing two-layer pulse graph convolution combined with posterior covariance adaptive regularization, this invention achieves micrometer-level 3D displacement analysis, milliwatt-level power consumption, and real-time robustness to external noise while keeping hardware costs under control. The overall inference time is approximately one-fifth of the frame period, meeting the stringent real-time requirements of e-sports and high-speed industrial input scenarios.
[0133] The value function is calculated based on the instantaneous displacement vector and the preset evaluation index. The quantization step size is determined, the instantaneous displacement vector is encapsulated, and sent through the communication interface. When the value function is lower than the threshold, the readout weights of the spiking neural network are updated according to the pulse timing dependence plasticity rule, and the piezoelectric driving signal corresponding to the displacement amplitude and the light-emitting diode driving signal corresponding to the displacement direction are output respectively.
[0134] The end-point control mechanism of this invention employs a "value function—adaptive quantization—dual-channel execution" framework to complete the communication encapsulation of instantaneous displacement vectors, network self-learning, and peripheral device driving. The core logic consists of five steps: evaluation index extraction, value function calculation, quantization step size update, pulse timing-dependent plasticity adjustment, and piezoelectric-photoelectric coordinated output.
[0135] The first step is to extract evaluation indicators, with the instantaneous displacement vector denoted as... The control unit simultaneously saves the prediction residual from the previous frame. Cumulative power consumption Changes in output events .in:
[0136] The second step is the calculation of the value function. Using the time-series difference approach, the multidimensional indicators are normalized and then linearly weighted to obtain the scalar value.
[0137] , , The operating condition calibration is written to the read-only memory. The lower the value, the smaller the prediction residual, the lower the power consumption, and the smoother the output, indicating a more ideal network condition.
[0138] The third step involves adaptive quantization step size encapsulation with fixed communication bandwidth, which needs to be based on... The quantization accuracy is dynamically adjusted. The system has three step sizes: high precision and low precision. ,standard Save bandwidth .like choose ,like Pick Take the rest After quantization, the displacement is encoded by sign-amplitude fixed-point encoding and pushed into the data frame, which is then sent via the SPI three-wire interface; the first byte carries a 2-bit level flag to ensure reversible decoding by the main chip.
[0139] The fourth step is to adjust the pulse timing-dependent plasticity. (Designed for) (1.2 times) Triggered self-learning: Records the arrival time of the pulse in the current frame. With readout layer pulse firing time .in accordance with:
[0140] Update readout weights; constant Pick time constant Take 2 microseconds. After the update, the weights are written back to the synapse register and take effect immediately. This allows for fine-tuning of the readout layer when the system is stable, further converging long-term biases; when noise increases... When the frequency increases, learning will automatically pause to prevent accidental updates.
[0141] Step 5: Piezoelectric-photoelectric synergistic output; displacement amplitude is determined by looking up the transduction constant in a table. Convert to piezoelectric drive level:
[0142] A metal disc is driven to generate tactile feedback. Displacement direction is mapped using spherical coordinates: azimuth is mapped to hue, polar angle to saturation, and constant brightness is output to a three-color LED controller for direction visualization. Both signals are output together after the SPI frame ends to ensure synchronization.
[0143] Example, Prototype , , Threshold , In continuous rapid tapping tests, the average value of 0.05 fell within the standard range, with a data frame size of 12 bytes. Static long presses reduced the value to 0.015, automatically switching to the bandwidth-saving mode, reducing the frame size to 8 bytes and improving interface utilization by 33%. Sudden environmental interference caused... Upon reaching 0.12, the system immediately switched to high precision mode, ensuring error suppression within 1.1 micrometers; after the interference was cleared, it returned to standard mode within 5 frames. The pulse timing-dependent plasticity showed a cumulative weight adjustment of no more than 3% during 10 seconds of stable operation, and the zero-point drift was 45% lower than the control group with learning disabled. Both piezoelectric feedback and photoelectric indication delays were less than 300 microseconds, resulting in no noticeable lag in the human experience.
[0144] By combining "value-oriented quantization + temporal flexibility + dual-channel execution," this invention achieves a dynamic balance between communication bandwidth, power consumption, and haptic-visual feedback. The value function serves as a global indicator, enabling the network to learn only during high-confidence periods, avoiding false convergence. Multiple step sizes allow the interface bandwidth to adapt to different scenarios. Piezoelectric and photoelectric technologies work together to enhance the interactive experience. The overall design ensures that the keyboard can still output micron-level displacement and provide real-time multimodal feedback under conditions of high-frequency input, temperature changes, and electromagnetic noise, fully demonstrating the high precision, low latency, and user-friendliness of the magnetic axis keyboard control method.
[0145] Preferably, the value function takes the distance between the instantaneous displacement vector and the prediction vector of the previous frame, as well as the power consumption integral, as input, and outputs a single scalar result for determining the adaptive quantization step size.
[0146] The instantaneous displacement has been output by the spiking neural network and denoted as a vector. Its physical unit is the micrometer. This invention establishes a unified evaluation mechanism across communication, execution, and online learning: through a single scalar value function. Simultaneously, prediction residuals and power consumption are measured to adaptively adjust data quantization accuracy within a frame-level time scale, and to trigger micro-updates of weights and peripheral drives in low-value (i.e., high-confidence) scenarios.
[0147] The system maintains three types of frame-level state variables in SRAM: prediction vectors This is obtained by extrapolating the internal state of the spiking neural network, representing the prediction of the current frame's displacement from the previous frame. Power consumption integral. The current power consumption is accumulated using a 32-bit fixed-point method, and the corresponding formula is:
[0148] in The number of pulses. and The first Average on-chip voltage and current during each pulse, It is the pulse interval. Event variation. : Depicting the inter-frame changes in displacement distance:
[0149] These quantities can be calculated at the end of any frame without blocking subsequent sampling.
[0150] In order to simultaneously reflect prediction error and power consumption using a single scalar for value function calculation, this invention constructs the following linear fusion model:
[0151] in The data was calibrated experimentally and written to OTP storage. In high-frequency typing scenarios during esports, , , It balances accuracy and power consumption. The hardware implementation uses a one-to-one multiplication-to-add pipeline with a latency of no more than 40ns, allowing generation at the end of the frame. .
[0152] The system features an adaptive quantization step size package and a 10MHz SPI communication interface, limiting bandwidth. The system adaptively selects the displacement quantization step size based on a value function. : Three step length settings: High Precision ;standard Save bandwidth .
[0153] Set threshold .like ,select ;like ,select ; other frames selected .
[0154] Quantization employs a 16-bit fixed-point method with sign-amplitude separation: 1 bit for the sign and 15 bits for the amplitude. The step size is written as a 2-bit flag in the first byte of the data frame to ensure reversible decoding by the main MCU. This strategy automatically reduces bandwidth in long-press or static scenarios and automatically increases resolution in rapid keystrokes or high-noise environments.
[0155] Pulse timing depends on plasticity and execution output; trigger condition: when ,in The system considers the network prediction reliable and enters micro-update mode. It learns rules and records the arrival time of the current input pulse. With readout layer distribution time Weight increment:
[0156] constant Control the learning rate, This is a time constant. This rule is consistent with the pulse timing-dependent plasticity commonly used in biology, and can be completed within one cycle of a hardware multiplier.
[0157] Dual-channel peripheral drive, piezoelectric feedback: displacement amplitude Multiplication energy conversion coefficient Direct control of the piezoelectric element level provides a perceptible tactile rebound. Optical feedback converts the displacement direction into spherical coordinates. Azimuth Mapping RGB hue, polar angle Mapping saturation, constant brightness The rear-drive tri-color LEDs provide color-coded directional cues. The hardware uses a lookup table method for color mapping, resulting in insufficient latency. .
[0158] Example: Continuous taps (10 times per second): Average value of 0.05 falls within the standard range, data frame is 12 bytes; power consumption is 25% lower than the full high-precision mode, displacement error is controlled within 1µm. Long press (hold for 3 seconds): The value drops to 0.015, the system switches to bandwidth-saving mode, and the data frame is 8 bytes; interface usage decreases by 33%, the network enters micro-update mode, and the residual zero-point drift is compressed by 45%. Magnetic interference suddenly increases by 5µT: the value spikes to 0.12, high-precision step size is immediately used and learning is paused, and the displacement error is limited to 1.1µm; after the interference is cleared, it returns to the standard mode after 5 frames. Haptic and optical synchronization: piezoelectric response time is 0.25ms, LED delay is 0.28ms, the human body cannot perceive the configuration lag, and the key feel is consistent with the visual cues.
[0159] By integrating prediction residuals and power consumption accumulation into a single value function, this invention achieves unified scheduling of quantization accuracy, learning triggering, and peripheral power allocation. Adaptive quantization ensures that communication bandwidth is dynamically optimal for different working scenarios; pulse timing-dependent plasticity updates readout weights only in high-confidence intervals, keeping network drift at the sub-micron level over long periods; piezoelectric and LED collaborative output enhances the user's tactile and visual experience. The overall control loop is completed at the hardware level, with a latency of approximately 5% of the frame period and power consumption not exceeding 12mW, meeting the triple requirements of low latency, high accuracy, and low power consumption for high-speed magnetic axis keyboards.
[0160] Preferably, when the value function is below the threshold, the readout weights of the spiking neural network are updated according to the pulse timing-dependent plasticity rule. The increase or decrease of the weights is exponentially related to the pulse arrival time difference. After the weight update is completed, the piezoelectric driving signal corresponding to the displacement amplitude and the light-emitting diode driving signal corresponding to the displacement direction are output respectively.
[0161] The idea of triggering closed-loop learning and multimodal feedback using a value function stems from the comprehensive trade-off between the three objectives of "accuracy, low power consumption, and strong feedback" during keyboard usage. At the end of each frame, the system subtracts the instantaneous displacement vector from the prediction result of the previous frame to obtain the Euclidean distance evaluation term; simultaneously, the pulse power consumption integrated by the on-chip power meter is used as a second evaluation term. These two terms are then linearly weighted to form a single scalar. The weighting coefficients are fixed in a one-time programmable memory after factory calibration, and therefore will not drift during operation. Falling into the range This indicates that the current frame prediction is accurate and power consumption is low, subsequently initiating the "timing plasticity-execution feedback-adaptive quantization" linkage process. First, pulse timing-dependent plasticity is executed. Hardware registers dual-channel time stamps: the time it takes for the input pulse to reach the synaptic front end of the readout layer. With the time of output pulse self-readout node release The weight increment is determined by the exponential window formula:
[0162] Calculation, where for Learning rate of magnitude Pick If the input leads the output, the exponent term is still close to 1. The weights are augmented if the input is delayed; if the input is delayed, the weights decay by the same amount. The entire matrix update is completed in one go within the parallel multiply-accumulate array, with a delay of no more than [missing information]. This ensures that the sampling time window of the next frame will not be eroded.
[0163] After the weight update is complete, the system immediately generates dual-channel physical feedback. Displacement amplitude. Multiplication energy conversion coefficient Converted to piezoelectric driving voltage Under typical key travel and piezoelectric response matching, the user can feel approximately... The vibration displacement provides a subtle yet clear mechanical feel. Directional feedback is obtained by taking the polar angle of the displacement vector. With azimuth By looking up the table Mapped to hue, The color is mapped to saturation, then combined with a fixed brightness to form a three-primary-color duty cycle signal that drives a three-color LED, achieving a direct color-direction correspondence. For example... When the azimuth angle is close to The LED displays pure red; if and Equal, azimuth angle becomes The LED displays an orange-yellow color. The optical signal and piezoelectric vibration are output in the same frame, with a total delay of no more than 0.3 ms between the two channels.
[0164] At the same time, the system is based on Choosing the quantization step size for data communication: when With extremely low and gradual frame-to-frame variations, the communication layer automatically switches the step size to 2.5 µm, sending in compact 8-byte frames; if The step size is automatically increased to 1.0 µm or even 0.5 µm to maintain decoding accuracy. The step size identifier is embedded with a 2-bit header, and bandwidth-error dynamic balancing is achieved synchronously with extremely low overhead.
[0165] Experimental verification: Continuous rapid double-clicking makes Maintained at 0.4µm, power consumption integral Approximately 1.3 µJ was obtained. The system triggered STDP, resulting in an overall increase in weights. Subsequently, a 0.9V piezoelectric drive and a cyan LED are output. When external magnetic interference increases by 5 µT, the residual rises to 2 µm. When the threshold value exceeds 0.09, learning is paused and a 0.5 µm step size is forcibly used. High-precision data ensures that the decoding error is still controlled within 1.2 µm. Two hours of long-term testing shows that the keyboard using this closed-loop strategy has a 40% reduction in readout layer weight drift, an average saving of 28% in interface bandwidth, and the piezoelectric-photoelectric feedback latency is maintained within 0.3 ms, so users cannot perceive any lag.
[0166] In summary, by leveraging the temporal plasticity and dual-modal driving of value function gating, this invention unifies signal accuracy, power consumption, and interactive experience within frame-level hardware logic: once the network enters a high-confidence interval, the readout weights are fine-tuned exponentially to track long-term deviations, while simultaneously providing vibration and color feedback corresponding to displacement amplitude and direction; in the event of high noise or large residuals, the code bandwidth automatically increases and learning freezes, ensuring accurate output without crashing, demonstrating the high robustness and high availability of magnetic axis keyboard control technology.
[0167] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A magnetic axis keyboard control method, characterized by, The method comprises the following steps: A multi-frequency excitation magnetic field is generated, and under the action of the excitation magnetic field, the following are synchronously acquired: a giant magnetoimpedance sensor impedance parameter, a first direction magnetic sensor induced voltage, a second direction magnetic sensor induced voltage orthogonal to the first direction, and a single frame measurement vector is packaged according to a unified time reference; The measurement vector is multiplied by a preset sparse matrix to generate a compressed observation vector, a weighted least one norm iterative reconstruction algorithm is used to obtain a reconstructed vector, and a Bayesian estimation is performed according to a covariance prior of a previous frame to obtain a corrected three-axis magnetic vector and a corresponding posterior parameter; The corrected three-axis magnetic vector is fixed-point quantized and converted into a pulse time difference signal, the pulse time difference signal is input into a pulse neural network, the network weight is adjusted by using the posterior parameter, and an instantaneous displacement vector is obtained; A value function is calculated according to the instantaneous displacement vector and a preset evaluation index, the quantization step is packaged, and the instantaneous displacement vector is sent through a communication interface; when the value function is lower than a threshold value, the readout weight of the pulse neural network is updated according to a pulse timing-dependent plasticity rule, and a piezoelectric drive signal corresponding to a displacement amplitude and a light-emitting diode drive signal corresponding to a displacement direction are respectively output.
2. The method of claim 1, wherein, The multi-frequency excitation magnetic field is synthesized by at least three sinusoidal signals which are not integer multiples of each other after phase synchronization, the amplitude and frequency of each sinusoidal signal remain constant to reduce intermodulation interference and stabilize the magnetic field amplitude.
3. The method of claim 1, wherein, The single frame measurement vector is time-stamped under a shared clock reference, and after packaging is completed, it is immediately written into a ring buffer, and an interrupt is triggered at the end of the sampling period to start the compressed observation vector generation step.
4. The method of claim 1, wherein, The non-zero element positions of the preset sparse matrix are determined by a pseudo-random sequence output by a linear feedback shift register, and the pseudo-random sequence is reinitialized after a preset number of frames to improve the probability that the compressed observation vector satisfies the sparse reconstruction condition.
5. The method of claim 1, wherein, The weighted least one norm iterative reconstruction algorithm updates the weight according to the reciprocal of the amplitude of the current reconstructed vector in each iteration, and terminates the iteration when the Euclidean distance between the reconstructed vectors obtained by two adjacent iterations is lower than a threshold value.
6. The method of claim 1, wherein, The Bayesian estimation obtains the corrected three-axis magnetic vector and the posterior parameter by linearly fusing the covariance prior of the previous frame and the covariance of the current frame, and writes back the posterior parameter as the covariance prior of the next frame.
7. The method of claim 1, wherein, Fixed-length format is used for fixed-point quantization to separate and encode the sign bits and amplitude bits of the corrected three-axis magnetic vector, and the quantization proportion coefficient is loaded when the system is powered on and remains constant during operation.
8. The method of claim 1, wherein, The pulse neural network is composed of two layers of pulse graph convolution layers, each layer establishes an adjacency matrix by calculating the cosine similarity of the node embedding vectors, and adjusts the regularization strength of the convolution weight in real time according to the posterior parameter during inference.
9. The method of claim 1, wherein, The value function takes the distance between the instantaneous displacement vector and the previous frame prediction vector and the power consumption integral as input, and outputs a single scalar result for determining the adaptive quantization step.
10. The method of claim 1, wherein, When the value function is lower than the threshold value, the readout weight of the pulse neural network is updated according to the pulse timing-dependent plasticity rule, the weight increase and decrease are exponentially related to the pulse arrival time difference, and the piezoelectric drive signal corresponding to the displacement amplitude and the light-emitting diode drive signal corresponding to the displacement direction are respectively output after the weight update is completed.