Searching \ for 'DTMF Tones? [Idea]How to produce sine wave' 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/pots/dtmf.htm?key=dtmf
Search entire site for: 'DTMF Tones? [Idea]How to produce sine wave'.

Truncated match.
PICList Thread
'DTMF Tones? [Idea]How to produce sine wave'
1999\11\12@140821 by Nikolai Golovchenko

flavicon
face
part 0 3906 bytes

{Quote hidden}

I may be inventing the wheel... Anyway, there was an interesting idea in
Scenix application notes on how to generate sine waveform not using table or
multiply, just addition. Basically, they generate triangle waveform, then
integrate it and, vou la, something very similar to sine is produced.
Triangle waveform is easy to implement - its just addition and substraction.
So, the frequency of sine waveform is equal to the primary triangle
frequency.

BUT, a problem appears when triangle frequency doesn't exactly match
sampling frequency divided by an integer. Typical way to make triangle is
something like: add to the current value fixed step untill the wave reaches
maximum, then substract the step untill the wave reaches minimum, and again.
What if the triangle reaches its maximums and minimums BETWEEN sampling
points? In this case, an error will appear, and frequency is corrupted.

A simple solution is: when triangle waveform goes over maximum, substract
the number it went over from the maximum (see appendix); and same for
minimum. As a result, the frequency is jitter free.

The drawback is that the resulting sine amplitude is varying slightly
depending on the step chosen.

For DTMF it must be okay. 16bit resolution for step, accumulators of
triangle and sine will be enough. For output, only 8 most significant bits
can be taken.

Is this the same as phase accumulators?
_

Nikolai Golovchenko, Electrical Engineering Student
National Mining University of Ukraine http://www.nmuu.dp.ua
Dnepropetrovsk, Ukraine
E-mail: .....golovchenkoKILLspamspam@spam@mail.ru


P.S.
Tracy, may I ask you what "dot lo" means?

:-)


Attachment converted: wonderland:solution.gif (GIFf/JVWR) (0000F660)

1999\11\12@162527 by Tracy Smith

picon face
--- Nikolai Golovchenko <golovchenkospamKILLspamMAIL.RU> wrote:

> I may be inventing the wheel... Anyway, there was an
> interesting idea in
> Scenix application notes on how to generate sine
> waveform not using table or
> multiply, just addition. Basically, they generate

It's fun to reinvent the wheel (except when it's on
your nickel).

> triangle waveform, then
> integrate it and, vou la, something very similar to
> sine is produced.

Are you sure this is not the Goertzel algorithm? Scott
has a page that discusses this algorithm.

Also, here's a dtmf generator that uses Goertzel
http://www.ti.com/sc/docs/psheets/abstract/apps/spra066.htm

http://www.interstice.com/~sdattalo/technical/theory/sinewave.html

But again, I think Eric Smith's solution is the best.

> Is this the same as phase accumulators?

No. Phase accumulators are really, really cool. I just
don't know how to adequately explain them. A quick
alta vista search produced:

http://www.g4dvj.demon.co.uk/dds.htm

> P.S.
> Tracy, may I ask you what "dot lo" means?
>
> :-)

I let that cat out of the bag when I'm ready. :)

.lo

=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

1999\11\12@181518 by Paul B Webster

flavicon
face
Nikolai Golovchenko wrote:

> Is this the same as phase accumulators?

 I beg to differ from Tracy.  I think it is.  Phase accumulators are
based on the principle of - as the name suggests - adding up little
pieces of the cycle and "rolling over" when the sum of these amounts to
or in fact exceeds, a full cycle.

 That appears to be exactly what is suggested here; you would be using
a phase accumulator to control the up/ down ramp of the wave, then
filtering it further in analogue circuitry.  It begs the question though
of using a full-blown phase accumulator/ DDS with (a number of stages
of) integration.

 Once you go the DDS path, you are in a position to vary the slope of
the waveform during the cycle, by using even a simple resistive DAC,
(or perhaps PWM) which *greatly* eases the requirements on your
integration/ low-pass filtering.

 I would think that even a 3-bit (six resistor) ADC would considerably
improve performance, and perhaps allow output of both tones via the one
channel (though Dave Van Horn's "twist" would still be a difficulty).
--
 Cheers,
       Paul B.  (away from home for a day or so!).

1999\11\12@181743 by Harold M Hallikainen

picon face
On Fri, 12 Nov 1999 13:24:37 -0800 Tracy Smith <.....dot_loKILLspamspam.....YAHOO.COM> writes:
>--- Nikolai Golovchenko <EraseMEgolovchenkospam_OUTspamTakeThisOuTMAIL.RU> wrote:
>
>> I may be inventing the wheel... Anyway, there was an
>> interesting idea in
>> Scenix application notes on how to generate sine
>> waveform not using table or
>> multiply, just addition. Basically, they generate
>
>It's fun to reinvent the wheel (except when it's on
>your nickel).
>
>> triangle waveform, then
>> integrate it and, vou la, something very similar to
>> sine is produced.
>

       Of course, a triangle wave is just a square wave run through an
integrator (which is sorta like a 0 Hz low pass filter with a 6 dB/octave
or 20 dB/decade roll-off).  I think an additional stage of LPF is cheaper
than doing a D/A of a triangle wave, then filtering it.
       I think phase accumulation and DDS is really neat, though I
haven't used it yet in anything.  By having different tables before the
D/A, you can do arbitrary waveform generation.  The anti-alias filter
needs to be somewhere above the maximum output frequency and below the
Nyquist frequency (50% of sample rate).  With a perfect filter, you'd get
a perfect sine wave out of the thing (assuming you are doing sine wave
synthesis).  You can vary the frequency and the output level remains the
same.  Anything that uses filters to remove harmonics (instead of alias
components) will have the output level vary as the frequency is varied
unless you have the filter track the output frequency (kind of a pain).
       One thing I'd like to try some time is to have a look up table
that simulates a linear mix of several sinusoidal signals (stuff around 1
MHz), then drive the D/A.  I wonder how much intermod there'd be...

Harold



Harold Hallikainen
haroldspamspam_OUThallikainen.com
Hallikainen & Friends, Inc.
See the FCC Rules at http://hallikainen.com/FccRules and comments filed
in LPFM proceeding at http://hallikainen.com/lpfm

___________________________________________________________________
Get the Internet just the way you want it.
Free software, free e-mail, and free Internet access for a month!
Try Juno Web: dl.http://www.juno.com/dynoget/tagj.

1999\11\12@194116 by Tracy Smith

picon face
--- S Webster <@spam@s.websterKILLspamspamSTUDENT.UNSW.EDU.AU> wrote:
A.K.A. Paul

> Nikolai Golovchenko wrote:
>
> > Is this the same as phase accumulators?
>
>   I beg to differ from Tracy.  I think it is.  Phase
> accumulators are
> based on the principle of - as the name suggests -
> adding up little
> pieces of the cycle and "rolling over" when the sum
> of these amounts to
> or in fact exceeds, a full cycle.

True, but that's not what Nikolai described (I
thought). OTOH, I'm hardly the Phase Accumulator
expert. My understanding of the phase accumulator is:

You start off with a single cycle of something you
wish to generate. This may be a square wave, sine
wave, or a hyperbolic paraboloid wave (what in the
hell is that?). The phase accumulator simply
determines which portion of the cycle you wish to
access.

In its simplest form, the single cycle of the wave
form is in an array and the phase accumulator is the
index. The array is accessed at a constant rate,
however the index is advanced according to the
frequency of the wave form. Here's a simple C example:

#define TABLE_SIZE  256

char wave_table[TABLE_SIZE];

float phase,delta_phase;

void phase_accumulator(void)
{
 int i;

 while(1) {

   phase += delta_phase;

   if(phase > TABLE_SIZE)
     phase -= TABLE_SIZE

   i = phase;

   output(wave_table[i]);

   routine_that_updates_delta_phase(&delta_phase);
 }

}

void main(void)
{

 delta_phase = ....
 init_wave_table(wave_table);

}


I'd definite do this in assembly instead of C (but
that's another thread). In each application, there are
always ways to optimize this approach. For example,
for square waves you don't need a table at all nor do
you need floating point arithmetic for the phase
accumulator.  Fixed point arithmetic works fine and
the most significant bit of the phase accumulator is
the output. For most pics, you're forced to optimize
because 256 element arrays (in ram aren't possible).
256 element arrays in code are possible, but are
always a pain in the ass (because of page boundaries).



Who knows, perhaps it's only semantic and S. and I are
on the same page. But like I said, I'm not the
expert...

>   I would think that even a 3-bit (six resistor) ADC
> would considerably
> improve performance, and perhaps allow output of
> both tones via the one
> channel (though Dave Van Horn's "twist" would still
> be a difficulty).

Borrowing a little from the best of both worlds is
often the best solution.

.lo

=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

1999\11\13@122130 by Nikolai Golovchenko

flavicon
face
-----Original Message-----
From: Tracy Smith <KILLspamdot_loKILLspamspamYAHOO.COM>
To: RemoveMEPICLISTTakeThisOuTspamMITVMA.MIT.EDU <spamBeGonePICLISTspamBeGonespamMITVMA.MIT.EDU>
Date: Friday, November 12, 1999 11:26 PM
Subject: Re: DTMF Tones? [Idea]How to produce sine wave


{Quote hidden}

Sure it is not. The Goertzel algorithm calculates sine value by a recursive
formula, which uses two previous values. Moreover, there is a multiply to do
and Scott mentions round off errors accumulation. The method I suggest uses
only one previous sample, no multiply, no frequency error, no ...  :-)
Should Scott Dattalo add yet another, 11th method?

>
>Also, here's a dtmf generator that uses Goertzel
>http://www.ti.com/sc/docs/psheets/abstract/apps/spra066.htm
>


Are you kidding? This is a decoder algorithm.

{Quote hidden}

Thanks for the link. Explanation is perfect.
I think that my method resembles phase accumulator and table method except
there is no table. The table is generated on the run and this is triangle.
In my case error of triangle generation is lower, because there is no
restriction to use only table values. Finally, this reduced error makes the
sine wave frequency more stable. Certainly, the phase accumulator method is
more straight-forward and simple, at the cost of frequency jitter. In case
of DTMF this is mainly the frequency what matters, because DTMF frequencies
are very close.

{Quote hidden}

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-----Original Message-----
From: Harold M Hallikainen <RemoveMEharoldhallikainenspamTakeThisOuTJUNO.COM>
To: PICLISTEraseMEspam.....MITVMA.MIT.EDU <EraseMEPICLISTspamMITVMA.MIT.EDU>
Date: Saturday, November 13, 1999 1:17 AM
Subject: Re: DTMF Tones? [Idea]How to produce sine wave

>        Of course, a triangle wave is just a square wave run through an
>integrator (which is sorta like a 0 Hz low pass filter with a 6 dB/octave
>or 20 dB/decade roll-off).  I think an additional stage of LPF is cheaper
>than doing a D/A of a triangle wave, then filtering it.

Thanks Harold, I wonder why it didn't come to my head... In this particular
case, triangle of fixed frequency seems easier to produce than square.



_

Nikolai Golovchenko, Electrical Engineering Student
National Mining University of Ukraine http://www.nmuu.dp.ua
Dnepropetrovsk, Ukraine
E-mail: RemoveMEgolovchenkoEraseMEspamEraseMEmail.ru

1999\11\14@110103 by Tracy Smith

picon face
> >Are you sure this is not the Goertzel algorithm?
> Scott
> >has a page that discusses this algorithm.
>
>
> Sure it is not. The Goertzel algorithm calculates
> sine value by a recursive

Yeah, I misunderstood what you were describing. Sorry


> >
> >Also, here's a dtmf generator that uses Goertzel
>
>www.ti.com/sc/docs/psheets/abstract/apps/spra066.htm
> >
>
>
> Are you kidding? This is a decoder algorithm.

No, I'm not kidding, just wrong.

> >http://www.g4dvj.demon.co.uk/dds.htm
> >
>
>
> Thanks for the link. Explanation is perfect.

1 out of 3 pieces of information distributed on the
pic list is decent. :)

{Quote hidden}

True, butt, if you incorporate the proper
interpolation along with your look up table, then the
jitter effects are mitigated. Without any
interpolation, the sinewave output from the look-up
table is a stair-stepped waveform. The higher the
update frequency, the smaller the steps and the closer
to a sine wave approximation. This 'stair-stepped'
wave form however is a form of interpolation;
specifically zero-order interpolation. You may have
heard of a "zero-order hold" in your studies on
signals and systems (and perhaps z-transforms).
According to the 'theory', as long as you satisfy the
Nyquist sampling criterion, you can exactly reproduce
the synthesized wave form. But I couldn't look at you
with a straight face and say it's possible. The caveat
is that a perfect low-pass filter must be constructed.
DTMF competition is much too cheap for us to insist on
perfect analog filters.

So the next step is first order interpolation. For our
application, this is linear interpolation between
consecutive samples in the table. (For sampling
theory, there are some subtle but important
differences on the interpretation of a first-order
hold.) Which is to say, if you need a sample that is
not (exactly) at one of the sample points in your
table, then you approximate it by using linear
interpolation. For example, suppose you had a table
with 10 samples: f(i) is the function defined for i
=0..9 . Now suppose you need f(2.25)? Well, using
linear interpolation you'd approximate this:

f(2.25) - f(2)    f(3)  - f(2)
-------------- = -------------
 2.25  -   2       3   -   2

f(2.25) ~= f(2) + 0.25*(f(3) -f(2))

>From a frequency or spectral point of view, linear
interpolation's effect on higher harmonics are
approximately the square of the harmonics introduced
by zero-order interpolation (sinc vs. sinc^2). And
since the magnitude of the higher harmonics is less
than one, this is a good thing (e.g. 1/9 is much
smaller than 1/3). The direct implication is that the
stringent low-pass filter constraints associated with
the stair stepped waveform can be relaxed.

>From an intuitive view, you can see how first-order
interpolation improves the table values. For example,
if you had 64 samples of sine wave over one cycle,
then the deviation between linear interpolation and
the 'true value' of the sine wave is quite small. In
fact, an error bound may be placed on it.
Specifically, as I alluded to in another thread, you
can use the Cauchy Remainder Theorem for
interpolation. In essence, this theorem states that
the error is bounded by the n'th derivative of the
function your approximating, where n is the order of
the interpolation (1 for linear). So in the above
example,

The error in approximating:

f(2.25) ~= f(2) + 0.25*(f(3) -f(2))

error <= abs(f'(3) - f'(2))

Now there are additional caveats, like you still have
to satisfy Nyquist.

.lo

ps. Please forgive any mistakes, this is all from memory...

=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

1999\11\15@021719 by Nikolai Golovchenko

flavicon
face
-----Original Message-----
From: Tracy Smith <RemoveMEdot_lospam_OUTspamKILLspamYAHOO.COM>
To: RemoveMEPICLISTTakeThisOuTspamspamMITVMA.MIT.EDU <EraseMEPICLISTspamspamspamBeGoneMITVMA.MIT.EDU>
Date: Sunday, November 14, 1999 6:01 PM
Subject: Re: DTMF Tones? [Idea]How to produce sine wave


>1 out of 3 pieces of information distributed on the
>pic list is decent. :)

I would say 1 out of 10. ;)


{Quote hidden}

This means a biggg table. Interesting, what size of table will be sufficient
to minimize jitter enough for DTMF application.

{Quote hidden}

Let me compare two methods of sine generation for DTMF application:
1)Triangle generation with subsequent integration.
2)Phase accumalator&table with linear interpolation;

The first method doesn't have table, instead, triangle waveform is generated
using addition of a fixed step to the previous sample. No need to use
interpolation means faster execution time. To produce sine waveform
integration is used - some degradation in the waveform, which is acceptable
in DTMF. As a result, the first method generates efficiently jitter free,
sine waveform signal.

The second method has table, therefore it requires more ROM; needs linear
interpolation - more computing time because of multiplication. Result is the
same.


What do you think?

_

Nikolai Golovchenko, Electrical Engineering Student
National Mining University of Ukraine http://www.nmuu.dp.ua
Dnepropetrovsk, Ukraine
E-mail: RemoveMEgolovchenkoKILLspamspammail.ru

1999\11\15@024911 by Dave VanHorn

flavicon
face
> What do you think?


You want the part number of that chip again?  :)
Three pins, clocked serial byte for what digit to say, and one pin as /xmit.
One external component, a 3.585 mhx xtal or resonator.

:o)

1999\11\15@101948 by Tracy Smith

picon face
--- Dave VanHorn <dvanhornSTOPspamspamspam_OUTCEDAR.NET> wrote:
> > What do you think?
>
>
> You want the part number of that chip again?  :)
> Three pins, clocked serial byte for what digit to
> say, and one pin as /xmit.
> One external component, a 3.585 mhx xtal or
> resonator.
>
> :o)

Wouldn't it be better to run the 12C508 off the
internal oscillator instead. :)

.lo


=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

1999\11\15@105408 by Tracy Smith

picon face
--- Nikolai Golovchenko <spamBeGonegolovchenkoSTOPspamspamEraseMEMAIL.RU> wrote:
> -----Original Message-----

> >True, butt, if you incorporate the proper
> >interpolation along with your look up table, then
> the
> >jitter effects are mitigated. Without any
> >interpolation, the sinewave output from the look-up
> >table is a stair-stepped waveform. The higher the
> >update frequency, the smaller the steps and the
> closer
> >to a sine wave approximation. This 'stair-stepped'
>
>
> This means a biggg table. Interesting, what size of
> table will be sufficient
> to minimize jitter enough for DTMF application.

Actually, the table is not biggg. That's the beauty of
linear interpolation. See below.


{Quote hidden}

Actually "some degradation" may not be acceptable. A
symmetrical triangle wave has odd harmonics whose
strengthes vary inversely to the square of the
harmonic number (e.g. the third harmonic is 1/9'th the
strength of the fundamental). A low pass filter would
be of no use since to generate 440Hz, you'd need to
block 1320Hz which would also block a few of the
higher frequency DTMF tones as well. Ideally, you want
to have to only block some very high frequency
carrier. For example, if you were using PWM with a
20kHz carrier to generate DTMF then you'd need to
block the 20kHz and pass (a maximum of) ~1600Hz. A
relatively simple 2'nd order low pass filter with
perhaps a cascaded 2'nd order notch (or band-stop)
would be sufficient.

>
> The second method has table, therefore it requires
> more ROM; needs linear
> interpolation - more computing time because of
> multiplication. Result is the
> same.
>
>
> What do you think?

I just re-visited Scott's sine wave page:

http://www.interstice.com/~sdattalo/technical/software/pic/picsine.html

His table contains only 16 entries and (according to
the comments) can generate a new sample every 65
instruction cycles. I see a way to knock 10 cycles
off. So to generate the two tones you'd need about 110
cycles plus an additional overhead of perhaps 50 more
cycles. This'll give you a new sample at about a 30kHz
rate (for a 20Mhz pic). But you'd still need a way to
convert this to analog. So perhaps you'd could back
the generation frequency to 20kHz (or ~256 cycles) and
use an 8-bit pwm.

---------

Perhaps it's not obvious, but the triangle-to-sine
algorithm may also be viewed as a kind of a digital
filter, or more specifically the impulse response of a
digital filter. Consequently, you may wish to consider
other simple algorithms. (e.g. a 4'th order FIR filter
with binary coefficients or perhaps a 3'rd order IIR.)

.lo

=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

1999\11\16@012723 by Nikolai Golovchenko

flavicon
face
-----Original Message-----
From: Tracy Smith <KILLspamdot_lospamBeGonespamYAHOO.COM>
To: EraseMEPICLISTspamEraseMEMITVMA.MIT.EDU <@spam@PICLIST@spam@spamspam_OUTMITVMA.MIT.EDU>
Date: Monday, November 15, 1999 5:54 PM
Subject: Re: DTMF Tones? [Idea]How to produce sine wave


>Actually, the table is not biggg. That's the beauty of
>linear interpolation. See below.


Sorry, I wasn't clear at this. I meant that interpolation may be omitted if
the table is big enough to reduce jitter for DTMF frequencies. The question
is how big.


>Actually "some degradation" may not be acceptable. A
>symmetrical triangle wave has odd harmonics whose
>strengthes vary inversely to the square of the
>harmonic number (e.g. the third harmonic is 1/9'th the
>strength of the fundamental). A low pass filter would
>be of no use since to generate 440Hz, you'd need to


You forget the integration. It acts like LP filter (6 dB/octave) and is made
digitally. Already, third harmonic magnitude A3 = 1/9 A1 (-19 dB, assuming 0
dB for the fundametal harmonic), and fifth A5 = 1/25 A1 (-28 dB). When
integration is applied, higher harmonics will be further attenuated by 9.5
dB for the third one and by 14 dB for the fifth. Totally, the relative level
of third harmonic is -28 dB and the fifth is -42 dB. As far as I know,
required signal to noise ratio in this kind of systems is 20 dB. So
integration solves the problem, isn't it?

{Quote hidden}

An LP filter should be used, of course, at the output stage of D/A or PWM.
It's pass band should include all DTMF frequencies.

{Quote hidden}

I dont have time right now to look at this routine, have to go to school. It
seems that this small table will require additional effort on calculation of
mid points to get more accurate frequency.

>Perhaps it's not obvious, but the triangle-to-sine
>algorithm may also be viewed as a kind of a digital
>filter, or more specifically the impulse response of a
>digital filter. Consequently, you may wish to consider


Yeah, this is a first order FIR filter with unitary coefficients.

>other simple algorithms. (e.g. a 4'th order FIR filter
>with binary coefficients or perhaps a 3'rd order IIR.)


Simple? :) Second order FIR may be. But 3'rd order IIR - no, thanks. First
order IIR is enough to generate sine waveform. It requires cumbersome
multiplication.

Bye for now.

_

Nikolai Golovchenko, Electrical Engineering Student
National Mining University of Ukraine http://www.nmuu.dp.ua
Dnepropetrovsk, Ukraine
E-mail: spamBeGonegolovchenkospamKILLspammail.ru

1999\11\16@183333 by Tracy Smith

picon face
At the risk of boring everyone with our on-line
dialog,

> >Actually, the table is not biggg. That's the beauty
> of
> >linear interpolation. See below.
>
>
> Sorry, I wasn't clear at this. I meant that
> interpolation may be omitted if
> the table is big enough to reduce jitter for DTMF
> frequencies. The question
> is how big.

Again, Cauchy Remainder Theorem for interpolation may
be used. In this instance however, it's zero order
interpolation (i.e. NO interpolation). IIRC, the error
will be proportional to the differences in consecutive
entries in the table (I don't know if or what the
proportionality constant is). I think intuitively this
makes sense. If the index into the table is a
fraction, you'll have to round to the nearest integer.
Consequently, the ideal sample which lies somewhere
between the two that are in the table will be off. And
assuming you're satisfying Nyquist, the error will be
bounded by the samples that are available.

> You forget the integration.

Could you perhaps drag up the details showing how this
algorithm really works?


> I dont have time right now to look at this routine,
> have to go to school. It
> seems that this small table will require additional
> effort on calculation of
> mid points to get more accurate frequency.

Compared to Eric's table, you're right. His takes
about 15 cycles; a savings of about 40 cycles. OTOH,
it has 64 entries in the table. I'd probably choose
Eric's sine over Scott's for DTMF (especially since
Eric already wrote the damn DTMF dialer). 64 table
entries is not that many. Further more since the
sample output rate is potentially 3 or 4 times faster
you could ease the filter requirements even more
(again, this depends on how you actually go from a to
d...)

{Quote hidden}

The simplest 3'rd order IIR I know is Simpson's
3/8'ths rule. It's not quite as good as the 1/3 rule,
but it's much better than the rectangular rule for
numeric integration. The only caveat is that even
though it is an integration formula, it's transfer
function in fact amplifies high frequencies.

.lo

=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

1999\11\17@152453 by Nikolai Golovchenko

flavicon
face
part 0 3051 bytes content-type:application/octet-stream;
>Could you perhaps drag up the details showing how this
>algorithm really works?


The algorithm is really simple. You can find the original version in Scenix
Application Note #11 (http://www.scenix.com). The original version is hard to use
for any frequency because of fixed triangle slope and amplitude. So I
changed the algorithm a little to adjust for DTMF frequencies generation.

First you initialize accumulators. There are two - one is a triangle
accumulator and another is a sine accumulator. Then,  each new sample is
calculated by a common routine. Note, that these accumulators contain
current value of sine/triangle, not phase.

Sine waveform is generated by adding to the last sine value the last value
of triangle. This may be regarded as integration or first-order FIR
filtering of triangle signal. As a result, the fundamental harmonic of
triangle is attenuated significantly less then other harmonics, and you have
almost clean sine wave. The sine wave frequency is equal to that of
triangle. Triangle waveform is primary in this case and generated by adding
pre-calculated fixed step to the triangle accumulator. When the accumulator
reaches top limit (also pre-calculated for the given frequency) the step's
sign is changed. A little nuance here. If the triangle peak lies somewhere
between current and last sample then a correction required to keep the
triangle value correct. After triangle reaches bottom limit, the step's sign
changes again.

Actually, I wrote the sine waveform generation routine for PIC. It takes 64
instructions, 8 RAM bytes, 24 cycles best case, and 41 cycles worst case.
This is 14 cycles savings from your supposed 55. The routine takes input 2
bytes for limit and 2 bytes for step, other 4 bytes are for 16 bit
accumulators.

For comparison I also simulated the routine of Scott Dattalo in MATLAB at 20
kHz sampling rate for all DTMF frequencies. Results are very good. There is
no frequency jitter at all and the frequency error is very small. Sorry for
wrong
suggestions.

The phase steps are:
f, Hz      Phase step
697        571
770        631
852        698
941        771
1209       990
1336       1094
1477       1210
1633       1338

phaseaccstep = round(16384 * f / f0), where f=needed freq. and f0=sampling
freq.

If I had to do DTMF dialer I would choose the phase accumulators method and
Scott Dattalo's routine, because it can provide close approximation to sine
wave, small program size, frequency can be changed smoothly, without phase
jerk.

I suppose other applications may exist where higher speed of my method is
very important.

Thanks for productive dialog. I hope this will help somebody else.


Best regards.
_

Nikolai Golovchenko, Electrical Engineering Student
National Mining University of Ukraine http://www.nmuu.dp.ua
Dnepropetrovsk, Ukraine
E-mail: .....golovchenkospam_OUTspammail.ru



Content-Type: application/octet-stream;
       name="sin.asm"
Content-Disposition: attachment;
       filename="sin.asm"

Attachment converted: wonderland:sin.asm (????/----) (0000F8FC)

1999\11\17@162744 by Dave VanHorn

flavicon
face
> For comparison I also simulated the routine of Scott Dattalo in MATLAB at
20
> kHz sampling rate for all DTMF frequencies. Results are very good. There
is
> no frequency jitter at all and the frequency error is very small. Sorry
for
> wrong suggestions.


So how do you establish twist?

1999\11\17@191816 by Tracy Smith

picon face
--- Nikolai Golovchenko <TakeThisOuTgolovchenko.....spamTakeThisOuTMAIL.RU> wrote:
{Quote hidden}

Without taking the time to read scenix's appnote, I'll
take your word at face value - (I have no reason not
to since you're obviously a logical thinker), and add
just one more comment. If instead of generating
triangle waves you wish to generate trapezoidal waves,
then it possible to exactly suppress all of the even
harmonics AND the third harmonic. I'll leave it as an
excercise for the student, but my theoretical analysis
proves that if the trapezoid has a rise and fall time
that is one third of the period then there'll be no
third harmonic.

I'm not sure if the scenix app is conducive to
generating trapezoids, but it's certainly worth an
effort to investigate. I'm not sure what the harmonics
of the integrated triangle wave look like either.
Perhaps


.lo

=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

1999\11\17@193450 by Tracy Smith

picon face
--- Dave VanHorn <TakeThisOuTdvanhornKILLspamspamspamCEDAR.NET> wrote:
> > For comparison I also simulated the routine of
> Scott Dattalo in MATLAB at
> 20
> > kHz sampling rate for all DTMF frequencies.
> Results are very good. There
> is
> > no frequency jitter at all and the frequency error
> is very small. Sorry
> for
> > wrong suggestions.
>
>
> So how do you establish twist?
>

How much twist is needed? 3dB? 6dB?

I think the best way to approach this is to write:

dtmf = A*sin1 + B*sin2

The twist will be 20*log(B/A), right? Determine how
many dB are needed and how much error can be tolerated
and then find two 'easy to multiply' integers for A
and B. 6dB is easy, because B=2 and A=1 would satisfy
the equation. To maximize the output amplitude (and
consequently minimize truncation errors) you'd want to
weight one term with 1/3 and the other with 2/3 for a
6dB twist. So you'd have one multiplication by 2 and
one division by 3. I think division by 3 has beaten to
blithering pulp.

.lo

=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

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