I have a Raspberry Pi outputting a 3.3v DC square wave that I'd like to be able to amplify to just under 20v, the maximum the piezo can handle. Just to clarify, the piezo does not have an internal oscillator and the Pi is outputting at anything from 50Hz to 3kHz to make audible tones.
From looking elsewhere online, there seem to be many different approaches to amplification but most require an AC wave to work.
I'd like to be able to simply and cheaply amplify the wave generated by the Pi to make recognisable musical tones with the piezo as loud as possible. The wave doesn't have to be perfect, but I'd rather there was as little interference or noise as possible!
I have 3.3v, 5v and 7.2v available on the project and I could add a pair of 9v batteries if 18v is needed.
The piezo has a 7kohm impedance, if I remember according to the data sheets, if that helps.
A circuit diagram would be good but a bit of an explanation to go with it would be preferred!
Edit: The data sheet is at http://www.farnell.com/cad/356850.pdf
Another edit: I'll be testing Spehro's answer as soon as I can, assuming that school has all the extra components needed.
You could use an inexpensive motor driver chip such as the Diodes ZXBM5210 (plus an inverter, such as 1/6 of a 74HC04 or a MOSFET + a resistor).
You put the piezo plus a small series resistor- perhaps 50\$\Omega\$- in place of the motor. Internal circuit looks like this:
So you would switch between Forward and Reverse using your port pin (you need the inverter to feed the complementary signal to (say) Reverse while the Forward input gets fed directly.
Note that this is a push-pull driver, so the peak-to-peak voltage across the piezo will be a bit less than double the supply voltage, so 9-10V is fine for the supply.
The resistor is to limit the peak current to 200mA since the piezo looks like a fairly low ESR capacitor. Put a good bypass capacitor on the higher voltage supply (perhaps 220uF/16V electrolytic or at least a 10uF/25V ceramic).
This chip has built-in dead time of about 3us so you can just drive the inputs in complementary fashion without worry. The PWM input should be tied to Vdd to avoid the chip itself doing PWM.
I also suggest putting a couple K ohms of series resistance in series with the port pins, just in case something gets shorted to the 10V supply it might save the processor from destruction.
Chances are the piezo will not fail with much higher voltage than the rated 20V, and this chip is rated for 18V maximum supply (36Vp-p) if you feel lucky and want to try it.