Play Tune on Piezo Buzzer Using PWM

Hello Nordic Team,

I am doing development in nrf52832 DK for playing Piezo Buzzer for generate some Tones or Tunes using PWM.

Currently I am using SDK 17.1.0 SES.

My Piezo Buzzer Part number is AB1560B.

I have also used PAM8904Q piezo sounder driver.

I have also try SDK example pwm_library. I am able to generate beep sound but I want to create some tones. In PWM example we just change duty cycle ( 0% to 50%) but for creating tune i need to change multiple frequency.

I have refer arduino-project for playing tunes. It is perfectly working in arduino.

Same like arduino, I want to play tune using nRF52832. So, How I create these kind of multi frequency to create tone in nrf52.

Note : 

char notesName[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };

these are represent the frequency like 1915 Hz , 1700 Hz, 1519 Hz like that.

 

I've read different multiple posts related to this in this forum. 

1)   PWM with a piezo buzzer,How can I change the PWM frequency? 

2)  PWM with a piezo buzzer,How can I change the PWM frequency? 

3)  RE: Changing Buzzer BEEP to tone 

4) PWM Audio driver 

5)   PWM code for a piezo buzzer 

6) Tone Library

7) https://devzone.nordicsemi.com/search?q=play%20piezo%20buzzer%20using%20pwm%20in%20nrf52

 

Among that some posts are before 9 or 10 years which I can't build in my nRF52 DK Board and some of them are just moving one case to another case so i am still confused about how to set up PWM to generate tunes signal.

Can you please provide some relevant posts or anything documents or examples ?

Thank you in advance for your assistance!

Parents Reply Children
  • I appreciate your guidance, Jonathan.

    I mention earlier I have already explored SDK PWM Library example pwm_library. Using that I am able to generate beep sound and i have also try to changing duty cycle but I didn't get expected output, According to PWM principles, it should alter the intensity of the Piezo Buzzer, but the output didn't meet my requirements.

    I also examined your microbit piano demo example. It's looking same, but unfortunately, it doesn't align with the nRF52832 Development Board (Devlop code into Segger Embedded Studio). Additionally, it utilizes more than one GPIO pin for generating different frequencies, contrary to my project's specification where I need to achieve this using just one GPIO pin using PWM.

    Mention above I have refer Arduino Project : https://github.com/giacomocerquone/arduino-projects/blob/master/arduino-jingle-bells/arduino-jingle-bells.ino

    that successfully generate various frequencies using PWM on a single GPIO pin & also it's create specific rhythms or tunes, precisely what I need for my application.

    I regret to inform you that, I have found similar queries which raise in this forum dating back 7 to 8 years and 4 to 5 years but still viable solutions not available.

    Regards,
    Anil Rathod

  • Sorry Anil, but this is what we currently have, there will be no new updates for the nRF5 SDK in terms of PWM examples. I would recommend to change to the nRF Connect SDK as this is our current focus. 

    But the nRF5 SDK should do the job and if you follow the recommendations form hmolesworth as well it would get you quite far. 

    Regards,
    Jonathan

Related