MPL3115A2 delta values?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPL3115A2 delta values?

Jump to solution
2,190 Views
paolog
Contributor III

My embedded application is communicating correclty with the MPL5115A2 on board. I want to add reading of delta values of altitude, but I obtain the same values of data out (i.e. the absolute altitude). Sensor is initialized as altimeter, 8 oversampling.

To read values I read 10 bytes from the sensor, starting from address 0, but registers OUT_P_DELTA_MSB and OUT_P_DELTA_CSB contain the same values of OUT_P_MSB and OUT_P_CSB. In order to read delta values should I set a different configuration? Shouldn't I just read adifference from the previously read values of altitude?

Labels (1)
0 Kudos
1 Solution
1,723 Views
darioarias
NXP Employee
NXP Employee

Hi Paolo,

I've been tracking this question since the beginning because it  interested me, and I think I can provide you an answer on the reason that you are not able to read the 10  bytes at once.

You should refer to the datasheet for the MPL3115A2 on the Table 11. Register address map: Area A (F_Mode = 0, FIFO disabled). In this table you will find a column that says Auto-increment address, where it says for each address, which the next address going to be (in auto-increment mode). Basically when you reach the 05h its corresponding auto-increment address is the 00h, this is because the address 00h and 06h refer to same register which is DR_STATUS, so the process is repeated and then you´ll get the same values output twice, when you expected to have output values and delta values.

Best regards,

Dario

View solution in original post

8 Replies
1,723 Views
david_diaz
NXP Employee
NXP Employee

Hello,

Thank you for writing.

In this case, I would like to recommend the sample project from the link below as a reference for your project. I made some exercises, and the DELTA registers are not the same of the DATA registers in Altimeter mode with the code mentioned.

Please note the device initialization.

MPL3115A2 - Bare metal example project

 

In case you still have the same issues, please let me know.

Regards,

David

1,723 Views
paolog
Contributor III

Hi David.

I looked at the project and checked the differences. Major one is that in my project sensor is generally in stand-by, set to active only when needed.

Checking the documentation seems like that the transition active->stand-by resets the previous reading, and therefore the delta values have the same value of the last reading. Is this the reason? In this case I have to abandon the idea to use the delta values feature.

Regards,

Paolo

0 Kudos
1,723 Views
david_diaz
NXP Employee
NXP Employee

Hello again Paolog,

Thank you for writing.

I did check what you said about the data being reset, I made many exercises where I would place the sensor in standby mode after retrieving the acquired data, then read data again to see if it changed or resets, however, what I found is that the data still the same. A this point I I’d like to ask you to please send us your initialization code, to try it ourselves and see if we can provide you with a resolution or the proper feedback.

Regards,

David

0 Kudos
1,723 Views
paolog
Contributor III

Thank you, David: this is what we do.

Macros are defined as:

STATUS_00_REG: 0x00

CTRL_REG1: 0x26

CTRL_REG2: 0x27

CTRL_REG3: 0x28

CTRL_REG4: 0x29

CTRL_REG5: 0x2A

PT_DATA_CFG_REG: 0x13

PDR_BIT: 0x04

REG1_SET_STANDBY: (ALT_BIT | OS2_BIT | OS0_BIT) or (0x80 | 0x20 | 0x08)

REG1_SET_OST: (ALT_BIT | OS2_BIT | OS0_BIT | OST_BIT) or (0x80 | 0x20 | 0x08 | 0x02)

CLEAR_CTRLREG2: 0x00

INT_EN_CLEAR: 0x00

INT_CFG_CLEAR: 0x00

PDEFE_BIT: 0x02

SlaveAddressIC is 0x60

Init in altitude mode (sensor should be in standby after this, 32 oversampling):

IIC_RegWrite(SlaveAddressIC, CTRL_REG1, REG1_SET_STANDBY);

IIC_RegWrite(SlaveAddressIC, CTRL_REG2, CLEAR_CTRLREG2);

IIC_RegWrite(SlaveAddressIC, CTRL_REG3, 0x00);

IIC_RegWrite(SlaveAddressIC, CTRL_REG4, INT_EN_CLEAR);

IIC_RegWrite(SlaveAddressIC, CTRL_REG5, INT_CFG_CLEAR);

IIC_RegWrite(SlaveAddressIC, PT_DATA_CFG_REG, PDEFE_BIT); // This should be 0x00, I think...

Read sensor (done once necessary, no faster than every 250 ms):

// Set active, one shot mode

IIC_RegWrite(SlaveAddressIC, CTRL_REG1, REG1_SET_OST);

do

    // Read 5 bytes

    IICReadRegN(SlaveAddressIC, STATUS_00_REG, 5, (unsigned char *)MyBuffer);

while (!(MyBuffer[0] & PDR_BIT));

MyBuffer elements are then used to calculate values. To get delta values we read 10 bytes instead of 5.

If we look at the content of the buffer, values of deltas are the same of sensor readings.

Thank you for looking at this!

Paolo

0 Kudos
1,723 Views
david_diaz
NXP Employee
NXP Employee

Hello,

Thank you for writing and for sharing your code with us.

This time I used your initialization and main function code to reproduce the error that you are getting, I did many tests and every time, I had a different value in the Delta register and Output registers. For example, 1576.19m in the output register, and 0.5625m in delta register, even after resetting the sensor, because the previous reading will remain in there. So, there are only three scenarios where you can have delta values equal to output values.

  •      The first reading is twice the second reading
  •      The second reading is perform at the sea level
  •      The RAW mode is active (which is not)

At this point I would highly recommend you to check with a different part because yours might be damaged. I’ll be sharing with you the project where I try your code so you can take a look.

Hope this was helpful

Regards,

David

0 Kudos
1,723 Views
paolog
Contributor III

Hi David, thank you for trying our code.

Well, I saw some differences (like setting the active bit with the OST bit before reading and then clearing it), but to make a long story short this is what I found out.

If I read 10 bytes with IICReadRegN to get altitude values and delta values in a single function call, I get the same values for altitude and delta.

If I make two separate calls to IICReadRegN reading altitude values first and delta values next, I get correct results.

Ain't this weird?

Best regards,

Paolo

0 Kudos
1,724 Views
darioarias
NXP Employee
NXP Employee

Hi Paolo,

I've been tracking this question since the beginning because it  interested me, and I think I can provide you an answer on the reason that you are not able to read the 10  bytes at once.

You should refer to the datasheet for the MPL3115A2 on the Table 11. Register address map: Area A (F_Mode = 0, FIFO disabled). In this table you will find a column that says Auto-increment address, where it says for each address, which the next address going to be (in auto-increment mode). Basically when you reach the 05h its corresponding auto-increment address is the 00h, this is because the address 00h and 06h refer to same register which is DR_STATUS, so the process is repeated and then you´ll get the same values output twice, when you expected to have output values and delta values.

Best regards,

Dario

1,723 Views
paolog
Contributor III

Thank you, Dario. I misread the datasheet and I thought the auto-increment was for the FIFO operation only. As it's a feature I'm not using I didn't read it carefully.

Well, this explains everything! Thank you for the explanation.

Best regards,

Paolo

0 Kudos