This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

About Thingy52 custom firmware: I can't choose accelerometer 16G range

Hi all,

I'm working with Nordic Thingy:52 (nRF6936 with nRF52832 inside).

Currently I'm working with original firmware (I mean, not modified firmware) version 2.1.0. But doing some tests with Thingy52 and nRF connect Android app, I realized that the range of the accelerometer axis is from -G (-9.81) to +G (9.81). So 9.81 is the limit even if I shake strongly the Thingy:52, and I need a higher range.

Taking a look to documentation, I see I can choose the acceleration range, so I decided to modify the firmware.

From "/NordicThingyFW/include/drivers/drv_acc_lis3dh_types.h":

/** @brief Acceleration ranges.
 */
typedef enum
{
  FULLSCALE_2             = 0x00,   ///<  2 G full scale.
  FULLSCALE_4             = 0x01,   ///<  4 G full scale.
  FULLSCALE_8             = 0x02,   ///<  8 G full scale.
  FULLSCALE_16            = 0x03    ///< 16 G full scale.
} Fullscale_t;

I'm not sure what I have to modify from firmware in order to change acceleration range, for instance, to FULLSCALE_16. I have tried unsuccessfully the following:

From "/NordicThingyFW/include/drivers/drv_acc_lis3dh_types.h", on "drv_acc_wakeup_prepare(bool wakeup)" function:

[...]
if(wakeup)
    {
        NRF_LOG_DEBUG("Configuring LIS3DH for wake on motion \r\n");

        uint8_t ctrl_regs[] = {(ODR_100Hz << 4) | CTRL_REG1_LPEN | CTRL_REG1_ZEN | CTRL_REG1_YEN, //| CTRL_REG1_XEN,  // CTRL_REG1
                                CTRL_REG2_FDS | CTRL_REG2_HP_IA1,                                                 // CTRL_REG2
                                CTRL_REG3_I1_IA1,                                                                 // CTRL_REG3
                                0,                                                                                // CTRL_REG4
                                CTRL_REG5_LIR_INT1};                                                              // CTRL_REG5
        uint8_t int1_ths[]  = {ACC_INT1_THRESHOLD,                                                                // INT1_THS
                               ACC_INT1_DURATION};                                                                // INT1_DURATION
        uint8_t int1_cfg[]  = {INT1_CFG_ZHIE | INT1_CFG_YHIE | INT1_CFG_XHIE};                                    // INT1_CFG

        err_code = lis3dh_write_regs(CTRL_REG1, ctrl_regs, (sizeof(ctrl_regs)/sizeof((ctrl_regs)[0])));
        RETURN_IF_ERROR(err_code);
[...]

I have modified CTRL_REG4 adding CTRL_REG4_FS0 and CTRL_REG4_FS1:

if(wakeup)
    {
        NRF_LOG_DEBUG("Configuring LIS3DH for wake on motion \r\n");

        uint8_t ctrl_regs[] = {(ODR_100Hz << 4) | CTRL_REG1_LPEN | CTRL_REG1_ZEN | CTRL_REG1_YEN, //| CTRL_REG1_XEN,  // CTRL_REG1
                                CTRL_REG2_FDS | CTRL_REG2_HP_IA1,                                                 // CTRL_REG2
                                CTRL_REG3_I1_IA1,                                                                 // CTRL_REG3
                                CTRL_REG4_FS1 | CTRL_REG4_FS0,                                                    // CTRL_REG4 Modified: FullScale_16
                                CTRL_REG5_LIR_INT1};                                                              // CTRL_REG5
        uint8_t int1_ths[]  = {ACC_INT1_THRESHOLD,                                                                // INT1_THS
                               ACC_INT1_DURATION};                                                                // INT1_DURATION
        uint8_t int1_cfg[]  = {INT1_CFG_ZHIE | INT1_CFG_YHIE | INT1_CFG_XHIE};                                    // INT1_CFG

        err_code = lis3dh_write_regs(CTRL_REG1, ctrl_regs, (sizeof(ctrl_regs)/sizeof((ctrl_regs)[0])));
        RETURN_IF_ERROR(err_code);

But this doesn't work. In the nRF Connect app I see the same limit in 9.81.

Any help?

Thank you,

Manuel Montenegro.

Parents
  • Hi Manuel,

    You are currently modifying the low power accelerometer, which is only used for waking up the Thingy device. You will need to use the other accelerometer on the Thingy device.

    I am not sure that you will need to make any changes to the code itself. I do not believe there is a n accelerometer limit in the Thingy SDK either. There could be some kind of limit in the nRF Connect apps maybe. I have tested with both iOS & Android using the Thingy apps & nRF Connect for Mobile. I was also unable to get a reading higher than +9.81 or -9.81 m/s^2. Whether this is due to a limit in the app itself or whether it is difficult for me to see a value higher than the acceleration of gravity, I am not so sure.

    I have tried to increase the .motion_freq_hz in the MOTION_DEFAULT_CONFIG define in m_motion.h from 10 to 100. If you combine that with using nRF Connect for Desktop, you can connect to your Thingy device, read the gravity values & download the log. The log values are unfortunately given in hexadecimal values, so you will need to figure out a way of converting the values with a script or going through the log itself to see if you can find a value greater than g. Hope that helps a bit!

    Kind Regards,

    Bjørn

Reply
  • Hi Manuel,

    You are currently modifying the low power accelerometer, which is only used for waking up the Thingy device. You will need to use the other accelerometer on the Thingy device.

    I am not sure that you will need to make any changes to the code itself. I do not believe there is a n accelerometer limit in the Thingy SDK either. There could be some kind of limit in the nRF Connect apps maybe. I have tested with both iOS & Android using the Thingy apps & nRF Connect for Mobile. I was also unable to get a reading higher than +9.81 or -9.81 m/s^2. Whether this is due to a limit in the app itself or whether it is difficult for me to see a value higher than the acceleration of gravity, I am not so sure.

    I have tried to increase the .motion_freq_hz in the MOTION_DEFAULT_CONFIG define in m_motion.h from 10 to 100. If you combine that with using nRF Connect for Desktop, you can connect to your Thingy device, read the gravity values & download the log. The log values are unfortunately given in hexadecimal values, so you will need to figure out a way of converting the values with a script or going through the log itself to see if you can find a value greater than g. Hope that helps a bit!

    Kind Regards,

    Bjørn

Children
Related