Skip to content

AP_Compass: add AF9838 backend - #33872

Open
Voltafield wants to merge 2 commits into
ArduPilot:masterfrom
Voltafield:AP_Compass-add-AF9838
Open

AP_Compass: add AF9838 backend#33872
Voltafield wants to merge 2 commits into
ArduPilot:masterfrom
Voltafield:AP_Compass-add-AF9838

Conversation

@Voltafield

@Voltafield Voltafield commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Adds an AP_Compass backend for the Voltafield AF9838 I2C magnetometer.

The driver supports AF9838 detection, initialization, single-measurement acquisition, magnetic XYZ conversion to milligauss, and probing through ArduPilot I2C bus paths.

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

Changes:

  • Adds the AP_Compass_AF9838 backend.
  • Adds DEVTYPE_AF9838 device identification and decode_devid.py support.
  • Adds AF9838 compile-time configuration.
  • Adds AF9838 I2C probing at address 0x0C.
  • Supports external I2C buses and HAL I2C buses classified as internal, as required by the CubePurple connector used during testing.

Hardware tested:

  • Flight controller: CubePurple
  • Sensor: AF9838 external I2C module
  • Interface: I2C
  • I2C address: 0x0C
  • CubeOrange: not tested

Build validation:

  • ./waf clean: PASS
  • ./waf configure --board CubePurple: PASS
  • ./waf copter: PASS
  • Final source commit: bc8f469d1ae4594011569a7819f5dcdf3c5823b7
  • AP_Compass driver commit: 84e28adcf274c0301305425e53241be10abc8e3f

Commit history note:

  • The original tested commit was 7ef6c16ecd0b3c9e1f85714322a9dadd0cd57faf.
  • The commit was split into AP_Compass: and Tools: commits to satisfy ArduPilot branch-convention CI.
  • The source tree before and after the split is identical; no source-code changes were introduced.

Hardware detection:

  • COMPASS_DEV_ID: 1707009
  • Decoded device type: DEVTYPE_AF9838
  • COMPASS_EXTERNAL: 1
  • Sensor detection and initialization: PASS

Raw magnetic XYZ validation:

  • AF9838 was rotated through yaw, roll and pitch axes.
  • X/Y/Z output changed continuously without stalls.
  • Full RAW_IMU telemetry and extracted CSV are included in the test evidence.

Additional bench validation:

  • Stationary stability test duration: 24 minutes 23 seconds
  • Compass remained detected throughout the stability test.
  • Three complete CubePurple power-cycle tests: PASS
  • AF9838 was automatically detected after every restart.
  • Final firmware was loaded and smoke-tested on CubePurple.

Test evidence:

  • AF9838 build logs
  • Firmware metadata and SHA-256
  • Detection logs and device-ID decoding
  • Raw magnetic XYZ CSV and telemetry logs
  • Stability-test logs
  • Power-cycle-test logs

AF9838_ArduPilot_Test_Evidence_CubePurple_20260729.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant