April 28, 2024, 05:37:48 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


RTTY - Radioteletype demo

Started by sapero, June 25, 2009, 01:01:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

June 25, 2009, 01:01:49 PM Last Edit: June 26, 2009, 04:00:45 AM by sapero
RTTY is a telecommunications system consisting of two or more teleprinters using radio as the transmission medium (more info)

This example program is using DirectSound to produce a test signal, or to transmit user defined text. You can change at any time the frequency of both tones (mark and space), the baudrate (speed), inverse tones (REV), the bit order (LSB or MSB first) and the output volume.
If you change any of the above settings, change will apply in up to 500ms, because the directsound thread uses one-second-long sound buffer divided into two parts. Each 500ms the first unused part is updated with new sound samples.

I have ported this exmple from Aurora, and got a fatal error from the gorc tool while compiling. The original resource compiler is too old to handle the resources script, therefore I've included the precompilled .res file.

EDIT: reuploaded v2.

Egil

Nice example Sapero.  ;D
As I am on vacation, and use a borrowed PC right now, I wont be able to try it out until I am back home.
But if you are interrested in RTTY (or any other digital transimission modes used by radio amateurs), maybe you'll like to check the web pages of MMHAMSOFT. Here is a link to them: http://mmhamsoft.amateur-radio.ca/
They have several tools for programmers wanting to make their own GUIs.
Support Amateur Radio  -  Have a ham  for dinner!

sapero

Thanks Egil,
I have reuploaded the archive with a bugfix - if the last byte (or more) overlapped two "buffers", the last part was not played.
For example if you typed two spaces in the text box, at 10baud only the first space was transmitted.
Added also the executable, so you can play with it.

Long time ago I was very active as radio amateur, but always preferred listening instead QSO'ing. I remember I have always coded demodulators on my old Z80 for each received digital modulation - cw, manchester, rtty, sstv, and other more or less advanced protocols, like ax.25.

Techno

Sapero,

Can you post an complete example for send and receive bytes with the serial port in the form of een EB Gui application and with I2C

Thanks

sapero

June 28, 2009, 04:29:06 AM #4 Last Edit: June 28, 2009, 04:37:02 AM by sapero
Stephane, you could find this topic yourself.

I have played with the FFTW library, and added a simple spectrum analysing control to this modulator. The code may look poor/complicated, excuse me :)
Note, you need libfftw3-3.dll in order to view the spectrum. Download it here: http://www.fftw.org/

Egil

July 04, 2009, 06:22:18 AM #5 Last Edit: July 04, 2009, 06:29:57 AM by Egil
Sapero,
I have been studying your RTTY code examples and the FFTW frequency spectrum example in http://www.ionicwind.com/forums/index.php/topic,3452.0.html with an ever growing interrest. When I have finished my part of the group project on ADS-B decoding, I think I will dive into the FFT subject.

Please correct me if I am wrong, but I have a crazy idea that by experimenting with the values of FREQUENCY_MIN and FREQUENCY_MAX, setting them only a few Hz appart, I will be able to test for signal energy present in that particular spectrum. And maybe be able to detect (and decode??) DGPS beacon signals way down in the noise... hmm
Support Amateur Radio  -  Have a ham  for dinner!

tbohon

Egil:

Regarding your last remark ... and that would allow us to, for example, locate a beacon of some kind maybe ... ???  That would have some serious application for my EmComm group here - our local authorities have asked us to investigate the use of our ham radios to assist in locating lost Alzheimer's patients who are wearing an RF beacon.  I'll be following your experimentation closely.

73,

Tom / KE7EJJ
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

Egil

Tom,
if the fftw-library can be used in the way I want, the manswer to your question is YES.
But I haven't started studying the matter yet.
Support Amateur Radio  -  Have a ham  for dinner!

sapero

Egil,
take a look at the Goertzel algorithm. It allows spectrum calculation at arbitrary points, whereas the FFT calculates the spectrum at evenly spaced points, so you save the time and have precise output.
I think in software demodulators using Goertzel is much better than FFT, for example CW - single frequency, rtty - two, dtmf - 8 frequencies.

Papers: wiki, dtmf, dsp programs in c.

' pFloats - pointer to floating point audio samples
' N       - number of samples
' frequency - the frequency you want to lookup
sub Goertzel(pointer pFloats, int N, float frequency, int samplerate),float

' http://www.exstrom.com/journal/sigproc/
double theta = 6.28318530717958647692 * frequency / samplerate
double Qr
double Qi
int _n
double u0, u1, u2 ' variable of the difference eq: u(k) = f(k) + 2cos(theta)u(k-1) - u(k-2)
double C0, S0 ' cos(theta) & sin(theta)
double C02 ' 2*cos(theta)
double CN, SN ' cos((N-1)*theta) & sin((N-1)*theta)
double yr, yi ' real and imaginary parts of yN

C0 = cos(theta)
C02 = 2.0*C0
S0 = sin(theta)
CN = cos((N-1)*theta)
SN = sin((N-1)*theta)
u0 = 0.0
u1 = 0.0

for _n = 0 to N-1

u2 = *<float>pFloats[_n] + C02*u1 - u0
u0 = u1
u1 = u2
next _n

' Calculate yN = yr + iyi
yr = u2 - C0*u0
yi = S0*u0

' Calculate F(theta) = yN*e^(-i(N-1)*theta)
Qr = yr*CN + yi*SN ' real part
Qi = yi*CN - yr*SN ' imaginary part
' sapero: convert the magnitude to logarithms
double value = sqrt(Qr*Qr + Qi*Qi)
return 20 * log10(value / N)
endsub


' example usage
int samplerate  = 44100
int samplescount = 0.5 * samplerate ' 0.5s buffer
pointer samples = new(float, samplescount)
float freq1 = 220
float freq2 = 230
float freq3 = 240
' generate samples
float a1 = 6.28318530717958647692 * freq1 / samplerate
float a2 = 6.28318530717958647692 * freq2 / samplerate
float a3 = 6.28318530717958647692 * freq3 / samplerate
int n
for n=0 to samplescount-1
*<float>samples[n] = sin(n*a1) + (sin(n*a2)/2) + (sin(n*a3)/4)
next n

' get the amplitudes
float amp1 = Goertzel(samples, samplescount, freq1, samplerate)
float amp2 = Goertzel(samples, samplescount, freq2, samplerate)
float amp3 = Goertzel(samples, samplescount, freq3, samplerate)

print "frequency",freq1, " power:", amp1, "dB"
print "frequency",freq2, " power:", amp2, "dB (+ ", amp2-amp1,"dB)"
print "frequency",freq3, " power:", amp3, "dB (+ ", amp3-amp2,"dB)"

delete samples

Egil

Sapero:
Thanks for the excellent example code and for the exstrom link. You have saved me a lot of pain for sure. ;D ;D ;D
There are so many tasks I want to program, but my largest challenge at present is that I have forgotten so much about programming during the two last decades, since I last did any coding.
It's just like beeing a novice again. But it is great fun... if not I wouldn't have been spending so much time doing it.
Support Amateur Radio  -  Have a ham  for dinner!