jgreen

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7931
    jgreen
    Participant

    yes,

     

    void setup() {
    // join i2c bus (address optional for master)
    Serial.begin(115200); // start serial for output

    detectIMU();
    enableIMU();

    delay(1000);
    }

    void enableIMU(){

    if (LSM9DS0){//For BerryIMUv1
    //Enable accelerometer
    writeTo(LSM9DS0_ACC_ADDRESS,LSM9DS0_CTRL_REG1_XM, 0b01100111); // z,y,x axis enabled, continuos update, 100Hz data rate
    writeTo(LSM9DS0_ACC_ADDRESS,LSM9DS0_CTRL_REG2_XM, 0b00100000); // +/- 16G full scale

    //Enable the magnetometer
    writeTo(LSM9DS0_MAG_ADDRESS,LSM9DS0_CTRL_REG5_XM, 0b11110000); // Temp enable, M data rate = 50Hz
    writeTo(LSM9DS0_MAG_ADDRESS,LSM9DS0_CTRL_REG6_XM, 0b01100000); // +/-12gauss
    writeTo(LSM9DS0_MAG_ADDRESS,LSM9DS0_CTRL_REG7_XM, 0b00000000); // Continuous-conversion mode

    // Enable Gyro
    writeTo(LSM9DS0_GYR_ADDRESS, LSM9DS0_CTRL_REG1_G, 0b00001111); // Normal power mode, all axes enabled
    writeTo(LSM9DS0_GYR_ADDRESS, LSM9DS0_CTRL_REG4_G, 0b00110000); // Continuos update, 2000 dps full scale
    }
    else if(LSM9DS1){//For BerryIMUv2
    // Enable the gyroscope
    writeTo(LSM9DS1_GYR_ADDRESS,LSM9DS1_CTRL_REG4,0b00111000); // z, y, x axis enabled for gyro
    writeTo(LSM9DS1_GYR_ADDRESS,LSM9DS1_CTRL_REG1_G,0b10111000); // Gyro ODR = 476Hz, 2000 dps
    writeTo(LSM9DS1_GYR_ADDRESS,LSM9DS1_ORIENT_CFG_G,0b10111000); // Swap orientation

    // Enable the accelerometer
    writeTo(LSM9DS1_ACC_ADDRESS,LSM9DS1_CTRL_REG5_XL,0b00111000); // z, y, x axis enabled for accelerometer
    writeTo(LSM9DS1_ACC_ADDRESS,LSM9DS1_CTRL_REG6_XL,0b00101000); // +/- 16g

    //Enable the magnetometer
    writeTo(LSM9DS1_MAG_ADDRESS,LSM9DS1_CTRL_REG1_M, 0b10011100); // Temp compensation enabled,Low power mode mode,80Hz ODR
    writeTo(LSM9DS1_MAG_ADDRESS,LSM9DS1_CTRL_REG2_M, 0b01000000); // +/-12gauss
    writeTo(LSM9DS1_MAG_ADDRESS,LSM9DS1_CTRL_REG3_M, 0b00000000); // continuos update
    writeTo(LSM9DS1_MAG_ADDRESS,LSM9DS1_CTRL_REG4_M, 0b00000000); // lower power mode for Z axis

    }
    }

    #7929
    jgreen
    Participant

    the function returns -3310

    float readTemp(){
    uint8_t block[2];
    readFrom(LSM9DS1_MAG_ADDRESS, 0x80 | LSM9DS1_OUT_TEMP_H, 2, block);
    int16_t temp = (int16_t)(block[0] | block[1] << 8);
    float temperature_c = (float)temp / 8.0 + 25;
    float temperature_f = temperature_c * 1.8 + 32;
    return temperature_f;
    }

    #7927
    jgreen
    Participant

    'LSM9DS1_OUT_TEMP_H_XM' was not declared in this scope

    I dont see the entry in LSM9DS1.h.  File from https://github.com/ozzmaker/BerryIMU/blob/master/arduino-BerryIMU/LSM9DS1.h

    #7925
    jgreen
    Participant

    2.3  When I run the gyro demo it states LSM9DS1 found

Viewing 4 posts - 1 through 4 (of 4 total)

Blip, blop, bloop...