[Radio] RTTY

This is RTTY (Radioteletype) code that you can use for your C++ application (for instance Arduino). This can be used for the transfer of information through radio (or optics, see...

This is RTTY (Radioteletype) code that you can use for your C++ application (for instance Arduino). This can be used for the transfer of information through radio (or optics, see below). I have used this for the Space Camera projects (see top menu). So you can use RTTY to give yourself an easy and robust method for transmitting information over the radio. You can use ‘free’ frequencies (Generally 433 MHz, limited to max 10mW power output). If you have a radio-license (like i have) you can use more power and more frequencies.

The code below is tuned to 50baud (transfer speed of 50 bit/s). You understand: this is a very slow communication, about 7 characters per second. Also, it uses 7bit ascii, you can also set it to 8 bit ascii (bit slower but more characters). Also i have the code for baudot (5bit) which is really fast, but with some restrictions. You can find that code here.

Tell me how it works

Easy: a “low beep” is a binary 0, a “high beep” a binary 1. Then if you emit every 0.02 seconds either one of these beeps, you can make up a data string in a “ASCII” way. For instance: “1010100″ is the character “T”. Repeating this same method you can make any data transmission you want.

(For more (historic) information see wikipedia)

How i have used this before

The beeps you are hearing (brrrzzz brzzzz) is actually the “RTTY” as i receive it from a radio receiver. Then i put that in the audiojack of my computer, which analyzes the sound and converts the beeps into bits and then into readable characters! That way i knew GPS information of the autonomous balloon.

Also cool: Optic RTTY

This uses the same code as for the radio, but the medium now is not radio waves, but light. You could use light of different wavelengths to separate the data that is transmitted.

Code

So you can either hook up two leds or a radio to the two corresponding pins. For hooking up a radio you can check this page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
// Project Hollands Hoogte © July 2010
// RTTY (original i believe by J. Coxon)
 
// Digital Pins
#define RTTY_PIN_1 		5	// RTTY space pin
#define RTTY_PIN_2 		6	// RTTY mark pin
#define RTTY_LED                30      // RTTY busy led
 
// Misc
#define RTTY_ASCII      7       // ASCII set for RTTY (7/8bit)
 
void setup() {
 
 
  Serial.begin(9600);
 
  pinMode(RTTY_LED, OUTPUT);
 
  // Setup for RTTY
  pinMode(RTTY_PIN_1, OUTPUT);
  pinMode(RTTY_PIN_2, OUTPUT);
 
}
 
void loop() {
        TxString("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()");
} 
 
 
 
// Calculates the checksum for a given string
// returns as integer
int getCheckSum(char *string) {
  int i; 
  int XOR;	
  int c;
  // Calculate checksum ignoring any $'s in the string
  for (XOR = 0, i = 0; i < strlen(string); i++) {
    c = (unsigned char)string[i];
    if (c == '*') break;
    if (c != '$') XOR ^= c;
  }
  return XOR;
}
 
 
// ------ RTTY ----------
 
// Transmit a string, log it to SD & produce debug output
void TxString(char *string) {
  digitalWrite(RTTY_LED, HIGH);
 
  // Checksum
  char txSum[4];
  int checkSum = getCheckSum(string);
  sprintf(txSum, "%02X", checkSum);
 
 
 
  rtty_txstring(string);
  rtty_txstring("*");
  rtty_txstring(txSum);
  rtty_txstring("\r\n");
  digitalWrite(RTTY_LED, LOW);
}
 
// Transmit a string, one char at a time
void rtty_txstring (char *string) {
  for (int i = 0; i < strlen(string); i++) {
    rtty_txbyte(string[i]);
  }
}
 
// Transmit a byte, bit by bit, LSB first
// ASCII_BIT can be either 7bit or 8bit
void rtty_txbyte (char c) {
  int i;
  // Start bit
  rtty_txbit (0);
  // Send bits for for char LSB first
  for (i=0;i<RTTY_ASCII;i++) {
    if (c & 1) rtty_txbit(1);
    else rtty_txbit(0);
    c = c >> 1;
  }
  // Stop bit
  rtty_txbit (1);
}
 
// Transmit a bit as a mark or space
void rtty_txbit (int bit) {
  if (bit) {
    // High - mark
    digitalWrite(RTTY_PIN_1, HIGH);
    digitalWrite(RTTY_PIN_2, LOW);
  } 
  else {
    // Low - space
    digitalWrite(RTTY_PIN_2, HIGH);
    digitalWrite(RTTY_PIN_1, LOW);
  }
  // Delay, not tuned to 50baud, but you can tune this
  delay(19);
  delayMicroseconds(250);
}

About Tim Zaman

There's page about myself with some babble and pics on this site Here!. // R&D : Vision/Imaging | 2D/3D Image Processing | Robotics/Automation | Programming | Electronics | Open Source | And, obviously, Photography.

Creative Commons License
The [Radio] RTTY by Tim Zaman, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 3.0 Unported License.