MLX90393 -- can this device be used for accurately sensing rotation speed?

Thread Starter

JamesAguilar

Joined Nov 11, 2024
17
Friends,

For my own entertainment, I'm working on a project that (may) partly involve turning a DC motor + a magnetometer into what I think could be called a servo motor? Here's my test setup:

PXL_20250107_003731726.jpg

The 3D printed apparatus holds three items: the magnetometer mentioned earlier, a magnet, and then a DC motor. The rest of the parts pictured here are a motor driver IC and an ESP32-C6.

In theory, the magnet is aligned with the magnetometer in an order that the datasheet says should allow rotation sensing (this is from the application note example for rotary encoding):

1736466344988.png

I seem to be able to get a pretty good angle signal out of this device, but when used to measure rotation speed, there appears to be a lot of jitter. When stationary, I get measurements within 1deg/sec of zero. However, when rotating the motor at a constant duty cycle, the apparent noise is significant -- on the order of +- 20deg/sec (sampling at a little less than 200hz).

There are a ton of possible sources of error -- bad firmware as written by me, a bad physical setup, maybe magnetic noise form the motor? Or maybe the motor's speed is really varying by the amounts I'm measuring (although visually it appears to run very smoothly). Assuming the motor is running at a nearly constant speed at a fixed duty cycle, then the measurements I'm seeing contain both high and low frequency noise. I know this because I've looked at plots of the noise both raw and smoothed with an EWMA (alpha=0.95) and I saw significant variance in the measured speed under both approaches.

My main question: I wanted to ask here to see if anyone would know if I have fundamentally misunderstood what is possible with this part. I'm wondering if this is just not a very good way of sensing rotation speed? I'm aware that there are other approaches, mostly encoder wheels combined with optical, physical, or magnetic sensors, as far as I'm aware. I would like to know if I just need to keep debugging, or if my princess is in another castle. If I should keep on pushing, I'd appreciate any sources you have for me to read that would help me work through the problems I'm grinding on.

If it's at all helpful, the reason why I thought I might be able to use this device is because I looked up how Lego does their servomotors. If you're not aware, their motors are also capable of both absolute position control and speed control. If you look at a teardown of their motors, they appear to use a similar IC on the motor output shaft, so I formed a belief that I could do something like what they do. My process for picking the parts for my design (if you can call it that) was to look for parts that do something similar to Lego's design and try to jam them together.

Here are links to the part datasheet and application notes.

Getting started guide: https://www.melexis.com/-/media/fil...n-notes/mlx90393-application-note-melexis.pdf

Datasheet: https://www.mouser.com/datasheet/2/734/MLX90393-Datasheet-Melexis-953267.pdf

Thank you in advance for any advice you have to offer.
 

Thread Starter

JamesAguilar

Joined Nov 11, 2024
17
(It's possible that this should have better been in "automation, robotics, and control" rather than in measurement. My apologies if so. :O
 

Thread Starter

JamesAguilar

Joined Nov 11, 2024
17
Hrm. From reading about it, maybe what I want is a magnetic rotary position sensor, like an AS5600 or an AS5132, not this MLX90393 device. If I look online at other people who have done this project, that seems to be what folks are using.

If anyone has the time to explain to me why the magnetometer is so much less suited to this purpose, I'm here to learn. But I think I know what avenues to pursue now.
 

nsaspook

Joined Aug 27, 2009
16,250
Hrm. From reading about it, maybe what I want is a magnetic rotary position sensor, like an AS5600 or an AS5132, not this MLX90393 device. If I look online at other people who have done this project, that seems to be what folks are using.

If anyone has the time to explain to me why the magnetometer is so much less suited to this purpose, I'm here to learn. But I think I know what avenues to pursue now.
Speed vs accuracy as a device design criteria. Sample rates, filtering and data transfer modes are optimized for the type of device. A quick look shows demos of the MLX90393 as a 3D Human Interface Device of high resolution for slow changes of motion, not a motor position type sensor.

The AS5600 is a much simpler device, using something much like a resolver sine/cosine rotation calculations.
https://look.ams-osram.com/m/7059eac7531a86fd/original/AS5600-DS000365.pdf
The AS5600 is a Hall-based rotary magnetic position sensor using planar sensors that convert the magnetic field component perpendicular to the surface of the chip into a voltage. The signals coming from the Hall sensors are first amplified and filtered before being converted by the analog-to-digital converter (ADC). The output of the ADC is processed by the hardwired CORDIC block (Coordinate Rotation Digital Computer) to compute the angle and magnitude of the magnetic field vector. The intensity of the magnetic field is used by the automatic gain control (AGC) to adjust the amplification level to compensate for temperature and magnetic field variations.
 
Last edited:
Top