CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Siren sound

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ernanemoraes



Joined: 28 Mar 2004
Posts: 2

View user's profile Send private message Send e-mail

Siren sound
PostPosted: Tue Mar 30, 2004 4:52 pm     Reply with quote

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

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Tue Mar 30, 2004 4:58 pm     Reply with quote

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
PostPosted: Thu Mar 20, 2008 2:20 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 20, 2008 4:24 am     Reply with quote

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







PostPosted: Thu Mar 20, 2008 5:34 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 20, 2008 8:25 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 20, 2008 9:14 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group