[time-nuts] VLF time is not dead :-)

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Oct 18 16:42:55 EDT 2004

In message <4173DD73.3000100 at usa.net>, Alberto di Bene writes:
>   Poul-Henning Kamp wrote:
>The receiver is homegrown:  A loop antenna, an amplifier and an A/D
>card in a computer.  The program generates a reference sine/cosine
>frequency for the carrier mixes with the a/d samples and averages
>over a second.  Sample-rate is 1MHz, 12 bits.  CPU is 560MHz P3.
>   How did you generate the reference frequency for the down mixing ?
>   If I understand correctly, it is a software NCO what you used. Which
>   was the source for its clock ?  Thanks

The fundamental clock is the sampling clock from the A/D card, which
is from a free-running PRS10 Rb.

A quadrature NCO is really easy to do in software, you figure out
the angle for each sample interval:

		2 * PI * carrier_frequency
	rho = ------------------------------

Then you calculate the sine and cosine of this angle:

	s0 = sin(rho);
	c0 = cos(rho);

Initialize your oscillator:

	ss = s0;
	cs = c0;

Then use the formula for addition of angles in a circle (This is much
more elegant in complex arithmetic btw).

	sn = ss * c0 - cs * s0;
	cn = ss * s0 + cs * c0;
	ss = sn;
	cs = cn;

And multiply and average the quadratures:

	a = getsample();
	sa += (a * ss - sa) * decay;
	ca += (a * cs - ca) * decay;
Then for every N samples you print out magnitude and phase:

	if (N % 1000000 == 0)
		printf("%f %f\n", sqrt(sa * sa + ca * ca), atan2(sa, ca));

If you havn't already, you can see some of the other stuff I'm doing
with this hardware at http://phk.freebsd.dk/loran-c

The GNU radio project is a good place to start to learn about
software defined radio: http://comsec.com/wiki?GnuRadioWiki

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

More information about the time-nuts mailing list