10-06-2019 03:19 PM
Hi
I've been able to get the BMX160 setup to update the Acc & Mag at 50Hz.
I followed the setup in the BMX160 datasheet, Table 16. Only difference is the ODR = 0x07 and REPXY and REPZ are set for to the high accuracy preset.
I have enabled Data Ready on INT1 pin.
When I receive an interrupt from INT1, I check the STATUS (0x1B) register and can confirm that both drdy_acc and drdy_mag are set (value=0xB0).
I then do a block ready from DATA_0 to DATA_19 and confirm that the Acc data is still correct.
However the Mag data does not change. I get an initial non-zero measurement, but then nothing changes further.
Why is the Mag data not changing?
Is there some setting I'm missing in the Mag setup?
Thanks
Solved! Go to Solution.
10-21-2019 06:17 PM - edited 10-21-2019 10:54 PM
@o_o wrote:
**PS: Handytech's code incorrectly sets the burst length to 1 byte, it should be 8 bytes.
To shortly comment about this::
Based on the above, one could reduce the amount of transactions to the magnetometer during the initialization by setting aux_rd_burst_len to 8 bytes, but I believe my code snippet using the official sensor API should work anyhow?
10-22-2019 11:44 PM
Hi o_o
Thanks for highlighting this incorrect write regiter. My burst write function was not incrementing the regiter.
I've fixed this and can confirm that the init I2C write traces are identical to yours.
I changed my code to poll the drdy_acc and drdy_mag bits (currently at 1sec intervals). Both are set correctly.
When I read the ACC and MAG data, the ACC data changes as expected.
The MAG data only updates correctly for 2 read cycles. After that the data goes to some bogus value and doesn't change.
I've outputted the BMM150 registers. Here are the I2C traces and register outputs when reading the registers:
// BMM150 Registers READ [REG: DATA]
// Read Reg: 0x4A
IC2_W: add:68 reg:4d data:4a
IC2_R: add:68 reg:04 len:08 data: c9 00 69 00 af 00 4d 69
4a: c9
// Read Reg: 0x4B & 0x4C
IC2_W: add:68 reg:4d data:4b
IC2_R: add:68 reg:04 len:08 data: 00 01 06 3f 07 00 00 07
4b: 00
4c: 01
// Read Reg: 0x4D - 0x50
IC2_W: add:68 reg:4d data:4d
IC2_R: add:68 reg:04 len:08 data: 01 06 3f 07 00 00 07 1a
4d: 01
4e: 06
4f: 3f
50: 07
// Read Reg: 0x51 & 0x52
IC2_W: add:68 reg:4d data:51
IC2_R: add:68 reg:04 len:08 data: 3f 07 00 00 07 1a ff 00
51: 3f
52: 07
Any thoughts on why the MAG data is only valid for 2 read cycles?
10-23-2019 01:02 PM
10-26-2019 03:26 PM
Hi o_o
I used my delay function to toggle a GPO & measure with a scope. My delay function was incorrect.
I corrected the delay function and confirmed the GPO toggle.
Tested the MAG output data again and I am getting this result: 1 measurements with sensible data, then no change.
What is interesting is that the ACC data is still responding as expected.
It seems that the issue is isolated to the BMM150 part of the BMX160 sensor only.
I wanted to check if there was some hidden info in the BMM150's register data to give a clue as to what if happening.
I read & print the BMM150 registers before every ACC & MAG data is read. What I saw does not make sense to me.
It appears that on the first read of MAG data no longer gives valid data.
Here are some of my observations from the BMM150 register printouts:
Just to check I am not misunderstanding, can the BMM150 registers be read at any time?
Just to ensure there isn't something weird with my setup, here is the I2C trace of my latest test setup
BMX160 init:
IC2_R: add:68 reg:00 len:01 data: d8
IC2_W: add:68 reg:7e data:b6
bmi160_init:0
IC2_R: add:68 reg:00 len:01 data: d8
chipID:d8
IC2_W: add:68 reg:7e data:19
IC2_R: add:68 reg:6b len:01 data: 00
IC2_W: add:68 reg:6b data:20
IC2_R: add:68 reg:4c len:01 data: 80
IC2_W: add:68 reg:4b data:20
IC2_W: add:68 reg:4c data:83
bmi160_aux_init:0
IC2_W: add:68 reg:4d data:4b
IC2_R: add:68 reg:04 len:08 data: 01 06 3f 07 00 00 07 1a
IC2_W: add:68 reg:4f data:01
IC2_W: add:68 reg:4e data:4b
IC2_W: add:68 reg:4d data:40
IC2_R: add:68 reg:04 len:08 data: 32 05 11 01 79 00 db ff
IC2_W: add:68 reg:4d data:5d
IC2_R: add:68 reg:04 len:08 data: 00 00 00 50 84 00 00 1e
IC2_W: add:68 reg:4d data:62
IC2_R: add:68 reg:04 len:08 data: 00 00 1e 1e 03 00 f2 02
IC2_W: add:68 reg:4d data:68
IC2_R: add:68 reg:04 len:08 data: f2 02 58 56 cd 1a 00 00
IC2_W: add:68 reg:4d data:70
IC2_R: add:68 reg:04 len:08 data: fd 1d ff ff ff ff ff ff
bmm150_init:0
IC2_W: add:68 reg:4d data:40
IC2_R: add:68 reg:04 len:08 data: 32 05 11 01 79 00 db ff
BmmID:32
IC2_R: add:68 reg:40 len:02 data: 28 03
IC2_W: add:68 reg:40 data:27
IC2_W: add:68 reg:41 data:05
IC2_R: add:68 reg:42 len:02 data: 28 00
IC2_W: add:68 reg:42 data:27
IC2_W: add:68 reg:43 data:04
IC2_R: add:68 reg:40 len:01 data: 27
IC2_W: add:68 reg:7e data:11
IC2_R: add:68 reg:02 len:01 data: 80
bmi160_set_sens_conf:0
IC2_W: add:68 reg:4d data:4c
IC2_R: add:68 reg:04 len:08 data: 06 3f 07 00 00 07 1a ff
IC2_W: add:68 reg:4f data:06
IC2_W: add:68 reg:4e data:4c
IC2_W: add:68 reg:4f data:07
IC2_W: add:68 reg:4e data:51
IC2_W: add:68 reg:4f data:1a
IC2_W: add:68 reg:4e data:52
bmm150_set_presetmode:0
IC2_W: add:68 reg:4d data:4c
IC2_R: add:68 reg:04 len:08 data: 06 3f 07 00 00 07 1a ff
IC2_W: add:68 reg:4f data:02
IC2_W: add:68 reg:4e data:4c
bmm150_set_op_mode:0
IC2_W: add:68 reg:4d data:42
IC2_R: add:68 reg:44 len:01 data: 0b
IC2_W: add:68 reg:44 data:07
IC2_R: add:68 reg:4c len:01 data: 83
IC2_W: add:68 reg:4b data:20
IC2_W: add:68 reg:4c data:03
bmi160_config_aux_mode:0
Here are the consequcitve BMM150 register reads ( followed by ACC & MAG data read)
Read #1(Power Control Bit=1, Self Test=1, Opmode=Normal):
BmmReg:
IC2_W: add:68 reg:4d data:4a
IC2_R: add:68 reg:04 len:08 data: 00 01 06 3f 07 00 00 07
4a: 00
IC2_W: add:68 reg:4d data:4b
IC2_R: add:68 reg:04 len:08 data: 01 06 3f 07 00 00 07 1a
4b: 01
IC2_W: add:68 reg:4d data:4c
IC2_R: add:68 reg:04 len:08 data: 01 06 3f 07 00 00 07 1a
4c: 01
IC2_W: add:68 reg:4d data:4d
IC2_R: add:68 reg:04 len:08 data: 3f 07 00 00 07 1a ff 00
4d: 3f
IC2_W: add:68 reg:4d data:4e
IC2_R: add:68 reg:04 len:08 data: 3f 07 00 00 07 1a ff 00
4e: 3f
IC2_W: add:68 reg:4d data:4f
IC2_R: add:68 reg:04 len:08 data: 00 00 07 1a ff 00 1f b4
4f: 00
IC2_W: add:68 reg:4d data:50
IC2_R: add:68 reg:04 len:08 data: 00 07 1a ff 00 1f b4 43
50: 00
IC2_W: add:68 reg:4d data:51
IC2_R: add:68 reg:04 len:08 data: 00 07 1a ff 00 1f b4 43
51: 00
IC2_W: add:68 reg:4d data:52
IC2_R: add:68 reg:04 len:08 data: 1a ff 00 1f b4 43 00 98
52: 1a
IC2_R: add:68 reg:12 len:06 data: 0f 1c 71 0f 00 fe
IC2_R: add:68 reg:04 len:08 data: 1a ff 00 1f b4 43 00 98
aX=-0.06,aY=0.48,aZ=-0.88 mX=-10.000000,mY=355.000000,mZ=2047.000000
Read #2(Power Control Bit=0, Self Test=0, Opmode=Sleep):
BmmReg:
IC2_W: add:68 reg:4d data:4a
IC2_R: add:68 reg:04 len:08 data: 00 01 06 3f 07 00 00 07
4a: 00
IC2_W: add:68 reg:4d data:4b
IC2_R: add:68 reg:04 len:08 data: 00 01 06 3f 07 00 00 07
4b: 00
IC2_W: add:68 reg:4d data:4c
IC2_R: add:68 reg:04 len:08 data: 06 3f 07 00 00 07 1a ff
4c: 06
IC2_W: add:68 reg:4d data:4d
IC2_R: add:68 reg:04 len:08 data: 3f 07 00 00 07 1a ff 00
4d: 3f
IC2_W: add:68 reg:4d data:4e
IC2_R: add:68 reg:04 len:08 data: 3f 07 00 00 07 1a ff 00
4e: 3f
IC2_W: add:68 reg:4d data:4f
IC2_R: add:68 reg:04 len:08 data: 00 00 07 1a ff 00 1f b4
4f: 00
IC2_W: add:68 reg:4d data:50
IC2_R: add:68 reg:04 len:08 data: 00 00 07 1a ff 00 1f b4
50: 00
IC2_W: add:68 reg:4d data:51
IC2_R: add:68 reg:04 len:08 data: 07 1a ff 00 1f b4 43 00
51: 07
IC2_W: add:68 reg:4d data:52
IC2_R: add:68 reg:04 len:08 data: 1a ff 00 1f b4 43 00 98
52: 1a
IC2_R: add:68 reg:12 len:06 data: 1b 1c 81 0f 03 fe
IC2_R: add:68 reg:04 len:08 data: 1a ff 00 1f b4 43 00 98
aX=-0.06,aY=0.48,aZ=-0.88 mX=-10.000000,mY=355.000000,mZ=2047.000000
Read #3(Power Control Bit=0, Self Test=0, Opmode=Normal):
BmmReg:
IC2_W: add:68 reg:4d data:4a
IC2_R: add:68 reg:04 len:08 data: 00 01 06 3f 07 00 00 07
4a: 00
IC2_W: add:68 reg:4d data:4b
IC2_R: add:68 reg:04 len:08 data: 00 01 06 3f 07 00 00 07
4b: 00
IC2_W: add:68 reg:4d data:4c
IC2_R: add:68 reg:04 len:08 data: 06 3f 07 00 00 07 1a ff
4c: 06
IC2_W: add:68 reg:4d data:4d
IC2_R: add:68 reg:04 len:08 data: 06 3f 07 00 00 07 1a ff
4d: 06
IC2_W: add:68 reg:4d data:4e
IC2_R: add:68 reg:04 len:08 data: 07 00 00 07 1a ff 00 1f
4e: 07
IC2_W: add:68 reg:4d data:4f
IC2_R: add:68 reg:04 len:08 data: 00 00 07 1a ff 00 1f b4
4f: 00
IC2_W: add:68 reg:4d data:50
IC2_R: add:68 reg:04 len:08 data: 00 00 07 1a ff 00 1f b4
50: 00
IC2_W: add:68 reg:4d data:51
IC2_R: add:68 reg:04 len:08 data: 07 1a ff 00 1f b4 43 00
51: 07
IC2_W: add:68 reg:4d data:52
IC2_R: add:68 reg:04 len:08 data: 1a ff 00 1f b4 43 00 98
52: 1a
IC2_R: add:68 reg:12 len:06 data: 17 1c 7d 0f 0b fe
IC2_R: add:68 reg:04 len:08 data: 1a ff 00 1f b4 43 00 98
aX=-0.06,aY=0.48,aZ=-0.88 mX=-10.000000,mY=355.000000,mZ=2047.000000
I have attached a text file (BMM150_Register_Traces.h) that contains the Setup & BMM150 register traces of multiple consecutive reads.
Each read is done at approx. 1second intervals (no intermediate reads eventhough output rate is set to 50Hz).
I ran the test code on 2 different PCB's to eliminate the posibility of a hardware fault.
Both boards give the same type of result (BMM150 registers changing between reads).
Is there a posibility of a hardware failure on both boards?
Is there other information I can provide that will give more insight?
10-26-2019 06:52 PM - edited 10-26-2019 06:52 PM
Hi o_o & handytech
I have found the final issue and MAG data is being read successfully.
In a nutshell: Don't read the BMM150 registers unless you are setting up the BMX160 sensor
In an attempt to find out if my compiler/project could be causing the issue, I ported the basic init & read code to a C project.
This project worked & gave reliable ACC & MAG data.
I think put the BMM150 register printout in the C project as well and then the MAG data being gave bogus values.
Going back to my C++ project, I removed the BMM150 register read function & was able to read reliable MAG data.
What other factors contributed to the resolution of this issue (please see earlier posts from o_o & handytech):
Thanks for all your help in resolving this issue.
I really appreciate your inputs.