Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

MLX90393 Gain change
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MLX90393 Gain change

by Owl2623 on Thu Jul 16, 2020 4:15 pm

I have been trying to setup the MLX90393 in its most sensitive configuration. My first attempt was to change the gain from 1X to 5X. I tested the gain change using the demonstration program mlx90393_simpletest.py provided from the Github site. The test involved setting the gain, start taking data then moving a magnet from 12 inched to 1 inch away from the MLX90393 sensor and then back to the starting location. I tried this test at G = 1X and 5X. I expected the measured output for the two test to differ be a factor of 5x. They were not. For instance at G = 1X the delta between the output at the two position was 315, and at G = 5X the delta was 307. The differences are based on a 10 sample average.

This is the line of code that I was using to set the gain.
SENSOR = adafruit_mlx90393.MLX90393(I2C_BUS, gain=adafruit_mlx90393.GAIN_5X)

Can you explain why the readings are so similar and suggest any other setup changes to make the part as sensitive and possible to changes in the magnetic field?

Owl2623
 
Posts: 7
Joined: Wed Aug 10, 2016 2:55 pm

Re: MLX90393 Gain change

by adafruit_support_mike on Sun Jul 19, 2020 2:16 am

To compare sensor readings, you need to specify the units.

If the device measures the same magnet having the same strength at the same position for two different levels of gain, the code is probably scaling the raw sensor readings to the same units in both cases.

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: MLX90393 Gain change

by Owl2623 on Fri Aug 14, 2020 2:17 pm

Thanks for your help. I have been reviewing the application data for the magnetometer chip and find a table that relates gain and resolution. The gain setting is covered in the program mlx90393_simpletest.py from GitHub. There is no option for selecting the resolution. It's unclear how to control resolution. See attached data.

Here is a link to Melexis and their application notes for this part.

https://www.melexis.com/en/product/MLX9 ... gnetometer

Thanks for your assistance,
Alan Croft
Attachments
Res_XYZ_App.jpeg
Resolution details
Res_XYZ_App.jpeg (156.12 KiB) Viewed 35 times
Gain_vs RES.jpeg
Table gain vs resolution
Gain_vs RES.jpeg (179.38 KiB) Viewed 35 times
adafruit_mlx90393.py
Adafruit breakout program
(10.68 KiB) Downloaded 3 times

Owl2623
 
Posts: 7
Joined: Wed Aug 10, 2016 2:55 pm

Re: MLX90393 Gain change

by Owl2623 on Mon Sep 07, 2020 2:21 pm

adafruit_support_mike wrote:To compare sensor readings, you need to specify the units.

If the device measures the same magnet having the same strength at the same position for two different levels of gain, the code is probably scaling the raw sensor readings to the same units in both cases.


adafruit_Support_mike,

I'm still looking for help on this topic. Any suggestions would be helpful.

Thanks,
Alan

Owl2623
 
Posts: 7
Joined: Wed Aug 10, 2016 2:55 pm

Re: MLX90393 Gain change

by adafruit_support_mike on Tue Sep 08, 2020 4:32 am

You still need to specify your units.

The tradeoff between gain and resolution is like having a scale with two measurement ranges:

- 0kg to 5kg +/-5g
- 0kg to 1kg +/- 1g

If you measure a 500g weight on both ranges, they'll both tell you it weighs 500g. The 0kg-5kg range won't tell you it weighs 2.5kg just because its range is 5x wider. The only difference is the expected amount of error in the measurement.

To demonstrate that, imagine measuring a 502g weight on both ranges. You can expect the 0kg-1kg range to give you an answer between 501g and 503g. You can expect the 0kg-5kg range to give you an answer of 500g or 505g, because that's the smallest difference it can measure.

Both ranges give roughly the same answer because they're measuring the same thing in the same units. Without units, there's no way to know what the number '500' means in relation to the thing you're measuring.

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: MLX90393 Gain change

by Owl2623 on Sat Sep 12, 2020 5:56 pm

Okay I see your point. I would measure the same value for both tests. The effect of the gain would just be in the amount of variation in the measured signal. The Gain = 1 would be noisy since it only takes .161 MicroTesla to change the measured value versus 0.805 microTesla at gain = 5. Is this correct?

Based on the information in the Adafruit application note, MLX90393 Wide-Range 3-Axis Magnetometer, "Resolution is managed internally in the driver itself, and defaults to the maximum value of +/- 2^15 LSBs." I would take this to mean that the default resolution is set to the RES = 0 values in the sensitivity table above. So a gain of 1x (GAIN_SEL = 7) and RES = 0 equates to a resolution of 0.161 microTesla per LSB (for instance +/- 1g in your example). At gain of 5x (GAIN_SEL = 0) the resolution would be 0.805 microTesla per LSB (for instance +/-5g in your example). I'm I interrupting this table correctly?

Thanks,
Owl2623

Owl2623
 
Posts: 7
Joined: Wed Aug 10, 2016 2:55 pm

Re: MLX90393 Gain change

by adafruit_support_mike on Thu Sep 17, 2020 4:39 am

Owl2623 wrote:The effect of the gain would just be in the amount of variation in the measured signal.

And a change in the size of the range you can measure. In the analogy above, a 2.5kg weight would be outside the 0kg to 1kg range's limits, but within the 0kg to 5kg range.

In general, you get the best resolution from the smallest range that covers the largest value you need to measure.

Owl2623 wrote:The Gain = 1 would be noisy since it only takes .161 MicroTesla to change the measured value versus 0.805 microTesla at gain = 5. Is this correct?

Vaguely.. noise is a different subject, whose relationship to a given signal, sensor, and resolution is complicated. The signal itself will always contain some noise that sets the minimum resolution where it's possible to get meaningful information. Any sensor will have internal noise sources, some of which are proportional to the range or resolution.

The most useful thing you can say about resolution is its definition: the smallest change a sensor can measure repeatably. The resolution you need is overwhelmingly dictated by the way you plan to use the measurement.

Owl2623 wrote:I'm I interrupting this table correctly?

Yes, that sounds like the correct reading of the table.

That approach to measurement truncation is related to the vaguely-tolerable concept of 'significant figures'.. the idea that you can't divide 100 by 3 and expect an answer of 33.333... to be accurate to an infinite number of decimal places.

With sig-figs, the value '100' implies an error range less than +.-0.5. The value '100.0' implies an error range less than +/-0.05, and so on. The core idea of significant figure arithmetic is that you can't expect the result of a calculation to have more significant figures than the original values. 100/3 means (100 +/-0.5)/(3 +/-0.5), which can land anywhere between 28.4 (99.5/3.5) and 40.2 (100.5/2.5). The shortest original value has one significant figure, so the result can only be reliable to one significant figure: 3x10e1.

(Sig-figs are a disaster when applied without informed judgement BTW, and 'informed judgement' is harder to explain than proper statistical error propagation).

In the MLX90393, you can select 16 significant binary digits from a 19-digit raw value. If you select the most significant set, you give up the three lowest digits of resolution. If you select the least significant set, you give up the three highest digits of range.

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.