'tone generation w/ramp'
|Well, as luck would have it, a friend of a friend came to me (as advised by
friend 'A') to see if I could create a solution for him.
Basically, its a ramping warble or alarm signal. Warble I assume is more of
a two-tone sound rather than a single frequency tone - right?
He wants to be able to control both the rate (frequency) and the volume such
that over a period of time if the alarm is not silenced, the tone's
frequency will increase and the audio level. He also wants to be able to
select from a warble and just a single beep tone, with the duty cycle of the
beeping also adjustable.
OK...so, warble and beep tones can be generated by a number of methods,
either something like a 555 (which if all he wanted was a single thing, that
would be the simple solution). But because the types of tones desired, and
other such things such as a ramping function for both level and frequency, a
little more control is going to be needed.
Well, could use a PIC, to generate the square waves, and could probably do
the frequency ramping just fine by looping on the actual tone generation and
decreasing the on/off counter variables after so many times thru the loop
until it reaches a final frequency. The PIC won't be able to drive a
speaker very well, so I figure to put some sort of audio amp, and if memory
serves me right, National has some new ones that have a digital volume
control (8 bit port or something like that....have to search the website for
that), so each time I increase the frequency I can increase the 'volume' on
the speaker. There are some other items, such as some relays to activate at
the same time, but thats a no brainier, done that type of interface dozens
So, does the approach sound OK? Anyone with a better idea? I'm not set on
doing this with a PIC by any certain terms. I can write verilog and target
a FPGA or CPLD as well, but perhaps someone has done a similar project or
knows of a available chip that generates tones that can vary frequency on a
ramp basis? I don't mind using a simple chip over writing a bunch of code.
Oh...and Mark.....let me know if this is an on-topic or off-topic and if its
off....everyone please reply private mail.
Sr. Hardware Engineer
Evans & Sutherland Computer Corp
Harrison Cooper wrote:
> The PIC won't be able to drive a speaker very well, so I figure to put
> some sort of audio amp, and if memory serves me right, National has
> some new ones that have a digital volume control (8 bit port or
> something like that....have to search the website for that),
It's going to be expensive!
A PIC has ternary outputs (1,0,off) so three outputs give you 27
levels. Four outputs gives 81 levels so if you allow for driving
alternately positive and negative, you have 40 possible output
amplitudes plus "off". The difference between 39 and 40 won't be too
noticeable however, while the difference between 2 and 3 will.
But for your purpose of a warning tone, that should work quite well.
An LM386 (standard component in sound cards) is a good cheap amplifier.
Note that horn speakers have a quite awful frequency response below
their aperture cut-off.
IOW, you use resistors on the output pins in ratios of three, e.g.:
100k, 33k, 10k, 3k3 and a pair of 2k2 to each rail (sets the quiescent
value to ¸Vcc). Capacitor from this common point to the amplifier
The actual output code consists of two nibbles for each volume; a TRIS
mask and an output code. Could use a lookup table, 40 entries. A
square wave is generated by complementing the output code, same as ever,
switching on/ off by TRIS to the volume code or all input.
How about a PWM-ed audio technique similar to what was discussed here a
The basic idea is this: have a loop which generates very fast PWM (lets say
40kHz in this case),with a duty cycle you control with register A. In
addition, the loop toggles the output pin by XORing it with the value in
the LSB of register B (rather than just toggling it directly by XORing with
THEN, you have a counter variable (C) which gets incremented at intervals
of several cycles of the PWM. In addition, when the counter C is
incremented, you check it to see if it has overflowed. If it has, you
toggle the LSB of B (thereby toggling the PWM output on or off) and set the
counter to a value D. You also increment an additional counter E when C
The value D sets the audible frequency (512-2*D is the number of iterations
of the PWM loop which constitue one period of the audible frequency).
Register A sets the volume level. The last counter,E, can be used as you
"large scale timer",on which you base the decision to ramp up the frequency
Finally, in hardware,all you need is two capacitors and a resistor. One cap
and a resistor to make a low-pass filter to remove the PWM,and the second
cap as DC block to the amplifier input.
I haven't tried this and I'm sure there are some catches with the timing
and the calculations,but I think the idea is sound.
At 01:07 PM 4/29/99 -0600, you wrote:
>Well, as luck would have it, a friend of a friend came to me (as advised by
>friend 'A') to see if I could create a solution for him.
>Basically, its a ramping warble or alarm signal. Warble I assume is more of
>a two-tone sound rather than a single frequency tone - right?
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
cornell.edu ICQ #: 3329174 shb7
More... (looser matching)
- Last day of these posts
- In 1999
, 2000 only
- New search...