EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: alank2 on April 18, 2017, 05:39:51 pm

Title: PIEZO driving from microcontroller pins...
Post by: alank2 on April 18, 2017, 05:39:51 pm
I've had a project where I had two pins connected to the piezo.  If I left one at ground or vcc and cycled the other, I could make a frequency.  If I cycle them both out of phase to each other, I can get the same frequency with more volume.  Here is my question - does it matter what the resting state is of these 2 pins?  It is the transitions that consume current, correct?  If one pin is low and one is high, it doesn't seem to be using any current.  Is that better or worse or the same than two pins low?
Title: Re: PIEZO driving from microcontroller pins...
Post by: mikeselectricstuff on April 18, 2017, 06:42:27 pm
Idle state doesn't matter. No need to use TVS as pin clamping diodes will do the job.
Title: Re: PIEZO driving from microcontroller pins...
Post by: Ian.M on April 18, 2017, 06:48:22 pm
Idle state doesn't matter. No need to use TVS as pin clamping diodes will do the job.
However *DON'T* immediately set the pins as inputs when idle at the end of a tone-burst.  If you set them both to outputs at the same level, the transducer will be heavily damped by the Rds_on of the output drivers and the clamping diodes wont conduct.  After the mechanical vibration has died away you can then reset them as inputs if you really need to.
Title: Re: PIEZO driving from microcontroller pins...
Post by: langwadt on April 18, 2017, 06:59:49 pm
Idle state doesn't matter. No need to use TVS as pin clamping diodes will do the job.

I'd say both pin high or both pins low might be slightly better, because it will short any voltage generated by the piezo
rather than pushing current into the supply possibly raising the voltage
Title: Re: PIEZO driving from microcontroller pins...
Post by: alank2 on April 18, 2017, 07:06:58 pm
Thanks everyone,  I was gonig to just use (H,L) as idle state, but it sounds like (L,L) is probably more ideal.  They will be configured as outputs only and stay outputs.  I'm using an AVR timer/ocr to generate the frequency.
Title: Re: PIEZO driving from microcontroller pins...
Post by: Zero999 on April 18, 2017, 07:58:51 pm
Thanks everyone,  I was gonig to just use (H,L) as idle state, but it sounds like (L,L) is probably more ideal.  They will be configured as outputs only and stay outputs.  I'm using an AVR timer/ocr to generate the frequency.
Good idea. The H,L state would apply a DC voltage to the piezo element for a long period of time which is not recommended, especially in a humid environment.

Quote
Ag migration might occur if DC voltage is applied to the
product under a high humidity environment. Please avoid
using it under high humidity and design the circuit not to
apply DC voltage.

http://www.murata.com/~/media/webrenewal/support/library/catalog/products/sound/p37e.ashx (http://www.murata.com/~/media/webrenewal/support/library/catalog/products/sound/p37e.ashx)
Title: Re: PIEZO driving from microcontroller pins...
Post by: alank2 on April 18, 2017, 08:06:31 pm
What do you guys think about the resistor in series idea - worth doing or unnecessary?
Title: Re: PIEZO driving from microcontroller pins...
Post by: mikeselectricstuff on April 18, 2017, 08:56:07 pm
What do you guys think about the resistor in series idea - worth doing or unnecessary?
Not necessary unless you are concerned about noise while beeping - e.g. doing analogue stuff. When you switch the outputs, there will be a current spike as it charges & discharges the capacitance of the piezo, which could couple somewhere, but only likely to be an issue for sensitive analogue stuff.  Adding some resistance probably won't make a huge difference to sound output.
Title: Re: PIEZO driving from microcontroller pins...
Post by: alank2 on April 20, 2017, 03:50:37 pm
Thanks Mike - I got the timer instructions all worked out so it is (low, low) at idle, and it will transition from idle into sound and from sound back to idle smoothly.  I can also leave one bit unset to drive only one line for less volume.