RadioBanter

RadioBanter (https://www.radiobanter.com/)
-   Digital (https://www.radiobanter.com/digital/)
-   -   Frequency discriminator algorithms? (https://www.radiobanter.com/digital/100601-frequency-discriminator-algorithms.html)

[email protected] August 5th 06 02:26 PM

Frequency discriminator algorithms?
 
Hi all,

I had been searching the 'net for simple digital frequency
discriminator algorithms (fm detection, eg for SSTV etc)
but have not really found any suitable info. In the mean
time though, I figured out what I think is a simple solution
to this problem and tried it, using my computer's sound
system to digitize a sinewave signal from my FT847 rig
(tuned to a MW BC station in CW mode and using the
narrowest filters).

The results were mixed, with an accuracy of about 1%
in many readings but with a small portion of them having
large errors 50%. The errors seemed to be spaced at 1/4
of an audio cycle and near peaks and zero's. But before I
speculate on possible causes, I would like to take the liberty
to describe this algorithm so that experienced DSP boffins
might first judge the viability and/or correctnes of it.

In a stream of digitized samples of a sine wave, the value s of
a sample is given by s = V * sin(F) where V is the peak amplitude
and F the phase of the sine wave at the moment the sample
was taken. If we take three consecutive samples, s0, s1, s2,
we can form the following set of simultaneous equations
(by expanding sin(F+dF) & sin(F-dF)).

1. s0 = V*sin(F-dF) = V*{sin(F)*cos(dF)-cos(F)*sin(dF)}
2. s1 = V*sin(F)
3. s2 = V*sin(F+df) = V*{sin(F)*cos(dF)+cos(F)*sin(dF)}

where dF is the phase difference between successive samples.

By adding 1. and 3. we have:

4. s0+s2 = V*2*sin(F)*cos(dF)

By substituting sin(F) from 2. we have:

5. s0+s2 = V*2*(s1/V)*cos(dF)

So finally solving 5. for dF we have:

6. dF = arc cos{(s0+s2)/(2*s1)}

The frequency f of the sampled signal can then be estimated by:

7. f = (df/2pi)*S or
f = S*arc cos{(s0+s2)/(2*s1)}/2pi (2pi=2*pi)

I tried this formula by feeding it with calculated samples and
it worked fine. In practice, the expected problems I had were
division by zero when s1 = 0 and failure of the acos() C function
when (s0+s2)/2s1 1. But there were inaccuracies in he
results as I mentioned near the peaks and zeros since it seems
errors in sampling by the dsp distorted the relationship between
consecutive samples.

I am using Linux and an AC97 type on-board sound system and
I already know there are some bugs in the ALSA (the Linux
sound systems project) drivers. This is especially obvious when
sampling at a non-native DSP rate (other than 48 Khz / 16-bit
linear) where the sound driver has to resample the output.

I would be greatful for any input on the "legitimacy" of the
above derived formula and/or its weak points, so that I can furher
study the output of the DSP for possible errors (not very easy ;-)).

My apologies for a longish and/or possibly boring article!

73's de "Nick" 5B4AZ http://5b4az.mattsnetwork.co.uk/



All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
RadioBanter.com