Re: rtty for linux (any spanish speaking hams?)
> I have found a rtty program for linux at
> http://bellota.ele.uva.es/~jesus/rtty.
I'll take a crack at translating the Spanish, in case it helps anyone
who has the setup and RTTY knowledge to try the software. I don't
have the appropriate hardware setup available to test the program,
and I've never successfully received RTTY.
Quality of this translation is not guaranteed. :-)
Dennis Boone
KB8ZQZ
The web page text translates as follows:
RTTY
Source code: rtty.tar.gz
This is a program for decoding the FSK transmissions that are
usually heard on short wave radios.
To run this program you need:
A PC with a pentium or better processor (it might work on a
486, but this has not been tested).
Linux. The kernel must include support for sound, and
SysV IPC.
A sound card supported by the kernel.
The XForms library, if you want to re-compile.
How it works: the file doc.txt describes the workings of the
prgoram. The following is a block diagram of the FSK decoder.
The diagram shows:
Audio input
MARK frequency passband filter
SPACE frequency passband filter
Low-pass filter
Zero-crossing
Digital output
The contents of the doc.txt file translate as follows:
RTTY
Experimental FSK decoder
for Linux + sound card
(By Jesús Arias, EB1DIX)
1. Motivation for this program
2. Algorithms
2.1 FSK decoding
2.2 Filter algorithms.
2.3 Recovery of bits. DPLL.
2.4 Recovery of asyncronous data (Baudot, ASCII).
2.5 Other formtats. HDLC.
2.5 Inter-process communication.
3. Minimum processing speed requirements.
4. Compiling
5. FSK encoder program
5.1 Generation of the carrier and FSK modulation
-------------------------------------------------------------------------------
1. Motivation for this program
It's been a long time since I tried to receive Baudot transmissions
on HF. Some years ago I thought the only solution was purchase
or construction of an analog demodulator which would connect to
the PC serial port. Such circuits were often seen in magazines
like "Elektor" and others, but the attempts made by EB1GXM and
myself all failed. We got the impression that decoders based on
PLL circuits like the XR2221 were difficult to adjust, and very
sensitive to noise. I believe I read an article by a ham bitterly
deploring the low quality of modern decoders built using integrated
circuits, when old equipment based on passive LC filters gave,
in his opinion, much better results.
Next came the HAMCOMM program by DL5YEC, where the interface to the
PC was a simple comparator, and the CPU was charged with decoding.
I suspect that the mark and space frequencies were detected
by counting. In any event, the results with this program were
disappointing when the signal was even lightly disturbed by noise.
Now, in the digital age, the proper solution would appear to be
use of a digital signal processor (DSP) to decode the FSK tones.
Personally, I didn't know anything about DSP until two years ago,
when I purchased the TMS320C3X starter kit from Texas Instruments.
The documentation for this DSP included many examples of signal
processing algorithms. This DSP looked like the best solution
to FSK decoding, until an estimate of the required processing
power showed me that a PC processor (a Pentium-100) was more
than sufficient for my needs. Using only a PC and sound card
was attractive, since it assumed that other hams in my situation
would not need any special equipment to receive FSK transmissions.
-------------------------------------------------------------------------------
2. Algorithms
2.1 FSK demodulation.
The algorithm employed is quite simple. It is inspired by an
active-filter hardware design I created one day, but never built.
The basic idea is to compare the amplitudes of the MARK and
SPACE carriers. The signal is applied to the inputs of two
pass-band filters in parallel. One of the filters passes the
MARK frequency, the other the space. The output of the filters
is the RMS value of the two signals, which are squared and passed
through a low-pass filter. Finally, the difference of the RMS
values is calculated. If the result is negative, the value is
logic "0"; if it is positive the value is logic "1".
In this scheme it is possible to use only one low-pass filter if
the difference is calculated before the filter. (See the block
diagram in the file demod.ps)
---------------------------------------
2.2 Filter algorithm
The three demodulator filters are Infinite Impulse Response
(IIR) filters. The algorithm is:
y[n]= a_0 * x[0] +
a_1 * x[1] +
.......... +
a_n * x[n]
+
b_0 * y[0] +
b_1 * y[1] +
.......... +
b_n-1 * y[n-1]
where x[0],x[1],...,x[n] are the last n sample values at the
input of the filter, y[0],y[1],...,y[n-1] are the last n-1
samples leaving the filter, and a_i and b_i are coefficients which
define the filter characteristics. The number of coefficients is
directly related to the order of the filter. En this case n=6,
with which the low pass filter has a response with a cutoff of
120 dB/decade and the pass band filters 60 dB/decade.
The actual values of the coefficients have been obtained from the
"mkfilter" program by A.J. Fisher <fisher@minster.york.ac.uk>.
They have been calculated for a large number of frequencies and
bandwidths, so that it is very easy to change the filter from
inside the program. (Much easier than a hardware decoder)
---------------------------------------
2.3 Recovery of the bits. DPLL.
To synchronize the PC with the data bits which are received, a
routine simulates the workings of a DPLL circuit. It consists
of a demodulated sample counter which runs for the duration of
a full bit. If during the counting a sign change in the input
signal is detected, the counter is advanced a small amount (1/32
of a bit time), so that the beginning of the next bit occurs
roughly in the middle of the counting. In this way the routine
ensures that the last sample is taken in the center of the bit.
The counter in this routine uses a static floating point variable,
and errors due to time quantization are accumulated for the
next bit. Thus, though the duration of a bit is not a whole
number of samples, the bits can be recovered in a viable way.
---------------------------------------
2.4 Recovery of asynchronous data (Baudot, ASCII).
The sign of the samples leaving the demodulator indicates the
logic level (0 or 1) of the signal. The recover of Baudot or
ASCII data is relatively direct. First, the decoder waits for a
high-to-low transition in the decoded samples. This transition
marks the beginning of a START bit in a 5-bit word (Baudot) or a
7 or 8 bit word (ASCII). Next, enough samples are read to reach
the middle of the bit, then the DPLL routine is called to recover
each data, parity, and if needed the stop bits. The parity
bits are compared to their correct value, and a parity error
(<P>) is generated if there is a mismatch. If the stop bit(s)
do not have a value of 1, a framing error (<F>) is generated.
The errors can also be given in a combined form (<PF>).
If the data consists of 5 bit words, the Baudot code is used,
in which case it is necessary to effect a conversion from Baudot
to ASCII. If, on the other hand, the data consists of 7 or 8
bit words, no conversion is necessary.
---------------------------------------
2.5 Other formats. HDLC.
In addition to asynchronous modes, the program can also decode
packets in HDLC format. This format uses an NRZI code, in which
zeros are represented by changes in the signal, and ones by the
absence of a change. HDLC packets are also unusual in that they
are delimited by two "flags" <01111110>, and by the fact that
between two flags, no byte can have the same value as a flag.
To ensure this, the transmitter inserts a zero into a run of bits
any time it has just sent five contiguous ones. The receiver must
eliminate these zeros from the data. In addition, each packet
ends with a two-byte CRC which must be checked to detect errors.
To check the CRC, I have utilized a routine copied from the Linux
kernel, which in turn was derived from the WAMPES program.
---------------------------------------
2.6 Communication between processes
The RTTY decoder actually consists of two programs: the decoder
proper, and a monitoring and control program. This latter program
has a graphical interface based on the XForms library. Using it,
we can select the filter MARK and SPACE frequencies, the bandwidth
of the filters, the data format (data bits, stop, parity) and
the data rate. In addition, two windows display the spectrum of
the signal at the input, and the form of the demodulated signal.
The latter is shown as a graph of many cycles overlayed together,
and is called an "eye diagram".
Communication between these two programs is accomplished via
a shared memory segment, which contains the majority of the
interesting variables. For this area to be created, the Linux
kernel must be compiled with the "System V IPC" option.
-------------------------------------------------------------------------------
3. Minimum calculation requirements.
The filter calculations are performed using floating point math,
which comprises the major limitation to running this program on
slower computers. An idea of the computation power required can
be gained by review of the floating point arithmetic operations
required by the filters:
Pass band filters (x2)
8 Adds/subtracts
7 Multiplications
------------------
30 SubTotal
Low pass filter
9 Adds/subtracts
9 Multiplications
------------------
18 SubTotal
==================
48 Total
In other words, for each sample, 48 floating point operations must
be executed. Since the sample rate is 11025 Hz, this requires
48 x 11025 = 529200 flops/second (~0.5 MegaFlops/second).
As you can see, the speed requirements are not that strict.
For example, a Pentium-100, even assuming only 5% of the total CPU
time, would hardly notice it was decoding RTTY. [translator note:
this paragraph seems to have been garbled in the original; I'm
not sure of the translation here.]
Neither is much memory required, and the bulk of that (about 200
kB) is used to hold the table of filter coefficients.
--------------------------------------------------------------------------------
4. Compilation
To compile these programs, you must have installed the XForms
library. I have used version 0.88, but the program should work
with older versions.
If you would like to experiment with the filters, you will also
need the "mkfilter" program, available from:
http://www.cs.york.ac.uk/~fisher/mkfilter
Keep in mind that it is necessary to recalculate the filter
coefficients if you change the audio sample rate. (common.h)
The compile the program with the existing coefficients, execute:
make
If this command completes without errors, it will create the
following programs:
rtty The RTTY decoder
rtty_c The control program
rtty_o The FSK transmitter program (keep reading)
To run the decoder, all you have to do is run the "rtty" program,
and it will in turn run the "rtty_c" program as a child process.
One of the many "mixer" programs can be used to select the desired
sound card audio input (normally Line-IN, the microphone only
works at low speeds).
-------------------------------------------------------------------------------
5. The FSK transmitter program
Finally, the package also includes a program to generate an FSK
signal from 8-bit ASCII data in the indicated file. The syntax is:
rtty_o f0 f1 baudrate file
where f0 is the SPACE frequency, f1 is the MARK frequency,
baudrate is the rate in bits per second, and file is the pathname
of a file to transmit. Example:
rtty_o 1000 1850 150 doc.txt
---------------------------------------
5.1 Generation of the carrier and FSK modulation
The generation of a sinusoidal signal without resorting to
repetitive trigonometric functions is a simple matter. All that
is necessary is the rotation of a vector in a plane through a
fixed angle dFi:
Unitary starting vector: V = (Vx=1, Vy=0)
Rotation: NV = Rot (V)
/ cos(dFi) -sin(dFi) \ / Vx \
(NVx , NVy) = | | | |
\ sin(dFi) cos(dFi) / \ Vy /
NVx = cos(dFi)*Vx - sin(dFi)*Vy
NVy = sin(dFi)*Vx + cos(dFi)*Vy
The values of cos(dFi) and sin(dFi) are fixed, and it is adequate
to calculate them at the beginning of the program. Thus, the
generation of the next sample requires only 4 multiplications,
one addition, and one subtraction: in other words, 6 floating
point operations. The carrier signal will be the x component of
the vector V. The angle dFi depends on the relationship between
the desired generation frequency, and the sample rate, as follows:
dFi = 360 * f/fs (en degrees °)
Thus for example, to obtain a frequency of 1000 Hz with a sample
rate of 11025 Hz dFi would be: 360*1000/11025 = 32.65°
Only one problem remains: the amplitude of the carries can vary due
to imprecisions in floating point calculations, and in the long
term, the carrier can shrink louder or quieter. To eliminate
this problem, we apply a correction to the amplitude of the
following form:
factor = 2 - ( Vx² + Vy² )
Vx = Vx * factor
Vy = Vy * factor
This correction costs another 6 floating point operations.
Finally, to generate FSK modulation, all that is necessary is to
swap the values of cos(dFi) and sin(dFi) based on the data bits.
Reply to: