View previous topic :: View next topic |
Author |
Message |
Krille28
Joined: 08 Nov 2007 Posts: 6
|
Drive a Piezo Transducer with PIC |
Posted: Fri Feb 08, 2008 6:51 am |
|
|
Hi
I´m trying to drive a transducer with my pic182455. It is directly connected to pin B4. The thing is that I cant get it to sound loud. The resonant freq. is 2400Hz.
My code:
Void Beep()
{
for(i=0; i<100; ++i)
{
OUTPUT_HIGH(PIN_B4);
Delay_us(207);
OUTPUT_LOW(PIN_B4);
Delay_us(207);
}
}
Has anyone been able to drive a transducer with PIC? |
|
|
nuwavedc
Joined: 06 Feb 2008 Posts: 17
|
|
Posted: Fri Feb 08, 2008 7:44 am |
|
|
So I take it that it is sounding quietly? I would take a look at the wave form with an oscilliscope and see what it looks like. Driving Piezos with ports never worked well for me.
You would be beter off tying the element between two ports and driving it like an H bridge configuration. Which means that PX1 is set high and PX2 is set low and then PX1 is set low and PX2 is set high. And then the cylcle reverses. This will effectively double the voltage seen by the piezo. Or you can buy a self oscillating type.
I show the mod for your code below just suggesting that the other port tied to the Piezo is B5.
Hope that helps.
Code: |
Void Beep()
{
for(i=0; i<100; ++i)
{
OUTPUT_HIGH(PIN_B4);
OUTPUT_LOW(PIN_B5);
Delay_us(207);
OUTPUT_LOW(PIN_B4);
OUTPUT_HIGH(PIN_B5);
Delay_us(207);
}
}
|
_________________ Thanks,
NuWaveDC |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Feb 08, 2008 8:27 am |
|
|
If you have a spare RS232 driver channel you can drive a piezo much louder with that than a 5V PIC pin. 5V H bridge is good, RS232 is a little better, RS232 H bridge is better still. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
SET
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
|
|
Posted: Fri Feb 08, 2008 9:11 am |
|
|
Quote: | You would be beter off tying the element between two ports and driving it like an H bridge configuration. Which means that PX1 is set high and PX2 is set low and then PX1 is set low and PX2 is set high. And then the cylcle reverses. This will effectively double the voltage seen by the piezo. Or you can buy a self oscillating type. |
Have done this with reasonable results - not ear shattering but easily audible. Be warned though needed a fairly big (25mm dia) device to be Ok. |
|
|
Guest
|
|
Posted: Fri Feb 08, 2008 4:08 pm |
|
|
I had some luck with a PWM port - you can adjust the frequency to get a nice resonance with the transducer - adjust the frequency and duty cycle for the proper harmonic content for that 'Just right' sound.
I had a small 1" transducer and it was loud enough for an instrument - click, click, click for key presses - but it would not have been loud enough for an alarm.
If all you need is user feedback kind of noises - it can be loud enough.
HTH - Steve H. |
|
|
|