2017-06-13 05:08 AM
I am working with IIS2DH accelorometer an I would like to configure single/double click tap detection. For that, I have done following configuration:
I2C_WriteByte(&ctrl_1,1,0x5F);
I2C_WriteByte(&ctrl_3,1,0x80); I2C_WriteByte(&ctrl_6,1,0x82); I2C_WriteByte(&ctrl_4,1,0x00); I2C_WriteByte(&int1_config,1,0x00); I2C_WriteByte(&ctrl_5,1,0x40); I2C_WriteByte(&click_config,1,0x15);I read click source register for single click detection but values are different every time. Also,interrupt flag not set for microcontoller.Is there any thing need to be wrong in my configuration?
Is any application note for IIS2DH(DM00171283)?
2017-06-29 01:59 AM
You configuration is correct, but you have to set also two configuration registers for single click detection (CLICK_THS, TIME_LIMIT).
If the device is configured for single-click event detection, an interrupt is generated when the input acceleration on the selected channel exceeds the programmed threshold CLICK_THS, and returns below it within a time window defined by the TIME_LIMIT register.
2017-06-29 10:56 PM
I2C_WriteByte(&ctrl_1,1,0x5F);
I2C_WriteByte(&ctrl_3,1,0x80);I2C_WriteByte(&ctrl_6,1,0x82);I2C_WriteByte(&ctrl_4,1,0x00);I2C_WriteByte(&int1_config,1,0x00);I2C_WriteByte(&ctrl_5,1,0x40);I2C_WriteByte(&click_config,1,0x01);//only x axis click enableI2C_WriteByte(&time_limit,1,0x05);I2C_WriteByte(&click_ths,1,0x0D);I have configured above registers and I read click source register continuously but when I click the accelerometer interrupt is generated and click source values is getting from sensor is 0x09,0x01,0x51 from that value I thought only 0x51 is correct to match with the only X axis enable detection whereas, form the other two values, I had got the interrupt as well. Am I done correct configuration? and I have one more query that in above configuration time_limit and
click_ths
register,I have load with 0x05 and 0x0d that means after how much time and after how much acceleration it generate the interrupt?So, could help me on that issue. Thank you for your support.
2017-06-30 07:40 AM
Hello,
I only found this in
http://www.st.com/content/st_com/en/resource-selector.html
(can't search for older documents than September 7th, 2015) :And one more discovered by Google
Since the documents seem pretty similar, I would try to read the theory of operation in them.
Batek.Miroslav
, is there a similar application note for newer devices?David
2017-07-02 11:57 PM
One more thing I would like to tell you that in the datasheet
of
DM00171283 there are no such bit like LIR in the click source register. So, how to use and configure that register for single click detection? Furthermore, my previous query still not be answered. I got the interrupt on single click but I only click one time, interrupt got multiple time. Please provide proper guidance for that.
2017-07-18 05:19 AM
CLICK_THS ... 1 LSB = full scale/128 (in you case FS = 2g, CLICK_TSH = 0x05 ... 5 * 2g / 128 = 0.078g)
TIME_LIMIT ... 1 LSB = 1/ODR (in you case ODR = 100Hz,
TIME_LIMIT = 0x0D ... 13 * 1 / 100 = 0.13s)
Concerning the behavior you described, I think the X and Sign bits (values 0x09 or 0x01) in CLICK_SRC register are set immediately when the CLICK_THS is reached and the IA bit (value 0x51 or 0x59) is set if the value returns below it within a time window defined by the TIME_LIMIT register. So the IA bit has latency of TIM_LIMIT time.
Basically
you can you can mask other bits in you program and the CLICK using only the IA bit in CLICK_SRC register or use the hardware interrupt signals.
2017-07-18 10:17 PM
Thank you for your exceptional support.
I2C_WriteByte(&ctrl_1,1,0x5F);
I2C_WriteByte(&ctrl_3,1,0x80); I2C_WriteByte(&ctrl_6,1,0x82); I2C_WriteByte(&ctrl_4,1,0x20);// 8g sensitivity set I2C_WriteByte(&int1_config,1,0x00); I2C_WriteByte(&ctrl_5,1,0x40); I2C_WriteByte(&click_config,1,0x15);//x,y,z, enable for click I2C_WriteByte(&time_limit,1,0x05); I2C_WriteByte(&click_ths,1,0x60);As per your answer, I have configured all registers as per above specification. Moreover, I have used IA bit to mask for interrupt generation, in my code I have continuously read click source register and once IA bit is set I have read x,y, and z axis value and following reading I have got. It is fine or not? Furthermore, sometimes I have got multiple time IA bit set for single click. So, any method to overcome this issue? Now, it is working very fine.
click src 54
x axis is 9y axis is -8z axis is 55******************click src 54x axis is -4y axis is 32z axis is -5******************click src 54x axis is -12y axis is -25z axis is 80******************click src 5ax axis is -7y axis is 66z axis is 127******************click src 54x axis is -2y axis is -24z axis is 81******************click src 5cx axis is -9y axis is -84z axis is 77******************click src 54x axis is 2y axis is 7z axis is 34******************click src 52x axis is 4y axis is 12z axis is -6******************click src 52x axis is -1y axis is 15z axis is -6******************click src 52x axis is 1y axis is 6z axis is 0******************I tap on particular hardware then I got the IA bit set but if I tap around the hardware nothing can happened. So, any specific region around the hardware to tap and got the interrupt?
2017-07-19 08:36 AM
The configuration and behavior seems OK to me.
Instead of continuous polling of CLICK_SRC register you can also use the hardware interrupt signal generated on INT1 or INT2 pin, if you have these signals connected to you microcontroller. In this case you can set the TIME_LATENCY and the interrupt will be kept active for this time (TIME_LATENCY) so it will mask multiple set of IA bit for single click. These multiple sets of IA bit are caused by bouncing of the device and this triggers the click detection multiple time. Another solution is to filter these multiple detection in software.Concerning the region around the hardware, where the click is detected, it is really dependent on the board on which the sensor is soldered and mechanical construction of your device. You have to fine tune the sensitivity by the click threshold settings.2017-07-19 10:07 PM
Hi Miroslav, I have done single click on both method by using hardware interrupt and IA bit masking. it is working fine. However, when I used hardware interrupt then once interrupt is active and I am reading click source register, sometimes it is shown value like below:
click src 2
x axis is -7y axis is -4z axis is 31******************click src 5ax axis is -17y axis is -11z axis is 45******************click src 1x axis is -28y axis is -13z axis is 73******************click src a
x axis is -4y axis is 5z axis is 15******************So, in the case like 0x02,0x01,0x0a IA bit is 0 means that interrupt is not active then how the hardware interrupt is activated? Can I use both condition to check interrupt is active or not? Ex.
if(hw_interrupt_flag)
{
if(click_source & (1<<6)
{
print('single click detect');
}
}
One more concern is you told that multiple click detection issue is solved by using software filter so, how I achieve it?
Thanks for your support.