Tap Detection data conversion for ADXL345 sensor

时间:2018-09-19 08:16:32

标签: arduino hex arduino-ide adc assembly-resolution

I am interfacing ADXL345 sensor by using the datasheet as well as other libraries I am able to under stand the setup of TAP threshold.

I need to confirm that in example code :

// Set values for what is considered a TAP and what is a DOUBLE TAP (0-
 255)
adxl.setTapThreshold(50);           // 62.5 mg per increment
adxl.setTapDuration(15);            // 625 μs per increment
adxl.setDoubleTapLatency(80);       // 1.25 ms per increment
adxl.setDoubleTapWindow(200);       // 1.25 ms per increment

in which user setup values which is mentioned according to scale factor as per mentioned in datasheet, I am facing doubt here and need to clear this

  1. the values mentioned for Tap solution is decimal or hexadecimal values ?

  2. Need to know the conversion formulae which is used to create for setup the threshold.

As ADXL345 sensor which, I am using has maximum resolution of 13 bits so I want to set the value as per 13 bits

Any suggestion advice regarding this will be very helpful for me to work on ADXL345 sensor interfacing with an Arduino

1 个答案:

答案 0 :(得分:0)

这些值是十进制值-您可以在注释中看到它们与实际物理值的关系:

adxl.setTapThreshold(50);           // 62.5 mg per increment -> 62.5mg * 50 = 3.125g
adxl.setTapDuration(15);            // 625 μs per increment -> 625us * 15 = 9.375ms
adxl.setDoubleTapLatency(80);       // 1.25 ms per increment -> 1.25ms * 80 = 100ms
adxl.setDoubleTapWindow(200);       // 1.25 ms per increment -> 1.25ms * 200 = 250ms

因此,要计算出Xg阈值所需的值,请使用公式

v = X / 62.5mg = X / 0.0625

例如,对于5g的阈值:

adxl.setTapThreshold(80); // Because 5 / 0.0625 = 80