let's make some noise!!

Discussion in 'Embedded Systems and Microcontrollers' started by Eric007, Oct 1, 2011.

  1. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    Hi all

    Here's what I'm working on:

    ' I'm trying to build an alarm that can be suitable for an emergency alert by making a 'two tone' alarm that will toggle every half second between two different frequencies that are variable so as to have a more realistic sound.'

    As you know, the hardware come first then the software!

    Attached is the amplifier schematics I'm planning to use (I have one BC547B npn transistor and a BC577 pnp transistor, 2k2 resistor, 100uF capacitance) and use PIC16F690 and a (8 ohm, 0.3 W) speaker.

    Here's how I'm planning to breadboard it: choose any I/O pin of the uc and connect it to Vin of amplifier, on the other side of amplifier (Vout) connect the speaker and ground the speaker as well via a resistor!

    My internet is down at the moment so can't google it for some information...

    My fisrt concer is if da way I'm planning to breadboard it is correct? Or I would need extra circuitry? And which resistor value would be suitable to ground the speaker with?

    As for the software part, I'm planing to choose 2 different sounding frequencies BUT I'm not too sure which ones??

    Now, I'm wondering if, in order to make the sound ramp up and down, I would need to have different magnitudes (5 for instance) for these 2 frequencies and toggle between those magnitudes and looping?

    Enough talking for now...

    Any comments/ guidance towards the right track would be really appreciated!

    Kindly Regards, Eric
  2. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    I'm surprised there's not a single comment...I'm wondering why...
    Anyways I managed to write a code and it working perfectly BUT I have a question...

    I choose 525.21Hz and 657.89 Hz as frequencies... Now I need to know if choosing large frequencies will result in louder sound??

    Will post my code later...

    Please comment...

    Kindly regards, Eric
  3. BillO

    Well-Known Member

    Nov 24, 2008
    Higher frequencies will carry more energy, but unfortunately the response of the human ear will not really make them seem louder.

    Besides, there are so many factors at play here. Such as any resonance response in the reproduction system or in your own hearing. Even in the physical properties of the room in which you are listening.

    My guess is, there will not be much overall difference within an octave or two of the frequencies you are currently using. Much beyond that and it may even get quieter for all the reasons stated above.
  4. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    Thanks Bill for your comments...i really appreciated it!

    im a bit lazy to post my solution but i will...and like i said it works perfectly!

  5. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    Hi all,

    Like I promised, here's my code attached for those who would like to have a look...I really wanted to post my solution (but didn't find the time) coz I had the impression from my previous thead that some people think/thought that i'm expected a ready given solution from the forum (absolutely not true!!!)

    that's why I always ask for ressources to read and understand what's going on....

    Anyways...have a look and of course i could have done a better job but it working and this is good enough...

    But writing it on the chip i noticed that the siren started from a high sound to a low sound then i re-wrote from volume 5 to 1 so that it can starts from lower to higher sound

    i will revisit this tread adding more interresting features later

    Cheerful regards,
  6. Markd77

    Senior Member

    Sep 7, 2009
    Nice, well commented code.
    You could save some program space by having a subroutine which is one of the sections and calling it repeatedly with the frequency and loudness in a couple or three registers.
    You could then store the sequence of notes and loundesses in lookup tables and cycle though them, or use an algorithm to set them.
    Eric007 likes this.
  7. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    Thanks Mard77 for your reply and remarks...

    You are 100% right...I knew I could have saved space but I think I was just being lazy...especialy as I'm doing some reading on what I would like to discuss...

    I was planning to do a second version where I would improve the code and reduce the space but well...too busy for that...

    I'll think of a better project to implement with all your suggestions some other time...

    Regards, Eric