2018-08-24 05:41 AM
Hi All,
I am working on the LIS3MDL register on my board. But When I try to measure the Magnetic field Produced by motors, I am getting very high deviation.
My settings for the LIS3MDL are as below.
0x22 -- 0x00 (also tried with 0x22 -- 0x03)
0x21 -- 0x00
0x23 -- 0x0C
0x24 -- 0x00
0x30 -- 0x00
0x32 -- 0x00
0x33 -- 0x00
And I am setting 300 ODR (HP Mode).
(delay of 100 ms after reading 1 sample from each axis).
(Below para is for reference , you can also neglect).
So The deviation Which I am talking here is, when I collect samples/time, and convert frequency I get somewhere around 30-35hz but when I measured with other sensor(bosch sensortech) I am getting exact match of magnetic readings. (verified with field applied and also converting as above (same conversion) ) the exact match would be 50hz.
Sensor is connected over SPI (4 wires) mode.
Here I wanted to know, If I am doing correct settings in the register and also Is there any other settings/process.
So , Please if any one can point me out in right direction, that would be very helpful.
Thanks in advance.
(also enclosing the x,y,z raw samples file)
2018-08-27 06:43 AM
What is your settings in register CTRL_REG1 (20h)?
How do you read the data? Are you using DRDY interrupt?
2018-09-10 08:25 PM
Hi Miroslav,
My settings in CTRL_REG1 is = 0x5E,
Reading data on 300 hz speed.( In main application it will be user defined, but the readings pasted here is on 300 hz.
Right now I am not using DRDY interrupt., And I read data directly from x,y,z registers as raw data over spi.
Please let me know for any other inputs required for solution.
Thanks,
Hinesh
2018-09-11 06:18 AM
OK, the configuration is correct.
But you have to measure the real ODR of the sensor using the DRDY signal to get correct frequency value. The ODR can have quite significant error from the typical value which is in datasheet.
2018-09-11 07:49 AM
Ok,
So what do suggest is good way to check as I need to collect the raw data.
And Here I am collecting is raw samples from the registers.
For collecting some 1000 samples , By the DRDY signal approach will take longer time.
2018-09-12 12:45 AM
My recommendation is to read the samples after DRDY interrupt and a the same time measure the data rate by a timer in your MCU (save time at first and last sample). It will take the same amount of time as polling status register for new data, which you are do now.
2018-09-12 02:27 AM
Hi @Miroslav BATEK
ok,
Let me try that way,
But Also Today I did one interesting thing.
I collected the raw samples from sensors, And I converted to FFT.
In fft , Though I have selected sampling freq. 300hz in reg. but when I gave sampling freq 250 (in fft calculation), I got match.
So, Another question,
is there any possibility that the ODR which is mentioned in data sheet, may have error, (as you said in last post) of 50hz?
Thanks,
Hinesh
2018-09-12 06:52 AM
50Hz seems to me too much, but I double check you configuration and I think I see the problem.
If you configure the CTRL_REG1 is = 0x5E (High-performance mode for X,Y axis) you have to configure also Z axis into the same mode, it means CTRL_REG4 = 0x80 (not 0x0C).
If the modes for X,Y and Z are different the ODR will be different, which you would see if you measure it using DRDY.
2018-09-13 04:32 AM
Hi @Miroslav BATEK ,
Thank you for insde, Let me try with the configuration for ctrl_reg4 as you have suggested.
I am implementing DRDY setting, (As in project, middle layer and application is already implemented, So going through them on driver level to implement same ).
Meanwhile, If you think any experiment that can be done to measure readings, That will be helpful.
Also I was going through the data sheet, And for CTRL_REG4 if I set 0x80 , then It would be
1000 0000 , Which As per data sheet may not be correct,
Are you trying to say CTRL_REG4= 0x08 ( Z high performance mode)?
UPDATE:-
I have tried with the register settings in CTRL_REG4=0x08 and 0x80,
But results from both are also almost similer to what I was getting for 0x0C, ( there is difference)
But Thank you for pointing it out, I have changed it for correctness.
Thanks,
Hinesh