lis3mdl maximum read rates - 1000Hz possible?

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
kevinjwalters
 
Posts: 1026
Joined: Sun Oct 01, 2017 3:15 pm

lis3mdl maximum read rates - 1000Hz possible?

Post by kevinjwalters »

I've switched from CircuitPython to C++/Arduino world for some high frequency reading of the CLUE's magnetometer. The lis3mdl is advertised as supporting 1000Hz. I've just written a simple program using Adafruit_LIS3MDL library. Both lis3mdl.getEvent() and lis3mdl.read() can only pull data at around 732 samples per second based on my tests. I'm reading 1000 samples (both read x/y/z which is 6 bytes) and it's taking 1.366211 seconds. I've got the i2c bus running at 400kHz. I'm curious if anyone else has tried to get continuous data out of it at the highest rate? I'd like to read every sample and not miss any.

I'll check the i2c traffic tomorrow. I've realised I'm not sure what the throughput is for 6 byte reads.

User avatar
kevinjwalters
 
Posts: 1026
Joined: Sun Oct 01, 2017 3:15 pm

Re: lis3mdl maximum read rates - 1000Hz possible?

Post by kevinjwalters »

This is a mixture of i2c bus not budging from 100kHz and some inefficiencies in Adafruit_LIS3MDL. I've not quite narrowed it down but the placement of

Code: Select all

Wire.setClock(400 * 1000);
relative to other stuff in setup() is important. I've now got 400kHz by placing it after everything including lis3mdl.begin_I2C() and I can read the samples (6 bytes work of actual data) at 2730 samples per second.

Locked
Please be positive and constructive with your questions and comments.

Return to “CLUE Board”