Back to 5.2.4 Padding

5.2.4 Padding — Electrical Integration

V-Model Traceability: This page addresses RM-6 (Absorb repeated strikes without damage; provide impact detection) at the electrical layer — covering IMU sensor selection, I²C topology, wiring design, and the strike detection signal pipeline.

Requirements Cascade

System Req Subsystem Implication
RM-6 Embedded IMU sensors must reliably detect impacts above threshold without false positives from arm motion

MPU6050 Sensor Selection

The InvenSense MPU6050 6-axis MEMS inertial measurement unit was selected for embedded impact detection. The sensor integrates a 3-axis accelerometer and a 3-axis gyroscope in a single QFN package (4 mm x 4 mm x 0.9 mm), communicating via I2C at up to 400 kHz.

Parameter Value Relevance
Accelerometer range ±2/4/8/16 g (configurable) Configurable ±2/4/8/16 g (hardware range); configured to ±16 g. Strike detection threshold: 20 m/s² (software L2 norm applied to raw acceleration vector)
Output data rate Up to 1 kHz Sampled at 200 Hz (matched to Teensy unified loop)
I2C addresses 0x68 (AD0 LOW), 0x69 (AD0 HIGH) Limits to 2 sensors per I2C bus; dual-bus topology required for 4 sensors
Operating voltage 3.3V (logic), 5V tolerant via breakout Compatible with Teensy 4.0 3.3V logic levels
Cost ~$2 per breakout board Enables deployment of 4 sensors within budget

The gyroscope channels are not used for strike detection. Velocity integration was evaluated but abandoned due to thermal random-walk drift inherent in MEMS gyroscopes. The system relies exclusively on accelerometer peak-vector magnitude tracking for impact classification.

Quad-IMU I2C Topology

The MPU6050 supports only two I2C addresses (0x68 and 0x69, selected by the AD0 pin). To accommodate four sensors, the Teensy 4.0's two independent hardware I2C buses are both utilised:

I2C Bus Teensy Pins Address 0x68 Address 0x69
Wire SDA: Pin 18, SCL: Pin 19 Centre Body Left Body
Wire1 SDA: Pin 17, SCL: Pin 16 Right Body Head Pad

Both buses operate at 400 kHz (I2C Fast Mode). Each MPU6050 read transaction requires approximately 14 bytes, consuming ~280 µs per sensor at 400 kHz.

Strike Detection Pipeline

The raw 3-axis acceleration from each IMU is included in the expanded /motor_feedback payload (21 doubles) published via micro-ROS at 200 Hz. On the application side On the application side, the IMU Diagnostics Tab computes the L2 norm:

||a|| = √(ax² + ay² + az²)

When ||a|| exceeds a configurable threshold (default: 2.0 g), the system registers a valid strike event and publishes data (sensor ID, peak acceleration, timestamp) to the /robot/strike_detected ROS 2 topic.

Nyquist-Aware Sample Scanning

The GUI refresh rate (20 Hz) produces 50 ms frames, but punch impact spikes can be as brief as 30 ms. A naive single-sample evaluation at the GUI tick boundary would miss impacts occurring between frames. The detection algorithm therefore scans using np.max(mag_arr[-n_scan:]), where n_scan equals the number of firmware samples per GUI frame (typically 10 at 200 Hz / 20 Hz).

IMU Timing Budget

Within 200 Hz Unified Loop

Task Allocation
CAN Tx/Rx (4 motors) ~0.8 ms
I2C IMU reads (up to 4 sensors) ~1.1 ms
micro-ROS publish ~0.5 ms
Safety checks + logic ~0.4 ms
Headroom ~2.2 ms (44%)

Total worst-case utilisation: ~2.8 ms of the 5.0 ms budget (56%).