This is the fourth part of my series explaining how to implement an APRS transmitter for your weather balloon.
|Basic message format
|Putting GPS data into the message
|Message at the bit level
|Converting to audio
The two bits in our binary message are transmitted using two different frequency pure audio tones: 1200Hz and 2200Hz. The bit rate, or baud of the transmitted signal is 1200 bits per second.
If you’re paying attention, you’ll notice that one complete cycle of a 1200Hz wave fits into exactly one transmitted bit time. When I first began developing my APRS transmitter, I assumed that the 2200Hz must have been a typo, and that 2400Hz would be correct. That way, exactly two cycles of 2400Hz would fit into one transmitted bit time.
Incorrect APRS Waveform
However, this is completely wrong. The reason they don’t use 2400Hz is because it’s the first harmonic of 1200Hz. Why is that a problem? Well, if the 1200Hz signal gets distorted in any way as it’s transmitted (very likely) then some 2400Hz harmonic will appear in the signal too. If the distortion is bad enough, then the receiver won’t be able to distinguish between the two tones.
So 2200Hz is used instead, which is different enough from 2400Hz that the receiver won’t be confused when it sees a slightly distorted signal. But how does that work? 2200Hz doesn’t fit nicely into a transmitted bit time.
Also incorrect APRS Waveform.
See, the end of the 2200Hz wave gets chopped off as the 1200Hz starts.
Of course, the correct way is to make the 1200Hz wave carry on from the same phase where the 2200Hz finished at the end of that bit time.
Correct APRS Waveform.
So, what does this look like with real data?
The first few bytes of an APRS packet.
When you first enable your transmitter, it will take a fraction of a second before its output is completely stable. During this time you can transmit a fixed 1200Hz signal if you want. This is the part of my waveform labelled “whatever”. Apparently, it’s even better to transmit alternating 1s and 0s (0x99). This helps the receiver to lock on to the signal. I don’t know if that’s true or not.
The interesting bit starts when the receiver sees the first flag byte. You can transmit as many flags as you want here. The message proper begins with the first non-flag byte; in this case, it’s the ‘M’ (left shifted and backwards) from my call sign “M6CYT”.
One more problem. Apparently the receiver can get upset if for some reason the high frequency part of the signal comes through with a lower amplitude than the low frequency. And due to various technical quirks of transmitters and receivers, it’s quite possible that the high frequencies will get squashed on the way. Therefore it’s a good idea to add some pre-emphasis to the signal before we sent it to the transmitter. Pre-emphasis basically means increasing the amplitude of the higher frequency components of a signal.
There’s actually a pretty easy way to do this electronically. You may remember that while a resistor doesn’t treat different frequencies differently, a capacitor does. A capacitor conducts higher frequencies better than low frequencies. Simply by using a capacitor, we can adjust the ratio of high and low frequencies:
Pre-emphasis added before transmission.
Generating the analogue signal
The final thing I want to cover is how to generate the analogue signal in the first place. I believe that some people use a PWM output from their microcontroller, and filter this with a resistor-capacitor low pass filter, but this is how I did it.
Cypress Programmable System on Chip (PSoC)
I don’t know why these things aren’t better known. This is a microcontroller from Cypress Semiconductor. You can write C code for it just like any other microcontroller. But the other thing you can do, which no other microcontroller allows, is to create your own circuits. You can literally wire up a circuit with the schematic editor built into the IDE, and have that circuit implemented inside the chip!
There is a large library of components to choose from. Everything from simple logic gates and op-amps, to CAN bus and digital filters. Also clocks, interrupts and DMA. This way I can easily create dedicated hardware in the chip for generating the APRS waveform.
PSoC APRS waveform generator
It seems a little daunting at first, but it’s actually very simple. On the far right is the Digital to Analogue Converter (DAC), connected to an output pin via a unity-gain op-amp. Data is fed to the DAC by the DMA component just to the left of it. Each time the DMA component gets a clock input, it sends the next sample of a 100-sample sine wave to the DAC. If the DMA was clocked at 100Hz, then the DAC would produce a 1Hz sine wave at its output.
On the far left we have two clocks, one 120kHz, and one 220kHz. Connecting either of these clocks to the DMA would produce 1200Hz or 2200Hz sine waves at the output.
In the middle, we have an SPI component. This is responsible for shifting our APRS message bits out one by one. It’s driven by a 1200Hz clock (actually it’s the 120kHz clock divided by 100). This is what gives us our 1200 baud. As the bits come out of the SPI component, they are connected to the multiplexer. This is a switch which chooses which clock connects to the DMA. So the two types of bit will produce two different output frequencies.
Lastly, there’s one more DMA component, which is responsible for making sure the SPI component is fed with data.
That’s it for my explanation of APRS. If you spot a mistake, or think something needs explaining better, please leave me a comment.