1
\$\begingroup\$

Requirement: Need to use only accelerometer in LSM6DS3 at 104 Hz in 2g full-scale mode and FIFO in Continuous mode. Interrupt should be generated every 320 msec.

Understanding: For every 1 sec there are 104 samples (104 "X" samples, 104 "Y" samples and 104 "Z" samples, 2 bytes each) i.e. 624 bytes per second. So to generate interrupt at 320 msec, I need to set FIFO threshold as 210 bytes. INT1 pin is configured as interrupt. I2C protocol is used.

Register Settings:

CTRL1_XL = 0x10; //operating at 2g mode and ODR is 104Hz
CTRL3_C = 0x64; // BDU=1,H_LACTIVE=1,IF_INC=1
CTRL4_C = 0x29 //STOP_ON_FTH =1 and INT2_on_INT1=1 and SLEEP_G=1
CTRL6_C = 0x10 //XL_HM_MODE =1 
MASTER_CONFIG = 0x80 //DRDY_ON_INT1=1
INT1_CTRL = 0x08
FIFO_CTRL1 =210 bytes as threslod 
FIFO_CTRL5 = 0x23 //FIFO ODR is set to 104 Hz and FIFO Continuous mode selected

Problem: No interrupt is generated.

Please let me know if anything is missing or anything needs to be added/modified. Any help greatly appreciated.

\$\endgroup\$
  • \$\begingroup\$ Note for other readers here: I just noticed that the same question was asked on the ST forums here: community.st.com/thread/… where it is already getting answers. So to avoid duplicated effort, it may be worth checking that link for updates. \$\endgroup\$ – SamGibson Feb 28 '18 at 17:31
  • \$\begingroup\$ Note for other readers: This question is related to later questions: "LSM6DS3 Interruput"; "LSM6DS3 TIMINGS"; "ODR and FIFO in LSM6DS3". \$\endgroup\$ – SamGibson Mar 2 '18 at 17:49
1
\$\begingroup\$

Background

Following normal troubleshooting procedure, in the absence of other data (e.g. using some of the device's status registers will give useful information) I formed some hypotheses for possible causes, checked those possible causes in the ST LSM6DS3 datasheet and some example code (see below) and found a problem. (There could still be more problems - troubleshooting is often iterative - but you need to fix this one.)

You are missing an initialisation setting - see below.

Without that setting, the accelerometer will not put any readings into the FIFO. In that case, as you have seen, the FIFO threshold interrupt cannot be triggered, since the FIFO is not being filled with readings and so it can never reach its threshold value.

Instead of doing all the work to decide how I would initialise the device, I reviewed an existing library from SparkFun, which also initialises the FIFO, as you want to do (some existing libraries ignore the FIFO). The main C++ course file is here:

https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library/blob/master/src/SparkFunLSM6DS3.cpp

Based on my review of the device datasheet, application note, and comparing that library's initialisation code to yours, I found the missing setting below which explains your symptom of "no FIFO interrupt".

Fix

Register FIFO_CTRL3 and/or FIFO_CTRL4 needs to be set to a non-zero value.

This is explained in Application Note AN4650 on the LSM6DS3 where it says on page 90:

It’s required to set at least one of the four decimation factors to 1 (no decimation).

Since neither of those are in your list of initialised registers, they will both be at the default value of zero meaning that no readings (gyroscope or accelerometer) are being put into the FIFO.

I expect that you will want to set FIFO_CTRL3 to 0b00000001 (i.e. DEC_FIFO_XL0 = 1).

Details of FIFO_CTRL3 register from ST App Note AN4650

If you still have problems, do more comparisons with the SparkFun code (I have stopped at the first problem I found) and use the device status registers to find out what is happening to the device in more detail, regarding any new problem you find.

\$\endgroup\$
  • \$\begingroup\$ Thank you for the response Pleae find the updated settings. CTRL9_XL = 0x38; CTRL1_XL = 0x40; //104Hz CTRL3_C = 0x64; //BDU=1 and H_LACTIVE =1 and IF_INC =1 auto incremented CTRL4_C = 0x01; //STOP_ON_FTH CTRL6_C = 0x10; //XL_HM_MODE=1 MASTER_CONFIG = 0x80; INT1_CTRL = 0x08; //INT1_FTH FIFO_CTRL1 = 228; //Bytes FIFO_CTRL2 = 0x00; FIFO_CTRL3 = 0x01; //Decimation FIFO_CTRL5 = 0x36; //FIFO Continuous mode and reading the FIFO @416Hz (FIFO ODR = 416Hz) \$\endgroup\$ – Ganesh Feb 28 '18 at 15:07
  • \$\begingroup\$ While setting CTRL1_XL do I need to consider BW_XL1 and BW_XL0 ?Because am not using any filters in my applicaiton I need to get Raw values of X,Y,Z. For the above settings am getting interrupt for every 315 msec and am not able to read the full data from the registers.Please find the details. CTRL3_C:when I set IF_INC =1 ,Register address automatically incremented(pg no 56 in data sheet) . \$\endgroup\$ – Ganesh Feb 28 '18 at 15:10
  • \$\begingroup\$ So when ever I do register read is it sufficient to read only OUTX_L_XL or do I need to read all the register?(Since we already set IF_INC bit) Currently am reading the register OUTX_L_XL, When ever interrupt comes,that time am reading that register OUTX_L_XL,once I read, am checking again FIFO_STATUS1 and FIFO_STATUS2 that time also am getting 128 bytes as unread samples(it should become zero?). I tried the same by changing FIFO_CTRL1 vales FIFO_CTRL1->no of unread samples after reading the reg OUTX_L_XL 102bytes->65bytes 228bytes->128bytes 216bytes->122bytes \$\endgroup\$ – Ganesh Feb 28 '18 at 15:14
  • \$\begingroup\$ Why it is happeing like that?Did I missed anything? Regarding interrupt No of byte for every 1sec is follows 1Sec = 104 samples (104 X,104 Y,104Z of each 2 bytes) = (104*2) + (104*2) + (104*2) = 624 bytes. 1000msec = 624bytes 1msec = 0.624bytes So,for 228 bytes 365 msec Regrding interrupt if I set 228 bytes as thresold,I should get interrupt for every 365 msec. but am getting interrupt for every 316 or 315 msec.Is there any error in calculations? \$\endgroup\$ – Ganesh Feb 28 '18 at 15:16
  • \$\begingroup\$ @Ganesh - Hi, "am getting interrupt" Good, so I have solved the problem you originally described i.e. "No interrupt is generated". You are new to Stack Exchange, so I recommend that you read the site tour. That explains that this is not a discussion forum - you can think of it as "one question per post". You seem to now be asking (at least) 3 new questions about BW_XL1 and BW_XL0; use of OUTX_L_XL; the timing calculation 365msec / 315msec. Those weren't the original problem statement and so they shouldn't be asked in comments here. \$\endgroup\$ – SamGibson Feb 28 '18 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.