Monday, 29 September 2014

The Transmitter

When I settled on the overall concept, I began searching for the specific parts. One condition was the availability of the parts for a reasonable price. Starting with the microcontroller, I chose Arduino Nano. Nano is one of the smaller models, but it still has a mini USB connector. That is useful for programming the microcontroller, because otherwise you need an additional board. I found it on Aukro (as mentioned before, the Czech version of Ebay).


When ordering the Arduino board, I went through the seller's other offers and came across a Ublox NEO-6M GPS module that would suit my purpose. Plus, I would save on the shipping costs. Additionally, by that time, I had already come across a couple of manuals dedicated to joining a Ublox module and an Arduino board. A significant aspect for me, since I saw both the Arduino and the GPS module for the first time in my life. An important thing when choosing the GPS module is finding a model that is capable of operating at high altitudes. Due to specific restrictions prohibiting commonly sold GPS devices to function at altitudes higher than 18km and at the same time exceeding the speed of 515m/s, this is not a norm. When programming such a module, you have to make sure that the 'airborne mode' or some version of the airborne mode is activated.


An existing manual played an important role in choosing the trnasmitter as well. I even managed to come across a Czech supplier. The transmitter in question was Radiometrix's NTX2 operating on 434.650 MHz.


The specific parts mentioned here are only those I actually used. Each one of them has more alternative options that would work just as well.


To interconnect all of this, I initially used a breadboard and a few wires. The wires can be easily obtained from a UTP cable and manually fitted with male or female connectors making it easy to connect and reconnect whatever you want.


Here, I was testing the wires using one of the basic Arduino educational scripts making the microcontroller blink an LED diode. The wires are fitted with KONPC-SPK pins and covered by an insulation.


This is the first wiring on a breadboard still using the USB as the power source. The Ublox module has 4 pins. The first labeled 'Vcc' connects to the Arduino pin '5V'. The second 'RX' goes to the Arduino's pin 'D4', the third 'TX' to the Arduino's 'D3' and the last 'GND' connects to the Arduino's 'GND'. The NTX2 has 7 pins. Three gathered together and then four in a group as well. The first three pins serve as an output for an antenna (more on that later). In the group of four, the first pin goes to the Arduino's pin 'D10', the second to 'D11', the third to the Arduino's 'GND' and the last one controls the transmitters frequency and goes to the Arduino's pin 'D9'. Both the GPS module and the NTX2 are powered by the Arduino. The GPS through the 5V output and the NTX2 by the pins 'D10' and 'D11' that both output 5V as well.

At this point, everything was ready for the code operating the device to be uploaded. The programming and uploading is done using the Arduino IDE and a USB cable. As I said, before ordering the parts, I came across a couple of manuals on how to wire and program all of this. In those and many other balloon projects, I found that the codes are usually based on Anthony Stirk's code for operating the NTX2 and a several codes published on the UKHAS website to operate the Ublox module. I followed the same path and wrote my code based on these too. Throughout the programming and testing, I ran into a couple of problems, so I equipped my code with a few commands to continuously print some information about the current processes.


This is the output of the Serial Monitor within the Arduino IDE when running my script. It shows the commands sent to the GPS module followed by the GPS's response. The responses are sentences containing information such as the current latitude, longitude, altitude, the number of satellites the module is locked to, and much more depending on the specific sentence. All these commands are described in the Ublox manual that is easily findable on the internet.
First, the code asks the GPS whether it is in the 'airborne mode' thus allowing it to operate up to 50km altitude. If not, it initializes the mode. Then it asks for information about the number of satellites and the GPS's Lock mode, and prints out the received values. It follows with request to receive the latitude, longitude and altitude data, and prints them out too. Lastly, it asks for the current time and, again, prints it out. This allows me to see whether there was any error in the communication. If there was an error in this cycle, it adds 1 to the 'GPS error count'. For some reason, I keep getting an erroneous communication in one of the sentences in about 25% of the time. At this point, I am not sure whether this is the standard or perhaps I made the physical wiring unreliable. Anyway, the one complete cycle of the code ends with constructing a sentence containing the received information such as this one: '$$TT7,200,08:51:04,49.491924,17.902342,9357,8,3,88,4957*C3E2'. Then the code transmits it and starts another round.

The transmission goes on like this. The sentence is cut into characters that are based on the ASCII table translated into the binary code. Each character represented by one byte. Each byte enclosed by a start bit and two stop bits. This string of 1s and 0s is then transmitted. The NTX2 is a frequency modulator. Based on the voltage delivered to the last pin (the one connected to the Arduino's pin 'D9'), the NTX2 is able to transmit in a different frequency within a range of 6000Hz. In our case, we deliver to the transmitter different voltage for a bit representing 0 and a different voltage for a bit representing 1, hence we use two different frequencies. When received, the signal looks like this.


And here is the code used in my Arduino. If you don't want to spend some time understanding the code and modifying it for your own transmitter, the code will work just fine with the parts I used (Arduino Nano, Ublox NEO-6M, NTX2) and the exact wiring I described earlier.

TT7_1_60.ino

The code also includes a section by Scott Daniels that is supposed to give information about the current battery voltage. Either I didn't understand its purpose correctly, or I did something wrong. In any case it keeps showing values close to 5V regardless of the time spent draining the batteries. 

One of the first working reception tests at the distance of some 20 meters.


With the transmitter working fine, it was time to make it more mobile. That meant replacing the USB power source with one consisting of batteries. The Arduino's recommended input voltage is 7-12V. Since I was connecting more devices requiring power to my Arduino and needed it to reliably supply 5V to them, I chose 6 AA batteries with a total voltage of 9V. To make things simple, I bought a casing for the batteries, and all I had to do was to fit the two casing wires with two KONPC-SPK pins that would attach to the Arduino's 'VIN' and 'GND' pins. I did not use any switches, so to turn the transmitter on or off I would simply connect or disconnect the 'VIN' pin.


The time to get rid of the breadboard had come. The Arduino Nano is quite handy, because it is already equipped with male pins attached to all the outputs and inputs. Thus all I needed to do was to connect the right wires fitted with the KONPC-SPK pins. The only problem arose with the 'GND' pins. The Arduino has two, but I needed three. And since I was reluctant to soldering, I improvised and squeezed two wires inside one KONPC-SPK pin and solved my problem. With the NTX2, I no longer could do without soldering, because it has some sort of pins too thin for a reliable connection with the KONPC-SPK pin. With everything in the right place and insulated, the result looked like this.


In the pictures, you can already see an antenna attached to the NTX2. I will come back to it later.

Later, I began testing the device together with the payload box and I immediately arrived at a problem. The GPS just wouldn't lock to any satellites when inside the box. Initially, I wasn't sure about the origin of the issue. Usually, I had programmed the Arduino connected to my desktop computer inside the house, so it had always taken the GPS a little longer to lock than the declared 27 seconds. Rather about 12-13 minutes to be honest. So the first idea I had was that there must be something wrong with the code (back then it was a different code than the one I made available a couple of paragraphs earlier). After a couple of sleepless nights of programming and taking the transmitter apart, I ended up with a new code and a revelation that the code wasn't the problem. When I took the device out without the box, it indeed locked to some satellites in less than a minute. That was quite a pullback, because everything else was prepared for right this box and not any other. Luckily, I had an idea to test every material the box was made of with regards to its GPS signal shielding properties.


The transmitter in the payload box not getting any GPS signal.
 

Trying different locations for the GPS's antenna. Without any results.


Taking it all out of the box, even removing the NTX2. The GPS gained signal as it was supposed to. The possible problem with the code disconfirmed.


Testing the polystyrene. The signal was fine.



Testing the foam used for insulation at that time. The signal was fine.



Finding the delinquent. The thermal blanket blocked the GPS signal. The solution was simple.



I stripped the box of the thermal blanket and covered it with the masking tape. With the transmitter inside the box, the acquisition of the signal took a little longer (a few minutes), but unlike with the thermal blanket on, it  got the GPS signal locked. Thus I finally had a working tracking solution.

No comments:

Post a Comment