Sunday 14 April 2013

The GPS Tracker

When we launch our payload we will need to know exactly where it is in the sky in order to follow and recover it. It is important then, to have a tracker that will give timely and accurate information to us on the ground about where it is and where it's heading. We decided in the early weeks of the project to use a radio based tracker, the kind that most high altitude balloon enthusiasts use, to track our balloon. There were a few reasons for this - it was proven technology, the radio infrastructure existed for balloon tracking and it would be a good challenge in itself to build a GPS tracker - something that we had no experience in before!

At the very start of the project we had no idea of the community and infrastructure that exists to enable balloon launchers to track their payloads as they fly through sky. A full and extensive explanation can he found on the UKHAS Wiki - definitely worth a read to gain a real understanding of what is going on. In a nutshell however:
  • Either via the #highaltitude channel on freenode IRC or the UKHAS Google Group, you let the community know of a future balloon launch. At this point it is important to know what transmitting frequency you will be using and the frequency shift you will be using to distinguish between a binary 0 and 1.
  • At the stated day and time, enthusiasts over the country listen out for the radio signal being transmitted from the balloon payload.
  • Using their receivers and computer software, they decode the GPS telemetry from the radio signal and upload this information to a central server, which then plots the balloon on the spacenear.us/tracker for the whole Internet to see.
  • This has been going on for a few years!

Components and code

There are two main parts to it, the Arduino Uno prefabricated board at the bottom and our arrangement of components soldered onto stripboard fitted on top. On the left of the board with the black blob antenna is the GPS receiver, the silver box is the radio transmitter with its additional SMA antenna connector, the flat component in the middle is an SD card reader and finally 6 AA Energizer Lithium batteries on the right to power it all. There are various LEDs and resistors also needed to complete the circuit - see the Wiki links below. It took a good few months to go from initial research to a fully working tracker! The computer (Arduino) needs to be programmed in order to get things working, you aren't able to just plug things in an expect it to work. The program works as follows:
    STRATODEAN - GPS Tracker
    Our GPS Tracker
  1. Arduino is initially powered up and does a check of all components to ensure that it can use them.
  2. It asks the GPS for location information - it returns lots of information including latitude, longitude, altitude and number of satellites it can see in a text format known as NMEA.
  3. The program extracts the useful bits of data that we need and puts it into a text format that UKHAS is expecting.
  4. The text string has a mathematical calculation performed on it, known as a checksum. This works out a four character sequence that must be added to the end of our string. When our string is received by the UKHAS listeners, their computer will do the same calculation - if the four characters match then they can be sure that the data they have received is how it was originally transmitted by the tracker.
  5. The whole string is then divided into its individual characters and the binary version of each character is sent over RTTY radio transmission by alternating the frequency about a particular wavelength (434MHz - unlicensed and free to use in the UK). This alternating creates the binary code for the string which is then decoded by the receivers.
  6. Saves a record of the text onto the SD card to act as a 'black box flight recorder'.
  7. Repeat steps 2 - 6 until the battery runs out!
STRATODEAN - Initial prototyping
Initial prototyping
When you start out on building your tracker you are always pointed to this tutorial, so we shall do the same: ukhas.org.uk/guides:linkingarduinotontx2. This contains everything you need to get you started on sending data over radio using an Arduino and as I found, a nice easy way to get started on C++. We started out with just the NTX2 radio transmitter on a breadboard and wires going to the Arduino.
STRATODEAN - First radio transmissions
First radio transmissions
In very little time we were able to send simple text message strings over the air and decode them at the other end. In the image you can see the Arduino IDE used to program the board on the right and on the left, dl-fldigi the program used to decode the radio signal. Whilst it's not important to know every detail of how radio transmission works, it is important to know the boundaries in which you can operate. Here in the UK we have 433MHz - 434MHz in which to operate radio transmissions without needing a licence. In order to facilitate this easily, the Radiometrix NTX2 that we are using comes in two preset frequences 434.075MHz and 434.650MHz. Both work in the same way but it is important that you know which one you have - there is a handy label on the side!
STRATODEAN - Prototyping GPS
Prototyping GPS
Once we were happy that we could generate the required RTTY signal using the Arduino and radio transmitter, we then moved on to the second integral part of the tracker - the GPS receiver. Again there is a brilliant guide put together on the UKHAS Wiki page that helped with getting this started: ukhas.org.uk/guides:ublox6. Initially I just soldered some wires into the GPS breakout board and plugged them into the Arduino and hoped everything would work as described, it didn't. The GPS was powering up but we were not getting any data back from the unit. The main reason for this is that this GPS unit with its passive antenna doesn't really work indoors! A quick dash outside with the laptop proved everything was working as expected.

It took a long while and a was a bit of a learning curve to start getting meaningful data back from the GPS. What gave us confidence however was that we were able to use the u-blox u-centre GPS evaluation software almost immediately. Connecting through the Arduino, we could see ourselves plotted on the map and where the satellites were located in the sky - interesting stuff and if you are doing this yourself, definitely download this software!

STRATODEAN - Prototyping GPS and radio
The radio and GPS on the same breadboard for the first time
Once we were happy that the GPS was automatically sending us accurate GPS coordinates and we were able to see these using the Arduino, it was time to try and combine the radio with it. There are a few people who have done this before so using the examples out there really helped get something 'working'. It is not OK though, to just get these examples, program your Arduino with them and hope things will work. It is paramount that you understand exactly what is happening on every line of the code. As well as having a knowledge of how it all works, you will feel much more satisfied! All of our code is available on our GitHub repository. Feel free to use as you wish. It is commented so hopefully should be pretty self explanatory. One thing that did trip us up and worth noting here, was that when using the built-in Software Serial, we were finding that half of the string was getting truncated. This is because of the buffer size in the Software Serial library. Changing this to 128 solved the problem.

We later added the SD card and this also caused problems - especially with RAM. Turns out, simply referencing the SD library causes a whole load of RAM to be used up. I then set about making the code more efficient (encasing all strings in the F() function for example) and using the FreeRam function.

Final solution

STRATODEAN - Underside of tracker
Underside
STRATODEAN - Graham helping with the soldering
Mark's brother Graham helping
with the soldering!
Once we were happy enough that the software was almost there and that the physical connections were correct, it was time to make a more permanent fixture for the components. As we had the Arduino Uno, the simplest solution was to create our own 'Arduino Shield'. This meant that we could 'plug in' our tracker when we wanted to use it and then remove it if we wanted to use the Arduino for something else at a later stage. We bought some prototyping stripboard from Maplin and set about soldering! It was just a case of then plugging it in and hoping for the best. It definitely felt more like a proper device in itself once it was soldered.

STRATODEAN - Coaxial shielding removed for antenna
Coaxial shielding removed
Finally you do need an antenna to work with this tracker else no one would hear it! This is is quite simple to achieve with some RG58 coax cable. We followed some examples and advice from the guys on the IRC channel. They said that the most effective and simple antenna is a quarter-wave with ground plane. This is exactly how it sounds - the length of the antenna is a quarter of the length of the whole wave. 434MHz is also known as the 70cm band - so 70cm / 4 = 17cm antenna length. A ground plane is a part of the antenna which help send the signals in a particular direction - in our case towards us on the ground! As mentioned in our Payload Part Two video, we used the coaxial shielding to form the ground plane and the centre coax cable as the main element. It was quite a tedious process to unbraid the shielding - but take your time and you get results.
STRATODEAN - Payload Antenna
Antenna attached to payload
Finally we created the ground plane by attaching the now divided coaxial shielding to the four corners of the payload box. Our payload is quite big compared to others, so if the ground plane over hangs, then use drinking straws or similar to support it. We have used a few drinking straws inside each other to support the centre element and to keep it straight during flight.

What we would improve

Although this tracker has yet to fly - there are already a few things that we would change or improve on the next version. The first is to use a different Arduino board. The Uno is a great prototyping board, but it requires 7v-12v power input so it can run at 5v. This means that we need to use 6AA (6x1.5v = 9v) batteries which are pretty heavy! Following on from this, we would possibly investigate fabricating our own DIY printed circuit board and solder components together with the Arduino chip directly together.

Hope this has helped

Although we haven't gone into the deep technical code and electrical side of things here, we hope this overview will show you the general processes needed in order to create your own High Altitude Balloon tracker. We hope to fly this very soon! If you have any questions please email stratodean@gmail.com or talk to the guys on the IRC channel. If you found this post useful or feel inspired to start your own project do let us know via email or Twitter - we'd love to hear from you!

1 comment:

  1. Great write up Mark! Looking forward to the launch :)

    ReplyDelete