Skip to main content
Visitor II
October 7, 2020
Question

Flexible Tilt angle measurement/interrupt in LIS2DW12

  • October 7, 2020
  • 2 replies
  • 3744 views

Hi ,

. I uses LIS2DW12. I have seen that 6D orientation angle is from 45 or 50 degrees only. So setting an interrupt for this wont be useful for my purpose.

I would like to wake up on minimum angle that I sets, say 5degree/10 degree . How could I achieve It. Is there any pseudo code available for that Like one is for 6D orientation (DT0097)?. When checked the STmem driver, I have seen that WAKE_UP_THS(34h) API is available for setting threshold values.

How I can get interrupt for a the tilt value I set (say 10 degree) for only one axis by setting threshold in this register. Also how to calculate to and from mg to degree(getting from raw value and setting to threshold)?.

Awaiting for the earliest response.

regards,

SV

    This topic has been closed for replies.

    2 replies

    ST Employee
    October 8, 2020

    Hi @Vsv.1​ ,

    I believe you could achieve your goal by using the wake-up embedded digital feature. A wake-up interrupt generated while the device is running always in normal mode. This feature is described in application note AN5038 p.21.

    You can define a threshold calculating the component of the "g" acceleration on one of the 3 spatial direction (see the AN4509 for a detailed calculation of this value, you can find some examples on page 6) and select the axis on which you want to detect the interrupt event.

    You can refer to this C code: lis2dw12_wake_up.c

    You should maybe disable this function if you are interested in quasi-static variation:

     /* Apply high-pass digital filter on Wake-Up function */
     lis2dw12_filter_path_set(&dev_ctx, LIS2DW12_HIGH_PASS_ON_OUT);

    Please let me know if this solution is feasible for you.

    -Eleon

    Vsv.1Author
    Visitor II
    October 13, 2020

    Hi @Eleon BORLINI​ 

    Thanks for all the Input.

    I went through the document and tried something. I am getting interrupts every time even in stationary(When I set feed and random offset value for all three axis, without that what I am getting is TAP interrupt only). Turning off interrupt for an axis also I haven't seen, other than for Tap(which is very much required).

    Can you give more light on weight setting , offset setting for each axis. Is that offset unit is 'mg' or it is angle, the maximum value of THS is 6 bits, so how it will be related to a large angle value.

    I have seen a conversion fs2tomg (multiplying with .016, may i know how arrived in this calculation), is there a calculation for raw to angle in the same way.

    All I expect is if I gives an offset 10, if any of the axis is tilted to more than 10degree from its current baseline, it should generate an interrupt.

    Regards,

    SV

    ST Employee
    October 13, 2020

    Hi @Vsv.1​ ,

    Let's see if I can help you.

    >> Can you give more light on weight setting , offset setting for each axis. Is that offset unit is 'mg' or it is angle, the maximum value of THS is 6 bits, so how it will be related to a large angle value.

    the AN4509 reports some of the thresholds related to the tilt degrees. Suppose you have your device with the z axis measuring 1g (flat position), the x and y axis will measure 0 LSB = 0 mg. If you set the threshold at 15° and enable X_WU and Y_WU (not the Z_WU), because the Z_WU would always generate an input when in flat position (Z = 1 g).

    0693W000004Jcc7QAC.pngFor the threshold calculation, please consider what reported in the datasheet p.48: Wakeup threshold, 6-bit unsigned 1 LSB = 1/64 of FS. Default value: 000000.

    >> I have seen a conversion fs2tomg (multiplying with .016, may i know how arrived in this calculation), is there a calculation for raw to angle in the same way.

    The conversion formula for the data output is the following one, and comes from the fact that the sensitivity is 0.244 mg/LSB and the output data is on 14-bit (i.e., you have to divide by 4 to get the 16-bit LSB). You can find in the datasheet p.6:

    float_t lis2dw12_from_fs2_to_mg(int16_t lsb)
    {
     return ((float_t)lsb) * 0.061f;
    }

    -Eleon

    Vsv.1Author
    Visitor II
    October 14, 2020

    @Eleon BORLINI​ . Thanks for the reply Eleon. I went busy in another loop and couldn't get some time later to spend on Mems. I shall come up with my doubts/result/findings on this this week.