Physical World Development

IMU Fundamentals: Accelerometer and Gyroscope

Opening post of the Motion Sensing series. Sensors are the window through which embedded systems perceive the physical world, and the IMU (Inertial Measurement Unit) is the most common type. This article skips heavy theory — just how MEMS sensors work, how to wire them, how to read data, and what the numbers actually look like. IMU Coordinate System The diagram below defines the three axes of the IMU — all formulas and discussions that follow are based on this coordinate system:

Continue reading →

Variable Step Size and Frequency-Domain Adaptive Algorithms

The Convergence Trade-off of Fixed Step Size Standard LMS and NLMS algorithms use a fixed step size parameter $\mu$. The choice of step size directly impacts algorithm performance, but a fundamental contradiction exists: Large step size: Fast convergence and quick adaptation to environmental changes, but large steady-state error and low filtering precision Small step size: Small steady-state error and high filtering precision, but slow convergence and sluggish response to abrupt changes This contradiction is particularly pronounced in applications such as echo cancellation and active noise control — the system needs fast convergence during startup, yet wishes to maintain low error in steady state. A fixed step size cannot satisfy both phases simultaneously.

Continue reading →

FXLMS and Active Noise Control System Architecture

Active Noise Control (ANC) works by generating an acoustic wave with equal amplitude and opposite phase to the incoming noise, canceling it through destructive interference at the target zone. Translating this into hardware requires two decisions: which sensors to use for noise sensing, and what control strategy to apply for anti-noise generation. These two factors define the three canonical ANC architectures: feedforward, feedback, and hybrid. Feedforward ANC A feedforward ANC system places a reference microphone upstream of the noise source to capture the disturbance early, feeds it to the DSP, and drives the speaker to produce the anti-noise. An error microphone near the ear monitors the residual noise and feeds it back to the adaptive algorithm for coefficient update.

Continue reading →

Image Basics & Getting Started with OpenCV

What Is a Digital Image Computer vision operates on digital images. At its core, a digital image is just a 2D array of pixels. Pixels and Grayscale Images A grayscale image is the simplest form—each pixel stores a single brightness value from 0 (pure black) to 255 (pure white). In Python, a grayscale image of width W and height H is a 2D array with shape (H, W): python 1 2 3 4 import numpy as np # Create a 100x100 gray square (brightness 128) gray_img = np.full((100, 100), 128, dtype=np.uint8) uint8 ranges from 0 to 255 because 8 bits can represent 2^8 = 256 unique values. If a pixel value exceeds its range, wrap around occurs: 255 + 1 becomes 0, not 256 (like an odometer rolling over). Use cv2.add() (saturating arithmetic) or np.clip() to prevent wrap around.

Continue reading →

Adaptive Filtering: From LMS to NLMS

The LMS Algorithm The core problem in adaptive filtering is: given a reference signal x(n) and a desired signal d(n), find a filter coefficient vector w such that the output y(n) approximates d(n). The Least Mean Square (LMS) algorithm is the most classic solution to this problem, proposed by Widrow and Hoff in 1960. The core idea is to take one step down the steepest gradient of the error surface at each iteration — stochastic gradient descent.

Continue reading →

Acoustic Waves & Digital Signal Processing Basics

Destructive Interference Active noise cancellation (ANC) builds on a simple physical principle: destructive interference. Two sound waves of the same frequency and opposite phase cancel each other out. The original noise signal: $$ p_n(t) = A \cos(2\pi ft + \phi) $$The anti-noise generated by the ANC system: $$ p_c(t) = -A \cos(2\pi ft + \phi) = A \cos(2\pi ft + \phi + \pi) $$Superposition: $$ p_{\text{total}} = p_n(t) + p_c(t) = 0 $$That is the ideal case. In a real ANC headset, the anti-noise travels from the speaker to the eardrum through an acoustic path, and the electronics introduce latency. If the phase shift is off by even a few degrees, or the amplitudes don’t match, cancellation degrades fast.

Continue reading →