Musical DoorBell with PIC16F84A

Microcontroller Topics

What do you think about this example?

Poll ended at Fri Apr 23, 2010 5:00 pm

Very good
10
83%
Good
2
17%
Bad
0
No votes
Very bad
0
No votes
 
Total votes: 12
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: Musical DoorBell with PIC16F84A

Post by Rksk » Mon May 23, 2011 10:05 pm

you are Welcome to robot.lk.

it seems you have to amplify the out put of PIC.

Below cricuit is very easy to build. tryout it.
LM386 Amp circuit
LM386 Amp circuit
lm386amp.gif (10.48 KiB) Viewed 8127 times
I'm unable to covert this ASM code to C, because I'm busy with my studies.

[ Post made via Mobile Device ] Image
User avatar
Shane
Captain
Captain
Posts: 226
Joined: Sun Jul 19, 2009 9:59 pm
Location: Jönköping, Sweden

Re: Musical DoorBell with PIC16F84A

Post by Shane » Mon May 23, 2011 10:38 pm

Sound of the Piezo speaker is very low
You must be using a type with less sound. Try to find a piezo speaker similar to the one in the following image. This one is very loud and I'm trying to find a way to reduce the volume ;)
1.jpg
1.jpg (2.75 KiB) Viewed 8124 times
DeepakPatil23
Sergeant
Sergeant
Posts: 20
Joined: Mon May 23, 2011 7:16 pm

Re: Musical DoorBell with PIC16F84A

Post by DeepakPatil23 » Tue May 24, 2011 12:24 pm

:P

Thanks , sure, tomorrow i will try to build that amplifier circuit. and also try to get the same piezo speaker.
:P
User avatar
Shane
Captain
Captain
Posts: 226
Joined: Sun Jul 19, 2009 9:59 pm
Location: Jönköping, Sweden

Re: Musical DoorBell with PIC16F84A

Post by Shane » Tue May 24, 2011 7:20 pm

I don't think you need the amplifier. Just buy a good piezo speaker.
SukhdeepMankoo
Lieutenant
Lieutenant
Posts: 92
Joined: Tue Oct 27, 2009 7:50 pm

Re: Musical DoorBell with PIC16F84A

Post by SukhdeepMankoo » Wed May 25, 2011 10:55 am

I suggest you to play wave file on pic using PWM. where you can have music whatever you want to play.It is really good to start wave file player using microcontroller.
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: Musical DoorBell with PIC16F84A

Post by Rksk » Wed May 25, 2011 3:43 pm

SukhdeepMankoo wrote:I suggest you to play wave file on pic using PWM. where you can have music whatever you want to play.It is really good to start wave file player using microcontroller.
Have you any tutorial, to play wav files using PIC16F84A?

[ Post made via Mobile Device ] Image
DeepakPatil23
Sergeant
Sergeant
Posts: 20
Joined: Mon May 23, 2011 7:16 pm

Re: Musical DoorBell with PIC16F84A

Post by DeepakPatil23 » Wed May 25, 2011 4:33 pm

I suggest you to play wave file on pic using PWM. where you can have music whatever you want to play.It is really good to start wave file player using microcontroller.
Do you have any code and cricuit for that if you have send me please ;)

Thanks :)
SukhdeepMankoo
Lieutenant
Lieutenant
Posts: 92
Joined: Tue Oct 27, 2009 7:50 pm

Re: Musical DoorBell with PIC16F84A

Post by SukhdeepMankoo » Thu May 26, 2011 9:10 am

First all you need to read wave file. after reading the wave file, you will get the data. send that data to pwm register or to DAC. will be get the sound on speaker. Note down the link, which tell you the wave file format.

https://ccrma.stanford.edu/courses/422/ ... aveFormat/


read the format and make program to get the information(data) in wave file.
User avatar
Shane
Captain
Captain
Posts: 226
Joined: Sun Jul 19, 2009 9:59 pm
Location: Jönköping, Sweden

Re: Musical DoorBell with PIC16F84A

Post by Shane » Thu May 26, 2011 6:51 pm

Hi guys
I suggest you to play wave file on pic using PWM. where you can have music whatever you want to play.It is really good to start wave file player using microcontroller.
Sukhdeep, though PWM is a piece of cake for you, it could be a little difficult for novice ;)

So I would like to suggest a more simple solution.
Do a little modification to the main circuit given by Rksk as below. (Only RB0 is connected to the Piezzo speaker and the other end of the speaker is connected to 0V). Keep RB1, RB2 and RB3 unconnected. Don't worry, 1 pin would be enough to power a Piezzo speaker.
cd1.PNG
cd1.PNG (8.2 KiB) Viewed 8099 times
I'm adding the C code for playSound function.

Code: Select all

// frequency table: periods in thousands of ms
#define NFREQ  7
const unsigned char t_period[NFREQ] = {132, 148, 165, 176, 198, 220, 247};

// s - Index of the sound in frequency table
// d - Duration of the sound in numbers of periods
// t - Duration of silence after the sound (to be multiplied by 10 ms)

void playSound (unsigned char s, unsigned char d, unsigned char t){

	unsigned char i, t1;

	t1 = t_period[s];

	for (i = 0; i < d; i++){
		RB0 ^= 1; // Toggle 1 and 0
		Delay_us(t1);
	}
	
	// Turn loudspeaker off
	RB0 = 0;
	
	// Do the silence (if needed)
	for (i = 0; i < t; i++){
		delay10ms();
	}
}
Note that, since 's' is the index of frequency table, you can pass 0 to 6 for different frequencies.

The above C code will work on HiTECH C compiler. However with little modifications to port writing codes, you can get this working for any platform.

deepak, What's the C++ compiler you use for PIC?
By grounding one side of the speaker and a little change to code that operates on RB0, RB1, RB2 and RB3, I think you would be able to get your code working.
DeepakPatil23
Sergeant
Sergeant
Posts: 20
Joined: Mon May 23, 2011 7:16 pm

Re: Musical DoorBell with PIC16F84A

Post by DeepakPatil23 » Fri May 27, 2011 1:04 pm

Hi,
deepak, What's the C++ compiler you use for PIC?
By grounding one side of the speaker and a little change to code that operates on RB0, RB1, RB2 and RB3, I think you would be able to get your code working.
I m using HiTECH C compiler. i have one PIC 16F688 in spare so i m trying to generate sound through this pic. In 16F688 PWM is not present. and for that generating sound is low and not that extend i can use for doorbell.

One more chip is there 16F628A which is in use but i will try with this one very easy and fine solution. Thanks for C code. :) 8-)
Post Reply

Return to “Microcontrollers”