In this short tutorial I’ll give you a step by step instructions on connecting a Radiometrix NTX2 to a Arduino providing a 425Hz shift. In the second part I’ll demonstrate how to use this circuit to transmit data at 50 or 300 baud.
There are a number of ways to get this working but the theory is you adjust the voltage on the NTX2's TXD pin which adjusts its transmission frequency slightly. The difference in this frequency is called the shift. By doing this in a controlled fashion you can transmit 1's and 0's and therefore data. Again there are a number of methods to adjusting the voltage, I’m using a simple voltage divider and the NTX2 is running at 5V.
Items you’ll need : Radiometrix NTX2 Arduino 2 x 22k resistors 1 x 10k resistor 1x 4.7K resistor Radio capable of receiving SSB at 434Mhz band. PC with DL-FLDIGI installed.
1/ Connect the VCC and GND Rails :
2/ Bridge the GND to TXD Pin with the 10K Resistor :
3/ Connect the other resistors as your bread board allows :
4/ Insert the NTX2 Module
5/ Bring in the Arduino and connect +5V to the top rail and GND to the bottom rail :
6/ Connect pins 4 & 5 to the MARK and SPACE as show on the circuit diagram :
7/ Plug in the Arduino and load up the following code :
/* AVA Radio Test Toggles the NTX2 high and low to generate a tone pattern to ascertain
if the radio and associated circuitry is working.
created 2011 by Upu http://ava.upuaut.net */
int RADIO_SPACE_PIN=4;
int RADIO_MARK_PIN=5;
void setup()
{
pinMode(RADIO_SPACE_PIN,OUTPUT);
pinMode(RADIO_MARK_PIN,OUTPUT);
}
void loop()
{
digitalWrite(RADIO_MARK_PIN, HIGH);
digitalWrite(RADIO_SPACE_PIN, LOW);
delay(50);
digitalWrite(RADIO_SPACE_PIN, HIGH);
digitalWrite(RADIO_MARK_PIN, LOW);
delay(50);
}
8/ Tune in your radio to the appropriate frequency ensure you have the mode set to LSB. You should hear an alternating sequence of beeps. If not go back and check your circuit.
9/ Now open up dl-fldigi and adjust the frequency and volume until you get a nice pair of lines on the water fall :
Note the distance between your lines is the shift and in this case is 425Hz, you can adjust this by playing with the values of the resistors.
Congratulations you’re transmitting!
In part 1 of this article I discussed linking the NTX2 to the Arduino and getting a high and low tone out of it. In this article we go one step further and turn this into a transmission of data.
Using the circuit discussed in the previous article upload the following code will transmit a short sentence at 50 baud, 7 bits ASCII 1 stop bit. Also the code includes the ability to add an CRC checksum at the end of the data string, you will need to uncomment the relevant lines out.
The DATASTRING is passed to a procedure called rtty_txtstring which takes care of transmitting the data by breaking it down into characters, then it transmits the individual bits of those characters. The key to getting the baud rate correct is the timing. Theoretically 50 baud should be 1/50th of a second = 20000μ seconds. Now for some reason the Arduino (at least the one I have) doesn’t seem to be able to accurately count this time interval so the delay is achieved by doing one delay of 10000μS and one of 10150μS.
300 baud after some playing seemed to be stable around 3370μS delay ( 300 baud should be 1/300s = 3333μS). You can uncomment the relevant lines out as needed.
/*
AVA Radio Data Transmission Test
Transmits data via NTX2
Created 2011
by Upu http://ava.upuaut.net
RTTY code from Rob Harrison Icarus Project.
*/
#include <string.h>
#include <util/crc16.h>
int RADIO_SPACE_PIN=4;
int RADIO_MARK_PIN=5;
char DATASTRING[200];
void setup() {
pinMode(RADIO_SPACE_PIN,OUTPUT);
pinMode(RADIO_MARK_PIN,OUTPUT);
}
void loop() {
sprintf(DATASTRING,"M6UPU TEST RTTY BEACON\n");
// If you uncomment the lines below and comment out the line above a CRC Checksum will be appended to the end of the DATASTRING
// sprintf(DATASTRING,"M6UPU TEST RTTY BEACON");
// unsigned int CHECKSUM = gps_CRC16_checksum(DATASTRING);
// char checksum_str[6];
// sprintf(checksum_str, "*%04X\n", CHECKSUM);
// strcat(DATASTRING,checksum_str);
noInterrupts();
rtty_txstring (DATASTRING);
interrupts();
delay(2000);
}
void rtty_txstring (char * string)
{
/* Simple function to sent a char at a time to
** rtty_txbyte function.
** NB Each char is one byte (8 Bits)
*/
char c;
c = *string++;
while ( c != '\0')
{
rtty_txbyte (c);
c = *string++;
}
}
void rtty_txbyte (char c)
{
/* Simple function to sent each bit of a char to
** rtty_txbit function.
** NB The bits are sent Least Significant Bit first
**
** All chars should be preceded with a 0 and
** proceded with a 1. 0 = Start bit; 1 = Stop bit
**
*/
int i;
rtty_txbit (0); // Start bit
// Send bits for for char LSB first
for (i=0;i<7;i++) // Change this here 7 or 8 for ASCII-7 / ASCII-8
{
if (c & 1) rtty_txbit(1);
else rtty_txbit(0);
c = c >> 1;
}
rtty_txbit (1); // Stop bit
}
void rtty_txbit (int bit)
{
if (bit)
{
// high
digitalWrite(RADIO_MARK_PIN, HIGH);
digitalWrite(RADIO_SPACE_PIN, LOW);
}
else
{
// low
digitalWrite(RADIO_SPACE_PIN, HIGH);
digitalWrite(RADIO_MARK_PIN, LOW);
}
// delayMicroseconds(1680); // 600 baud unlikely to work.
delayMicroseconds(3370); // 300 baud
// delayMicroseconds(10000); // For 50 Baud uncomment this and the line below.
// delayMicroseconds(10150); // For some reason you can't do 20150 it just doesn't work.
}
void callback()
{
digitalWrite(RADIO_SPACE_PIN, digitalRead(RADIO_SPACE_PIN) ^ 1);
}
uint16_t gps_CRC16_checksum (char *string)
{
size_t i;
uint16_t crc;
uint8_t c;
crc = 0xFFFF;
// Calculate checksum ignoring the first two $s
for (i = 2; i < strlen(string); i++)
{
c = string[i];
crc = _crc_xmodem_update (crc, c);
}
return crc;
}
Upload the code and again open up DL-FLDIGI you should hear a wonderful sound of RTTY warbling away. Make sure DL-FLDIGI is set correctly by clicking Op Mode → RTTY → Custom.
Set the carrier shift to 425, baud to 50, 7 bits per character, no parity and 1 stop bit.
If you can hear the sound of the transmission but you’re getting garbled text you may need to hit the RV button. This means you have the MARK and SPACE wires crossed. If everything is working ok you should get the data printing out :