cancel
Showing results for 
Search instead for 
Did you mean: 

IIS328DQ Interrupt

Wenwei Qiao
Associate
Posted on April 26, 2017 at 21:12

Hi, I am using 

IIS328DQ in a new design. I want to set up an interrupt when the orientation is tilted away from Z-axis. So I set up INT1 as XHIE, XLIE, YHIE and YLIE. ZHIE and ZLIE are disabled.

Here is the setup sequence according an AppNote:

1. write CTRL_REG1

2. write CTRL_REG2

3. write CTRL_REG3

4. write CTRL_REG4

5. write Reference

6. write INT1_THS

7. write INT1_DUR

8. write INT2_THS

9. write INT2_DUR

10. read HP_FILTER_RESET (if filter is enabled)

11. write INT1_CFG

12. write INT2_CFG

13. write CTRL_REG5

here is the reading of the sensor and all the registers:

AX -0.039

AY -0.063

AZ 0.965

WHO_AM_I : 0x32

CTRL_REG1 : 0x27

CTRL_REG2 : 0x08

CTRL_REG3 : 0xC0

CTRL_REG4 : 0x30

CTRL_REG5 : 0x00

HP_FLT_RST: 0x00

REFERENCE : 0x00

STATUS_REG: 0x00

OUT_X_L : 0x60

OUT_X_H : 0xFF

OUT_Y_L : 0x00

OUT_Y_H : 0xFF

OUT_Z_L : 0x70

OUT_Z_H : 0x0F

INT1_CFG : 0x0F

INT1_SRC : 0x6A

INT1_THS : 0x01

INT1_DUR : 0x32

INT2_CFG : 0x7F

INT2_SRC : 0x00

INT2_THS : 0x0F

INT2_DUR : 0x01

The problem is that, even though INT1_CFG=0x0F (ZHIE=0, ZLIE=0, YHIE=1, YLIE=1, XHIE=1, XLIE=1), the INT1_SRC shows 0x6A where ZH=1.

How can I solve this problem?

Thanks for help in advance.

-wwqiao

#iis328dq #interrupt
2 REPLIES 2
Miroslav BATEK
ST Employee
Posted on April 28, 2017 at 16:23

  • The register INT1_CFG defines which condition will trigger the interrupt

  • Nevertheless the conditions are evaluated for all axis, so even if it is not selected in INT1_CFG you can see the result in INT1_SRC

  • To detect the orientation is tilted away from Z-axis you should set only XHIE and YHIE (INT1_CFG = 0x0A). If you enable both condition (higher, lower) it will be always true and the interrupt will be always triggered. Please be aware absolute value of acceleration in each axis is evaluated.

  • Your setting of the threshold INT1_THS is very low, I would recommend to increase the value for example to 0x10. The exact value depends how sensitive it should be and which Full Scale you use.
Posted on May 05, 2017 at 19:33

Hello Miroslav:

Thanks for reply and suggestion. But I am still confused a little.

We use the chip for an embedded system that sits in the mobile carrier in an industrial tool. We basically needs three functions:

(1) knowing exact orientations of the carrier.

(2) generating an interrupt when the carrier is tilted away from Z-axis.

(3) generating an interrupt when a shock happens.

The chip is configured as:

CTRL_REG1 : 0x27   (PM=001 (ODR Normal), DR=00 (50/37Hz), Zen=1, Yen=1, Xen=1)

CTRL_REG2 : 0x08   (BOOT=0, HPM=00 (normal), FDS=0 (HP Enabled), HPen2=1, HPen1=0, HPCF=00 (HPc=8))

CTRL_REG3 : 0xE4   (IHL=1 (active low), PP_OD=1 (open drain), LIR2=1 (latch), I2_CFG=00 (I2 source), LIR1=1 (latch), I1_CFG=00 (I1 source))

CTRL_REG4 : 0x80   (BDU=1 (block), BLE=0, FS=00 (00:2g, 01:4g, 11:8g), STsign=0, 0, ST=0, SIM=0)

CTRL_REG5 : 0x00

HP_FLT_RST: 0x00

REFERENCE : 0x00

(1) there is no difficulty to read and determine the orientations. However, I noticed it may report back the gravity over 1.0g (the chip is stationary). Do I need to normalize them by SQRT(X^2+Y^2+Z^2)?

(2) We try to use INT1 for the tilt detection. The requirement is small, 15 degree away from Z-axis. How do we understand the INT1_THS value? It is small if for Z-axis interrupt (ZHIE or ZLIE). It is big if for X- and/or Y-axis. Is the 

INT1_THS value an absolute value? In other words, if we set it for XHIE and YHIE (your suggestion), what happens if X/Y reading value is minus? When the carrier is tilted away from Z-axis, X and/or Y reading could be positive or negative. How do we understand?

INT1 duration is set as 50 (at DR 50Hz, so about 1 second).

(3) for the shock detection, we set  INT2_CFG : 0x7F (all 6 directions enabled and OR'ed). The threshold value sets 0.5g. INT2 has high-pass filter enabled. More or less, it generates interrupt. But we have observed that the INT2_SRC seems always indicate high event in XH, YH and ZH no matter what direction the chip sat and strikes applied. Can you shed lights? 

INT2 duration is set as 1.

Thanks for helps in advance.

-wwqiao