Skip to main content
MKS
Associate III
Jul 9, 2019 6:35 AM UTC
Solved

Setting a threshold value

Hi ,

i need to know how to set a threshold value for state machine interrupt, can u explain with an example. precisely means setting the value in the register for wakeup statemachine

    This topic has been closed for replies.
    Eleon BORLINI
    Eleon BORLINIBest answer
    ST Employee
    Jul 18, 2019 1:40 PM UTC

    Hi @MKS​ , I'm afraid I've mistaken the formulas. Please consider that as FS we intend +-2g, so in the formula the correct FS valuue is +-2g=4g for the Threshold LSB. So you have to double the previous values I wrote. Sorry and regards

    5 replies

    Eleon BORLINI
    ST Employee
    Jul 10, 2019 4:20 PM UTC

    HI @MKS​ , please consider p. 75 of AN3393 for the wake-up FSM description. The threshold value (THRS1_1 (57h) = 55h in the example case, meaning FS/2^8 * 85 = 664mg), is the comparison value that generates an interrupt if the sensor data out exceeds that value and the masks are properly set to detect a particular axis or the overall acceleration resultant. I don't know if I catch your question. Regards

    0690X000009YcymQAC.png

    MKS
    MKSAuthor
    Associate III
    Jul 15, 2019 7:35 AM UTC

    Hi @Eleon BORLINI​  thanks for your reply,

    i have seen this document and this section specifically, but i want to know how value :(THRS1_1 (57h) = 55h is deprecated as 664mg, i.e. if i want to set threshold of different value, what (eg.300mg) how can i make calculation on register part, can u explain in detail.

    Thank You

    Eleon BORLINI
    ST Employee
    Jul 15, 2019 10:53 AM UTC

    ​Hi, the calculation is the following:

    (1) THS_value (mg) = FullScale/2^8 * THS_value (LSB)

    and the reverse is:

    (2) THS_value (LSB) = 2^8/FullScale * THS_value (mg)

    So, for example, if you want to set 300mg of threshold and you are working with a 2g FS, you should use equation (2) and get 38.4 decimal, meaning 38dec (the nearest integer). In hexadecimal is 26h.

    Regards

    MKS
    MKSAuthor
    Associate III
    Jul 18, 2019 5:36 AM UTC

    Hi @Eleon BORLINI​  thanks for your answer but considering p. 80 of AN3393 in the register configuration of freefall threshold register value is 18h(THRS2_1 56h), if i apply your first formula , i am getting 187.5mg but they have mentioned it as 300(Inside tabular column), so what i this value then.

    Regards,

    Manjunath

    Eleon BORLINI
    Eleon BORLINIBest answer
    ST Employee
    Jul 18, 2019 1:40 PM UTC

    Hi @MKS​ , I'm afraid I've mistaken the formulas. Please consider that as FS we intend +-2g, so in the formula the correct FS valuue is +-2g=4g for the Threshold LSB. So you have to double the previous values I wrote. Sorry and regards