ADXL345 how often can it be asked for a value?

Hello

How often can I ask the ADXL345 for a value? Or it doesn't matter how many a second I would ask it since I will just give me a value back as soon as it is able to so and just ignore any other requests until its ready again?

Its time critical to what it will be used for but to check the "busy bit" takes a little longer then instead of just constantly asking it for a new value.

Yes it has 2 interrupts but they are, as I understand, more to know when the sensor detect any movement at all, I need values from it constantly as fast as it can give me and as many it can give me in a time frame.

You can ask for a new value whenever you expect (or know) that one is available, or less often.

The ADXL345 sample rate is an option you can set. 3200 Hz is the maximum sample frequency.

So I can fex constantly bang it with requests 100000 times a second with no issue, it will just give me a value when its ready to do so and there will be no ill effects by doing so?

Not with I2C. You are limited to the available I2C communication rates, and the sensor output data rate that you set, among the available ODR settings.

From the data sheet:

Due to communication speed limitations, the maximum output data rate when using 400 kHz I2C is 800 Hz and scales linearly with a change in the I2C communication speed. For example, using I2C at 100 kHz would limit the maximum ODR to 200 Hz.

SPI is faster, but I thought it was clear that it makes no sense to interrogate the sensor at any rate faster than it can produce data.

The most efficient way to proceed is to monitor the sensor data ready output, and collect a sample when one is available.

True, that would perhaps best the best as such.

I will of course use SPI at 2MHz for 3200Hz sampling, but that SPI speed is minimum as it seemed. So If max 2MHz SPI, and all set correctly in registers, I can send a request 3200 times a second and guaranteed get a result back would have been good.

It also seem that you could go faster than since it said minimum at the SPI but I don't know if that equates in faster sample requests or if it just ignore them.

There is no such guarantee, because the ADXL345 clock is asynchronous with the MCU clock, and not very accurate.

It makes sense only to request data when data are available to be collected.

If you request data when it is not available, you have wasted that entire transmission cycle.

The other option is to use the FIFO and expect to collect data in bursts.

But at only 3200Hz and 2MHz SPI would that really be an issue? Cpu is at a much higher frequency so maybe some clock cycles off or so at most.

But I don't know how long it will take from I send a command, with Wire.h, to check if the sensor is ready for a new sample and then send the command for a sample and get it back. If that is very fast then I might work anyway to check if its ready.

I have now checked the delays and such and it seem that there shouldn't really be any problems time wise by checking the DATA_READY when needed, but there might perhaps be problems doing it much more then 3200 times a second. Oh well I will see when I get the stuff. Thanks for the help, very appreciated!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.