EFS Sensor Clustor
Table of Contents
Introduction
The purpose of this project is to utilize an STM32L433RC MCU to fetch data from sensors on the PCB, convert it into CAN format, and communicate with the Pixhawk6x. This document will record the details and progress of each sensor.
Reference: Sensor Cluster
GitHub repo: https://github.com/UWARG/efs-can-sensor-clustor https://github.com/UWARG/efs-canard
Standard Data Types: List of standard data types - DroneCAN
General CAN Stuff
For each sensor, refer to the standard data types to learn the data class to transfer. Here is an example sender function using canard
void send_MLX90393(void) {
uint8_t buffer[UAVCAN_EQUIPMENT_AHRS_MAGNETICFIELDSTRENGTH2_MAX_SIZE];
// put whatever you like in here for display in GUI
mlx90393_node.sensor_id = 1;
//1 uT = 0.01 Gauss, transfer in Gauss
mlx90393_node.magnetic_field_ga[0] = (float)mlx90393.get_x_data() / 100.0;
mlx90393_node.magnetic_field_ga[1] = (float)mlx90393.get_y_data() / 100.0;
mlx90393_node.magnetic_field_ga[2] = (float)mlx90393.get_z_data() / 100.0;
mlx90393_node.magnetic_field_covariance.len = 9;
//Covariance matrix with variance terms only, refer to 13.1 for noise standard deviation
//Settings: OSR = 3, digital filter = 5, conversion time = 52.92ms
//Standard deviation for XY-axis error = 5 mGauss, Z-axis = 7 mGauss
//Covariance is 0?
mlx90393_node.magnetic_field_covariance.data[0] = 2.5E-5;
mlx90393_node.magnetic_field_covariance.data[1] = 0.0;
mlx90393_node.magnetic_field_covariance.data[2] = 0.0;
mlx90393_node.magnetic_field_covariance.data[3] = 0.0;
mlx90393_node.magnetic_field_covariance.data[4] = 2.5E-5;
mlx90393_node.magnetic_field_covariance.data[5] = 0.0;
mlx90393_node.magnetic_field_covariance.data[6] = 0.0;
mlx90393_node.magnetic_field_covariance.data[7] = 0.0;
mlx90393_node.magnetic_field_covariance.data[8] = 4.9E-5;
uint32_t len = uavcan_equipment_ahrs_MagneticFieldStrength2_encode(&mlx90393_node, buffer);
// we need a static variable for the transfer ID. This is
// incremeneted on each transfer, allowing for detection of packet
// loss
static uint8_t transfer_id;
canardBroadcast(&canard,
UAVCAN_EQUIPMENT_AHRS_MAGNETICFIELDSTRENGTH2_SIGNATURE,
UAVCAN_EQUIPMENT_AHRS_MAGNETICFIELDSTRENGTH2_ID,
&transfer_id,
CANARD_TRANSFER_PRIORITY_LOW,
buffer,
len);
}
You can redirect to the uavcan equipment files in the dsdlc genereated folder to check for the max size, signature, and id of your data type.
Sensors
MLX90393 Magnetometer @Henry Wu @Yutong Zhu
Data sheet:
Application note:
Reference libraries: https://github.com/adafruit https://github.com/tedyapo/arduino-MLX90393
Breakout board: 4022 Adafruit Industries LLC | Development Boards, Kits, Programmers | DigiKey
Progress
Setup basic I2C transceive function(in blocking mode)
Setup functions for each command(refer to data sheet 15.1)
Setup functions to manipulate register values and data conversion(refer to data sheet 16)
Debugged and verified measurement read by comparing with sample Arduino code under same register settings - Nov 10, 2024
Test functions to change register values and switch to unblocking transfer- Nov 28, 2024
Write register and read register function tested and verified. Readings change according to settings. - Nov 12, 2024
DMA transfer ready to test - Nov 12, 2024
I2C interrupt transfer tested - Nov 28, 2024
CAN integration - Ongoing
Setup CAN message function for MagneticFieldStrength2, able to see txdata with logic analyzer. Need to decode data for verification.- Nov 28, 2024
Tx and Rx working, Ardupilot acknowledging data transferred - Jan 26, 2025
Notes
Consideration of DMA Use interrupt
Register settings: Higher OSR and digital filter setting lead to higher accuracy and lower noise, but higher covnersion time(refer to datasheet 16.2.5). Current setting: OSR = 3, digital filter = 5, conversion time = 52.92ms. Standard deviation of noise:
XY-axis = 5 mGauss, Z-axis = 7 mGauss
.
Sensitivity setting: Gain and resolution need to be tested on breakout board(refer to datasheet 16.2.4) Current setting: Sens-XY = 1, Sens-Z = 0, Gain_Sel = 0
Calibration of the sensor requires the accelerometer data from the drone. For more details see: Compass Calibration — Copter documentation
Barometer
Rangefinder
Datasheet: https://www.mouser.ca/datasheet/2/1126/XM125_datasheet-3133248.pdf
Reference libraries: efs-can-sensor-clustor/Drivers at A121-rangefinder · UWARG/efs-can-sensor-clustor
Breakout board: Acconeer XM125
Progress