kriswiner / EM7180_SENtral_sensor_hub

(Affordable) Ultimate Sensor Fusion Solution
https://www.tindie.com/products/onehorse/ultimate-sensor-fusion-solution/
96 stars 37 forks source link

Overlap of Accel Calibration Regs and LPF BW Regs #40

Closed braincore closed 5 years ago

braincore commented 5 years ago

Register 0x5B is used for both setting the accelerometer LPF bandwidth and for setting the accelerometer calibration.

From Global.h: EM7180_ACC_LPF_BW = 0x5B EM7180_GP36 = 0x5B

How does the EM7180 distinguish between the two different values being written to 0x5B? Both writes are done after setting host control to 0x00 so my only guess is that it has to do with the magnitude of the value being written.

kriswiner commented 5 years ago

These refer to the same register. The EM7180 reserves a few registers for general use. We have chosen to use 36, 37, and 38 to set the MPU9250 sensor parameters.

On Mon, Oct 8, 2018 at 8:49 PM Ken Elkabany notifications@github.com wrote:

Register 0x5B is used for both setting the accelerometer LPF bandwidth and for setting the accelerometer calibration.

From Global.h: EM7180_ACC_LPF_BW = 0x5B EM7180_GP36 = 0x5B

How does the EM7180 distinguish between the two different values being written to 0x5B? Both writes are done after setting host control to 0x00 so my only guess is that it has to do with the magnitude of the value being written.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/EM7180_SENtral_sensor_hub/issues/40, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qn9gpcZcT4MFqkPG1OBb9IdwNdi5ks5ujBy6gaJpZM4XQQ21 .

braincore commented 5 years ago

I understand. So how does the EM7180 know when I'm writing 0x03 to the register for 41Hz LPF BW, I'm not actually writing a value for the accelerometer calibration? What if I switched the order so that we wrote the LPF BW first followed by the accelerometer calibration?

In the actual code, EM7180_acc_cal_upload() writes to the register, and then a few lines down the same register is written to with a value for setting LPF.

braincore commented 5 years ago

FWIW, I'm using a different code base that's heavily inspired by the code in this repo so it's possible I'm doing something differently.

I noticed that my linear-acceleration samples had bias which is why I began investigating. I just removed the LPF BW code and now the linear-acceleration samples are much cleaner. So at least in my case, I suspect that the LPF writes were being interpreted as calibration parameters.

kriswiner commented 5 years ago

I can;t say anything about your modifictions of the code but what it looks like is that the general registers are first used to store the accel calibration data, and then retreive the data vi warm start load, then the general regiters are used to store sensor configuration data, all consistent with the idea that the general registers are for transferring data between host and the EM7180. I agree it is complicated and not as transparent as I'd like, but it does work.

On Mon, Oct 8, 2018 at 10:00 PM Ken Elkabany notifications@github.com wrote:

FWIW, I'm using a different code base that's heavily inspired by the code in this repo so it's possible I'm doing something differently.

I noticed that my linear-acceleration samples had bias which is why I began investigating. I just removed the LPF BW code and now the linear-acceleration samples are much cleaner. So at least in my case, I suspect that the LPF writes were being interpreted as calibration parameters.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/EM7180_SENtral_sensor_hub/issues/40#issuecomment-428060208, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qnbXP0wSEZNFRxtXpW_zeh1MJHIxks5ujC1lgaJpZM4XQQ21 .

braincore commented 5 years ago

I should have brought this up sooner, but I'm actually using the LSM6DSM + LIS2MD USFS. Any chance the GP registers used for accel calibration or LPF BW are different from the MPU9250 USFS? It was only after I read https://github.com/kriswiner/EM7180_SENtral_sensor_hub/issues/39 that it occurred to me that there might be a difference.

kriswiner commented 5 years ago

The EM7180 registers are likely the same but the LPF and BW and sample rates, etc are certainly not.

https://github.com/kriswiner/EM7180_SENtral_sensor_hub/tree/master/EM7180_LSM6DSM_LIS2MDL_LPS22HB_Butterfly

On Wed, Oct 10, 2018 at 1:56 AM Ken Elkabany notifications@github.com wrote:

I should have brought this up sooner, but I'm actually using the LSM6DSM + LIS2MD USFS. Any chance the GP registers used for accel calibration or LPF BW are different from the MPU9250 USFS? It was only after I read #39 https://github.com/kriswiner/EM7180_SENtral_sensor_hub/issues/39 that it occurred to me that there might be a difference.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/EM7180_SENtral_sensor_hub/issues/40#issuecomment-428492967, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qqWu_uSU7VYiWbAW8oSKtxTlSufiks5ujbY_gaJpZM4XQQ21 .

braincore commented 5 years ago

Makes sense. Thanks!