View previous topic :: View next topic |
Author |
Message |
ernanemoraes
Joined: 28 Mar 2004 Posts: 2
|
Siren sound |
Posted: Tue Mar 30, 2004 4:52 pm |
|
|
Hi friends, somebody may help me to progam the 16f628 to reproduce
siren sounds ? (wail, yelp, hyelp, horn hair) |
|
|
carlosma
Joined: 24 Mar 2004 Posts: 53 Location: Portugal
|
|
Posted: Tue Mar 30, 2004 4:58 pm |
|
|
Hello
See the example EX_TONES.C just need change the time of PWM.
The example plays the song "Happy Birthday."
Carlos |
|
|
Depner Guest
|
Siren sound generator |
Posted: Thu Mar 20, 2008 2:20 am |
|
|
Hi!
I'm new in CCS C. My first project in C would be a siren sound generator. (wail, yelp, etc.) Could someone help me how to start? I would like to use a 16F873. The signal must be a square-wave. Please give me some hint how to start.
Thank you very much!
Greetings from Hungary
Depner |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Mar 20, 2008 4:24 am |
|
|
You have 2 options.
1. Synthisize the sound. This is great for a siren as it is a simple sign wave with a regular varying frequency or even simpler a sign wave played at 2 different frequencies. Not so good for a yelp as it has alot of non regular varying frequencies.
2. Sample. This is easy to do but requires much more memory. Simply make a pic device to sample a sound at a specific rate. Sample all the sounds you want to reproduce. Now make a pic to play those samples back at the correct rate. The only issue with this is producing a seemless siren sound. You will need to modify the sample so that the end matches the begining so when it loops it plays smoothly. Sampling would also play any sound you sample so it can be "happy birthday" spoken if you want, as long as you have enough memory! Reducing the sample rate will reduce the memory required but degrade the quality.
3. A mixture of the 2. |
|
|
Depner Guest
|
|
Posted: Thu Mar 20, 2008 5:34 am |
|
|
Hi Wayne_,
thanks for the answer. I'm quite familiar with the theory, I've the problems with the practice. I would like to solve with the sound synthisize. But I don't really know how to do this in CCS C.
I'm thinking of some seperate routines. One should be the rising sound. Imput parameters are the starting freq., the finishing freq. and the time for the rise. Other is the reverse of this, falling sound. I would like to ask some help to write this routines. |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Mar 20, 2008 8:25 am |
|
|
The code required to do this is hardware dependant. So you need to either explain your hardware or post a schematic with explanation of functionality. I then will doubt anyone will write the code for you but they may piont you in the right direction or give you examples.
To start with, how do you intend to generate the sound ?
PWM to a speaker,
Programable freq generator,
Direct speaker on/off control,
programable synth.
If you have not yet decided then the things to think about are speed and ease of use. Will a PWM have a fast enough response to create the sounds or quality you want. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Mar 20, 2008 9:14 am |
|
|
It might be worth reading about how a numerically controlled oscillator (NCO) or digitally controlled oscillator (DCO) works. I wrote one for a PIC16C56 at 20MHz that could synthesize up to about 32kHz. With a better PIC at lower output frequencies you could probably do several superimposed tones. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|