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

BLE CSCS cadence value problem

HI

I am working with BLE CSCS example, and I found some problem during read cadence value. Simulator is changing values and I am observing situation: if cadence value is less than 50rpm occasionally shows 0rpm. I think that it occured when cumulative_crank_revs is not incerement during 1 seceond (BICYCLE_POWER_MEAS_INTERVAL).

Have anyone meet the same problem ?

Parents
  • Ok, can you please specify the following?

    Is it the "ble_app_cscs" example  you are referring to?

    By "cadence value", do you mean crank rev?

    What is "BICYCLE_POWER_MEAS_INTERVAL"?

  • My code (using SDK version 12.1.0) looks like this;

    static void csc_sim_measurement(ble_cscs_meas_t * p_measurement)
    {
        static uint16_t cumulative_crank_revs = 0;
        static uint16_t event_time            = 0;
        static uint16_t wheel_revolution_mm   = 0;
        static uint16_t crank_rev_degrees     = 0;

        uint16_t mm_per_sec;
        uint16_t degrees_per_sec;
        uint16_t event_time_inc;

        // Per specification event time is in 1/1024th's of a second.
        event_time_inc = (1024 * SPEED_AND_CADENCE_MEAS_INTERVAL) / 1000;

        // Calculate simulated wheel revolution values.
        p_measurement->is_wheel_rev_data_present = true;

        mm_per_sec = KPH_TO_MM_PER_SEC * sensorsim_measure(&m_speed_kph_sim_state,
                                                           &m_speed_kph_sim_cfg);

        wheel_revolution_mm     += mm_per_sec * SPEED_AND_CADENCE_MEAS_INTERVAL / 1000;
        m_cumulative_wheel_revs += wheel_revolution_mm / WHEEL_CIRCUMFERENCE_MM;
        wheel_revolution_mm     %= WHEEL_CIRCUMFERENCE_MM;

        p_measurement->cumulative_wheel_revs = m_cumulative_wheel_revs;
        p_measurement->last_wheel_event_time =
            event_time + (event_time_inc * (mm_per_sec - wheel_revolution_mm) / mm_per_sec);

        // Calculate simulated cadence values.
        p_measurement->is_crank_rev_data_present = true;

        degrees_per_sec = RPM_TO_DEGREES_PER_SEC * 40;

        crank_rev_degrees     += degrees_per_sec * SPEED_AND_CADENCE_MEAS_INTERVAL / 1000;
        cumulative_crank_revs += crank_rev_degrees / DEGREES_PER_REVOLUTION;
        crank_rev_degrees     %= DEGREES_PER_REVOLUTION;

        p_measurement->cumulative_crank_revs = cumulative_crank_revs;
        p_measurement->last_crank_event_time =
            event_time + (event_time_inc * (degrees_per_sec - crank_rev_degrees) / degrees_per_sec);

        event_time += event_time_inc;
    }

    Perhaps you could try replace your code with the code above.

  • Now I am using stock examle from SDK15. Just hardoce crank revolution = 40;

     // Calculate simulated cadence values.
        p_measurement->is_crank_rev_data_present = true;

        degrees_per_sec = RPM_TO_DEGREES_PER_SEC * 23; //sensorsim_measure(&m_crank_rpm_sim_state, &m_crank_rpm_sim_cfg);

        crank_rev_degrees     += degrees_per_sec * SPEED_AND_CADENCE_MEAS_INTERVAL / 1000;
        cumulative_crank_revs += crank_rev_degrees / DEGREES_PER_REVOLUTION;
        crank_rev_degrees     %= DEGREES_PER_REVOLUTION;

        p_measurement->cumulative_crank_revs = cumulative_crank_revs;
        p_measurement->last_crank_event_time =
            event_time + (event_time_inc * (degrees_per_sec - crank_rev_degrees) / degrees_per_sec);

        event_time += event_time_inc;

    Plese look for screen recorder from Android app:

    https://youtu.be/YAJQy5uj--E

  • It looks like you have a different application than the one I'm using. Try downloading the "nRF Toolbox for BLE" application on your phone, and see if the problem persists.

  • I look like everything is fine with nRf Toolbox. But when I am using third-party app like "Strava", "Wahoo fitness" "Motosumo" this bug occured.

  • I suggest you use the nRF toolbox application with the cscs example. If you need your own functionality, you can implement it yourself by using the source code for the nRF toolbox found here,

    github.com/.../Android-nRF-Toolbox
    github.com/.../IOS-nRF-Toolbox

Reply Children
Related