A while ago now I wrote an article for the UKHAS website on linking an NTX2 to the Arduino. This tutorial, available here : http://ukhas.org.uk/guides:linkingarduinotontx2 is still valid however there are other ways to modulate the NTX2 or the NTX2B to get RTTY.
In part 1 of this article I’ll discuss using PWM to generate the required voltages to modulate the NTX2B, the physical wiring, how to test it and sample code. Part 2 will extend this to transmitting RTTY and finally part 3 will discuss using this to transmit DominoEX.
Please follow this entire article the basic code allows you to demonstrate step by step that your circuit is working.
Introduction
Getting your Arduino to transmit via the radio initially may seem daunting but its actually pretty simple. Please freely substitute the word “Arduino” for any micro-controller you wish to use. The example below works for 5V and 3.3V micro-controllers.
Please read this :
This may be the first bit of code you’ve come across with regards to creating a radio tracker. There is always the temptation to cut and paste it and away you go. And in isolation this may work. However should you then cut and paste further code without understanding what is going you will end up with an unworkable mess and something that is next to impossible for us to assist you with. Please take the time to work out what the code below is doing, redo it yourself, break it, fix it most importantly understand it.
Theory
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 transmit meaningful data.
The NTX2 is a FM (Frequency Modulation) module intended to have a voltage applied to the TXD pin of between 0 and 3 volts. This voltage range changes the output frequency of the module by about 6KHz (i.e for a 434.200Mhz module 0V on TXD = 434.195Mhz and 3V on TXD = 434.202Mhz.
This means for each 1Hz change in frequency you need to change the voltage by 0.0005v (3 divided 6000) so to get a shift of 500hz you need to toggle the voltage applied to the TXD pin by 425×0.0005=0.2125v.
To get this voltage shift we are going to use PWM (Pulse Width Modulation). See this article for more information on PWM : http://arduino.cc/en/Tutorial/PWM. The resolution of this is 8 bits which means the Arduino can change the voltage by 256 (2^8) steps. This means the maximum voltage of 5V can be broken into 5/256 steps or 0.0195v per step. The maximum input of the NTX2B is 3V therefore there is no point applying voltages of greater than 3V. As a decimal this means 3/5* 256 = 153.
In theory the standard shift of 425Hz equates to a 0.2125/0.0195 = 11, however in reality on an NTX2B a value of 10 gave a perfect 425Hz shift. Don’t get too hung up on getting the exact shift, any shift from 350-500Hz is fine.
Items Required
Radiometrix NTX2B
Arduino or similar micro-controller
Circuit Diagram
Connect Arduino 5V to the NTX2B VCC pin 5
Connect Arduino 5V to the NTX2B EN pin 4
Connect Arduino GND to the NTX2B GND pin 6
Connect Arduino pin 9 to the NTX2B TXD pin 7
Once done it should look like this (you don’t need an antenna in at this point) :
The Code
The code is similar to the Fade example built into Arduino (File->Examples->03.Analogue->Fade)
/* Demo Code to Drive NTX2B via PWM Written by Anthony Stirk M0UPU This example code is in the public domain. */ #define RADIOPIN 9 void setup() { pinMode(RADIOPIN, OUTPUT); setPwmFrequency(RADIOPIN, 1); } void loop() { analogWrite(RADIOPIN,100); delay(500); analogWrite(RADIOPIN,110); delay(500); } void setPwmFrequency(int pin, int divisor) { byte mode; if(pin == 5 || pin == 6 || pin == 9 || pin == 10) { switch(divisor) { case 1: mode = 0x01; break; case 8: mode = 0x02; break; case 64: mode = 0x03; break; case 256: mode = 0x04; break; case 1024: mode = 0x05; break; default: return; } if(pin == 5 || pin == 6) { TCCR0B = TCCR0B & 0b11111000 | mode; } else { TCCR1B = TCCR1B & 0b11111000 | mode; } } else if(pin == 3 || pin == 11) { switch(divisor) { case 1: mode = 0x01; break; case 8: mode = 0x02; break; case 32: mode = 0x03; break; case 64: mode = 0x04; break; case 128: mode = 0x05; break; case 256: mode = 0x06; break; case 1024: mode = 0x7; break; default: return; } TCCR2B = TCCR2B & 0b11111000 | mode; } }
Excluding the setPwmFrequency procedure (all this does is set the PWM speed as quick as it will go to made the voltage presented to the NTX2B PWM pin as more “analogue”) this code simply opens pin 9. It then alternates the voltage on this pin by 10 every 1/2 second. You can plug an LED into pin 9 to see what its doing.
Load this code up to the Arduino.
Ok now take your radio and tune it into the frequency of the NTX2B module. You should hear the high and low tones. If you’re using an RTL + SDR# set the frequency to something above the frequency of the module, i.e in this example our NTX2B is transmitting on 434.200Mhz so I’ve set SDR# to 434.500Mhz. You can see a peak on the left of the spectrum analyzer at the top around 434.200Mhz :
If you’re unsure if this is the radio, turn it off. It will disappear. Zoom in the line using the zoom on the right. You may want to increase the resolution in the FFT Display at this point, with a resolution of 262144 you should see some distinct high and low tones separated by about 425hz :
Congratulations you’re transmitting. If you’re ever unsure if your radio is working you should step back to this extremely simple code to check the basic operation. Now move to part 2 of this article to transmit some meaningful data : http://ava.upuaut.net/?p=627
Dear Anthony
Good evening.
Please, I need the board to control rotor arduino interface, the two boards, display and control board v3.
Please, can I know where I buy these boards?
Thank you
Regards,
Hi there I no longer sell these boards. You are welcome to send the gerbers to you PCB Fab of choice and get them made.
Cheers