Interfacing a buzzer with CPLD - Page 1
Forum section: electronics / general

author: garvind25
author_rank: Regular Contributor
timestamp: March 25, 2018, 03:59:17 pm
content: 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.pWHLW8I 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.

author: ebastler
author_rank: Super Contributor
timestamp: March 25, 2018, 04:43:50 pm
content: 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.

author: rstofer
author_rank: Super Contributor
timestamp: March 25, 2018, 08:38:26 pm
content: If it really is a Piezo Buzzer, and it seems like it is, maybe this will helphttps://www.pantechsolutions.net/fpga-tutorials/how-to-interface-buzzer-with-fpga-cpld-udbYour CPLD will need to wiggle the pin at the appropriate frequencies.http://www.sengpielaudio.com/calculator-notenames.htmDon't try to drive a 16 Ohm load from the CPLD pin.

author: technix
author_rank: Super Contributor
timestamp: March 27, 2018, 03:14:05 am
content: 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.

author: garvind25
author_rank: Regular Contributor
timestamp: March 29, 2018, 10:11:42 am
content: 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 CPLDThanks again,Arvind Gupta

author: technix
author_rank: Super Contributor
timestamp: March 29, 2018, 11:14:29 am
content: Quote from: garvind25 on March 29, 2018, 10:11:42 amIf 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.

author: SiliconWizard
author_rank: Super Contributor
timestamp: March 30, 2018, 12:33:10 pm
content: 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.

author: garvind25
author_rank: Regular Contributor
timestamp: April 01, 2018, 04:15:40 pm
content: 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.Regards,Arvind Gupta