[HARD] Make a piezo go louder without any extra parts

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Piezotransducers are cool parts: They can make sound! They are small, consume virtually no energy while they are inactive (in the sense if you feed them a square wave they will consume energy only until they are charged up to the value of the current state and then act as charged capacitor), inexpensive and when used properly, they can be VERY loud.

How does it work?
THe piezoelectric effect is a best demonstrated on a plate of such a material (ofcourse this example is extremely simplified). If you have a plate and on each side you have an electrode (A and B) and apply + on A and - on B the plate will SHRINK in length (not by much, but enough) and if you apply - on A and + on B it will GROW in lenght. If the difference of voltages (on the electrodes) is 0V then the plate will have a "default" lenght.
(for a better and less sucking explanation goto This wiki article on the given subject )

If constructed properly, using this effect you can make a speaker, loudspeaker, resonator, or the crystals you use to clock your AVRs.

Connecting yer piezo
Most people connect the piezo in this way:

       |     \----/
AVR PIN|-----|    |---| GROUND or any other voltage
       |      ----
       |      PIEZO

There is actually nothing wrong with this, only it could be a bit better.

If you put a logic high on the PIN the crystal will expand. If you put a zero there it will go to its default size.

BUT:
If you connect it this way:

        |
AVR PIN1|----|
        |   |---/|
        |   |    |   PIEZO
        |   |___ |
    PIN2|----|  \|
        |

And make sure that PIN1 is always the logic negation of PIN2 the setup will act like this:
You put 1 (+5V) on the PIN1, therefore on PIN2 is 0 (0V). The crystal will expand to lenght_a.
Now you put 0 on PIN1 and 1 on PIN2. The crystal will SHRINK to length_b, which is LESS than lenght_default.
So the difference is about a double.

Even louder?
All piezos have their resonant frequency. Operate them at this particular frequency and you'll see (or rather hear) the sound it makes better.

Code anyone?
This code is from one of my projects, the Sanity nullifier ( an evil little project meant for the first of april ) http://daqq.eu/index.php?show=pr... .


#define BUZZER1() {sbi(PORTB,0);cbi(PORTB,1);}
#define BUZZER0() {cbi(PORTB,0);sbi(PORTB,1);}
#define BUZZER_OFF() {cbi(PORTB,0);cbi(PORTB,1);}

void beep()
{
    unsigned int temp;
    for(temp=0;temp!=BEEP_LENGTH;temp++)//does the beeping on the piezo.
    {
        BUZZER0();
        wait(_ms(BEEP_INTERVAL));
        BUZZER1();
        wait(_ms(BEEP_INTERVAL));
    }
    BUZZER_OFF();
    return;
}

It's just a pseudocode, an example, but you should get the idea.

The BUZZER_OFF function sets the buzzer to a zero state. It's more of a safety thing. If a piezo is expanded/shrunk for a prolonged period of time, then the material may degrade (thanks user KMR for the suggestion).

NOTE: Please forgive/correct any physical/other mistakes I made.

Enjoy,

David Gustafik

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

Last Edited: Mon. Jul 30, 2007 - 08:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

top idea mate!! Now I can make my projects twice as annoying :twisted:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Now I can make my projects twice as annoying

Welcome to the dark side.

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

David, you probably want to set both pins low (or high) after creating your audio. As I understand it, prolonged voltage (and deformation) across a piezo degrades the material. I've also seen people use a bleeding resistor across the piezo to drain any charge, but setting both pins to ground should work as well. Also, some piezos have current limits, so you may want to measure the current across the piezo and consider a series resistor. (as well as being sure that you're not overtaxing the current from your AVR IO pins)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the suggestion, I'm updating the tutorial now.

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And thanks for your work on this!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hijack ref:
https://www.avrfreaks.net/index.p...

< Has been taken care of - Nard >