简体   繁体   中英

Tap Detection data conversion for ADXL345 sensor

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

The values are decimal values - you can see in the comments how they relate to actual physical values:

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

So to work out the value you need for a threshold of Xg, use the formula

v = X / 62.5mg = X / 0.0625

For example, for a threshold of 5g:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM