Sound2

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Hi All

what I am trying to do is when button is pressed, we get some pleasant door bell sound in the speaker...sound should last up to 10 second...

No use of PWM! input = push button, output on one I/O pin = sound

some example below:

http://www.youtube.com/watch?v=ROsymjaJ3OY

http://www.youtube.com/watch?v=DXBCwpSl7-A

Any idea how to proceed? I mean how to get it sound like the one in the link...well it can be different...

thanks!
 

DerStrom8

Joined Feb 20, 2011
2,390
Hi All

what I am trying to do is when button is pressed, we get some pleasant door bell sound in the speaker...sound should last up to 10 second...

No use of PWM! input = push button, output on one I/O pin = sound

some example below:

http://www.youtube.com/watch?v=ROsymjaJ3OY

http://www.youtube.com/watch?v=DXBCwpSl7-A

Any idea how to proceed? I mean how to get it sound like the one in the link...well it can be different...

thanks!
What are you using to play the sound? Are you planning on using that audio clip, or making something that sounds like it? If you want to make your own doorbell sound from scratch, you'll need PWM in one form or another. They might make doorbell modules that you can buy and connect your own switches to.
 

THE_RB

Joined Feb 11, 2008
5,438
You don't really need PWM. In the early PIC days people would make tunes by toggling an output pin at the "note" frequency, it's really not that hard to play a little tune.

You can also take off the harsh sounding square wave edge by running the sound through an RC filter or a couple of RC filters before the amp.
 

DerStrom8

Joined Feb 20, 2011
2,390
You don't really need PWM. In the early PIC days people would make tunes by toggling an output pin at the "note" frequency, it's really not that hard to play a little tune.

You can also take off the harsh sounding square wave edge by running the sound through an RC filter or a couple of RC filters before the amp.
That'll get you the right "notes", but not the right "tone". In order to get a better tone, you'd need PWM.

How much does this have to sound like a doorbell? Can you just have a two-tone sound (high then low)?
 

John P

Joined Oct 14, 2008
2,068
A few years ago, there was a guy who invented an interesting way of playing sound from a PIC, but I forget exactly who it was. It had something to do with predicting the time constant of an RC filter. Maybe someone else remembers.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
What are you using to play the sound?
Are you planning on using that audio clip, or making something that sounds like it? If you want to make your own doorbell sound from scratch, you'll need PWM in one form or another. They might make doorbell modules that you can buy and connect your own switches to.
Nothing much...just a PIC16F, push button and , circuit attached for speaker! Guess so! will have to use PWM...dont have to use anything else...I will try to write a quick code later...as I am preparing for an exam now...I will choose 2 arbitrary frequencies in order to have 2 different tone but I was hoping to make an identifiable doorbell sound as one of those in the above link...but don't kow the correct frequencies to choose...anyway..

You don't really need PWM.
In the early PIC days people would make tunes by toggling an output pin at the "note" frequency, it's really not that hard to play a little tune.
You can also take off the harsh sounding square wave edge by running the sound through an RC filter or a couple of RC filters before the amp.
Yeah I can produce a square wave by toggling a pin but will probably produce some strange sound
unless doing some math...

That'll get you the right "notes", but not the right "tone". In order to get a better tone, you'd need PWM.
How much does this have to sound like a doorbell?
Can you just have a two-tone sound (high then low)?
Yeah PWM is needed...that what I am planning to do just two tone...
ding dong king of sound...but sound must last at least 5 seconds

Anyway will try something

Thanks all!
 

Attachments

DerStrom8

Joined Feb 20, 2011
2,390
If you're just doing the two-tone thing you probably don't need PWM. The PWM would be used to add a little "twang" to make it sound more realistic and to smooth off the edges, but you can get a regular two-tone 'beep boop" without it.
 

t06afre

Joined May 11, 2009
5,934
It was an Elector magazine article named "Polyphonic Doorbell" This article resulted in a lot of "offsprings" Just google doorbell pic16f84
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I decided to use PWM...it a two tones sound...so it not a lot of work...

But I was wondering...for a nice effect...what delay should i use...I mean 0.5/1/... second between the two?

ding
call delay
dong
call delay

the above is going to be played twice on every button press...so it gong sound like this:

ding
dong

ding
dong

lol:D
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I am trying to create 2 delays..

one of 33ms for push button deboucing and another one of 1 second for the duration of each tone...

Hope it makes sense! check the attachment!

thanks!
 

Attachments

Last edited:

Markd77

Joined Sep 7, 2009
2,806
That looks like it might work, don't forget to use "movlw d'245' " etc unless you have set the radix to decimal.
Add in a little test code in your main loop to toggle pins every time the flags are set and you will be able to see if it works.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Attached is the full code...

Hope it makes sense ...haven't tested it yet...

twotones is called twice in main:

ding
dong

ding
dong

so I can the above effect...each tone last for 1 secand...I have coded it the old way...i don't really like it coz at each delay or getkey...I am stuck in a *ugly* loop...t as there's nothing much going on + I don't have time to write a better code...

doing breadboard now so i can test it...

Thanks!

[I will remove the code later] when everything ok!
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
a quick stupid question...in my circuit attachement , which polarity (+ or -) of the capacitor goes to 'output'

I forgot...:rolleyes:
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
the speaker has '+' and '-'

'-' will go to ground and '+' will go to one end of the cap (which on? + or -?)

the othe end of cap is connected to the two transistor...
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I think my code is WRONG!!!!:(

I tried an old code project on the same circuit and ot worked...

wiring is not a problem...

Any help in my logic?? I know it sometimes hard to read some one else code...
 

DerStrom8

Joined Feb 20, 2011
2,390
I think my code is WRONG!!!!:(

I tried an old code project on the same circuit and ot worked...

wiring is not a problem...

Any help in my logic?? I know it sometimes hard to read some one else code...
I never got much into ASM personally, but looking at your config settings I see

&_INTRC_OSC_NOCLKOUT

Isn't the & supposed to be separate? "& _INTRC_OSC_NOCLKOUT"
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I checked and fixed that but still nothing...I am working on it...I got to be quick fixing it I got a big exam in two days time! #not good#
 

Markd77

Joined Sep 7, 2009
2,806
- end of capacitor to speaker then Vss, + end of capacitor to the transistors, which can never be lower than Vss but sometimes are higher.
You've got MCLR on, have you connected it to Vdd?
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I think I have found out the bug!

I don't see where I have enabled global interrupt and timer0 interrupt!;)

Hope it works when i fix that
 
Top