Searching \ for 'How to create a tone output?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ios.htm?key=output
Search entire site for: 'How to create a tone output?'.

Truncated match.
PICList Thread
'How to create a tone output?'
1997\02\27@135927 by Scott Horton

flavicon
face
I have a simple project I'm working on where I need to have my pic provide
a tone or beep for 1/2 to 1 sec or so.  This is for audibile notification
of a switch closing.  I need to use plain old headphones like those used
with Sony walkman type radios.  I know haow to do everything except have a
PIC generate a "beep".

Can one of you EE guru's help me with what I hope is a simple solution?

Thanks very much in advance.

Scott

1997\02\27@163140 by David W. Duley

picon face
In a message dated 97-02-27 14:01:08 EST, you write:

<<
I have a simple project I'm working on where I need to have my pic provide
a tone or beep for 1/2 to 1 sec or so.  This is for audibile notification
of a switch closing.  I need to use plain old headphones like those used
with Sony walkman type radios.  I know haow to do everything except have a
PIC generate a "beep".

Can one of you EE guru's help me with what I hope is a simple solution?

Thanks very much in advance.

Scott
 >>
Scott,
Beeping is very easy.
Connect a piezo speaker directly between an output pin (one of the port pins)
and ground, or you can use a cheap PM speaker like the ones found in an IMB
PC.  You might want to put a series resistor of about 270 ohm or so to limit
the current from the pin.  You also might want to put a capacitor in series
with a speaker so the speaker won't heat up if you leave the output pin on.

Now for the beep

The basics for tone generation is simple


Beep
       Turn_On_Speaker_Bit
        Delay
        Turn_Off_Speaker_Bit
        Delay
        Goto Beep

This is Psudo Code of course.
This will generate a tone with a 50% duty cycle of 'DELAY' period.

You will probably want to add a 16 bit counter to limit the length of the
beep.

This is a snipit of code I used on a project.  This code uses the RTC to time
the beep duration
Buzzit
       bcf     intcon,7        ;disable RTC interupt
       movlw   .2
       movwf   Time
       clrf    rtc
       bcf     StatFlag,0      ;clear the timeout flag
       bsf     intcon,7        ;enable RTC interupt
BuzzLoop
       bsf     BuzzPort,Buzzer  ;Turn on speaker port
       movlw   .65
       movwf   wait1
       call    shortdelay
       bcf     BuzzPort,Buzzer  ;Turn off speaker port
       movlw   .65
       movwf   wait1
       call    shortdelay
       btfss   StatFlag,0      ;see if rtc has timed out
       goto    BuzzLoop

shortdelay     ;8 bit delay routine
       movwf   wait1
shortloop
       decfsz  wait1,f
       goto    shortloop
       retlw   0

You could replace the bsf and bcf (turning on and off the port) with an
exclusive OR.  Anything excusive ored with 1 will generate a push on push off
type response.  eg. 0 xor 1 = 1, 1 xor 1 = 0.  You eliminale a few lines of
code this way.

Hope this helps
Dave Duley
V.P. DreiTek Inc.

1997\02\27@165151 by Scott Horton

flavicon
face
David:

Thanks for the suggestion.  Forgive my lack of understanding of speaker
electronics but I don't understand a couple of things...maybe you can
help.

Your Suggested pseudo-code:
>>Beep
>>        Turn_On_Speaker_Bit
>>         Delay
>>         Turn_Off_Speaker_Bit
>>         Delay
>>         Goto Beep

I can't use a piezo buzzer of PC-speaker as you suggested.  I actually
NEED to use a small headphone.  The reason for this is that I need a user
to audibly detect an discreet event being monitored by my PIC.  The device
will be used in a high noise (loud auditory) enviroment.  They aren't
always looking at the led indicator which blinks, and can't hear something
on the device.

Using you suggestion, how do I adjust volume, and tone on a set of
headphone speaker(s)?

Thanks,

Scott

1997\02\27@184113 by Steve Hardy

flavicon
face
{Quote hidden}

If the headphones are high impedance (>200 ohms) then drive them directly
from a port pin, through a 1uF capacitor.  If low impedance, use one
of those mini 'transistor radio' transformers which have a 500ohm primary
and 8ohm secondary.  Again, drive the primary through a cap and connect
the headphones to the secondary.  I have used this arrangement to drive
headphones and even a mini speaker.  If not loud enough, you can add
an extra 6dBm by using two outputs in bridge mode.

To adjust the volume, use PWM.  This is easy if you are using one of
the PICs with PWM - you can even generate sine waves and arbitrary
waveforms.  It's still fairly easy if you have to program the PWM
yourself.

Regards,
SJH
Canberra, Australia

1997\02\28@030039 by David BALDWIN

flavicon
face
Look at the app. notes from Microchip, I didn't remember the number,
but it was over Pic 16C5x and talked about making a complete clock with
alarm, and of course beep...

       Hope this helps.

1997\02\28@083940 by Jean Robitaille

flavicon
face
>> Using you suggestion, how do I adjust volume, and tone on a set of
>> headphone speaker(s)?
>

>To adjust the volume, use PWM.  This is easy if you are using one of
>the PICs with PWM - you can even generate sine waves and arbitrary
>waveforms.  It's still fairly easy if you have to program the PWM
>yourself.
>
>Regards,
>SJH
>Canberra, Australia
>

What is PWM?

If I want to adjust just the volume, what would you do?

Jean

1997\02\28@085218 by Larry G. Nelson Sr.

flavicon
face
At 03:48 PM 2/27/97 -0600, Scott Horton wrote:
>David:
>
>Thanks for the suggestion.  Forgive my lack of understanding of speaker
>electronics but I don't understand a couple of things...maybe you can
>help.
>
>Your Suggested pseudo-code:
>>>Beep
>>>        Turn_On_Speaker_Bit
>>>         Delay
>>>         Turn_Off_Speaker_Bit
>>>         Delay
>>>         Goto Beep
 I actually
>NEED to use a small headphone.  The reason for this is that I need a user
>to audibly detect an discreet event being monitored by my PIC.
>Using you suggestion, how do I adjust volume, and tone on a set of
>headphone speaker(s)?

Change the loop to have on and off with two delays, ie delay1 and delay2.
Have power flow thru the headphones for a shorter time than the current is
off and the volume will go down. This is what PWM is all about.

Larry
Larry G. Nelson Sr.
.....L.NelsonKILLspamspam@spam@ieee.org
http://www.ultranet.com/~nr

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...