PDA

View Full Version : Propeller and piezo



computer guy
01-31-2008, 02:55 PM
Hi everyone,

What is the easiest way to connect a piezo speaker up to a propeller chip?
The piezo I have is 5v.


Thank you http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR (http://robot.tmcp.com.au)
If you like my avatar then check this out Propeller Domed Sticker (http://forums.parallax.com/showthread.php?p=701193)

OzStamp
01-31-2008, 03:06 PM
Hi

I would use a transistor like a 2n3904 or bc337 or similar with a 1K base resistor.
These are NPN transistor..

Supply the piezo speaker with 5VDC on 1 wire and the other wire switch it to GND

Driving it direct from an output pin might work but the volts is a little low..

Your stuff left today as well to DeniL.... cheers Ron

computer guy
01-31-2008, 03:15 PM
Thanks Ron,

That sounds like a good idea.

@OzStamp

Just to illustrate how sparse electronics shops are around here I will tell you a quick story.

I walked into Jaycar in Shepparton the other day and asked if they had any variable resistors and they said no so I asked for some wire ties and they said they had none of them either.

So I might have to source a 2n3904 transistor online.
It is a shame, I only ordered some electronics online the other day. http://forums.parallax.com/images/smilies/cry.gif

Thanks http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR (http://robot.tmcp.com.au)
If you like my avatar then check this out Propeller Domed Sticker (http://forums.parallax.com/showthread.php?p=701193)

deSilva
01-31-2008, 04:33 PM
To boost the voltage swing you can connect the piezo to two Propeller pins, alternating their polarity, This will give 4 fold power U2/R

computer guy
01-31-2008, 05:05 PM
deSilva,

Thank you, however four-fold power sounds like it would be complex to implement. http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR (http://robot.tmcp.com.au)
If you like my avatar then check this out Propeller Domed Sticker (http://forums.parallax.com/showthread.php?p=701193)

Beau Schwabe (Parallax)
02-01-2008, 04:55 AM
computer guy (http://forums.parallax.com/member.php?u=48345),

You can't drive a piezo with an open collector configuration without some sort of leakage resistor across the piezo.
The reason is because the piezo crystal behaves like a capacitor... In open collector mode, it charges, but is not allowed to discharge.

See this link below for some alternative 1 pin examples...

http://forums.parallax.com/showthread.php?p=464410

Note:
The two transistor inverter solution is designed for 5V operation, and needs different valued resistors to work at 3.3V

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

computer guy
02-01-2008, 05:28 AM
Beau,

wouldn't it be easier to just add a leakage resistor?

Thank you http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR (http://robot.tmcp.com.au)
If you like my avatar then check this out Propeller Domed Sticker (http://forums.parallax.com/showthread.php?p=701193)

Beau Schwabe (Parallax)
02-01-2008, 05:48 AM
computer guy (http://forums.parallax.com/member.php?u=48345),

You could, but you wouldn't get the volume you would from deflecting the crystal in both directions.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

computer guy
02-01-2008, 05:50 AM
Beau,

I have used the piezo with the BS2 before with plenty of volume.
Wouldn't this get the same volume, or at least close to?

Thank you http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR (http://robot.tmcp.com.au)
If you like my avatar then check this out Propeller Domed Sticker (http://forums.parallax.com/showthread.php?p=701193)

Beau Schwabe (Parallax)
02-01-2008, 05:58 AM
computer guy (http://forums.parallax.com/member.php?u=48345),

Sorry, I misread your original post... for some reason I thought you wanted more volume.

OzStamp (http://forums.parallax.com/member.php?u=40686)'s solution is fine, just place a resistor (1K to 4.7K) in parallel with the piezo in addition to what he mentioned.

deSilva (http://forums.parallax.com/member.php?u=49880)'s solution will also work, just fine and is capable of boosting the volume. Just drive 2 pins 180 deg out of phase.





▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

Post Edited (Beau Schwabe (Parallax)) : 1/31/2008 11:03:29 PM GMT

computer guy
02-01-2008, 06:05 AM
Ok, Thanks Beau will do. http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR (http://robot.tmcp.com.au)
If you like my avatar then check this out Propeller Domed Sticker (http://forums.parallax.com/showthread.php?p=701193)

Phil Pilgrim (PhiPi)
02-01-2008, 06:19 AM
If you use one of the Propeller's built-in counters, driving two pins 180 degrees out of phase is a slam dunk. Just use the "NCO differential" mode (%00101). You can key the piezo on and off via DIRA and adjust the frequency via FRQx.

-Phil

computer guy
02-01-2008, 06:49 AM
Phil,

Thank you however I am happy with the circuit that Ron and Beau have provided.
I am just wanting to drive a piezo from 3.3v.

Thank you http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR (http://robot.tmcp.com.au)
If you like my avatar then check this out Propeller Domed Sticker (http://forums.parallax.com/showthread.php?p=701193)

Graham Stabler
02-01-2008, 08:14 AM
If you used deSilva's technique and Phil's suggestion it is loud, easy to implement and there is no circuit as such just connect two pins to the piezo and it IS being driven by 3.3v.

I don't understand your comment:

"Thank you, however four-fold power sounds like it would be complex to implement"

4 fold power means 4 times more power.

Graham

computer guy
02-01-2008, 10:44 AM
Graham,

I understand what four-fold power is.
I just mean in terms of writing code that can alternate the pins and still generate the desired frequency on the piezo.

Thank you http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR (http://robot.tmcp.com.au)
If you like my avatar then check this out Propeller Domed Sticker (http://forums.parallax.com/showthread.php?p=701193)

Graham Stabler
02-02-2008, 01:48 AM
Why should alternating the pins be hard, say you code it with an XOR to toggle the pins, start with one pin high and the other low and they will then always be opposite.

Or do as Phil suggests and use a counter, in differential mode the pins will automatically be opposite. Not sure how to proceed, then have a look at the app note and ask a question when you get stuck.

Graham

computer guy
02-02-2008, 05:18 AM
Graham,

I am happy with the volume I am getting, so the circuit that I have works fine for me.

Thank you anyway http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR (http://robot.tmcp.com.au)
If you like my avatar then check this out Propeller Domed Sticker (http://forums.parallax.com/showthread.php?p=701193)