/* RTTY carrier modem generator by serial programming the AD9850 by Alastair GW0AJU */ int W_CLK=10; // Pin 10 - connect to AD9850 module word load clock pin (CLK) int FQ_UD=11; // Pin 11 - connect to freq update pin (FQ) int DATA=12; // Pin 12 - connect to serial data load pin (DATA) int RESET=13; // Pin 13 - connect to reset pin (RST). int RTTY_logic=9; // Pin 9 - TTL output of RTTY data signal logic // rtty data from left shift, the "b0 = (1 * start low)" + "b1 to b5 = (5 bit data)" + " b6 + b7 = (2 * stop high)" = 8bit single byte // bit zero is the start bit, next five are the RTTY data, followed by bits 6 and 7 for stop bit. // 2 bits are used for the stop instead of the 1.5bits, the extra addition to 2bit for a stop bit will not matter, // it will only extenduate the data sequence, but still be synchronised by the rtty decoder. byte info[] = {0x13,0x7F,0x2B,0x57,0x2B,0x57,0x0B,0x23}; // space,letter shift,R,Y,R,Y,carrige return,line feed unsigned long freq; void pulseRESET() { digitalWrite(RESET, LOW); delayMicroseconds(50); digitalWrite(RESET, HIGH); delayMicroseconds(50); digitalWrite(RESET, LOW); } void pulseW_CLK() { digitalWrite(W_CLK, LOW); delayMicroseconds(50); digitalWrite(W_CLK, HIGH); delayMicroseconds(50); digitalWrite(W_CLK, LOW); } void pulseFQ_UD() { digitalWrite(FQ_UD, LOW); delayMicroseconds(50); digitalWrite(FQ_UD, HIGH); delayMicroseconds(50); digitalWrite(FQ_UD, LOW); } // frequency calc from AD9850 datsheet // program data = (sys clock) * (frequency tuning word)/2^32 void sendFrequency(float frequency) { { freq = frequency * 4294967295/125000000; // note 125 MHz clock on AD9850 //Serial.println(freq,HEX); //Serial.println(freq,DEC); for (int b=0; b<4; b++, freq>>=8) { tfr_byte(freq & 0xFF); } phase(); } } // transfer the phase info plus trigger AD9850 internal loading void phase() { tfr_byte(0x00); // Final control byte, $00 for AD9850 chip pulseFQ_UD();// Done! Should see output } // transfers a byte, a bit at a time, LSB first to the // AD9850 via serial DATA line void tfr_byte(byte data) { //Serial.println(data,HEX); for (int i=0; i<8; i++, data>>=1) { digitalWrite(DATA, data & 0x01); pulseW_CLK(); //after each bit sent, CLK is pulsed high } } void collect_tx_message() // collect rtty data stream message { byte d; digitalWrite(RTTY_logic, HIGH); // TTL RTTY output at pin 12 sendFrequency(14.061445e6); // mark freq = (space freq + 170Hz) for (d=0 ; d<8 ; d++ ) // d = the number RTTY message + control characters in bytes { tx_data_message(info[d]); //delay(30); } digitalWrite(RTTY_logic, HIGH); // TTL RTTY output at pin 12 sendFrequency(14.061445e6); // mark freq = (space freq + 170Hz) } void tx_data_message(byte mess) // decode data stream message and transmit rtty signal { byte p; int sense; for (p=0; p<8 ; p++, mess<<=1) // rtty data sent in pattern due to data sequence { if ((mess & 0x01) == 0x01) // detect for mark tone { sense = 1; // Serial.print("1"); digitalWrite(RTTY_logic, HIGH); // TTL RTTY output at pin 12 sendFrequency(14.061445e6); // mark freq = (space freq + 170Hz) delay(20); // delay period of data bit transmission } else if ((mess & 0x01) == 0x00) // detect for space tone { sense =0; // Serial.print("0"); digitalWrite(RTTY_logic, LOW); // TTL RTTY output at pin 12 sendFrequency(14.061275e6); // space freq delay(20); // delay period of data bit transmission } } // delay period before retransmission of RTTY message // TX tone is mark tone as last used for stop bit of 1.5bits } void setup() { // Serial.begin(9600); // configure arduino data pins for output pinMode(FQ_UD, OUTPUT); pinMode(W_CLK, OUTPUT); pinMode(DATA, OUTPUT); pinMode(RESET, OUTPUT); pinMode(RTTY_logic, OUTPUT); Serial.begin(9600); pulseRESET(); pulseW_CLK(); pulseFQ_UD(); // this pulse enables serial mode sendFrequency(14.061445e6); // mark freq = (space freq + 170Hz) } void loop() { collect_tx_message(); //delay(500); // Serial.println(); }