This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Threshold of sensortag(exactly acceleormeter)

Hi to all, 

I'm using Sensortag device , and i'm interssting just to kionix's accelerometer , I like  to know the value of Threshold of kionix's accelerometer. After reading a datasheet of accelerometer , i think that it is seting to 0.5g but i'm not sure, is this correct? 

" This is a portion about threshold from datasheet "

WAKEUP_THRESHOLD
This register sets the threshold for wake-up (motion detect) interrupt is set. The KXTJ9 will ship from
the factory with this value set to correspond to a change in acceleration of 0.5g. Note that to properly
change the value of this register, the PC1 bit in CTRL_REG1 must first be set to “0”."

Thanks in advance 

  • Hi,

    Yes, default wake up threshold is 0.5g. 

    Default value of register = 0000 1000 (0x08)

    If you see equation which is on next page,

    Threshold steps =  (threshold in g) * 16 

    for 0.5G steps = 8. Thus default value = 8. 

  • Thanks a lot for your reply.

    threshold steps = 8 is in Counts unit? please when can i find this value in Sensortag open source, and it is possible to modify it?

    2) - It is necessary to calculate Wake Up Delay Time ?

    Thank you in advance 

  • Hi,

    You can modify it easily in FW code. 

    If you have BLE stack 1.4.0, then hal_acc.c file is driver file for accelerometer. 

    You can write corresponding value to register as needed. you can find file at :  

    C:\Texas Instruments\BLE_CC254x_140\Components\hal\target\CC2541ST\hal_acc.c

    Example driver is not changing value, but register definitions are given at top. You can write to the wake up threshold register and modify it. 

    Regarding wake up time calculations, Yes it is necessary to calculate because if your sensor is in sleep mode then when you are reading sample from it, you need to wake up the sensor. You can take reliable reading from sensor after wake up delay time only. 

    If your sensor is always on then you don't need to worry about wake up delay. It's not that much critical.

  • Thanks Maulik. 
    Thus are resgisters's values in hal_acc.c, but i don't know the exact name of threshold register? 
    #define ACC_REG_ADDR_TDT_L_THRESH      0x2D // R/W
    #define ACC_REG_ADDR_TDT_TAP_TIMER     0x2E // R/W
    #define ACC_REG_ADDR_TDT_TOTAL_TIMER   0x2F // R/W
    #define ACC_REG_ADDR_TDT_LATENCY_TIMER 0x30 // R/W
    #define ACC_REG_ADDR_TDT_WINDOW_TIMER  0x31 // R/W
    #define ACC_REG_ADDR_WUF_Threshold ( i think that's the register of threshold because in datasheet i was found this :

    WAKEUP_TIMER (counts) = Desired Delay Time (sec) x OWUF (Hz)

    Equation 2. Wake Up Delay Time

    if i suppose that ACC_REG_ADDR_TDT_L_THRESH is the threshold, it's value is set to : 0x2D hex ? 
    Other question please: in variables defintions, i saw : #define ACC_REG_ADDR_TILT_ANGLE 0x05, is mean that tilt angle is set to 0x05?
    #define ACC_REG_ADDR_TILT_POS_CUR  0x15
    #define ACC_REG_ADDR_TLT_POS_PRE  0x16
    it mean that the tilt of current position is set to 0x15 and precedent is setting to 0x16? it doesn't exist a function which calculate tilt ?
    Thanks in advance 
  • Hi, 

    These are all address of registers. ACC_REG_ADDR_TDT_L_THRESH  represents address of threshold register not content.  In short whenever macro contains wors "ADDR" it means it represents address. 

    No, there is no function to calculate tilt but you can search an algorithm to calculate tilt and implement on application side. 

  • Hi, 

    So when can i find content of  "ACC_REG_ADDR_TDT_L_THRESH"

     

    Thanks in advance 

  • Hi,

    If you see in accelerometer driver, there is no code for modifying threshold value. 

    If you want to read default value use "HalSensorReadReg" API which is available in hal_sensor.c 

    function :  bool HalSensorReadReg(uint8 addr, uint8 *pBuf, uint8 nBytes)

    you can pass address as "ACC_REG_ADDR_TDT_L_THRESH" , take one buffer of single byte and pass address, and nBytes = 1. 

    Thus you can read default value. 

    If you want to modify it, you can use "HalSensorWriteReg" function. 

  • Hi, 

    Thanks a lot for your reply.

    1) - To read the value of Threshold, I tried to modify addr with "ACC_REG_ADDR_TDT_L_THRESH" like this:

    bool HalSensorReadReg(uint8 ACC_REG_ADDR_TDT_L_THRESH , uint8 *pBuf, uint8 nBytes)

    {
    uint8 i = 0;
    nBytes = 1;

    /* Send address we're reading from */
    if (HalI2CWrite(1,&ACC_REG_ADDR_TDT_L_THRESH ) == 1)
    {
    /* Now read data */
    i = HalI2CRead(nBytes,pBuf);
    }

    return i == nBytes;
    }

    After i debug the program which don't give me error; i search for output of this function but i can't find its place. 

    2) - In Sensortag, the value of threshold is 0.5? Can i do my work with this value?

    Thanks in advance 

     

  • Hi, 

    You don't need to modify "HalSensorReadReg" function for that. 

    Sample code: 

    uint8 data_read = 0; 
    uint8 no_of_bytes = 1; 
    bool status = 0; 
    
    status = HalSensorReadReg(ACC_REG_ADDR_TDT_L_THRESH , &data_read , no_of_bytes);

    Now, check that status should return 0 after this function has been called. data_read should contain data of register.

    2. Yes, you can do your work with wakeup threshold of 0.5G. (I assume you just want to get data of accelerometr) . 

     

  • Hi , 

    Thanks very very much. 

    Please , it's possible to connect SensorTag to Matlab to view data in real time . I'm using BLE Device Monitor, but it's an application not open source, should i create my own application? If yes, should i use a functions in SensoTag?

    Thanks a lot in advance 

  • Hi,

    I am not aware whether it can work with Matlab  or not. 

    But you can use android application or make one. 

    Here is source code for BLE sensor tag demo app : 

    https://github.com/StevenRudenko/BleSensorTag