Contact mail
Overview Geometry Rev 1 Hardware GUI Studio Megnito Rev 2 Validation Lessons
SPATIAL SENSING & EMBEDDED INSTRUMENTATION CASE STUDY
PLATFORM: MAGSENSE 5-AXIS CROSS | REVISION: 1.0 (BENCH) & 2.0 (CAD)
REV 1: BENCH TESTED & OPERATIONAL REV 2 (MEGNITO): 6-LAYER CAD COMPLETE // UNFABRICATED warning UNCALIBRATED // RELATIVE FLUX ONLY

MagSense — Multi-Sensor Magnetic-Field Imaging Platform

An experimental instrumentation platform designed to evaluate multi-point spatial magnetic-field acquisition, real-time bicubic gradient heatmap rendering, and the transition from loose breakout wiring to an autonomous 6-layer edge-computing instrument.

Populated Rev 1 Sensor Array HARDWARE BENCH
Populated MagSense Rev 1 sensor board on test fixture
play_circle Jump to Bench Video Demonstration
arrow_forward
MAGNETOMETERS 5× MMC5983MA 18-bit AMR (100 Hz)
ARRAY GEOMETRY 20 mm Radius Equilateral Cross
REV 1 CONTROLLER ESP32 DevKit V1 100 kHz SPI / FreeRTOS
REV 2 CONTROLLER STM32G431CBTx 6-Layer CAD / CAN-FD
ENGINEERING MOTIVATION & FULL SPECIFICATIONS expand_more

Engineering Motivation: Traditional magnetometers capture only single-point flux density vectors B⃗ = (Bx, By, Bz), making it impossible to separate background geomagnetic bias from local dipole position, field curvature, or gradient anomalies.

MagSense addresses this by distributing five anisotropic magnetoresistive (AMR) sensors in a cross formation (r = 20 mm). In Revision 1, an external ESP32 controller streams high-speed binary packets to a custom Python/PySide6 visualizer. In Revision 2 (Megnito), the architecture is redesigned into a monolithic 6-layer PCB with an onboard STM32G431 MCU, CAN-FD, native USB-C, and intelligent power multiplexing.

Auxiliary Sense TMP112 (I²C) Thermal drift tracking
Serial Protocol COBS Binary 69-byte packed packet
Baud & Rate 921,600 Baud 102.1 Hz stream
Visualizer GUI PySide6 + OpenGL Bicubic spline zoom
MATHEMATICAL & PHYSICAL TOPOLOGY

Measurement Concept & Five-Sensor Cross Geometry

Standard 3-axis magnetometers cannot differentiate between a homogeneous ambient magnetic field (such as Earth's geomagnetic flux) and a localized magnetic field disturbance caused by a nearby ferromagnetic object or permanent magnet. MagSense solves this by implementing a five-point differential spatial array.

The 20 mm Equilateral Cross Layout

The array places one MMC5983MA sensor at the coordinate origin (0, 0) as a central reference baseline, with four peripheral sensors placed along orthogonal axes at a radial distance of r = 20.00 mm:

Center Sensor (IC1) Coordinates: (0, 0) mm Primary vector reference Bcenter
Left Sensor (IC3) Coordinates: (−20.00, 0) mm Differential X-negative node
Right Sensor (IC4) Coordinates: (+20.00, 0) mm Differential X-positive node
Top Sensor (IC6) Coordinates: (0, −20.00) mm Differential Y-positive node
Bottom Sensor (IC5) Coordinates: (0, +20.00) mm Differential Y-negative node

Spatial Gradient & Anomaly Detection Formulations

By taking differential readings between opposite sensor pairs separated by Δd = 40.00 mm, common-mode ambient fields cancel out, isolating the local field gradient tensor components:

∂B⃗ / ∂x ≈ (B⃗Right − B⃗Left) / (2r) = (B⃗Right − B⃗Left) / 40.00 mm
∂B⃗ / ∂y ≈ (B⃗Top − B⃗Bottom) / (2r) = (B⃗Top − B⃗Bottom) / 40.00 mm
∇2B⃗ ≈ (B⃗Right + B⃗Left + B⃗Top + B⃗Bottom) − 4×B⃗Center

When a magnetic anomaly moves over the array, these second-order differences generate localized peaks and troughs, providing the mathematical input data required to project continuous flux heatmaps.

MagSense PCB silkscreen and trace routing macro
zoom_in
Physical PCB Layout: Macro shot of the bare Rev 1 PCB. Notice the star-routed chip select traces radiating from the connector breakout to each of the five sensor pads, maintaining matching geometry to minimize clock skew across the shared SPI bus.
PHYSICAL HARDWARE & FIRMWARE PIPELINE

Revision 1 Hardware & Embedded Acquisition Architecture

Revision 1 was realized as a modular two-board system: a dedicated sensor carrier PCB connected to an external ESP32 DevKit V1 controller via a 15-conductor JST-XH wiring loom.

Hardware Pinout & Bus Topology

All five MMC5983MA sensors share common clock, data-in, and data-out SPI lines, while five dedicated GPIO pins provide individual active-LOW chip select control. The TMP112 sensor communicates over a separate two-wire I²C bus.

SCK GPIO 18
All 5 ICs (100 kHz)
MISO GPIO 19
All 5 ICs (Data Return)
MOSI GPIO 23
All 5 ICs (Command)
CS_Center GPIO 5
Center Sensor (Active LOW)
CS_Bottom GPIO 32
Bottom Sensor (Active LOW)
CS_Top GPIO 27
Top Sensor (Active LOW)
CS_Right GPIO 13
Right Sensor (Active LOW)
CS_Left GPIO 25
Left Sensor (Active LOW)
I2C_SDA GPIO 21
TMP112 (0x48, 400 kHz)
I2C_SCL GPIO 22
TMP112 (0x48, 400 kHz)

Empirical Engineering Reality: Harness Parasitics

During bench bring-up, the unshielded 15-wire jumper harness introduced significant parasitic capacitance and ground-bounce inductance. Attempting to clock the SPI bus at 4 MHz or 10 MHz caused bit slippage and MISO corruption.

Practical Solution: The SPI bus was conservatively throttled to 100 kHz Mode 0 in firmware (main.cpp). Because 5 sensors × 6 bytes of measurement data require only 30 bytes per frame, 100 kHz provided more than enough bandwidth to achieve 102.1 Hz sampling while guaranteeing 100% signal integrity.

Binary Pipeline & FreeRTOS Task Architecture

Firmware is written in modern C++ with PlatformIO. Acquisition is managed by a high-priority FreeRTOS task pinned to ESP32 Core 1 (StreamingTask.cpp) to avoid contention with USB serial interrupts:

// MagSense Binary Frame (69 bytes packed)
#pragma pack(push, 1)
struct SensorPacket {
  uint32_t timestampUs;         // 4 bytes: Boot timestamp
  float    temperatureC;        // 4 bytes: TMP112 °C
  float    magX[5];             // 20 bytes: Center, B, T, R, L
  float    magY[5];             // 20 bytes: Center, B, T, R, L
  float    magZ[5];             // 20 bytes: Center, B, T, R, L
  uint8_t  activeSensorsBitmask; // 1 byte: Health mask (bits 0-4)
};
#pragma pack(pop)
Packet Serialization COBS (Consistent Overhead Byte Stuffing)
Frame Delimiter 0x00 Null Byte
Serial Transport USB CDC @ 921,600 Baud
Fault Isolation Disconnected sensors masked out to avoid SPI hang
EMPIRICAL BENCH DEMONSTRATION & SOFTWARE

MagSense Studio — Live Visualization & Video Evidence

The PC client is built using Python, PySide6 (Qt6), PyQtGraph, PyOpenGL, NumPy, and SciPy. Below is the authentic bench testing recording demonstrating live dynamic field projection.

MAGSENSE_LIVE_PROBE_TEST.MP4
Bench Demonstration Reality: Live video recording of the working testbench. A magnetic probe moving over the physical sensor array causes immediate real-time gradient updates in MagSense Studio. (Proves physical interaction, sensor reading, binary communication, and visualizer rendering; does not prove calibrated field intensity).
MagSense Studio software screen
MagSense Studio Desktop Capture Terminal execution: python.exe main.py streaming at 102.1 Hz with COBS binary decoding. Enlarge full screenshot arrow_forward

Heatmap Math: Sparse Grid to Spline Surface

It is vital to understand how the visualizer turns five discrete point sensors into a smooth 2D heatmap. In heatmap_2d.py:

  1. 1. Scalar Vector Calculation: Each sensor computes total flux magnitude |B| = √(Bx2 + By2 + Bz2) or inclination dip angle.
  2. 2. 3×3 Grid Mapping: The five values are assigned to grid cells:
    Center=(1,1), Top=(0,1), Bottom=(2,1), Left=(1,0), Right=(1,2)
  3. 3. Synthetic Corner Averaging: The four missing corners are calculated by averaging adjacent orthogonal sensors:
    Grid[0,0] = (Top + Left) / 2.0
  4. 4. High-Resolution Spline Zoom: The 3 × 3 grid is upscaled by a factor of 80 using third-order bicubic spline interpolation:
    scipy.ndimage.zoom(grid, 80, order=3)
Caution The smooth 240 × 240 color gradient displayed on screen is a mathematical interpolation across five sparse physical nodes. It should not be misinterpreted as a high-density imaging camera.
SECOND ITERATION MONOLITHIC REDESIGN

Revision 2 — The Megnito Monolithic Instrument

While Revision 1 successfully validated the 5-sensor acquisition pipeline, loose jumper wiring and an external DevKit limited robustness and industrial integration. The second iteration—named Megnito—integrates the entire instrument into an autonomous 6-layer high-density PCB.

design_services
Design-Phase Verification Status Designed in KiCad 9.0; complete 6-layer layout and DRC verified; manufacturing Gerbers exported October 11, 2026. Unfabricated design milestone.
6-LAYER GERBERS EXPORTED
Processing & Clocking memory

STM32G431CBTx MCU

Arm Cortex-M4F core clocked at 170 MHz with hardware floating-point unit (FPU) and DSP acceleration. Replaces the external ESP32, enabling local finite-difference gradient calculations and DMA-driven continuous SPI streaming.

Clock Source: Abracon ASV-xxxMHz active 4-pin crystal oscillator (Y1) for ultra-low jitter.
Physical Architecture layers

6-Layer Shielded Stackup

Compact 50.05 × 50.05 mm square footprint with M2 mounting holes. Symmetrical 6-layer stackup featuring solid internal ground planes (In1.Cu and In4.Cu) to shield sensitive AMR sensors from high-speed digital switching transients.

Dimensions: 50.05 × 50.05 mm, 1.6 mm thickness, 0.15 mm min trace width.
Power Management battery_charging_full

Auto-Switching Power Mux

TI TPS2115ADRBT power multiplexer (IC7) autonomously switches between USB-C 5V and external battery power (J4, JST-PH 2.0 mm LiPo header) without resetting the MCU. Backed by a TI TPS7A0233DBVR ultra-low-noise 3.3V LDO (IQ = 25 nA).

Regulation: Clean analog supply rail eliminates sensor readout ripple.
Industrial Fieldbus hub

CAN-FD & Daisy Chaining

Infineon TLT9251VLEXUMA1 automotive-grade CAN transceiver (IC8) enables robust differential communication over long distances. Features an onboard switchable 120 Ω termination resistor (R13, 2512 package) via solder jumper JP1.

Connector: 4-pin JST-SH 1.0 mm header (J3) carrying CAN_H, CAN_L, and power.
High-Speed I/O usb

USB-C & Qwiic Ecosystem

16-pin USB Type-C receptacle (J5) protected by a ST USBLC6-2SC6 low-capacitance ESD clamp array (U3). Includes a SparkFun Qwiic I²C connector (J1), auxiliary SPI2 header (J2, 5-pin), and dedicated 3-pin UART debug port (J6).

ESD Protection: High-speed clamping protects D+/D- against electrostatic discharge.
On-Device HMI touch_app

RGB Telemetry & Tare Button

A WS2812B-2020 miniature addressable RGB LED (D4) is placed at (84.52, 89.15) mm immediately adjacent to the central sensor for dynamic optical alerts. A low-profile C&K PTS815 tactile switch (S1) provides physical zeroing/tare control.

Status LEDs: Discrete 0402 LEDs (D1, D2) for power and streaming activity.
Megnito 6-Layer Manufacturing Stackup (Megnito-job.gbrjob)
F.Cu (L1) — Outer Copper 35 µm (1 oz)
Component pads, decoupling caps, local high-speed routing
Prepreg Dielectric 1: 100 µm (FR4, εr = 4.5)
In1.Cu (L2) — Inner Ground 35 µm (1 oz)
Solid Ground Reference Plane (GND) — Low return inductance
Core Dielectric 2: 535 µm (FR4, εr = 4.5)
In2.Cu (L3) — High-Speed Signal 35 µm (1 oz)
Internal high-speed SPI bus & CAN differential pairs
Prepreg Dielectric 3: 100 µm (FR4, εr = 4.5)
In3.Cu (L4) — Power Rails 35 µm (1 oz)
Power distribution rails (+3.3V, 5V, VIN) & control lines
Core Dielectric 4: 535 µm (FR4, εr = 4.5)
In4.Cu (L5) — Ground Shield 35 µm (1 oz)
Solid Ground Shield Plane (GND) — Magnetic isolation
Prepreg Dielectric 5: 100 µm (FR4, εr = 4.5)
B.Cu (L6) — Bottom Copper 35 µm (1 oz)
Bottom ground shield pour, connector escapes, test points
TRUTH-IN-ENGINEERING SCORECARD

Empirical Validation, Calibration Status & Boundaries

In keeping with strict engineering rigor, this section explicitly delineates what has been experimentally proven on physical hardware versus what remains an unvalidated design specification.

Verification & Evidence Matrix
Rev 1 Multi-Sensor SPI Verified in Hardware
Evidence: magsense-live-test.mp4, main.cpp
Boundary: Throttled to 100 kHz due to harness line parasitics.
COBS Serial Pipeline Verified in Software
Evidence: magsense-studio-heatmap.jpg
Boundary: Requires initial 'S' handshake to start streaming.
Dynamic Anomaly Tracking Verified in Video
Evidence: magsense-live-test.mp4 (6.37s)
Boundary: Qualitative response only; field intensity is uncalibrated.
Bicubic Heatmap Rendering Verified in Python
Evidence: heatmap_2d.py, requirements.txt
Boundary: Corners are mathematically synthesized; not physical nodes.
Absolute Field Calibration Uncalibrated / Missing
Evidence: No calibration logs or chamber data
Boundary: Uses datasheet nominal sensitivity only (16384 counts/G).
Thermal Compensation Partial (Telemetry Only)
Evidence: TMP112 read in Packet.h
Boundary: Temperature is transmitted but not applied to drift equations.
Rev 2 Megnito Board CAD & Gerbers Complete
Evidence: Megnito.kicad_pcb, Megnito-job.gbrjob
Boundary: Unfabricated. Zero physical board testing or bring-up logs.
info METROLOGICAL BOUNDARY STATEMENT

The MagSense platform currently functions as a spatial field anomaly and gradient visualizer, not a certified laboratory magnetometer. No 3-axis Helmholtz coil tests, zero-gauss mu-metal chamber baseline calibrations, or hard/soft-iron ellipsoid corrections have been performed on the physical assembly. All numeric Tesla/Gauss values are derived strictly from MEMSIC nominal factory conversion parameters.

ENGINEERING RETROSPECTIVE

Lessons Learned & Development Roadmap

Developing the MagSense prototype provided valuable practical lessons in high-speed sensor buses, sparse matrix interpolation, and the engineering trade-offs of modular breakouts versus monolithic integration.

Lesson 01

Harness Capacitance Dominates

Jumper wires and unshielded ribbon cables introduce severe parasitics that ruin SPI rise times across multi-drop nodes. While throttling clock frequency is a valid bench workaround, physical board integration with controlled ground planes is the only true engineering solution.

Lesson 02

Bicubic Interpolation Traps

Third-order spline interpolation produces visually striking heatmaps that can easily mislead observers into believing high spatial sensor density exists. Engineers must maintain clear distinction between real spatial measurements and mathematical surface approximations.

Lesson 03

Protocol Decoupling Pays Off

Adopting a packed C++ binary struct with COBS framing over high-speed UART (921,600 baud) kept MCU loop execution deterministic and lightweight, leaving computation-heavy matrix math and OpenGL rendering to the desktop client.

Revision 2 Development Roadmap
PHASE 1 // FABRICATION Order 6-layer ENIG PCB panel and SMD stencils using exported KiCad Gerbers.
PHASE 2 // STM32 BRING-UP Assemble power mux and STM32G431 core; flash USB-C CDC and CAN-FD drivers.
PHASE 3 // SPI DMA STREAMING Implement high-speed SPI DMA polling across all 5 magnetometers on internal layers.
PHASE 4 // CALIBRATION Perform 3D Helmholtz coil characterization and implement hard/soft iron matrix correction.