Post Go back to editing

Optimizing ADXL345 Settings for Movement Detection with Minimal Power Consumption

Category: Software
Product Number: ADXL345

Hi,

We are using the ADXL345 accelerometer in our project to detect the movement of equipment, with an emphasis on minimizing power consumption. We do not need to detect impacts such as taps or double taps, just the regular movement of the device that contains this sensor.

Our primary goal is to adjust the ADXL345 settings to:

  • Exclusively detect actual movement of the equipment.
  • Significantly reduce power consumption by eliminating unnecessary detections and minimizing the sensor’s operational overhead.

Currently, we are trying different configurations from the datasheet, specifically positions 0x2C to 0x2F, corresponding to:

  • BW_RATE = 0x2C
  • POWER_CTL = 0x2D
  • INT_ENABLE = 0x2E
  • INT_MAP = 0x2F

Could you please advise on the best settings or configurations to achieve these objectives? Specifically, we are looking for ways to fine-tune the sensitivity and potentially deactivate functions that detect impacts, focusing solely on movement detection.

We appreciate any detailed guidance or recommendations you can provide to help us optimize the use of the ADXL345 for our specific needs.

I have attached the program file we are using for testing.

Thank you for your support.

Thanks!


ADXL345_TESTS.zip



Fix ADXL version...
[edited by: xOliveCi at 3:16 PM (GMT -4) on 3 Jul 2024]

Top Replies

  • Hi  

    Thank you for posting your question on EZ. If I understand correctly, you can set the "DATA-READY" interrupts for your application (do not need to set up the activity, tap,...). (Please find…

Parents
  • Hi  

    Thank you for posting your question on EZ. If I understand correctly, you can set the "DATA-READY" interrupts for your application (do not need to set up the activity, tap,...). (Please find attached file which is a MATLAB code to communicate with ADXL345 via NI USB-8452. It shows the registers, their value and sequence. Feel free to change it based on your desired value (range, ODR,...). 

    The power consumption can be reduced by activating the low power mode (at the expense of noise performance). Also, the ADXL345 automatically modulates its power consumption in proportion to its output data rate, as outlined in Table 7 of the datasheet

    Please let me know if you have any questions or my understanding of your problem/application is incorrect. 

    Regards,

    Mohammad


    clear all
    clc
    close all
    
    list = ni845xlist;
    controllerList = ni845xlist;
    ni845Obj = ni845x(controllerList.SerialNumber(1));
    accelerometerAddress = scanI2CBus(ni845Obj);
    adxlDevice = device(ni845Obj, 'I2CAddress', accelerometerAddress);
    
    DeviceidRegisterAddress = 0x00;
    
    % Enable data-ready interrupt (bit 7) in INT_ENABLE register (0x2E)
    writeRegister(adxlDevice, 0x2E, 0x80);
    
    % Map data-ready interrupt to INT1 (bit 0) in INT_MAP register (0x2F)
    writeRegister(adxlDevice, 0x2F, 0x00);
    
    % setting ODR and low-power mode
    writeRegister(adxlDevice, 0x2C, 0x1B);
    
    % data format
    writeRegister(adxlDevice, 0x31, 0x8);
    
    dataRegs = hex2dec('32'):hex2dec('37');
    
    % Set the ADXL345 in measuring mode
    writeRegister(adxlDevice, 0x2D, 8);
    
    % Specify the number of samples to acquire
    numSamples = 1000; % Change this to the desired number of samples
    
    
    % Read acceleration data from ADXL345
    sampleCount = 0;
    while sampleCount < numSamples
        % Check if data-ready interrupt is active
         intSource = readRegister(adxlDevice, 0x30);
         dataReady = bitget(intSource, 8);
        % Check if new data is ready
         if dataReady==1
                
            % Read acceleration data
              accelerationData = readRegister(adxlDevice, 0x32, length(dataRegs), 'uint8');
              
    
            % Convert the raw data to signed 16-bit integers
            xAccraw = typecast(uint16(accelerationData(1) + bitshift(accelerationData(2), 8)), 'int16');
            yAccraw = typecast(uint16(accelerationData(3) + bitshift(accelerationData(4), 8)), 'int16');
            zAccraw = typecast(uint16(accelerationData(5) + bitshift(accelerationData(6), 8)), 'int16');
    
            % Scale the acceleration values
            scaleFactor = 3.9; % scale factor
            xAcc = xAccraw * scaleFactor;
            yAcc = yAccraw * scaleFactor;
            zAcc = zAccraw * scaleFactor;
    
            % Display the acceleration values
            fprintf('Acceleration - X: %.2f g, Y: %.2f g, Z: %.2f g\n', xAcc, yAcc, zAcc);
    
    
            sampleCount = sampleCount + 1;
            pause off;
        end
    end
    

Reply
  • Hi  

    Thank you for posting your question on EZ. If I understand correctly, you can set the "DATA-READY" interrupts for your application (do not need to set up the activity, tap,...). (Please find attached file which is a MATLAB code to communicate with ADXL345 via NI USB-8452. It shows the registers, their value and sequence. Feel free to change it based on your desired value (range, ODR,...). 

    The power consumption can be reduced by activating the low power mode (at the expense of noise performance). Also, the ADXL345 automatically modulates its power consumption in proportion to its output data rate, as outlined in Table 7 of the datasheet

    Please let me know if you have any questions or my understanding of your problem/application is incorrect. 

    Regards,

    Mohammad


    clear all
    clc
    close all
    
    list = ni845xlist;
    controllerList = ni845xlist;
    ni845Obj = ni845x(controllerList.SerialNumber(1));
    accelerometerAddress = scanI2CBus(ni845Obj);
    adxlDevice = device(ni845Obj, 'I2CAddress', accelerometerAddress);
    
    DeviceidRegisterAddress = 0x00;
    
    % Enable data-ready interrupt (bit 7) in INT_ENABLE register (0x2E)
    writeRegister(adxlDevice, 0x2E, 0x80);
    
    % Map data-ready interrupt to INT1 (bit 0) in INT_MAP register (0x2F)
    writeRegister(adxlDevice, 0x2F, 0x00);
    
    % setting ODR and low-power mode
    writeRegister(adxlDevice, 0x2C, 0x1B);
    
    % data format
    writeRegister(adxlDevice, 0x31, 0x8);
    
    dataRegs = hex2dec('32'):hex2dec('37');
    
    % Set the ADXL345 in measuring mode
    writeRegister(adxlDevice, 0x2D, 8);
    
    % Specify the number of samples to acquire
    numSamples = 1000; % Change this to the desired number of samples
    
    
    % Read acceleration data from ADXL345
    sampleCount = 0;
    while sampleCount < numSamples
        % Check if data-ready interrupt is active
         intSource = readRegister(adxlDevice, 0x30);
         dataReady = bitget(intSource, 8);
        % Check if new data is ready
         if dataReady==1
                
            % Read acceleration data
              accelerationData = readRegister(adxlDevice, 0x32, length(dataRegs), 'uint8');
              
    
            % Convert the raw data to signed 16-bit integers
            xAccraw = typecast(uint16(accelerationData(1) + bitshift(accelerationData(2), 8)), 'int16');
            yAccraw = typecast(uint16(accelerationData(3) + bitshift(accelerationData(4), 8)), 'int16');
            zAccraw = typecast(uint16(accelerationData(5) + bitshift(accelerationData(6), 8)), 'int16');
    
            % Scale the acceleration values
            scaleFactor = 3.9; % scale factor
            xAcc = xAccraw * scaleFactor;
            yAcc = yAccraw * scaleFactor;
            zAcc = zAccraw * scaleFactor;
    
            % Display the acceleration values
            fprintf('Acceleration - X: %.2f g, Y: %.2f g, Z: %.2f g\n', xAcc, yAcc, zAcc);
    
    
            sampleCount = sampleCount + 1;
            pause off;
        end
    end
    

Children
No Data