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.

calculate Tilt angle of Sensortag



Hi to all, 

i have an SensorTag, i like to know the direction or orientation of the Sensor. here , i just like using an acceleromter and not acceleromter+ gyroscope

as far as i know that acceleration is the sum of dynamic acceleration ( due mouvement) and static acceleration (due gravity). in fact, gravity acceleration can help me to know a tilt or direction of Sensortag (when we base just in accelerometer),

i thinked to calculate a Tilt angle for each axes and substract it from acceleration data after, but i don't know if with Kionix J9 is correct or no?

other method, i tried to apply a low pass butterowrth to remove gravity from acceleration but i donc't know if its correct or no?

please i need your help

Thanks in advance 

  • Hi,

    Found one good resource which explains about accelerometer calibration and tilt angle calculations.

    Hope it helps. Tilt calculations must be same for Kionix also.

  • thank you very very much . 

    in addition, i found this link about tilt angle calculations http://www.kionix.com/sites/default/files/AN005%20Tilt%20Sensing.pdf, i think that it can be same for kionix j9. 

    Other question please, i found your answer in this post : http://e2e.ti.com/support/wireless_connectivity/f/538/t/349490.aspx

    "If you change polling interval to 100 but your sensor generates data at 10hz then you'll read old data which may not give accurate results. That's why I was telling you to change sampling rate from control register." 

    In fact, i have a same problem like as mentioned above : i like to define my sampling rate to 100 hz but when i modify interval to 100 ms, the sample rate is : 10hz. here we said that we can change control register :

    sould i modifiy this line of code : #define ACC_REG_ADDR_CTRL_REG3         0x1D // CTRL_REG3        *   R/W 0x1D 0001 1101?

    PS: please did you have any idea about using butterworth filter to remove gravity from acceleration?

     

    thanks in advance 

  • Hi,

    Your sampling rate = 100Hz it means your interval should be 10 ms not 100 ms .  because 1/100 Hz = 10 ms. 

    About line of code 

    #define ACC_REG_ADDR_CTRL_REG3         0x1D // CTRL_REG3        *   R/W 0x1D 0001 1101

    It is address of control register 3. You should not change address but look for instance where it is used. At somepoint in  the code, we must be writing something to this register, change that. 

    I'll point to exact location in code :

    There is HalAccelEnableConfigTable. 

    In that there are arrays for address and values

     { ACC_REG_ADDR_CTRL_REG3, 0 },

    Here change 0 with appropriate value for register 3. It should work. 

    Sorry but I don't have idea about using butterworth filter to remove gravity.

  • Thanks a lot Maulik Vaghela. 

    i will explain for you exactly what i did do to define a sample rate. i modified a AA13 characteristic of accelerometer wihch refers to accelerometer period . the period is defined as below: 

    Period = [Input*10] ms, (lower limit 100ms), default 1000 ms

    i set 10ms as input so : period = [10*10] = 100ms ( so here the sampling rate will be : 10hz ). ( in this case , i can't define input = 1 ms as lower limit is 100ms. i pretty understant that Period is interval between sending two data not the value of sampling rate? is this correct please? 

    please where i can find HalAccelEnableConfigTable ? i tried to open open source of Sensortag by using IAR workbensh but i don't find this istance. 

     

    we said that i should modify 0 with appropriate value for resiter 3. for example: if i have a sample date = 6.25, i should modify 0 with 001 .

     { ACC_REG_ADDR_CTRL_REG3, 001 }, is this correct?

    here i don't found  sample rate = 10hz , in the table of Output Data Rate for Wake Up Function ?  i found juste 12.5 

    with what can i change 0 value  { ACC_REG_ADDR_CTRL_REG3, ?? }

    thanks in advance 

  • Hi, 

    So , this table may not be in sensor tag app but it's in BLE stack 1.4.

    path : \Components\hal\target\CC2541ST\hal_acc.c

    In hal_acc.c file , you'll find that instance. This file is driver file for accelerometer.

    FOr ACC_REG_ADDR_CTRL_REG3, 

    add following code  in HalAccRead routine immediately after HalAccselect()  : 

    static uint8 accel_config_3 = 0;
    bool success = HalSensorReadReg( ACC_REG_ADDR_CTRL_REG3, &accel_config_3, sizeof(accel_config_3));
    accel_config_3 &= ~(0x03);
    accel_config_3 |= 0x02;
    HalSensorWriteReg(ACC_REG_ADDR_CTRL_REG3, &accel_config_3, sizeof(accel_config_3));

    First, I am reading  control register 3 to get default values.

    Then I am making last 2 bits (LSBs) zero because they represent output data rate.

    Then I am doing OR operation to set last 2 LSBs '10' which is for 100Hz. Thus I am preserving other configurations also. 

    Now write this configuration to Accel control register 3.  Thus it'll just change frequency configurations, nothing other, 

     

  • Hi,

    Thanks very much for your reply. 

    as i said for you that low interval here is :100ms so my rate sample = 10hz, its this correct?

    if it correct, normally i should set frenquecy to 10 hz (in configuration to accel control register 3)? after i modifiy frequency , should i recompile open source?

    Please, we sent me last time a very good paper about tilt angles and if possible i have a  question. ( i actived just accelerometer in Sensortag, i obtained in log files accelerations data in 3 axis, i like to remove gravity from acceleration data, i don't know if you have any idea about removing gravity , i thinked that if i caluclate a Tilt angles, after i substract it from acceleration data can gives me linear acceleration.

    Thanks in advance 

  • Hi,

    Yes, that seems to be correct and yes, you need to recompile source code. 

    Regarding removing gravity , I don't have much idea but I  think this link might be helpful. 

  • Thanks for your help !

  • Hey,
    i have the same problem as intissar, I need the accelereometer data with a 100Hz frequeny but it seems that this solution doesn't work for me.

    Maulik why are you set the last 2 bits on '10' ? The sampling frequency of the sensor is still set on the last three bits and should be '111' (for 100Hz), or not?

    But regardless, when I insert the code, the data values ​​are still the same for several measurements (5 times consecutively). Any ideas what could be the problem?

    The other problem i have: I am trying to send the Data to my PC for reading them with BTool. Sometimes there is more than 20ms between the measurements (up to 50ms), although the time interval is set to 10 ms.

    #define ACC_DEFAULT_PERIOD      10

    Any ideas what are the problems or any hints for me?

     

    Any help related to this would be highly appreciated.

  • Hi Bator, 

    I haven't experienced such issue but you can try following things: 

    1. Make sure that you are not modifying accelerometer period from accelerometer service. Check current value in sensor period characteristic and modify as per your need. Make sure you divide value by 10 as sensor period resolution is 10 ms, so value should be 1. 

    2. Regarding delay it's because connection interval is too high for SensorTag application. Modify it into "SensorTag.c" file. 

    Current: 

    // Minimum connection interval (units of 1.25ms, 80=100ms) if automatic parameter update request is enabled
    #define DEFAULT_DESIRED_MIN_CONN_INTERVAL 80

    // Maximum connection interval (units of 1.25ms, 800=1000ms) if automatic parameter update request is enabled
    #define DEFAULT_DESIRED_MAX_CONN_INTERVAL 800

    Modify it to: 

    #define DEFAULT_DESIRED_MIN_CONN_INTERVAL 6    //7.5ms

    #define DEFAULT_DESIRED_MAX_CONN_INTERVAL 20 // 25 ms

    Please try the mentioned things and check if this works for you.

    Maulik.

  • Hi Maulik,

    first of all: thx for your reply!

    Your hint with the connection interval was great! After modifying  I get every 10 ms a message with the accelerometer data. So this problem is solved.

    I am not sure what are you meaning where I have to change the period now. So far I had changed the period in sensortag.c file as Eirik said here.

    After that exactly two successively values were identical so I debugged the program and looked again in the datasheet beacause the sensor still seems to have a 50 Hz sample rate. Am I wrong or is the sample rate of the sensor set in the "DATA_CTRL_REG" ? I modified this register this way..

      // Read register entry
      success = HalSensorReadReg(ACC_REG_ADDR_DATA_CTRL_REG, &accel_config, sizeof(accel_config)); 
      // Enable last 2 Bits for Frequency 100Hz
      accel_config |= 0x03;
      // Write new value to the register
      HalSensorWriteReg(ACC_REG_ADDR_DATA_CTRL_REG, &accel_config, sizeof(accel_config));

    .. and now every 10 ms I get a new value. Maybe it's helpfully for other people with the same problem.

    Best regards