how to make the buzzer to sound with different tone??

Author
decoder
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2005/12/29 21:19:47
  • Status: offline
2006/04/12 09:31:31 (permalink)
0

how to make the buzzer to sound with different tone??

hi everyone,
 
i need to ask if anyone here been dealing with piezo buzzer before?? i personally wants to find out the tone of do, re, fa and so on. i try to go through all the data sheet of the piezo buzzer but they never provide us with all this information.
 
i know in order to heard the buzzer sound when we tune it frequency between 2000hz - 20000hz??(correct me if i was wrong)..
 
i trying to use assembly to edit a simple music. can anyone give me some advise of how i can create a different tone on my buzzer?? or is there any web site talk about buzzer stuff using assembly language??
 
from decoder..
#1

13 Replies Related Threads

    jspaarg
    Super Member
    • Total Posts : 2926
    • Reward points : 0
    • Joined: 2005/05/25 16:47:08
    • Location: PA, now MN via NJ,AZ,OR,CA
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/12 09:36:25 (permalink)
    0
    You need to find a website that provides frequencies for standard notes.
     
    do is middle C in the key of C; I don't know the frequency.
     
    Also, if you are driving a piezo from a PWM, even at the desired frequency, you will not get the sound that you want because you are driving a square wave.
     

    PM personal questions and observations only. Keep technical questions to the forums where everyone can benefit.
    When it comes to binary, there are 10 kinds of people: those who understand, and those who don't.
    #2
    kalpak
    Super Member
    • Total Posts : 3265
    • Reward points : 0
    • Joined: 2004/03/12 23:01:40
    • Location: India
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/12 09:54:38 (permalink)
    0
    The piezo buzzer has a piezo element of resonating type, which coupled with an amplifier will produce a fixed note. These piezos are 3 terminal devices. If you get hold of 2 terminal elements then you can use them like a speaker, though the sound quality is not as good.
    These elements you can drive with the PWM output with preferably 50% duty cycle and you will have to change the PWM freq to have different notes.
    #3
    Mariano H. Caballero
    Senior Member
    • Total Posts : 155
    • Reward points : 0
    • Joined: 2005/10/14 05:26:52
    • Location: Buenos Aires, Argentina
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/12 10:00:40 (permalink)
    0
    The tone that is used as a base for the afination ofa guitarr is a "la" and its frecuency is 440 Hz.
     
    #4
    Polyene
    Super Member
    • Total Posts : 857
    • Reward points : 0
    • Joined: 2006/01/08 03:53:41
    • Location: Sweden
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/12 11:53:10 (permalink)
    0
    Well, A normal "A3" is 440Hz. For each octave, the frequency is doubled, so "A4" is 880Hz. The relation between the tones aren't linear, so you need to calculate them in an exponential way.

    There are 12 half tones in each octave. (A, A#, B, C, C#, D, D#, E, F, F#, G, G#)

    The factor between each octave is 2, therefore the factor between each half tone is 2^(1/12).

    An example: From "A" to "D#" there are six half tone steps. To get the frequency of "D#", just do 440 * ( (2^(1/12)) ^ 6). The frequency of "D#" is 622,254Hz.

    #5
    Guest
    Super Member
    • Total Posts : 80499
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: how to make the buzzer to sound with different tone?? 2006/04/15 10:05:23 (permalink)
    0
    >hello  i had a project, little music keyboard with 8 main notes C,D,E,F,G,A,B, and C2. in my circuit we have 8 buttons and we can play simple melodies.i used ATMEL 89C52 microcontroller.i have finished this project 3 months ago.
    >but now i want to improve this project and i want to play 2 octave music(25 note sounds starting with note C and to C3 note( 2 upper octave)) this is ok
    >and i also want to play more than one note sound at the same time( to make play achors like A minor etc)
    > for ex i must play notes A,C and E at the same time for achor A minor. how can i manage this? can u suggest me something about this?
    >and also can i record the melodies that i played?
    >i will be pleased if u reply
    thanks
    #6
    Polyene
    Super Member
    • Total Posts : 857
    • Reward points : 0
    • Joined: 2006/01/08 03:53:41
    • Location: Sweden
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/15 11:08:39 (permalink)
    0
    Adding octaves are really simple. Just multiply the frequency of the same tone in the lower octave by 2.

    Playing multiple tones at the same time is a lot harder, though.. You will need a mixer-algorithm that keeps track of all simultaneous frequencies and adds them together and send the result as output. The output needs to be updated at a quite high frequency. The fact that you're (probably) using a square wave with only two different states as output doesn't make it easier..

    I've never experimented with this.. Maybe someone else did?
    #7
    Guest
    Super Member
    • Total Posts : 80499
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: how to make the buzzer to sound with different tone?? 2006/04/15 13:41:57 (permalink)
    0
    PICDEM 2 PLUS has an example driving a buzzer at different frequency. However, you may have to fine tune it.
    #8
    RDH
    New Member
    • Total Posts : 22
    • Reward points : 0
    • Joined: 2005/02/23 23:05:59
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/15 14:26:22 (permalink)
    0
    Funny, my first self-taught project after flashing lights was a making a piezo buzzer play a tune.  Previous responses about musical tones are correct- Start at A440 Hz then just go up and down in half steps at the proportion of the "twelveth root of two"  Best way is just make a spreadsheet, what you really want for programming is the half period 1/(2f), which is how often you will switch your output pin. Tones are of musical quality between A110 Hz and about A2200, but you will never need that kind of range, so pick a few octaves and you will be fine.
     
    To encode music, you also need to encode duration, as well as tone.  I wrote the music as a lookup table of 8 bit "notes"-3 bits for the duration (Double Whole, Whole, Half, Quarter, Eighth, Sixteenth, Thirty-second, Sixty-fourth), then five bits for tone value, (rest, plus 31 tones, more than two octaves-plenty!).  End of song is encoded as a sixty-fourth rest.
     
    After decoding the duration data and the tone data through respective lookup tables, the tone is played by a variable length loop toggling the output pin.  Tone duration is controlled by checking TMR0.
     
    All this fits very comfortably on a 10F200 chip.  Program runs in a sleep loop and is activated by pulling an input pin to ground, so the chip goes into nanoamp sleep at the end of the song if the input pin is high.

    If you pick up a starving dog and make him prosperous, he will not bite you.
    This is the principal difference between a dog and a man.
    Mark Twain
    #9
    bobledoux
    Super Member
    • Total Posts : 218
    • Reward points : 0
    • Joined: 2004/10/12 05:54:57
    • Location: Salem, OR USA
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/16 05:48:24 (permalink)
    0
    I use tones for debugging purposes. My current tones vary by frequency or tone width.  For example, I have a pseudo Morse Code routine to read out values using a single output pin on a PIC. 

    I'd like to expand the tone library to include other types of tones like a "whoop" or a "buzz."

    Is anyone aware of such a software library?
    #10
    decoder
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2005/12/29 21:19:47
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/16 20:56:07 (permalink)
    0
    hi everyone,
     
    In order to play different toning from the piezo buzzer, do i really have a use microchip with PWM feature??
     
    Currently, i am using PIC16f84a for my current project. I have try before using a port to make the piezo buzzer to sound in a single tone. That's all i can manage. I try different ways to let my buzzer to change it frequency after the first, but it just dont work..
     
    I alway feel that if you are writing in c programming to play different tone is much more simpler.Smile
    #11
    Polyene
    Super Member
    • Total Posts : 857
    • Reward points : 0
    • Joined: 2006/01/08 03:53:41
    • Location: Sweden
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/17 00:39:46 (permalink)
    0
    First of all you have to make sure that you're using a buzzer without a built-in oscillator. If you do, then the frequency will be controlled by the internal oscillator, and all you can do is to turn it on and off.

    Of course you can also create a software PWM (preferably using a timer interrupt), but a device with a hardware CCP-module will create a more stable frequency. When you're dealing with higher frequencies you will be able to hear every single instruction cycle that your edge gets delayed.
    #12
    RDH
    New Member
    • Total Posts : 22
    • Reward points : 0
    • Joined: 2005/02/23 23:05:59
    • Status: offline
    RE: how to make the buzzer to sound with different tone?? 2006/04/17 08:06:48 (permalink)
    0
    No, you do not "need" PWM.  You can drive piezo device right from chip with a square wave with 50% duty cycle for simplest coding. If you choose to use PWM, you have to add filters. 
     
    Previous post about NOT using an oscillator-containing piezo device is very important.  All you need is the piezo disc, sometimes called a piezo speaker.  Disc has a natural harmonic, but works at a range around the natural harmonic.  If you attach it to a sounding board (i.e lab bench) you will get a good amount of volume.  You can increase your output if instead of switching one pin high and low, you have two pins switching in opposition.
     
    To correct my earlier post in this thread 2200Hz is not an A on chromatic scale.  My bad.

    If you pick up a starving dog and make him prosperous, he will not bite you.
    This is the principal difference between a dog and a man.
    Mark Twain
    #13
    Guest
    Super Member
    • Total Posts : 80499
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: how to make the buzzer to sound with different tone?? 2006/05/23 20:11:48 (permalink)
    0
    ORIGINAL: AKA Troll

    PICDEM 2 PLUS has an example driving a buzzer at different frequency. However, you may have to fine tune it.

     
    right now, i'm using the PICDEM 2 PLUS..however, i've got problem to make the buzzer sound..can you give me the sample coding to set the pmw...i really need ur help..thanks a lot..
    #14
    Jump to:
    © 2017 APG vNext Commercial Version 4.5