How to change ODR setting of ADXL355

  accelerometer, arm, c++, embedded, mbed

I am using adxl355 and confused how to change the setting of odr(output data rate). Here is the code. As you can see, I have the set_filter_ctl_reg in the main. But it seems not working. I feel that only the part in the while loop influence the sampling rate(same with odr here). In the datasheet, it does say that adjusting the filter to changing the odr. Anyone knows? Thank you!

#include "mbed.h"
#include "system_stm32f4xx.h"
#include "ADXL_355Z.h"

void Data_Collect(void);
    //The virtual COM port
    Serial pc(SERIAL_TX,SERIAL_RX);

    //The voltage supply for the accelerator and the sEMG
    DigitalOut SC1(PC_9);
    DigitalOut SC2(PC_8);
    ADXL355 acclA(PC_9, PC_12, PC_11, PC_10); //Set the SPI for the ACC_1
    ADXL355 acclB(PC_8, PC_12, PC_11, PC_10); //Set the SPI for the ACC_1

    Timer Time_up; //The timer for the arrangement

    //All the variable here, are global variable
    //They will be called by the Ticker function
    float ADC_Value;
    float xA, yA, zA;
    float xB, yB, zB;

    void Data_Collect(void) {
        xA = acclA.convert(acclA.scanx())*acclA.axis355_sens;
        yA = acclA.convert(acclA.scany())*acclA.axis355_sens;    
        zA = acclA.convert(acclA.scanz())*acclA.axis355_sens;

        xB = acclB.convert(acclB.scanx())*acclB.axis355_sens;
        yB = acclB.convert(acclB.scany())*acclB.axis355_sens;
        zB = acclB.convert(acclB.scanz())*acclB.axis355_sens;
        
        pc.printf("%.6f%.6f%.6f%.6f%.6f%.6f%n", xA,yA,zA,xB,yB,zB);    
}    

int main() {
    pc.baud(9600);
    pc.printf("ADC sEMG demorn");

    acclA.reset();
    acclB.reset();

    wait(0.1); //The waiting is needed

    acclA.set_filter_ctl_reg(acclA.HPFOFF,acclA.ODR4000HZ);
    acclB.set_filter_ctl_reg(acclB.HPFOFF,acclB.ODR4000HZ);

    wait(0.1); //The waiting is needed
    
    acclA.set_power_ctl_reg(acclA.MEASUREMENT);    
    acclB.set_power_ctl_reg(acclB.MEASUREMENT);

    wait(0.1); //The waiting is needed
    
    Time_up.start();

    while(1) {
        Data_Collect();    
    }
}

Source: Windows Questions C++

LEAVE A COMMENT