PDA

View Full Version : Using Sound cmd on 16F88



Gator_sound
- 7th October 2006, 08:14
Hi all,

I've been trying to generate a sound on the 16f88 for the past couple of weeks and have no luck generating a good sound. I'm using a piezo speaker, I can get a sound but nothing significant enough to wake a person up. I looked through the various threads on this forum but no luck. I've looked through the PBP manual and I set it up to the dot. I used the code:

sound portb.1 [127,1]

I want to be able to generate a loud enough alarm buzzer to wake a person up. Any help would be greatly appreciated. Thank you so much in advance.

gator_sound

sayzer
- 7th October 2006, 09:00
Consider this schematic.
If it works for you, you need to pull the buzzer pin low after each sound command.
For example:

sound portb.1, [127,10]
low portb.1



<img src="http://img8.picsplace.to/img8/21/buzzer.GIF" alt="Image Hosting by PicsPlace.to" >

mister_e
- 7th October 2006, 17:45
Knowing your piezo-speaker resonnant frequency you should be able to produce a louder sound. Use a simple High/pauseUS/low/pauseUS loop or HPWM to produce the right resonnant frequency.

Experimentation will give you the right resonnant frequency, kinda piezo g-spot. Closer you are, louder it is :D

sayzer
- 7th October 2006, 20:52
... piezo g-spot. Closer you are, louder it is :D

Hi Steve,

Is it true in other cases, too?



---------------

mister_e
- 7th October 2006, 23:59
LMAO! i guess it would depend of the hardware :D

Gator_sound
- 8th October 2006, 05:37
Thanks for the reply sayzer and mister_e. I've tried both of your methods but but just the capacitor is louder then the npn transistor unless I am connecting it incorrectly. Any other suggestions? Thanks again for your ideas and help.

mister_e
- 8th October 2006, 08:58
Provide your piezo part # so we could try to find the g-spot of it !

Darrel Taylor
- 8th October 2006, 09:24
Most piezo's oscillate at their resonant frequency when a DC voltage is applied.

The SOUND command outputs a complex form of PWM that is intended to produce a sudo Sine Wave when used with a Low Pass Filter. This won't allow the piezo to oscillate very well at all.

To get the Loudest sound, use sayzer's circuit (with 12V) then set the pin HIGH. (Don't have your ear too close or you'll lose it).

Of course, I wouldn't want to wake up with that sound. It's more like a Smoke Detector high pitch blast.

If you want a better sound using the SOUND command, run it through a low pass filter, then amplify it, then use a normal speaker instead of a piezo.
<br>

mister_e
- 8th October 2006, 09:31
I'm using a piezo speaker, I can get a sound but nothing significant enough to wake a person up.

That raise a question about the part you're using...Is that a simple Piezo or a transducer? If you put 5V across.. what happen? continuous sound or nothing else than a single 'tick'...


Piezo buzzer
piezo sounder
piezo transducer
....
....
...

Part # will be handy.

Gator_sound
- 8th October 2006, 10:42
Hi Steve,

Its a cheap Radio Shack Piezo Element 1500-3000Hz Buzzer (#273-073):

I get a working continuous buzzing sound in it but its not loud enough. I used a function generator and it produced a better sound than what I'm getting from my PIC. Hope this info helps.

sayzer
- 8th October 2006, 11:11
...1500-3000Hz.. I used a function generator and it produced a better sound than what I'm getting from my PIC...


Since you are using Note 127, you are driving your piezzo by 10,000Hz.
Check Sound command details to find the correct Note number which should give you a frequency between 1500-3000Hz. So g-spot of this piezzo has been found & touched!



LMAO! i guess it would depend of the hardware

Provide your piezo part # so we could try to find the g-spot of it !

The hardware is ticking like a Swiss clock. No doubt on that!
But, sometimes when you know for sure that you are not even close to g-spot, you still get a loud sound. How about that?




-------------------------------

mister_e
- 8th October 2006, 20:32
But, sometimes when you know for sure that you are not even close to g-spot, you still get a loud sound. How about that?

I could disgress and talk about using the right i/o but...

Gator, use HPWM and a loop like that


Freq var Word

Start:
For Freq=1500 to 3000 step 100
HPWM 1,Freq, 127
Pause 200
next
Goto Start


You'll notice some 'volume' change on every different frequency, choose the louder one. Using the Sayzer driver circuit will add to your pleasure.

OR use your function generator, measure the frequency once you hit the louder frequency, and apply it on the HPWM command.

Gator_sound
- 13th October 2006, 03:57
Hi mister_e,

Are you talking about using the HPWM on the 16f88 or a PIC with a physical PWM pin?

mister_e
- 13th October 2006, 04:13
Both.. THE PIC16F88 have a built-in PWM module... also named CCP.

Gator_sound
- 14th October 2006, 21:06
mister_e,

Thank you and sayzer for the information. If its not too much of a hassle is it possible to provide an example for the PWM using the CCP register. I'm still trying to get used to programming in basic. Programming in assembly has thrown me off when I'm thinking about programming in basic. Thanks in advance.

mister_e
- 14th October 2006, 21:09
HPWM will handle it for you. if 8 bit resolution is enough, it's the easiest way.

BigWumpus
- 14th October 2006, 21:22
I've tried a lot with piezo-summers... (without any circuit in them!)!

Forget it !

Buy readymade Piezo-beepers for intrusion-detection !

Piezo-beepers are allowed to have 24 Volt accross them. So I have used a circuit to double the power (5V -> 10V) with one pin of the PIC and loaded a 1000uF condensator. Then I use a MOSFET-driver ICL7667 to drive the beeper from this 10V. It is loader, but using some cheap magnetic beepers from digisound is much more easy....

;-)

Gator_sound
- 14th October 2006, 21:38
BigWumpus,

Do you have a part number or a particular place where I can purchase a ready made piezo-beeper? thanks.

BigWumpus
- 19th October 2006, 13:44
Digisound F/UCW 03 or ...06

Gator_sound
- 28th October 2006, 20:31
Hi everyone,

I finally got a PIC with HPWM. Is there anything else I have to setup aside from the ccp1con? Thanks

sayzer
- 29th October 2006, 11:29
Which pic is it?

PR2, T2CON are others most likely.


----------------------

Gator_sound
- 31st October 2006, 16:14
Hi sayzer,

its a 18f1320 with the HPWM without the HPWM 16f88. thanks

sayzer
- 31st October 2006, 16:50
Hi Gator,

18f1320 has "Enhanced CCP module" which is more complicated then the others.
Also it has four PWM outputs, P1A through P1D, and this makes CCP1CON register more complicated to be set.

It is over my head, and I have zero experience in it. I am eager to learn it though as I will have to work with 6pwm channels soon.

May be our highly experienced members can give you hand on that? and you can post the ongoing progress here...


-----------------------------

Gator_sound
- 5th November 2006, 23:18
Its finally working. The code (sound command) was right but not sure why it did not work. I changed the output pin and now its working. Thanks for those who have replied. I really appreciate it.