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

Power consumption using PWM powering a Piezo buzzer

Hi,

Currently I am sounding a simple beep on and off sound with a Piezo Buzzer on the nRF52832 and using the power profiler, it is consuming approx 713.323 μA, I was wondering it that sound a bit on the high side, and if so, what kind of recommendations I should be following to try and lower this output.

Thanks in advance for your help.

Jason Anderssen

Parents
  • Hi,

    It is difficult to say weather that is high or not without knowing more about the buzzer and how you drive it. Can you provide a bit more info?  Also, what is the current consumption of your device if you disconnect the buzzer but keeps everything else the same?

  • Hi Einar,

    Thanks for your reply, my code is as follows, basically I create a timer, so every 1/2 a second, it calls play_buzzer_alert, but before the timer starts, I call the start_buzzer_alert() once.  Before the sounds, I am running at approx 14μA, hope that clarifies things a bit better.  I am always happy to hear a better way to do the following if you have one.

    static void start_buzzer_alert()

    {   

        if (buzzer_emergency_active)

            return;

    #ifdef DEVELOPMENT_BOARD

        app_pwm_config_t pwm_alert_cfg = APP_PWM_DEFAULT_CONFIG_1CH(1000L, 31);

        uint8_t pwm_alert_channel = 0;

    #else

        app_pwm_config_t pwm_alert_cfg = APP_PWM_DEFAULT_CONFIG_2CH(1000L, SPEAKER_HZ, SPEAKER_2);

        uint8_t pwm_alert_channel = 1;

    #endif

        

        pwm_alert_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH;

        

        app_pwm_init(&PWM1, &pwm_alert_cfg, pwm_ready_callback);

        app_pwm_enable(&PWM1);

        

        alert_buzzer_value = 50;

        buzzer_play_count = 10;

        buzzer_emergency_active = true;

        while (app_pwm_channel_duty_set(&PWM1, pwm_alert_channel, alert_buzzer_value) == NRF_ERROR_BUSY);

    }

    static void play_buzzer_alert()

    {

        if (beacon_state != MODE_EMERGENCY)

            return;

        if (alert_buzzer_value == 0) {

            alert_buzzer_value = 50;

        } else {

            alert_buzzer_value = 0;

        }

        if (buzzer_play_count == 0) {

            alert_buzzer_value = 0;

        } else {

            // for now we do continuing beeps, as if we try and uninit here, it seems to cause issues in the beacon.

            //buzzer_play_count--;

        }   

    #ifdef DEVELOPMENT_BOARD

        uint8_t pwm_alert_channel = 0;

    #else

        uint8_t pwm_alert_channel = 1;

    #endif

        while (app_pwm_channel_duty_set(&PWM1, pwm_alert_channel, alert_buzzer_value) == NRF_ERROR_BUSY);

    }

    static void stop_buzzer_alert()

    {

        if (buzzer_emergency_active == false)

            return;

        if (beacon_state == MODE_EMERGENCY)

            return;

        app_pwm_disable(&PWM1);

        app_pwm_uninit(&PWM1);

        buzzer_play_count = 0;

        buzzer_emergency_active = false;

    }

    Thanks

    Jason

Reply
  • Hi Einar,

    Thanks for your reply, my code is as follows, basically I create a timer, so every 1/2 a second, it calls play_buzzer_alert, but before the timer starts, I call the start_buzzer_alert() once.  Before the sounds, I am running at approx 14μA, hope that clarifies things a bit better.  I am always happy to hear a better way to do the following if you have one.

    static void start_buzzer_alert()

    {   

        if (buzzer_emergency_active)

            return;

    #ifdef DEVELOPMENT_BOARD

        app_pwm_config_t pwm_alert_cfg = APP_PWM_DEFAULT_CONFIG_1CH(1000L, 31);

        uint8_t pwm_alert_channel = 0;

    #else

        app_pwm_config_t pwm_alert_cfg = APP_PWM_DEFAULT_CONFIG_2CH(1000L, SPEAKER_HZ, SPEAKER_2);

        uint8_t pwm_alert_channel = 1;

    #endif

        

        pwm_alert_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH;

        

        app_pwm_init(&PWM1, &pwm_alert_cfg, pwm_ready_callback);

        app_pwm_enable(&PWM1);

        

        alert_buzzer_value = 50;

        buzzer_play_count = 10;

        buzzer_emergency_active = true;

        while (app_pwm_channel_duty_set(&PWM1, pwm_alert_channel, alert_buzzer_value) == NRF_ERROR_BUSY);

    }

    static void play_buzzer_alert()

    {

        if (beacon_state != MODE_EMERGENCY)

            return;

        if (alert_buzzer_value == 0) {

            alert_buzzer_value = 50;

        } else {

            alert_buzzer_value = 0;

        }

        if (buzzer_play_count == 0) {

            alert_buzzer_value = 0;

        } else {

            // for now we do continuing beeps, as if we try and uninit here, it seems to cause issues in the beacon.

            //buzzer_play_count--;

        }   

    #ifdef DEVELOPMENT_BOARD

        uint8_t pwm_alert_channel = 0;

    #else

        uint8_t pwm_alert_channel = 1;

    #endif

        while (app_pwm_channel_duty_set(&PWM1, pwm_alert_channel, alert_buzzer_value) == NRF_ERROR_BUSY);

    }

    static void stop_buzzer_alert()

    {

        if (buzzer_emergency_active == false)

            return;

        if (beacon_state == MODE_EMERGENCY)

            return;

        app_pwm_disable(&PWM1);

        app_pwm_uninit(&PWM1);

        buzzer_play_count = 0;

        buzzer_emergency_active = false;

    }

    Thanks

    Jason

Children
Related