What is the correct way to connect a buzzer to my PIC and do I just put it<br>
HIGH, LOW to switch it on and off or is there a better way of doing this?
And what is the differece between a buzzer and a piezo sounder?
What is the correct way to connect a buzzer to my PIC and do I just put it<br>
HIGH, LOW to switch it on and off or is there a better way of doing this?
And what is the differece between a buzzer and a piezo sounder?
Hi Koossa,
I always use a GP transistor to drive either a buzzer or piezo. I think the differences are 1) the sound they make and 2) buzzers are more mechanical and a piezo is not. I was hoping someone else would jump on your question before me but since that didn't happen I thought I would take a shot at it.
I think the buzzer issue also has to take into consideration what size buzzer you are using and how much current does it draw. This,of course, would then determine the type of driver you will need.
I have some small 6volt buzzers that I bought from Jameco and a 2n2222a is just fine for driving it. I also use the same driver on my piezos.
Hope this helps.
BobK
A buzzer is a coil with a mechanical interrupter. When you apply a voltage, the coil energises, mechanically moves a core (usually soft iron) which in turn breaks a contact. The core moves back, contact is made once again and the process starts all over again. The core is usually connected to a sounding board (in better buzzers) to produce the noise, or in cheaper buzzers they just let the core movement produce the noise.
The upside of the buzzer is you just apply volts and it works. The downside is that you have a COIL which is being switched on/off by it's own integral interruptor. This means (a) it's relatively power hungry, usually more than the 25mA maximum a PIC can drive, (b) in most cases requires more than 5v to drive to make a decent noise, but more importantly (c) the crappy ones can produce a significant back-emf which can easily destroy a transistor (or PIC pin) if you don't put a suppression diode across them. Connect a junk Buzzer (or use a Relay cross-connected in series with it's own contacts) to a Battery, and put your fingers across the Battery - the result is the kind of thing you use in prisoner interrogation (or job interviews) where they don't have handy AC volts comming out of the wall (you get the best tips and tricks on this forum - mention it in your Resume when you're applying for your next CIA job).
A piezo sounder is a piece of crystal which changes shape (moves) when you apply a voltage across it (kinda like when you get strapped into old sparky). The movement is constant depending on the mechanical properties of the crystal.
The upside of the piezo sounder is (a) low power, they have an impedance of meghoms therefore require next to no current to drive them, (b) they DO require a voltage to excite the piezo material but it can be as low as 1.5v, (c) they make a hell of a noise when you hit their resonant frequency. The downside is (a) they require being pulsed AT their resonant frequency (ie if it's a 4kHz piezo, they need to be driven at 4kHz), and (b) if you don't feed them with their desired frequency as a drive signal, the noise they produce is quite miserable.
I never use buzzers with PICs because they're mechanically large, need suppression, and are power hungry so require additional circuitry to drive them.
However with piezo's, the secret is you MUST hit that resonant frequency. In one application I used to drive a piezo sounder at 35v in order to get the sound output I desired. Only later I discovered my drive was off by some 300Hz, and by adjusting the software and hitting the right frequency I can now get the same output from the sounder at 5v direct from the PIC only going through a 100nF Capacitor.
Hi Melanie
Thank you very much for the explanation, now I understand better.
I think I will defenately use the piezo's.
My piezo only use 1mA.
I'm using the PWM function to produce a beep on a piezo.
Will it be correct if I use the schematic displayed at the PWM section in the Picbasic Pro Manual.
Currently I have connected the piezo directly between PortC.2 and GND and then in my code use <b>PWM PORTC.2,230,7</b>.
Will this configuration of connecting the piezo directly between PortC.2 and GND affect my circuit in any way?
I normally connect a Piezo via a 100nF Capacitor (same sort I use for decoupling on my PCB's) because I once met a brand of Piezo's that randomly 'hung' when connected directly. See schematic. The Higher drive level option requires having one pin go High and the other Low alternatively. You can achieve this by manipulating the pins directly (you won't drive this conventionally 'as is' by using the PWM or HPWM commands).
I have read Mel's explanation about how to connect piezos.
So I made this project as you can see it here. It is connected in parallel with an electric doorlock.<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3886&stc=1&d=126354649 5">
*don't trust the PIC's pins connections on this shema - I used a 12F675 component in EAGLE just for the drawing - I couldn't find a 10F202.
When I power the circuit with 6 to 8V DC for testing, it works fine and the piezo sounds loud and clear.
When the circuit is connected to the AC power supply that goes up to 18VAC, no sound comes from the piezo anymore (?!).
The strange thing is, the piezo seems to affect the voltage regulator ability to provide a stable 5V. In fact, the voltage regulator doesn't supply a constant 5VDC but goes up to 7VDC.
I added a decoupling 100nF (in fact, I connected different capas for test - none did the trick) capacitor in serie with the piezo but this didn't change anything.
I replaced the piezo by a 5V led and then, the voltage regulator has no problem and feeds a steady 5VDC while the circuit is fed with 18VAC.
My oscilloscope shows some disturbances on the output of the voltage regulator when the piezo is connected and nothing with the led. But how do I get rid of them?
Any idea what the piezo does?
My piezo's datasheet is here: http://datasheet.octopart.com/HGP-05...eet-580811.pdf
Roger
It's got a COIL - which means it's NOT a Piezo.
What you have is basically a poor-mans Loudspeaker (as opposed to a Buzzer). It's frequency response is dependent on it's mechanical construction.
OHMS LAW... how much current is it going to suck?
Is it going to generate a Back-EMF?
Your poor Regulator at the higher voltage supply is going to have a hard time feeding the PIC and the Sounder which incidentally will most probably introduce a lot of horrible noise on the Supply line adversely affecting the PIC.
This is a poor choice of device for any low-current application. For best efficiency, you're going to have to adjust your circuit and drive the device more like the way you would an Audio Loudspeaker.
Thanks Melanie,
I'm feeling stupid not having noticed my piezo ...is not a piezo
I better understand all other of my problems with this circuit now.
Roger
Dear Melanie,
You forum has lots of interesting informations. Thanks for keeping upto-date information.
I have a problem. I got a piezo buzzer from a smoke detecting alarm.
I like to use it in my PIC based circuit.
This buzzer has three wires. (red, black & white)
Can you suggest why there are three wires. I guess red for +, and blank for -.
Since this one is sealed I am unable to go thru.
Please help me.
DOminic
Riyadh
Saudi Arabia
First make sure it's the Piezo you've got - and not the Sensor.
The three wire devices usually employ the third wire to change the tone. When connected to Vdd you'll get one tone, and when connected to 0v you get another. That's the way they get the 'warbling' effect for the Alarm sound.
Other more sophisticated Piezo's allow the sychronisation of several sounders - and they use the third wire for that purpose. You'll know that is the type if the original smoke alarm had an additional conector for connecting to additional alarms.
Experiment and see what you get...
Bookmarks