Author Topic: PIEZO driving from microcontroller pins...  (Read 3464 times)

0 Members and 1 Guest are viewing this topic.

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
PIEZO driving from microcontroller pins...
« 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?
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13746
  • Country: gb
    • Mike's Electric Stuff
Re: PIEZO driving from microcontroller pins...
« Reply #1 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.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12857
Re: PIEZO driving from microcontroller pins...
« Reply #2 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.
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4422
  • Country: dk
Re: PIEZO driving from microcontroller pins...
« Reply #3 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
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: PIEZO driving from microcontroller pins...
« Reply #4 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.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: PIEZO driving from microcontroller pins...
« Reply #5 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
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: PIEZO driving from microcontroller pins...
« Reply #6 on: April 18, 2017, 08:06:31 pm »
What do you guys think about the resistor in series idea - worth doing or unnecessary?
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13746
  • Country: gb
    • Mike's Electric Stuff
Re: PIEZO driving from microcontroller pins...
« Reply #7 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.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: PIEZO driving from microcontroller pins...
« Reply #8 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf