This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

About Full-Scale Range setting of Gyroscope in CC2650 SensorTag

Other Parts Discussed in Thread: CC2650, CC2541

Hello,

I am developing my project by referring to CC2650 SensorTag and its official project source code. In the source code, there are corresponding functions or statements which set full scale range and resolution parameters of accelerometer and magnetometer respectively. However, I could not find any key word related to full scale range setting of gyroscope. Besides, I have read this post "e2e.ti.com/.../402228", but I could not find the file they mentioned. I wonder if there is any existing function with feature changing this parameter in source code.

Could someone help me ? Any suggestion will be appreciated.


Thank you.

  • Hi Bohan,

    The post you link to tells you exactly how to do it.

    Cheers,
    Fredrik
  • Hi, Fredrik

    Thanks for your reply. However, as I mentioned in my original post, I could not find file named "hal_gyro.h" and any "HalGyroXXX" functions, either.

    Thank you.

  • The link is for cc2541. Where can the procedure for changing gyroscope range for cc2650 be found???
  • Hi, Vamsi

    I think there is no such APIs in current project source code. However, you can implement it by referring to accelerometer.

    The following code is a snippet of my implement in sensor_mpu9250.h and sensor_mpu9250.c. Maybe, it is not elegant one but it works.

    #define GYRO_RANGE_250        0
    #define GYRO_RANGE_500        1
    #define GYRO_RANGE_1000      2
    #define GYRO_RANGE_2000      3

    static uint8_t gyroRange;
    static uint8_t gyroRangeReg;

    /*******************************************************************************
    * @fn sensorMpu9250GyroSetRange
    *
    * @brief Set the range of the gyroscope
    *
    * @param newRange: GYRO_RANGE_250, GYRO_RANGE_500, GYRO_RANGE_1000, GYRO_RANGE_2000
    *
    * @return true if write succeeded
    */
    bool sensorMpu9250GyroSetRange(uint8_t newRange)
    {

    bool success = false;

    if (newRange == gyroRange)
        return true;

    if (!SENSOR_SELECT())
    {
        return false;
    }

    // Clear bit 3 and 4 first
    gyroRangeReg = ((gyroRangeReg & (~(0x18))) | (newRange << 3));

    // Apply the range
    success = sensorWriteReg(GYRO_CONFIG, &gyroRangeReg, 1);
    SENSOR_DESELECT();

    if (success)
        gyroRange = newRange;

    return success;


    }

    /*******************************************************************************
    * @fn sensorMpu9250GyroReadRange
    *
    * @brief Set the range of the gyroscope
    *
    * @param none
    *
    * @return ange: GYRO_RANGE_250, GYRO_RANGE_500, GYRO_RANGE_1000, GYRO_RANGE_2000
    */
    uint8_t sensorMpu9250GyroReadRange(void)
    {


    if (!SENSOR_SELECT())
    {
        return false;
    }

    // Apply the range
    sensorReadReg(GYRO_CONFIG, &gyroRangeReg, 1);
    SENSOR_DESELECT();

    gyroRange = (gyroRangeReg>>3) & 3;

    return gyroRange;


    }

    Variables gyroRange and gyroRangeReg are mainly for restoring purpose. Besides, bit 0 ~ 1 of gyroscope configuration register are for Fchoice_b. I am not sure what it is and if it is used or not, so I prefer to keeping it untouched. For this purpose, I invocate sensorMpu9250GyroReadRange() before sensorMpu9250GyroSetRange(). However, you can modify this as you need.

    Hope this helps.

  • Hi Bohan,
    I have used sensorMpu9250GyroSetRange() in the sensorMpu9250Init() function just like sensorMpu9250AccSetRange is used in the function. But I don't see any change in the range as I checked the raw values. What could be the reason for this??

    bool sensorMpu9250Init(void)
    {
    bool ret;

    #ifdef WOM_ENABLE
    isWomEnabled = false;
    #endif
    accRange = ACC_RANGE_INVALID;
    mpuConfig = 0; // All axes off

    if (!SENSOR_SELECT())
    {
    return false;
    }

    // Device reset
    val = 0x80;
    sensorWriteReg(PWR_MGMT_1, &val, 1);
    SENSOR_DESELECT();

    delay_ms(100);

    ret = sensorMpu9250Test();
    if (ret)
    {
    // Initial configuration
    sensorMpu9250AccSetRange(ACC_RANGE_8G);

    //Added by Vamsi Krishna
    sensorMpu9250GyroSetRange(GYRO_RANGE_2000);
    //--

    #ifdef FEATURE_MAGNETOMETER
    sensorMagInit();
    #endif
    // Power save
    sensorMpuSleep();
    }

    return ret;
    }
  • Hi, Vamsi

    If you have debug tool, you could check the value of register again after you set.
    In my case, register is set correctly, and my colleague told me that it had some improvement but just a little... XD
    Sorry, I don't know much about sensor behavior, so I cannot tell you if this little improvement is correct or just a variation.
    I just can check it from H/W side. Maybe, this is the reason why this function is not supported currently.
    Experts on TI EE might give us a better suggestion or advice.

    Thanks
  • Hi Vamsi,

    Did you mange to set the resolution of the Gyroscope sensor? If so can you tell me how did you change the resolution? I am also trying to change the firmware to change the resolution of the gyroscope sensor.

    Thanks,
    Fazlay