1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

How To Generate Music Tone Using Pic Microcontroller?

Discussion in 'Microcontrollers' started by earlbesario, Mar 1, 2007.

  1. earlbesario

    earlbesario New Member

    Joined:
    Oct 2, 2006
    Messages:
    6
    Likes:
    0
    Location:
    Dumaguete City, Philippines
    HI...

    I want to build music tone using pic16f84? so i can make a sound. This is to be used in our project in Microcontroller subject (ex: a pic musical doorbell project).

    How to understand the conversion of the tones in assembly codes...?
    How to do that?

    Can anybody show me how to convert any music to an assembly program?
     
  2. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,216
    Likes:
    640
    Location:
    Derbyshire, UK
  3. Gayan Soyza

    Gayan Soyza Active Member

    Joined:
    Oct 23, 2006
    Messages:
    1,821
    Likes:
    19
    Location:
    Colombo
    Last edited: Mar 1, 2007
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. szabi

    szabi New Member

    Joined:
    May 21, 2006
    Messages:
    41
    Likes:
    1

    You find a good one in the Labcenter Electronic's Proteus examples.
     
  6. earlbesario

    earlbesario New Member

    Joined:
    Oct 2, 2006
    Messages:
    6
    Likes:
    0
    Location:
    Dumaguete City, Philippines
    Thanks for the reference (http://www.beyondlogic.org/pic/ringtones.htm)
    ...so i need to understand about RTTTL (Ringing Tones Text Transfer Language)..Can anybody explain what is RTTT..pls?
    so i can convert music tone to assembly code...I will use piezo speaker of my project...i'll just hope that it will create a different sounds with 2 or more inputs...

    i really need effort of this.....

    tnx...
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,216
    Likes:
    640
    Location:
    Derbyshire, UK
    The website above has links to everything you need to know, you don't have to use RTTL - it's just convenient if you want to play tunes.
     
  8. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    You do not need to understand RTTT. It would be overkill.

    The article mentioned by Gayan Soyza should be what you need to do.

    A speaker is easier to use then a piezo. The hardware as laid out in the ringtone page would work. Use a 47uF cap.
     
  9. House0Fwax

    House0Fwax Member

    Joined:
    Nov 15, 2006
    Messages:
    583
    Likes:
    17
    Location:
    Hampshire U.K.
    ONLINE
    I have built that circuit and tried the programs on the site and can confirm that it works fine.
     
  10. lord loh.

    lord loh. Member

    Joined:
    Jan 7, 2005
    Messages:
    634
    Likes:
    0
    Location:
    Lubbock, TX
    I managed to do this on an AVR and plays decent music (Square Wave) I shall post the programme soon... It is capable of playing 4 octaves...
     
  11. philba

    philba New Member

    Joined:
    Mar 12, 2006
    Messages:
    1,886
    Likes:
    8
    Location:
    Seattle
  12. SPDCHK

    SPDCHK Member

    Joined:
    May 26, 2006
    Messages:
    446
    Likes:
    17
    Location:
    South Africa
  13. ArtemisGoldfish

    ArtemisGoldfish Member

    Joined:
    Jan 7, 2007
    Messages:
    193
    Likes:
    1
    Location:
    Spokane, WA
    I don't especially know much about microcontrollers, but couldn't you generate a bit more of a sine wave-type sound using cap(s) and an D/A convertor? Juuust wondering.

    EDIT: Just to clarify, I meant by using a D/A convertor to step the voltage up, then down and caps to antialias the wave.
     
    Last edited: Mar 2, 2007
  14. philba

    philba New Member

    Joined:
    Mar 12, 2006
    Messages:
    1,886
    Likes:
    8
    Location:
    Seattle
    yes, you could certainly use a DAC. The ideas that people are putting forth are about using one or 2 pins. A parallel DAC will take 8-10-12 pins while a serial DAC will take fewer pin but is a bit more complex to use. I would not use parallel with a uC but rather a serial one. However, I didn;'t get the sense you needed all that great quality.

    Look at the Roman Black page - his algorithm actually produces fairly good sound quality with 2 output pins.

    By the way, a DAC doesn't step the voltage up or down but rather you tell it what voltage level to output, thus tracking the waveform you are trying to reproduce.
     
  15. Gayan Soyza

    Gayan Soyza Active Member

    Joined:
    Oct 23, 2006
    Messages:
    1,821
    Likes:
    19
    Location:
    Colombo
  16. philba

    philba New Member

    Joined:
    Mar 12, 2006
    Messages:
    1,886
    Likes:
    8
    Location:
    Seattle
    that's called an R-2R ladder and it is, in fact, a simple DAC. 8 bit, simple low pass filter.

    it uses an RC oscillator for the clock so it will be pretty innacurate - better to use a real crystal.
     
  17. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,216
    Likes:
    640
    Location:
    Derbyshire, UK
    It doesn't matter for this application, and it gives the advantage that you can add a poteniometer and make the speed variable if you want.
     
  18. gramo

    gramo New Member

    Joined:
    Oct 2, 2006
    Messages:
    1,221
    Likes:
    23
    Location:
    Newcastle, Australia
  19. nodoubtman

    nodoubtman New Member

    Joined:
    Aug 16, 2011
    Messages:
    6
    Likes:
    0
    generating melody ...

    Hello! I'm new at pic programming, is this pic : PIC16F87, is good for the http://www.beyondlogic.org/pic/ringtones.htm

    can i replace the PIC16F876 by the pic16f87?

    thank you soo much!
    Have a good night! :)
    marC:)
     

Share This Page