Author Topic: Interfacing a buzzer with CPLD  (Read 1839 times)

0 Members and 1 Guest are viewing this topic.

Offline garvind25Topic starter

  • Regular Contributor
  • *
  • Posts: 59
  • Country: in
Interfacing a buzzer with CPLD
« on: March 25, 2018, 03:59:17 pm »
Hi,

  I wanted to connect a buzzer with an I/O pin of CPLD (XC2C128 – VQ 100 package). The I/O pin will be driven at 3.3v (LVCMOS logic levels). How should I connect the buzzer: directly connect the positive terminal of the buzzer to the I/O pin with a series resistance or use a npn transistor to drive the buzzer as a load to the collector of the transistor. I only need to have a continuous beep when required. I am planning to use the buzzer as per the link as below:

https://www.aliexpress.com/item/5PCS-Lot-Passive-Buzzer-AC-12MM-8-5MM-12085-16R-Resistance-3V-5V-9V-12V-In/32503620431.html?spm=a2g0s.13010208.99999999.263.pWHLW8

 I could not find its datasheet. Does anyone have any prior experience with such devices pls? To be specific, how much minimum current does it require for a beep?

Thanks and Regards,
Arvind Gupta.

 

Online ebastler

  • Super Contributor
  • ***
  • Posts: 6205
  • Country: de
Re: Interfacing a buzzer with CPLD
« Reply #1 on: March 25, 2018, 04:43:50 pm »
Not sure whether you are aware of it: The buzzer you have selected is described as a "passive buzzer" and an "AC buzzer" by the seller. That means that you cannot simply apply DC voltage to it to get a tone output -- you need to toggle the driving line low and high at the sound frequency you want.

That has the advantage that you can control the frequency (within limits; the buzzer will have a resonance frequency, and if you are too far away from that, it will not be very loud). But you will need to provide suitable logic on your CPLD to create the alternating drive signal.

There are "active buzzers" which will create a tone when a DC voltage is applied. In general, if you are not very familiar with these devices, I would recommend to order them from a seller who provides a complete description and specifications; that may not be an Aliexpress seller.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9886
  • Country: us
Re: Interfacing a buzzer with CPLD
« Reply #2 on: March 25, 2018, 08:38:26 pm »
If it really is a Piezo Buzzer, and it seems like it is, maybe this will help

https://www.pantechsolutions.net/fpga-tutorials/how-to-interface-buzzer-with-fpga-cpld-udb

Your CPLD will need to wiggle the pin at the appropriate frequencies.

http://www.sengpielaudio.com/calculator-notenames.htm

Don't try to drive a 16 Ohm load from the CPLD pin.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Interfacing a buzzer with CPLD
« Reply #3 on: March 27, 2018, 03:14:05 am »
That thing is effectively a 16 ohm speaker. If you want to drive it, treat it as a speaker and use an audio output power amplifier, and drive it with an audio signal. I would suggest use your CPLD to generate either a PWM signal or a I2S stream. For PWM signal it goes directly to a MOSFET switching power amplifier and low pass filter, making it a Class-D output. For I2S you need an external DAC and a set of proper analog amplifiers and buffers.
 

Offline garvind25Topic starter

  • Regular Contributor
  • *
  • Posts: 59
  • Country: in
Re: Interfacing a buzzer with CPLD
« Reply #4 on: March 29, 2018, 10:11:42 am »
Thanks for your replies. As I understood from the posts, for driving an AC buzzer, I will require to generate a square pulse of particular frequency. By changing the frequency of the driving signal, various sound pitches can be generated. I hope my understanding is correct.

In that case, if I wanted to play a song (suppose) through the buzzer, I would have to continuously change the output frequency at the CPLD pin. Is there any standard programming technique to do so (in VHDL). I could see from the links posted that every note (in music) has a corresponding frequency. Hence, if I have the notes of the song, I can maybe play the song through the CPLD  :D

Thanks again,
Arvind Gupta
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Interfacing a buzzer with CPLD
« Reply #5 on: March 29, 2018, 11:14:29 am »
Thanks for your replies. As I understood from the posts, for driving an AC buzzer, I will require to generate a square pulse of particular frequency. By changing the frequency of the driving signal, various sound pitches can be generated. I hope my understanding is correct.

In that case, if I wanted to play a song (suppose) through the buzzer, I would have to continuously change the output frequency at the CPLD pin. Is there any standard programming technique to do so (in VHDL). I could see from the links posted that every note (in music) has a corresponding frequency. Hence, if I have the notes of the song, I can maybe play the song through the CPLD  :D

Thanks again,
Arvind Gupta
If you are playing a song through it, it might be better to implement a I2S and use an external DAC. The I2S sends out audio samples over a serial link.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14309
  • Country: fr
Re: Interfacing a buzzer with CPLD
« Reply #6 on: March 30, 2018, 12:33:10 pm »
If you need this kind of buzzer and are ok with the sound quality you're going to get out of it, I'd suggest using a piezo buzzer, which actually can approx. be seen as equivalent to a capacitive load. A lot of those small buzzers will have capacitances in the audio range that will give you a much higher impedance, usually in the kohm range, which will usually allow you to drive them directly with digital I/Os. The best arrangement I've used is to drive them with a complementary output (two digital outputs with opposite phase).

Regarding outputing arbitrary signals, the most common way of doing this is to use PWM. You can then feed samples to your PWM generator. Depending on the PWM frequency, the sound quality will be kind of poor but it may be adequate for such buzzers anyway. You would get much better results by implementing a delta-sigma modulator. You can easily find DSM implementations in VHDL and Verilog. But if your sound quality requirements are modest, PWM will do the job.
« Last Edit: March 30, 2018, 12:38:05 pm by SiliconWizard »
 

Offline garvind25Topic starter

  • Regular Contributor
  • *
  • Posts: 59
  • Country: in
Re: Interfacing a buzzer with CPLD
« Reply #7 on: April 01, 2018, 04:15:40 pm »
Thanks for all the explanations. Presently I will settle for a PCB mountable DC buzzer. Can anyone suggest any low cost buzzers on the internet pls.  :D

Regards,
Arvind Gupta
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf