首页 > 解决方案 > 如何更改 ADXL355 的 ODR 设置

问题描述

我正在使用 adxl355 并且对如何更改 odr(输出数据速率)的设置感到困惑。这是代码。如您所见,我主要有 set_filter_ctl_reg。但它似乎不起作用。我觉得只有 while 循环中的部分会影响采样率(与此处的 odr 相同)。在数据表中,确实说调整过滤器以更改 odr。有谁知道?谢谢!

#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 demo\r\n");

    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();    
    }
}

标签: c++armembeddedaccelerometermbed

解决方案


推荐阅读