MPL3115A2 with FXLC95000

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

MPL3115A2 with FXLC95000

Jump to solution
7,379 Views
vitaliysiplichu
Contributor III

Hi!
I am a beginner with Freescale platform but I need to implement some new fitures in our device. So I need help. Now I have FXLC95000 as a hub and two sensors: internal accelerometr and external MAG3110. I use Intelligent Sensing Framework v1.1. There are additional libs with sensor adapters for MAG3110 and internal accelerometr. But now I need to implement new sensor MPL3115A2. But I can't find Digital Sensor Abstraction Adapter for MPL3115. What should I do? Does anyone have source code of this adapter?

Labels (1)
0 Kudos
Reply
1 Solution
6,060 Views
margaretnadworn
NXP Employee
NXP Employee

Vitaliy,  you are correct.  My apologies.  Training Module 7 is attached.  It isn't polished and so it never got posted to the web site.  Please understand that  there may be errors and it should be used at your own risk.  You will need Module 6 to add your new sensor adapter.  It is still valuable to look at the MAG3110 sensor adapter as an example.  

    The sensor adapter for the FXAS21000C is similar but not correct for the FXAS21002C.  You should start with the FXAS21000C sensor adapter to make one for the FXAS21002C.    We have an unpublished sensor adapter for the FXAS21002C that is also attached.    

    Finally, an unpublished version of a sensor adapter for the MPL3115 is attached.   No guarantees if either of these work but it will be a starting point for you.

View solution in original post

0 Kudos
Reply
18 Replies
6,060 Views
margaretnadworn
NXP Employee
NXP Employee

Hi, Vitaliy,    First the bad news - The sensor adapter for the MPL3115A2 was not produced for the FXLC95000.   Now the good news -   you could write your own sensor adapter for the MPL3115A2 and ISF 1.1 for the FXLC95000.  Training Module number 6 on the ISF 1.1 Training Tab can be used to show  the steps required to write your own sensor adapter for it.  The steps would be similar but instead of adding the magnetometer, you add the MPL3115A2 instead.      You can also use the other sensor adapters for the FXLC95000 as examples.  

      In addition, there is a sensor adapter for the MPL3115 for the Kinetis devices.  You would need to download the ISF 2.1 for Kinetis and the ISF 2.1 PEupd file to look at it.    The source code for that sensor adapter is provided.   The APIs are different and it is set up as a Processor Expert component, but you may be able to distinguish between the two APIs to capture the key features of the MPL3115A2 sensor adapter. 

      If you create one, please post to the community page to share with others.

6,060 Views
vitaliysiplichu
Contributor III

Hello, Margaret!
I hope you can help me. You gave me sensor adapter for MPL3115 and it works perfectly. But I have some questions. In example project for MPL3115 we have next settings:

mpl3115AppState.CfgBuffer.ctrlReg.reg = STATE_STOPPED_UNSUBSCRIBED;

mpl3115AppState.CfgBuffer.settings.nSettingsToUse = SM_GIVEN_SETTINGS;;

mpl3115AppState.CfgBuffer.settings.nFifoDepth = 1;

mpl3115AppState.CfgBuffer.settings.nCurrentReportRate = FSL_MPL3115_PRESS_1HZ;

I try to read it and I have next datas:

Miliseconds                 Pressure   Alt         Temperature

[00012210] Altimeter: 100195      94.8      22.7

[00013211] Altimeter: 100250      89.13    22.11

[00014213] Altimeter: 100212      93.1      22.8

[00015213] Altimeter: 100218      92.9      22.9

[00016208] Altimeter: 100209      93.5      22.9

[00017208] Altimeter: 100178      95.15    22.6

[00018209] Altimeter: 100215      92.13    22.9

[00019210] Altimeter: 100211      93.2      22.8

[00020211] Altimeter: 100200      94.1      22.9

As you can see I have different pressure and altitude every second from 89.13 to 94.8 meters.
Next day I try to read it and I have datas:

Miliseconds                 Pressure   Alt         Temperature

[00038198] Altimeter: 100082     103.15   25.12

[00039198] Altimeter: 100124     100.7     25.14

[00040198] Altimeter: 100038     107.10   25.9

[00041200] Altimeter: 100076     104.8     25.11

[00042200] Altimeter: 100037     107.12   25.8

[00043198] Altimeter: 100015     109.9     25.8

[00044198] Altimeter: 100052     106.7     25.10

[00045198] Altimeter: 100068     105.2     25.11


So IN THE SAME PLACE I have different datas of pressure and altitude: 89.13 to 94.8 meters -  first day, 100.7 to 109.9 meters - second day. But the real altitude is something about 60 meters. It is 30-45 meters less than I can read from MPL3115!!!
Here are my questions:
1. Can I change nCurrentReportRate from 1Hz to 10Hz for example? How to do it?
2. In the file fsl_mpl3115_i2c_1D_press_config_types.h I can see the stucture with settings:

uint8 oversampleRatio; //Oversample Ratio = 2^OS (e.g., 0 = 1, 1 = 2, 2 = 4, ... 7=128).

uint8 rawMode;         //0 = Normal output; 1 = Raw data with no post ADC processing.

uint8 altBaroMode;     //0 = Barometer mode; 1 = Altimeter mode.

uint8 autoAcqTimeStep; //Auto acquisition time step = 2^ST (range of 1 second to 9.1 hours).

uint8 alarmSelect;     //0 = Use absolute pressure-temperature targets; 1 = Use pressure-temperature windows and thresholds.


What does it mean? Can I use it to make datas more stable?
3. How to make datas more stable? Should I use my own low pass filter?

0 Kudos
Reply
6,060 Views
jimmcglasson
Contributor III

Vitaliy,

You are likely seeing typical barometric changes due to weather conditions in your area.

The MPL3115 is very sensitive and will see pressure changes due to doors being opened and closed, HVAC operations, and changes due to weather conditions.

In the datasheet you’ll find that the fastest ODR the MPL3115 can be programmed to provide is 1Hz but the oversampling ratio can be set as high as 128 at this ODR

giving it an internal sampling rate of 128Hz. (This is governed by the autoAcqTimeStep and oversampleRatio you quote below)

Although the MPL3115 can also be used in one shot mode where it can be externally triggered to take a sample on command allowing an effective ODR faster than 1 Hz, one-shot mode is not supported by the version of the sensor adapter you are using. (It is supported by ISF 2.1 on Kinetis)

Atmospheric pressure changes relatively slowly so the need for pressure ODRs faster than 1Hz is rare.

In fact we find that a low pass filter with a time constant of about 5.0 seconds is nice for post-processing the 1 Hz pressure data.

I’d recommend 128 times oversampling at 1Hz ODR and then running through a 5sec low-pass filter.

-Jim

6,060 Views
vitaliysiplichu
Contributor III

Margaret, thanks for your answer! But I still have some questions.
You say:
" you could write your own sensor adapter for the MPL3115A2 and ISF 1.1 for the FXLC95000.  Training Module number 6 on the ISF 1.1 Training Tab can be used to show  the steps required to write your own sensor adapter for it."
But in Module 6 I can find only Adding the existing sensor adapter for mag3110. And I found next:
"The creation of a sensor adapter is the subject of Module 7 of the training."

So, where is Module 7 ? I can't find it!

And one more thing. Can I use sensor adapter (fsl_fxas21000_i2cspi_3D_gyro_config_types.h) with fxas21002 in real device? Do I need to cange something except Device address for I2C?

0 Kudos
Reply
6,061 Views
margaretnadworn
NXP Employee
NXP Employee

Vitaliy,  you are correct.  My apologies.  Training Module 7 is attached.  It isn't polished and so it never got posted to the web site.  Please understand that  there may be errors and it should be used at your own risk.  You will need Module 6 to add your new sensor adapter.  It is still valuable to look at the MAG3110 sensor adapter as an example.  

    The sensor adapter for the FXAS21000C is similar but not correct for the FXAS21002C.  You should start with the FXAS21000C sensor adapter to make one for the FXAS21002C.    We have an unpublished sensor adapter for the FXAS21002C that is also attached.    

    Finally, an unpublished version of a sensor adapter for the MPL3115 is attached.   No guarantees if either of these work but it will be a starting point for you.

0 Kudos
Reply
6,060 Views
vitaliysiplichu
Contributor III

Hello!

Here is my problem with FXAS21002. I want to use gyroscope with FXLC95000. I have sensor adapter for FXAS21002 and everything should be ok! But gyroscope doesn't answer! Other sensors on this I2C works perfectly. Using logic analyzer I noticed that FXLC95000 in the begining try to ask gyroscope (with address 0x40) but get NACK and doesn't ask him anymore. Is it right behavior and what does it mean? Schematic and screenshot of logic analyzer in attachment.
What can be wrong and how to make it works? !

P.S. I removed R14 on Reset pin. So the problem is not here. Where is FXAS21002 in the real device (not FXAS21000 as shown on schematic).

0 Kudos
Reply
6,060 Views
jimmcglasson
Contributor III

I believe FXAS21002 I2C addresses are either 0x20 or 0x21 depending on configuration. Verify that your entry in isf_sensor_configuration.c

looks like:

{&fsl_fxas21000_i2cspi_3D_gyro_adapter, NULL, &fxas21000SpecificSettings, I2C_MASTER1, 0x21 }

-Jim

0 Kudos
Reply
6,060 Views
vitaliysiplichu
Contributor III

Hi, James!

This is my settings:

{&fsl_fxas21000_i2cspi_3D_gyro_adapter,    NULL, &fxas21000SpecificSettings,  I2C_MASTER1,  0x20}

I use address 0x20 because SA0=0 in my schematic. So everything should be ok!

I attached logic analyzer log file. There are four sensors: MPL3115(with addresses 0xC0 0xC1), MAG3110(with addresses 0x1C 0x1D), FXMS3110(with addresses 0x1E 0x1F), and FXAS21002(with addresses 0x40 0x41).
As you can see FXLC95000 in the begining try to write address 0x40, gets NACK and doesn't ask this address anymore. As I understand my gyro FXAS21002 doesn't work!

Could it be because of I2C speed? I use 400KHz. Maybe I shoud try 100KHz? How to do it? In the file isf_sysconf_comms.c I can see next enum for I2C speed:

enum i2c_Speed{

    I2C_SPEED_START = 0,                 /*!< The start of the speed range.  */

    I2C_SPEED_600_KHZ = I2C_SPEED_START, /*!< The speed at 600 KHz.  */

    I2C_SPEED_400_KHZ = 1,               /*!< The speed at 400 KHz.  */

    I2C_SPEED_200_KHZ = 2,               /*!< The speed at 200 KHz.  */

    I2C_SPEED_END = 3                    /*!< The end of the speed range. It is 200 KHz now. */

};

But there is no 100KHz! How to enable this speed?

0 Kudos
Reply
6,060 Views
jimmcglasson
Contributor III

Vitaliy,

I looked at your logic trace.

Although you say, "I use address 0x20 because SA0=0 in my schematic. So everything should be ok!"

Your trace shows you using 0x40  not 0x20.  So that's the first thing.

Second, you should continue to use 400Khz I2C bus frequency.  There is no  reason to drop to 100 with just 4 sensors on the bus.

Once you are talking to FXAS21002 at 0x20 I think you will have a problem with the current adapter software because it was designed for FXAS21000 which has a different WHO_AM_I value.  FXAS21000 - D1,  FXAS21002 - D7.  During initialization the adapter reads the WHO_AM_I to verify it's talking to the expected sensor and will fail if it gets back the wrong value.

The sensor adapter provided with ISF1P195K was built before the 21002 was released and does not support a WHO_AM_I value of D7

So Initialization will fail.  We'll need to get you some updated adapter code that properly recognizes both D1 and D7.

To answer your other question- yes. we only try once.  There isn't really a reason that a sensor would fail to respond one time but would respond successfully the next.

-Jim

0 Kudos
Reply
6,060 Views
vitaliysiplichu
Contributor III

Hello!
I can't fix my problem with gyroscope. That is a huge problem!
So I decided to summarize the information:

Picture of schematic is in attachments. Only one detail: where is FXAS21002 instead FXAS21000.

I have several sensors on I2C bus. They all works perfectly except gyroscope.

I use FXAS21002C sensor adapter that Margaret Nadworny gave to me.
Settings of my sensor adapter:
{&fsl_fxas21002_i2cspi_3D_gyro_adapter,    NULL, &fxas21002SpecificSettings,  I2C_MASTER1,  0x20}

I use address 0x20 because SA0=0 in my schematic(connected to GND).

James, you wrote to me:
"Your trace shows you using 0x40  not 0x20"

If you look at FXAS21002.pdf, Table 10, page 15 you will see that Device address 0x20 - Address Byte Transmitted by Master 0x40 in that case. So I'm sure that everything is OK with address.

You wrote to me:
"Once you are talking to FXAS21002 at 0x20 I think you will have a problem with the current adapter software because it was designed for FXAS21000 which has a different WHO_AM_I value.  FXAS21000 - D1,  FXAS21002 - D7.  During initialization the adapter reads the WHO_AM_I to verify it's talking to the expected sensor and will fail if it gets back the wrong value."

But if you look at logic analyzer data you will see that FXLC95000 doesn't even try to ask WHO_AM_I answer because it gets NACK for first Write 0x40 command and doesn't do anything with gyroscope anymore.

Maybe where are some delays to start gyroscope or some starting procedures or commands sequences?

I'm desperate...

0 Kudos
Reply
6,060 Views
aswins
NXP Employee
NXP Employee

Hi Vitaliy,

                     I am an Apps Engineer from Freescale. Can you pls contact me @aswin.sivakumar@freescale.com to discuss this problem in detail over mail/phone?

Thanks

Aswin

0 Kudos
Reply
6,060 Views
vitaliysiplichu
Contributor III

Hello, Margaret!
I'm trying to compile project MPL3115_release_compass that you gave me. But I have errors. Because where is no file "fsl_mpl3115_i2c_1D_press_config_types.h".
Where can I find it? Can you help me?

0 Kudos
Reply
6,060 Views
margaretnadworn
NXP Employee
NXP Employee

Vitaliy,

I’ve sent email out to reinforcements – let me get back to you.

Regards,

Margaret

0 Kudos
Reply
6,060 Views
vitaliysiplichu
Contributor III

Margaret, sorry. But I'm not sure that I understood your last email. :smileysad:
Like I said I have recieved MPL3115_release_compass.zip from you. But there is no fsl_mpl3115_i2c_1D_press_config_types.h

Have you that file?
Sorry for my English. It's not perfect. :smileyhappy:

0 Kudos
Reply
6,060 Views
margaretnadworn
NXP Employee
NXP Employee

Hi, Vitaliy,

No problem with your English. Please do not apologize.

If the file wasn’t in the project I sent you, then I didn’t have it either.

My earlier email meant that I had to ask people for help. The writer of the MPL3115 sensor adapter is in China so we have to wait overnight to get a response. I just wanted you to know that I saw your request and was working on it.

However, in the meantime, I have located the corresponding file for what is thought to be the Kinetis sensor adapter.

You could try it and see if it compiles.

The recommendation would be to compare the analogous files for the MAG3110 on FXLC95000 and Kinetis and see how they differ between the two MCUs. You could then make those similar accommodations for the file that is attached.

Please let me know how you make out.

Margaret

0 Kudos
Reply
6,060 Views
vitaliysiplichu
Contributor III

Hello, Margaret!


Thanks for your sensor adapter of mpl3115. It seems to me that everything works.
But I have another question. I want to use two magnetometers in my device mag3110 and fxms3110. As I know they are the same. Difference is only in address.
I have sensor adapter for mag3110 and I haven't for fxms3110.
Can you help me with that problem? Can you give me sensor adapter for fxms3110?

0 Kudos
Reply
6,060 Views
jimmcglasson
Contributor III

Vitaliy,

Since they are the same except for the slave address you can use the same adapter.

I assume you are still doing all this on the FXLC95000.

All you need to do is configure the second sensor.

This is done in isf_sensor_configuration.c by adding a new line for the new sensor in the gSensorList[] array:

SensorConfig_t gSensorList[DSA_NUM_SUPPORTED_SENSORS] =

{ // sm_DsaAdapter_t, *pSensorHandle, *pSensorSpecificSettings, device channel, dev address

{&fsl_mag3110_i2c_3D_mag_adapter, NULL, &mag3110SpecificSettings, I2C_MASTER1, 0x0E },

{&fsl_mag3110_i2c_3D_mag_adapter, NULL, &mag3110SpecificSettings, I2C_MASTER1, 0x0F},

};

Then in isf_sensor_configuration.h add an new enum for the new sensor:

typedef enum Sensor_sensors_en

{

DSA_FSL_3D_MAGNETOMETER,

THE_NEW_FXMS3110_MAG,

DSA_NUM_SUPPORTED_SENSORS

} SensorId_t;

You should then be able to subscribe to the new sensor.

let us know how it works for you.

-Jim

6,060 Views
vitaliysiplichu
Contributor III

Thanks! It works for me!

0 Kudos
Reply