The personal website of Scott W Harden

Tooth as a Radio Receiver?

We've all heard the urban legend where someone's tooth filling picks up radio signals, some versions claim AM radio stations' music is heard, others that wartime Morse code is heard. Is this really possible? Well, as a dental student and an electrical engineering / RF engineering enthusiast, I can think of no one better prepared to put this myth to the test! Yeah, I'm going to put my money where my mouth is. (zing!) Myth Busters attempted to replicate this, but they concluded it was "busted", however I think they were going about it the wrong way. Let's back up! Here's a quote from Lucille Ball who is often accredited for originating this urban legend:

One night I came into the Valley over Coldwater Canyon, and I heard music. I reached down to turn the radio off, and it wasn't on. The music kept getting louder and louder, and then I realized it was coming from my mouth. I even recognized the tune. My mouth was humming and thumping with the drumbeat, and I thought I was losing my mind. I thought, What the hell is this? Then it started to subside. I got home and went to bed, not sure if I should tell anybody what had happened because they would think I was crazy.
--Lucille Ball

It was noted that Lucy recently had several temporary lead fillings installed in her teeth which caused this unique phenomenon. Let's assume this isn't a made-up story. If this were possible, what would cause it? Without going into detail as to how (whether by galvanic corrosion or other means), we'd have to assume that RF could be absorbed by the filling (whatever type it was), and turned into electrical activity. This electrical activity was either transferred directly to the nerves (felt as tingly electric shocks, which I feel isn't likely) or converted into mechanical energy (creating vibrations which would be hears as sound waves). The piezoelectric effect may be one method where an electrical signal could produce these vibrations. Many small speakers are called piezoelectric speakers, because they have a small crystal in them (usually quartz) which changes its dimension as electricity is applied to the crystal, creating mechanical vibrations (turned into sound waves). Tooth enamel is 98% hydroxyapatite crystal - I wonder if it could be coaxed to vibrate similarly to quartz? There's only one way to find out!

First, I start with a jar of teeth. Yeah, this is mine. Don't ask how I got it! They're all nasty as heck, and require sterilization before I will touch them without gloves. There are many advantages of spending every day in a medical setting, one of which is easy access to an autoclave! After picking a tooth which I think will have a lot of enamel I can isolate, I sterilized it.

I started by sectioning the tooth mesio-distally using a slow-speed air-driven handpiece and a #2 round burr. As I cut through the enamel, you can see the darker, yellowish dentin layer showing through.

This is my test subject. It's a maxillary left first premolar. My goal is to isolate only enamel from this tooth, take it home and experiment with it.

Although dentin is crystal too, it's about half organic matter and I feel it's less likely to exhibit significant piezoelectric effect. Therefore, I'm going to try to eliminate all the dentin attached to the enamel. The image above shows some yellow dentin remaining near the center of the enamel. The lingual surface of the tooth has already been removed, leaving a thin shell of the facial surface. I'll try to be more aggressive taking out more dentin...

Oops! Enamel is strong, but brittle. This brittleness is exacerbated by the process of autoclaving. While trying to drill away dentin, a large amount of the enamel chipped off, but I think it's enough to use for my experiment.

Here's what I have to work with. It's pretty thick - I imagine if I make it thinner still, it will have a better chance of vibrating. Either way, it's a start! The view above shows the facial aspect of the tooth - just think, this was probably on someone's mouth for 50 years, viewed by thousands of people. Now it's in my hands, and I'm about to turn it into a radio. I love my life.

From the other side, you can see enamel gets thicker toward one side of the tooth. My plan once I go home tonight (after I spend the afternoon in oral surgery, possibly extracting some teeth) is to gator-clip leads onto different sections of this tooth and run current through it. I'm thinking half a watt of 28MHz (since I have that transmitter I made yesterday still on my workbench), amplitude-modulated to produce a 300Hz tone. If my piezoelectric tooth enamel theory holds water, the tooth will vibrate at 300Hz when I do this. I can't wait to try it out!

Update - 3pm 8/15/2011

We had a cancellation in the student oral surgery clinic, so with my unexpected free time I decided to prepare another tooth and attempt to isolate a larger, thinner selection of enamel. I chose a maxillary left lateral incisor this time, and carefully drilled it down until it was only enamel, and pretty thin at that. Take a look!

I don't have my calipers on me, so I can only estimate its thickness to be between 500 and 1000 microns. It's likely still too thick to vibrate extremely well, but it will be a good starting point. We'll see how it fairs when I apply some RF current through it tonight at home!

To add credibility to this story, here is the official description of an episode from the Gilligan's Island Episode List wikipedia page:

Gilligan's mouth becomes a radio when a filling in a tooth is knocked loose. Just in time too, as the regular radio is broken and a monster typhoon is on its way.
"Hi-Fi Gilligan", Season 2, Episode 10, November 25, 1965

Update - 9:50 pm 8/15/2011

I'm starting to feel like I might have been played. I tried sending different types of current through flakes of enamel and nothing I did seemed to make it vibrate measurably. I tried audio level 5V square waves, audio level modulated RF 30PPV sine waves, and a few other things at all locations on the enamel, but I couldn't get it to produce sound. I think it's either (a) not thin enough to vibrate freely, (b) not highly piezoelectric, (c) not fed the correct frequency, for which I really need a RF sweep generator, or (d) simply not possible and I'm chasing a ghost on this one... If someone has any ideas of what to try, I'd appreciate it. If I can't make it vibrate from electrical current, I'll never make progress toward proving the "tooth radio" story, so I guess it ends here for now. If you have any ideas, feel free to share them with me! I'll probably move on to bigger, better things now...

Second wind: I'm starting to think that I'm beginning this project too complexly. I know a quartz peizoelectric speaker works. I should probably start by replicating this, using a fragment of enamel rather than quartz. Also, most of the volume from a peizo speaker comes from its resonant chamber. Technically, this could be vibrating in front of me right now and I wouldn't be able to hear or see it! I should find a crystal peizo speaker, replace the quartz with enamel, and start from there...

Update - 10:35 pm 8/15/2011

SUCCESS! I can't believe I gave up that easily! I'd actually started moving onto another project, when I had an idea and revisited this one. So what if the piezoelectric vibration experiment didn't work? Is it possible that RF could be turned into electrical signals that could be sensed by the mouth? Two dissimilar metals in contact may form a P-N junction, the fundamental unit of semiconductors. A simple diode would take audio-level amplitude modulated radio frequency signal and act as an envelope detector, producing electrical output corresponding to the audio used to modulate the carrier signal. A simple diode should do the same thing. Therefore, if a diode in my mouth produces a tingle of electricity upon RF exposure, and if I can figure out which dental materials are P-type and N-type, I can replicate this! First test, diode.

There's a simple 1N914 diode with a tooth beside it for scale reference. A diode, when exposed to RF, acts a bit like a half-wave rectifier, the body acts as a lowpass filter, and the result is a small electrical current delivered upon RF exposure. The black stripe indicates the + side of the diode. I place this on my tongue, touch the other end with my hand and and let's try keying up a transmitter...

ZAP! Even though I'm not holding the radio (as evidenced by a black/Mexican hand with nail polish), every time my wife presses the transmit button I feel a slight tingle in my mouth. This is a 5W radio a few feet away. I couldn't even imagine what a 50,000 watt AM radio station would feel like! Now, if I can just figure out which dental materials would act like a diode, I can construct this dental device in a human tooth and measure the current produced! If I'm confident it's sterilized, I guess I can put it in my mouth and see if I can feel it tingle. eww! I'll cross that bridge when I come to it. Time for more research!

TO BE CONTINUED...

Markdown source code last modified on January 18th, 2021
---
title: Tooth as a Radio Receiver?
date: 2010-08-15 12:13:39
tags: old
---

# Tooth as a Radio Receiver?

__We've all heard the urban legend where someone's tooth filling picks up radio signals__, some versions claim AM radio stations' music is heard, others that wartime Morse code is heard. Is this really possible? Well, as a dental student and an electrical engineering / RF engineering enthusiast, I can think of no one better prepared to put this myth to the test! Yeah, __I'm going to put my money where my mouth is.__ (zing!) [Myth Busters attempted to replicate this](http://www.youtube.com/watch?v=OwfAyo4twqg), but they concluded it was "busted", however I think they were going about it the wrong way. Let's back up! Here's a quote from Lucille Ball who is often accredited for originating this urban legend:

<blockquote class="wp-block-quote"><p>One night I came into the Valley over Coldwater Canyon, and I heard music. I reached down to turn the radio off, and it wasn't on. The music kept getting louder and louder, and then I realized it was coming from my mouth. I even recognized the tune. My mouth was humming and thumping with the drumbeat, and I thought I was losing my mind. I thought, What the hell is this? Then it started to subside. I got home and went to bed, not sure if I should tell anybody what had happened because they would think I was crazy.<br/>--Lucille Ball</p></blockquote>

__It was noted that Lucy recently had several temporary lead fillings__ installed in her teeth which caused this unique phenomenon. Let's assume this isn't a made-up story. If this were possible, what would cause it? Without going into detail as to how (whether by [galvanic corrosion](http://en.wikipedia.org/wiki/Galvanic_corrosion) or other means), we'd have to assume that RF could be absorbed by the filling (whatever type it was), and turned into electrical activity. This electrical activity was either transferred directly to the nerves (felt as tingly electric shocks, which I feel isn't likely) or converted into mechanical energy (creating vibrations which would be hears as sound waves). The [piezoelectric effect](http://en.wikipedia.org/wiki/Piezoelectricity) may be one method where an electrical signal could produce these vibrations. Many small speakers are called [piezoelectric speakers](http://en.wikipedia.org/wiki/Loudspeaker#Piezoelectric_speakers), because they have a small crystal in them (usually quartz) which changes its dimension as electricity is applied to the crystal, creating mechanical vibrations (turned into sound waves). [Tooth enamel](http://en.wikipedia.org/wiki/Tooth_enamel) is 98% hydroxyapatite crystal - I wonder if it could be coaxed to vibrate similarly to quartz? There's only one way to find out!

<div class="text-center img-border">

[![](IMG_5554_thumb.jpg)](IMG_5554.jpg)

</div>

__First, I start with a jar of teeth.__ Yeah, this is mine. Don't ask how I got it! They're all nasty as heck, and require sterilization before I will touch them without gloves. There are many advantages of spending every day in a medical setting, one of which is easy access to an autoclave! After picking a tooth which I think will have a lot of enamel I can isolate, I sterilized it.

<div class="text-center img-border">

[![](IMG_5562_thumb.jpg)](IMG_5562.jpg)

</div>

__I started by sectioning the tooth mesio-distally__ using a slow-speed air-driven handpiece and a \#2 round burr. As I cut through the enamel, you can see the darker, yellowish dentin layer showing through.

<div class="text-center img-border">

[![](IMG_5563_thumb.jpg)](IMG_5563.jpg)

</div>

__This is my test subject.__ It's a maxillary left first premolar. My goal is to isolate only enamel from this tooth, take it home and experiment with it.

<div class="text-center img-border">

[![](IMG_5567_thumb.jpg)](IMG_5567.jpg)

</div>

__Although dentin is crystal too, it's about half organic matter and I feel it's less likely to exhibit significant piezoelectric effect.__ Therefore, I'm going to try to eliminate all the dentin attached to the enamel. The image above shows some yellow dentin remaining near the center of the enamel. The lingual surface of the tooth has already been removed, leaving a thin shell of the facial surface. I'll try to be more aggressive taking out more dentin...

__Oops!__ Enamel is strong, but brittle. This brittleness is exacerbated by the process of autoclaving. While trying to drill away dentin, a large amount of the enamel chipped off, but I think it's enough to use for my experiment.

__Here's what I have to work with.__ It's pretty thick - I imagine if I make it thinner still, it will have a better chance of vibrating. Either way, it's a start! The view above shows the facial aspect of the tooth - just think, this was probably on someone's mouth for 50 years, viewed by thousands of people. Now it's in my hands, and I'm about to turn it into a radio. I love my life.

__From the other side, you can see enamel gets thicker toward one side of the tooth.__ My plan once I go home tonight (after I spend the afternoon in oral surgery, possibly extracting some teeth) is to gator-clip leads onto different sections of this tooth and run current through it. I'm thinking half a watt of 28MHz (since I have that transmitter I made yesterday still on my workbench), amplitude-modulated to produce a 300Hz tone. If my piezoelectric tooth enamel theory holds water, the tooth will vibrate at 300Hz when I do this. I can't wait to try it out!

<div class="text-center img-border">

[![](IMG_5570_thumb.jpg)](IMG_5570.jpg)

[![](IMG_5573_thumb.jpg)](IMG_5573.jpg)

[![](IMG_5577_thumb.jpg)](IMG_5577.jpg)

[![](IMG_5578_thumb.jpg)](IMG_5578.jpg)

[![](IMG_5583_thumb.jpg)](IMG_5583.jpg)

</div>

### Update - 3pm 8/15/2011

__We had a cancellation in the student oral surgery clinic__, so with my unexpected free time I decided to prepare another tooth and attempt to isolate a larger, thinner selection of enamel. I chose a maxillary left lateral incisor this time, and carefully drilled it down until it was only enamel, and pretty thin at that. Take a look!

__I don't have my calipers on me,__ so I can only estimate its thickness to be between 500 and 1000 microns. It's likely still too thick to vibrate extremely well, but it will be a good starting point. We'll see how it fairs when I apply some RF current through it tonight at home!

__To add credibility to this story,__ here is the official description of an episode from the [Gilligan's Island Episode List](http://en.wikipedia.org/wiki/List_of_Gilligan's_Island_episodes) wikipedia page:

<blockquote class="wp-block-quote"><p>Gilligan's mouth becomes a radio when a filling in a tooth is knocked loose. Just in time too, as the regular radio is broken and a monster typhoon is on its way.<br/><i>"Hi-Fi Gilligan", Season 2, Episode 10, November 25, 1965</i></p></blockquote>

### Update - 9:50 pm 8/15/2011

__I'm starting to feel like I might have been played.__ I tried sending different types of current through flakes of enamel and nothing I did seemed to make it vibrate measurably. I tried audio level 5V square waves, audio level modulated RF 30PPV sine waves, and a few other things at all locations on the enamel, but I couldn't get it to produce sound. I think it's either (a) not thin enough to vibrate freely, (b) not highly piezoelectric, (c) not fed the correct frequency, for which I really need a RF sweep generator, or (d) simply not possible and I'm chasing a ghost on this one... If someone has any ideas of what to try, I'd appreciate it. If I can't make it vibrate from electrical current, I'll never make progress toward proving the "tooth radio" story, so I guess it ends here for now. If you have any ideas, feel free to share them with me! I'll probably move on to bigger, better things now...

__Second wind: I'm starting to think that I'm beginning this project too complexly.__ I know a quartz peizoelectric speaker works. I should probably start by replicating this, using a fragment of enamel rather than quartz. Also, most of the volume from a peizo speaker comes from its resonant chamber. Technically, _this could be vibrating in front of me right now and I wouldn't be able to hear or see it!_ I should find a crystal peizo speaker, replace the quartz with enamel, and start from there...

### Update - 10:35 pm 8/15/2011

__SUCCESS!__ I can't believe I gave up that easily! I'd actually started moving onto another project, when I had an idea and revisited this one. So what if the piezoelectric vibration experiment didn't work? Is it possible that RF could be turned into electrical signals that could be sensed by the mouth? Two dissimilar metals in contact may form a [P-N junction](http://en.wikipedia.org/wiki/P-n_junction), the fundamental unit of semiconductors. A simple diode would take audio-level amplitude modulated radio frequency signal and act as an envelope detector, producing electrical output corresponding to the audio used to modulate the carrier signal. A simple diode should do the same thing. Therefore, if a diode in my mouth produces a tingle of electricity upon RF exposure, and if I can figure out which dental materials are [P-type](http://en.wikipedia.org/wiki/P-type_semiconductor) and [N-type](http://en.wikipedia.org/wiki/N-type_semiconductor), I can replicate this! First test, diode.

<div class="text-center img-border">

[![](DSCN1732_thumb.jpg)](DSCN1732.jpg)

</div>

__There's a simple [1N914 diode](http://www.fairchildsemi.com/ds/1N/1N914.pdf) with a tooth beside it for scale reference.__ A diode, when exposed to RF, acts a bit like a half-wave rectifier, the body acts as a lowpass filter, and the result is a small electrical current delivered upon RF exposure. The black stripe indicates the + side of the diode. I place this on my tongue, touch the other end with my hand and and let's try keying up a transmitter...

<div class="text-center img-border">

[![](DSCN1733_thumb.jpg)](DSCN1733.jpg)

</div>

__ZAP!__ Even though I'm not holding the radio (as evidenced by a black/Mexican hand with nail polish), every time my wife presses the transmit button I feel a slight tingle in my mouth. This is a 5W radio a few feet away. I couldn't even imagine what a 50,000 watt AM radio station would feel like! Now, if I can just figure out which dental materials would act like a diode, I can construct this dental device in a human tooth and measure the current produced! If I'm confident it's sterilized, I guess I can put it in my mouth and see if I can feel it tingle. eww! I'll cross that bridge when I come to it. Time for more research!

#### _TO BE CONTINUED..._

Prime Failure 1 Year in the Making

My expression is completely flat right now. I simply cannot believe I'm about to say what I'm preparing to say. I spent nearly a year cracking large prime numbers. In short, I took-on a project I called The Flowering N'th Prime Project, where I used my SheevaPlug to generate a list of every [every millionth] prime number. The current "golden standard" is this page where one can look-up the N'th prime up to 1 trillion. My goal was to reach over 1 trillion, which I did just this morning! I was planning on being the only source on the web to allow lookups of prime numbers greater than 1 trillion.

However, when I went to look at the logs, I realized that the software had a small, fatal bug in it. Apparently every time the program restarted (which happened a few times over the months), although it resumed at its most recent prime number, it erased the previous entries. As a result, I have no logs below N=95 billion. In other words, although I reached my target this morning, it's completely irrelevant since I don't have all the previous data to prove it. I'm completely beside myself, and have no idea what I'm going to do. I can start from the beginning again, but that would take another YEAR. [sigh]

So here's the screw-up. Apparently I coded everything correctly on paper, but due to my lack of experience I overlooked the potential for multiple appends to occur simultaneously. I can only assume that's what screwed it up, but I cannot be confident. Honestly, I still don't know specifically what the problem is. All in all, it looks good to me. Here is the relevant Python code.

def add2log(c,v):
 f=open(logfile,'a')
 f.write("%d,%dn"%(c,v))
 f.close()

def resumeFromLog():
 f=open('log.txt')
 raw=f.readlines()[-1]
 f.close()
 return eval("["+raw+"]")

For what it's worth, this is what remains of the log file:

953238,28546251136703
953239,28546282140203
953240,28546313129849
...
1000772,30020181524029
1000773,30020212566353
1000774,30020243594723
Markdown source code last modified on January 18th, 2021
---
title: Prime Failure 1 Year in the Making
date: 2010-08-11 07:49:58
tags: python, old
---

# Prime Failure 1 Year in the Making

__My expression is completely flat right now.__ I simply cannot believe I'm about to say what I'm preparing to say. I spent nearly a year cracking large prime numbers. In short, I took-on a project I called [_The Flowering N'th Prime Project_](http://swharden.dyndns.org:8081/), where I used my [SheevaPlug](http://en.wikipedia.org/wiki/SheevaPlug) to generate a list of every \[every millionth\] prime number. The current "golden standard" is [this page](http://primes.utm.edu/nthprime/) where one can look-up the N'th prime up to 1 trillion. My goal was to reach over 1 trillion, which I did just this morning! I was planning on being the only source on the web to allow lookups of prime numbers greater than 1 trillion.

<div class="text-center img-border">

[![](flowering_primes_thumb.jpg)](flowering_primes.png)

</div>

__However, when I went to look at the logs,__ I realized that the software had a small, fatal bug in it. Apparently every time the program restarted (which happened a few times over the months), although it resumed at its most recent prime number, it erased the previous entries. As a result, I have no logs below N=95 billion. In other words, although I reached my target this morning, it's completely irrelevant since I don't have all the previous data to prove it. I'm completely beside myself, and have no idea what I'm going to do. I can start from the beginning again, but that would take another YEAR. \[sigh\]

__So here's the screw-up.__ Apparently I coded everything correctly on paper, but due to my lack of experience I overlooked the potential for multiple appends to occur simultaneously. I can only assume that's what screwed it up, but I cannot be confident. Honestly, I still don't know specifically what the problem is. All in all, it looks good to me. Here is the relevant Python code.

```python
def add2log(c,v):
 f=open(logfile,'a')
 f.write("%d,%dn"%(c,v))
 f.close()

def resumeFromLog():
 f=open('log.txt')
 raw=f.readlines()[-1]
 f.close()
 return eval("["+raw+"]")
```

__For what it's worth,__ this is what remains of the log file:

```python
953238,28546251136703
953239,28546282140203
953240,28546313129849
...
1000772,30020181524029
1000773,30020212566353
1000774,30020243594723
```

Converting Numbers to Morse Code with GCC

One of my microcontroller projects requires me to measure values and transmit then in Morse code. There may be code out there to do this already, but I couldn't find it. I'm sure there are more elegant and efficient ways to handle the conversion, but this works for me. Hopefully someone will find it useful!

#include <stdio.h>

//Morse code numbers from 0 to 9
char *array[10] = {"-----", ".----", "..---", "...--", "....-",
                   ".....", "-....", "--...", "---..", "----."};

void beep(char v)
{
    // beep (or print) Morse code as necessary
    printf("%s ", array[v]);
}

void send(int l)
{
    // convert a number into Morse code
    char d = 0;
    int t = 0;
    int val = 0;
    for (t = 100000; t > 0; t = t / 10)
    { //number of digits here
        if (l > t)
        {
            d = l / t;
            beep(d);
            l -= d * t;
        }
        else
        {
            beep(0);
        }
    }
    printf("n");
}

void main()
{
    // program starts here
    int l = 0b1111111111; //sample number (maximum 10-bit)
    printf("%d ", l);
    send(l);
    l = 0b11010001100101100011; //larger sample number
    printf("%d ", l);
    send(l);
}
Markdown source code last modified on January 18th, 2021
---
title: Converting Numbers to Morse Code with GCC
date: 2010-08-09 07:55:47
tags: python, qrss, old
---

# Converting Numbers to Morse Code with GCC

__One of my microcontroller projects__ requires me to measure values and transmit then in Morse code. There may be code out there to do this already, but I couldn't find it. I'm sure there are more elegant and efficient ways to handle the conversion, but this works for me. Hopefully someone will find it useful!

<div class="text-center img-border">

[![](binary_to_Morse_thumb.jpg)](binary_to_Morse.png)

</div>

```c
#include <stdio.h>

//Morse code numbers from 0 to 9
char *array[10] = {"-----", ".----", "..---", "...--", "....-",
                   ".....", "-....", "--...", "---..", "----."};

void beep(char v)
{
    // beep (or print) Morse code as necessary
    printf("%s ", array[v]);
}

void send(int l)
{
    // convert a number into Morse code
    char d = 0;
    int t = 0;
    int val = 0;
    for (t = 100000; t > 0; t = t / 10)
    { //number of digits here
        if (l > t)
        {
            d = l / t;
            beep(d);
            l -= d * t;
        }
        else
        {
            beep(0);
        }
    }
    printf("n");
}

void main()
{
    // program starts here
    int l = 0b1111111111; //sample number (maximum 10-bit)
    printf("%d ", l);
    send(l);
    l = 0b11010001100101100011; //larger sample number
    printf("%d ", l);
    send(l);
}
```

Idea: vdFSK modulation

My goal is to create a QRPP (extremely low power) transmitter and modulation method to send QRSS (extremely slow, frequency shifting data) efficiently, able to be decoded visually or with automated image analysis software. This evolving post will document the thought process and development behind AJ4VD's Frequency Shift Keying method, vdFSK.

Briefly, this is what my idea is. Rather than standard 2-frequencies (low for space, high for tone) QRSS3 (3 seconds per dot), I eliminate the need for pauses between dots by using 3 frequencies (low for a space between letters, medium for dot, high for dash). The following images compare my call sign (AJ4VD) being sent with the old method, and the vdFSK method.

Again, both of these images say the same thing: AJ4VD, .- .--- ....- ...- -.. However, note that the above image has greater than a 3 second dot, so it's unfairly long if you look at the time scale. Until I get a more fairly representative image, just appreciate it graphically. It's obviously faster to send 3 frequencies rather than two. In my case, it's over 200% faster.

This is the code to generate audio files converting a string of text into vdFSK audio, saving the output as a WAV file. Spectrographs can be created from these WAV files.

generate_audio.py

# converts a string into vdFSK audio saved as a WAV file

import numpy
import wave
from morse import *


def makeTone(freq, duration=1, samplerate=5000, shape=True):
    signal = numpy.arange(duration*samplerate) / \
        float(samplerate)*float(freq)*3.14*2
    signal = numpy.sin(signal)*16384
    if shape == True:  # soften edges
        for i in range(100):
            signal[i] = signal[i]*(i/100.0)
            signal[-i] = signal[-i]*(i/100.0)
    ssignal = ''
    for i in range(len(signal)):  # make it binary
        ssignal += wave.struct.pack('h', signal[i])
    return ssignal


def text2tone(msg, base=800, sep=5):
    audio = ''
    mult = 3  # secs per beep
    msg = " "+msg+" "
    for char in msg.lower():
        morse = lookup[char]
        print char, morse
        audio += makeTone(base, mult)
        for step in lookup[char]:
            if step[0] == ".":
                audio += makeTone(base+sep, int(step[1])*mult)
            if step[0] == "-":
                audio += makeTone(base+sep*2, int(step[1])*mult)
            if step[0] == "|":
                audio += makeTone(base, 3*mult)
    return audio


msg = "aj4vd"
file = wave.open('test.wav', 'wb')
file.setparams((1, 2, 5000, 5000*4, 'NONE', 'noncompressed'))
file.writeframes(text2tone(msg))
file.close()

print 'file written'

morse.py

# library for converting between text and Morse code
raw_lookup="""
a.- b-... c-.-. d-.. e. f..-. g--. h.... i.. j.--- k-- l.-.. m--
n-. o--- p.--. q--.- r.-. s... t- u.- v...- w.-- x-..- y-.-- z--..
0----- 1.---- 2..--- 3...-- 4....- 5..... 6-.... 7--... 8---.. 9----.
..-.-.- =-...- :---... ,--..-- /-..-. --....-
""".replace("n","").split(" ")

lookup={}
lookup[" "]=["|1"]
for char in raw_lookup:
    """This is a silly way to do it, but it works."""
    char,code=char[0],char[1:]
    code=code.replace("-----","x15 ")
    code=code.replace("----","x14 ")
    code=code.replace("---","x13 ")
    code=code.replace("--","x12 ")
    code=code.replace("-","x11 ")
    code=code.replace(".....","x05 ")
    code=code.replace("....","x04 ")
    code=code.replace("...","x03 ")
    code=code.replace("..","x02 ")
    code=code.replace(".","x01 ")
    code=code.replace("x0",'.')
    code=code.replace("x1",'-')
    code=code.split(" ")[:-1]
    #print char,code
    lookup[char]=code

Automated decoding is trivial. The image above was analyzed, turned into the image below, and the string (AJ4VD) was extracted:

decode.py

# given an image, it finds peaks and pulls data out
from PIL import Image
from PIL import ImageDraw
import pylab
import numpy

pixelSeek = 10
pixelShift = 15


def findPeak(data):
    maxVal = 0
    maxX = 0
    for x in range(len(data)):
        if data[x] > maxVal:
            maxVal, maxX = data[x], x
    return maxX


def peaks2morse(peaks):
    baseFreq = peaks[0]
    lastSignal = peaks[0]
    lastChange = 0
    directions = []
    for i in range(len(peaks)):
        if abs(peaks[i]-baseFreq) < pixelSeek:
            baseFreq = peaks[i]
        if abs(peaks[i]-lastSignal) < pixelSeek and i < len(peaks)-1:
            lastChange += 1
        else:
            if abs(baseFreq-lastSignal) < pixelSeek:
                c = " "
            if abs(baseFreq-lastSignal) < pixelSeek:
                c = " "
            if abs(baseFreq-lastSignal) < pixelSeek:
                c = " "
            directions.append(
                [lastSignal, lastChange, baseFreq, baseFreq-lastSignal])
            lastChange = 0
        lastSignal = peaks[i]
    return directions


def morse2image(directions):
    im = Image.new("L", (300, 100), 0)
    draw = ImageDraw.Draw(im)
    lastx = 0
    for d in directions:
        print d
        draw.line((lastx, d[0], lastx+d[1], d[0]), width=5, fill=255)
        lastx = lastx+d[1]
    im.show()


im = Image.open('raw.png')
pix = im.load()
data = numpy.zeros(im.size)
for x in range(im.size[0]):
    for y in range(im.size[1]):
        data[x][y] = pix[x, y]

peaks = []
for i in range(im.size[0]):
    peaks.append(findPeak(data[i]))

morse = peaks2morse(peaks)
morse2image(morse)
print morse
Markdown source code last modified on January 18th, 2021
---
title: Idea: vdFSK modulation
date: 2010-07-22 12:39:54
tags: python, qrss, old
---

# Idea: vdFSK modulation

<blockquote class="wp-block-quote"><p>My goal is to create a QRPP (extremely low power) transmitter and modulation method to send QRSS (extremely slow, frequency shifting data) efficiently, able to be decoded visually or with automated image analysis software. This evolving post will document the thought process and development behind AJ4VD's Frequency Shift Keying method, <b>vdFSK</b>.</p></blockquote>

__Briefly, this is what my idea is.__ Rather than standard 2-frequencies (low for space, high for tone) QRSS3 (3 seconds per dot), I eliminate the need for pauses between dots by using 3 frequencies (low for a space between letters, medium for dot, high for dash). The following images compare my call sign (AJ4VD) being sent with the old method, and the vdFSK method.

<div class="text-center img-border">

[![](traditional_thumb.jpg)](traditional.png)

</div>

__Again,__ both of these images say the same thing: AJ4VD, `.- .--- ....- ...- -..` However, note that the above image has greater than a 3 second dot, so it's unfairly long if you look at the time scale. Until I get a more fairly representative image, just appreciate it graphically. It's obviously faster to send 3 frequencies rather than two. In my case, it's over 200% faster.

<div class="text-center img-border">

[![](modulation_thumb.jpg)](modulation.png)

</div>

__This is the code to generate audio files__ converting a string of text into vdFSK audio, saving the output as a WAV file. Spectrographs can be created from these WAV files.

### generate_audio.py

```python
# converts a string into vdFSK audio saved as a WAV file

import numpy
import wave
from morse import *


def makeTone(freq, duration=1, samplerate=5000, shape=True):
    signal = numpy.arange(duration*samplerate) / \
        float(samplerate)*float(freq)*3.14*2
    signal = numpy.sin(signal)*16384
    if shape == True:  # soften edges
        for i in range(100):
            signal[i] = signal[i]*(i/100.0)
            signal[-i] = signal[-i]*(i/100.0)
    ssignal = ''
    for i in range(len(signal)):  # make it binary
        ssignal += wave.struct.pack('h', signal[i])
    return ssignal


def text2tone(msg, base=800, sep=5):
    audio = ''
    mult = 3  # secs per beep
    msg = " "+msg+" "
    for char in msg.lower():
        morse = lookup[char]
        print char, morse
        audio += makeTone(base, mult)
        for step in lookup[char]:
            if step[0] == ".":
                audio += makeTone(base+sep, int(step[1])*mult)
            if step[0] == "-":
                audio += makeTone(base+sep*2, int(step[1])*mult)
            if step[0] == "|":
                audio += makeTone(base, 3*mult)
    return audio


msg = "aj4vd"
file = wave.open('test.wav', 'wb')
file.setparams((1, 2, 5000, 5000*4, 'NONE', 'noncompressed'))
file.writeframes(text2tone(msg))
file.close()

print 'file written'
```

### morse.py

```python
# library for converting between text and Morse code
raw_lookup="""
a.- b-... c-.-. d-.. e. f..-. g--. h.... i.. j.--- k-- l.-.. m--
n-. o--- p.--. q--.- r.-. s... t- u.- v...- w.-- x-..- y-.-- z--..
0----- 1.---- 2..--- 3...-- 4....- 5..... 6-.... 7--... 8---.. 9----.
..-.-.- =-...- :---... ,--..-- /-..-. --....-
""".replace("n","").split(" ")

lookup={}
lookup[" "]=["|1"]
for char in raw_lookup:
    """This is a silly way to do it, but it works."""
    char,code=char[0],char[1:]
    code=code.replace("-----","x15 ")
    code=code.replace("----","x14 ")
    code=code.replace("---","x13 ")
    code=code.replace("--","x12 ")
    code=code.replace("-","x11 ")
    code=code.replace(".....","x05 ")
    code=code.replace("....","x04 ")
    code=code.replace("...","x03 ")
    code=code.replace("..","x02 ")
    code=code.replace(".","x01 ")
    code=code.replace("x0",'.')
    code=code.replace("x1",'-')
    code=code.split(" ")[:-1]
    #print char,code
    lookup[char]=code

```

<div class="text-center img-border">

[![](produced_thumb.jpg)](produced.png)

</div>

__Automated decoding__ is trivial. The image above was analyzed, turned into the image below, and the string (AJ4VD) was extracted:

### decode.py

```python
# given an image, it finds peaks and pulls data out
from PIL import Image
from PIL import ImageDraw
import pylab
import numpy

pixelSeek = 10
pixelShift = 15


def findPeak(data):
    maxVal = 0
    maxX = 0
    for x in range(len(data)):
        if data[x] > maxVal:
            maxVal, maxX = data[x], x
    return maxX


def peaks2morse(peaks):
    baseFreq = peaks[0]
    lastSignal = peaks[0]
    lastChange = 0
    directions = []
    for i in range(len(peaks)):
        if abs(peaks[i]-baseFreq) < pixelSeek:
            baseFreq = peaks[i]
        if abs(peaks[i]-lastSignal) < pixelSeek and i < len(peaks)-1:
            lastChange += 1
        else:
            if abs(baseFreq-lastSignal) < pixelSeek:
                c = " "
            if abs(baseFreq-lastSignal) < pixelSeek:
                c = " "
            if abs(baseFreq-lastSignal) < pixelSeek:
                c = " "
            directions.append(
                [lastSignal, lastChange, baseFreq, baseFreq-lastSignal])
            lastChange = 0
        lastSignal = peaks[i]
    return directions


def morse2image(directions):
    im = Image.new("L", (300, 100), 0)
    draw = ImageDraw.Draw(im)
    lastx = 0
    for d in directions:
        print d
        draw.line((lastx, d[0], lastx+d[1], d[0]), width=5, fill=255)
        lastx = lastx+d[1]
    im.show()


im = Image.open('raw.png')
pix = im.load()
data = numpy.zeros(im.size)
for x in range(im.size[0]):
    for y in range(im.size[1]):
        data[x][y] = pix[x, y]

peaks = []
for i in range(im.size[0]):
    peaks.append(findPeak(data[i]))

morse = peaks2morse(peaks)
morse2image(morse)
print morse
```

High Altitude Balloon Transmitter

SUMMARY: A small group of high school students taking an AP class for college credit launched a high-altitude weather balloon with a small payload. In addition to a video transmitter and GPS transmitter, they decided to include a simple transmitter built from scratch. This is the story of the project, with emphasis on the simple transmitter's design, construction, implementation, and reception (which surprised me, being detected ~200 miles away and lasting the entire duration of the flight!) [sample.ogg]

6/16/2010 - TRACKING

I'm impressed how well the transmitter/receiver worked! For only a few milliwatts, I was able to track that thing all the way from takeoff to landing in Gainesville, FL a few hundred miles away.

ANALYSIS: the text on the image describes most if it, but one of the most interesting features is the "multipathing" during the final moments of the descent, where the single carrier signal splits into two. I believe this is due to two Doppler shifts: (1) as the distance between the falling transmitter and the receiver is decreasing, producing a slight in increase in frequency, and (2) a signal reflected off of a layer of the atmosphere above the craft (the ionosphere?) before it gets to the receiver, the distance of which is increasing as the craft falls, producing a decrease in frequency. I'll bet I can mathematically work backwards and determine how high the craft was, how fast it was falling, and/or how high the layer of the reflecting material is - but that's more work than this dental student is prepared to do before his morning coffee!

HERE IS SOME AUDIO of some of the strongest signals I received. Pretty good for a few milliwatts a hundred miles away! [beeps.ogg]

6/16/2010 - THE FLIGHT

The design team:

Walking the balloon to its launch destination at NASA with an awesome rocket (Saturn 1B - identified by Lee, KU4OS) in the background.

The team again, getting ready for launch. I've been informed that the reason their hands are up is to prevent the balloon from tilting over too much. I'd imagine that a brush with a grass blade could be bad news for the project!

Last minute checks - you can see the transmitter and battery holders for it taped to the Styrofoam.

The transmitter in its final position:

Note the coil of yellow wire. That serves as a rudimentary "ground" for the antenna's signal to push off of. I wasn't very clear on my instructions on how to make it. I meant that it should be a huge coil wrapped around the entire payload (as large as it can be), which would have probably produced a better signal, but since I was able to capture the signal during the whole flight it turned out to be a non-issue.

The antenna can be seen dropping down as a yellow wire beneath the payload. (arrow)

Launch! Look how fast that balloon is rising!

It's out of our hands now. When I got the text message that it launched, I held my breath. I was skeptical that the transmitter would even work!

One of the students listening to my transmitter with QRSS VD software (score!)

Video capture from an on-board camera was also attempted (900MHz), but from what I hear it didn't function well for very long.

6/15/2010 - IMPROVED BUILD

Here you can see me (center arrow) showing the students how to receive the Morse code signal sent from the small transmitter (left arrow) using a laptop running QRSS VD (my software) analyzing audio from and an Icom706 mkII radio receiver attached to a dipole (right arrow).

I amped-up the output of the oscillator using an octal buffer chip (74HC240) with some decent results. I'm pleased! It's not perfect (it's noisy as heck) but it should be functional for a 2 hour flight.

Closeup of the transmitter showing the oscillator at 29.4912 MHz, the Atmel ATTiny44a AVR microcontroller (left chip), octal buffer 74HC240 (right chip), and some status lights which blink as the code is executed.

This is my desk where I work from home. Note the styrofoam box in the background - that's where my low-power transmitter lives (the one that's spotted around the world). All I needed to build this device was a soldering iron.

Although I had a radio, it is not capable of receiving 29MHz so I was unable to test the transmitter from home. I had to take it to the university to assess its transmitting capabilities.

I connected the leads to the output of the transmitter, shorted by a 39ohm resistor. By measuring the peak-to-peak voltage of the signal going into a resistor, we can measure its power.

Here's the test setup. The transmitter is on the blue pad on the right, and the waveform can be seen on the oscilloscope on the upper left.

With the amplifier off, the output power is just that of the oscillator. Although the wave should look like a sine wave, it's noisy, and simply does not. While this is unacceptable if our goal is a clean radio signal with maximum efficiency, this is good enough to be heard at our target frequency. The PPV (peak-to-peak voltage) as seen on the screen is about 100mV. Since I'm using a x10 probe, this value should be multiplied by 10 = 1V. 1V PPV into 39 ohms is about 3 milliwatts! ((1/(2*2^.5))^2/39*1000=3.2). For the math, see this post

With the amplifier, the output is much more powerful. At 600mV peak-to-peak with a 10x probe (actually 6V peak-to-peak, expected because that's the voltage of the 4xAAA battery supply we're using) into 39 ohms we get 115 millivolts! (6/(2*2^.5))^2/39*1000=115.38.

Notes about power: First of all, the actual power output isn't 115mW. The reason is that the math equations I used work only for pure sine waves. Since our transmitter has multiple waves in it, less than that power is going to produce our primary signal. It's possible that only 50mW are going to our 29MHz signal, so the power output assessment is somewhat qualitative. Something significant however is the difference between the measured power with and without the amplifier. The 6x increase in peak-to-peak voltage results in a 36x (6^2) increase in power, which is very beneficial. I'm glad I added this amplifier! A 36 times increase in power will certainly help.

6/14/2010 - THE BUILD

Last week I spoke with a student in the UF aerospace engineering department who told me he was working with a group of high school students to add a payload to a high-altitude balloon being launched at (and tracked by) NASA. We tossed around a few ideas about what to put on it, and we decided it was worth a try to add a transmitter. I'll slowly add to this post as the project unfolds, but with only 2 days to prepare (wow!) I picked a simplistic design which should be extremely easy to understand by everyone. Here's the schematic:

The code is as simple as it gets. It sends some Morse code ("go gators"), then a long tone (about 15 seconds) which I hope can be measured QRSS style. I commented virtually every line so it should be easy to understand how the program works.

#include <avr/io.h>
#include <util/delay.h>

char call[] = {2, 2, 1, 0, 2, 2, 2, 0, 0, 2, 2, 1, 0, 1, 2, 0, 2, 0, 2, 2, 2, 0, 1, 2, 1, 0, 1, 1, 1, 0, 0};
// 0 for space, 1 for dit, 2 for dah

void sleep()
{
    _delay_ms(100);      // sleep for a while
    PORTA ^= (1 << PA1); // "flip" the state of the TICK light
}

void ON()
{
    PORTB = 255;          // turn on transmitter
    PORTA |= (1 << PA3);  // turn on the ON light
    PORTA &= ~(1 << PA2); // turn off the ON light
}

void OFF()
{
    PORTB = 0;            // turn off transmitter
    PORTA |= (1 << PA2);  // turn on the OFF light
    PORTA &= ~(1 << PA3); // turn off the OFF light
}

void ID()
{
    for (char i = 0; i < sizeof(call); i++)
    {
        if (call[i] == 0)
        {
            OFF();
        } // space
        if (call[i] == 1)
        {
            ON();
        } // dot
        if (call[i] == 2)
        {
            ON();
            sleep();
            sleep();
        } // dash
        sleep();
        OFF();
        sleep();
        sleep(); // between letters
    }
}

void tone()
{
    ON(); // turn on the transmitter
    for (char i = 0; i < 200; i++)
    { // do this a lot of times
        sleep();
    }
    OFF();
    sleep();
    sleep();
    sleep(); // a little pause
}

int main(void) // PROGRAM STARTS HERE
{
    DDRB = 255; // set all of port B to output
    DDRA = 255; // set all of port A to output
    PORTA = 1;  // turn on POWER light

    while (1)
    {           // loop forever
        ID();   // send morse code ID
        tone(); // send a long beep
    }
}

I'm now wondering if I should further amplify this signal's output power. Perhaps a 74HC240 can handle 9V? ... or maybe it would be better to use 4 AAA batteries in series to give me about 6V. [ponders] this is the schematic I'm thinking of building.

UPDATE: This story was featured on Hack-A-Day! Way to go everyone!

Markdown source code last modified on January 18th, 2021
---
title: High Altitude Balloon Transmitter
date: 2010-07-14 08:05:46
tags: qrss, amateur radio, old
---

# High Altitude Balloon Transmitter

<blockquote class="wp-block-quote"><p><b>SUMMARY:</b> A small group of high school students taking an AP class for college credit launched a high-altitude weather balloon with a small payload. In addition to a video transmitter and GPS transmitter, they decided to include a simple transmitter built from scratch. This is the story of the project, with emphasis on the simple transmitter's design, construction, implementation, and reception (which surprised me, being detected ~200 miles away and lasting the entire duration of the flight!) [<a href="http://www.SWHarden.com/blog/images/beeps.ogg">sample.ogg</a>]</p></blockquote>

# 6/16/2010 - TRACKING

__I'm impressed __ how well the transmitter/receiver worked! For only a few milliwatts, I was able to track that thing all the way from takeoff to landing in Gainesville, FL a few hundred miles away.

<div class="text-center img-border">

[![](balloon_track_thumb.jpg)](balloon_track.jpg)

</div>

__ANALYSIS:__ the text on the image describes most if it, but one of the most interesting features is the "multipathing" during the final moments of the descent, where the single carrier signal splits into two. I believe this is due to two Doppler shifts: (1) as the distance between the falling transmitter and the receiver is decreasing, producing a slight in increase in frequency, and (2) a signal reflected off of a layer of the atmosphere above the craft (the ionosphere?) before it gets to the receiver, the distance of which is increasing as the craft falls, producing a decrease in frequency. I'll bet I can mathematically work backwards and determine how high the craft was, how fast it was falling, and/or how high the layer of the reflecting material is - but that's more work than this dental student is prepared to do before his morning coffee!

__HERE IS SOME AUDIO__ of some of the strongest signals I received. Pretty good for a few milliwatts a hundred miles away! \[[beeps.ogg](http://www.SWHarden.com/blog/images/beeps.ogg)\]

# 6/16/2010 - THE FLIGHT

![](https://www.youtube.com/embed/qjLrytsDPjw)

The design team:

<div class="text-center img-border">

[![](DSC_7127_thumb.jpg)](DSC_7127.jpg)

</div>

<strong>Walking the balloon</strong> to its launch destination at NASA with an awesome rocket (Saturn 1B - identified by Lee, KU4OS) in the background.

<div class="text-center img-border">

[![](DSC_7210_thumb.jpg)](DSC_7210.jpg)

</div>

<strong>The team</strong> again, getting ready for launch. I've been informed that the reason their hands are up is to prevent the balloon from tilting over too much. I'd imagine that a brush with a grass blade could be bad news for the project!

<div class="text-center img-border">

[![](DSC_7232_thumb.jpg)](DSC_7232.jpg)

</div>

<strong>Last minute checks</strong> - you can see the transmitter and battery holders for it taped to the Styrofoam. 

<div class="text-center img-border">

[![](DSC_7248_thumb.jpg)](DSC_7248.jpg)

</div>

The transmitter in its final position:

<div class="text-center img-border">

[![](DSC_7250_thumb.jpg)](DSC_7250.jpg)

</div>

Note the coil of yellow wire. That serves as a rudimentary "ground" for the antenna's signal to push off of. I wasn't very clear on my instructions on how to make it. I meant that it should be a huge coil wrapped around the entire payload (as large as it can be), which would have probably produced a better signal, but since I was able to capture the signal during the whole flight it turned out to be a non-issue.

<strong>The antenna</strong> can be seen dropping down as a yellow wire beneath the payload. (arrow)

<div class="text-center img-border">

[![](DSC_7253_thumb.jpg)](DSC_7253.jpg)

[![](DSC_7279_thumb.jpg)](DSC_7279.jpg)

</div>

<strong>Launch!</strong> Look how fast that balloon is rising!

<div class="text-center img-border">

[![](DSC_7294_thumb.jpg)](DSC_7294.jpg)

</div>

<strong>It's out of our hands</strong> now. When I got the text message that it launched, I held my breath. I was skeptical that the transmitter would even work!  

<div class="text-center img-border">

[![](DSC_7297_thumb.jpg)](DSC_7297.jpg)

</div>

<strong>One of the students</strong> listening to my transmitter with QRSS VD software (score!)

<div class="text-center img-border">

[![](DSC_7365_thumb.jpg)](DSC_7365.jpg)

</div>

<strong>Video capture</strong> from an on-board camera was also attempted (900MHz), but from what I hear it didn't function well for very long.

<div class="text-center img-border">

[![](DSC_7334_thumb.jpg)](DSC_7334.jpg)

</div>

# 6/15/2010 - IMPROVED BUILD

__Here you can see me__ (center arrow) showing the students how to receive the Morse code signal sent from the small transmitter (left arrow) using a laptop running [QRSS VD (my software)](http://www.swharden.com/blog/qrss_vd/) analyzing audio from and an Icom706 mkII radio receiver attached to a dipole (right arrow).

<div class="text-center img-border">

[![](DSC_7082_thumb.jpg)](DSC_7082.jpg)
[![](72hc240_qrp_amplifier_thumb.jpg)](72hc240_qrp_amplifier.jpg)

</div>

__I amped-up the output of the oscillator__ using an octal buffer chip (74HC240) with some decent results. I'm pleased! It's not perfect (it's noisy as heck) but it should be functional for a 2 hour flight.

<div class="text-center img-border">

[![](01_closeup_thumb.jpg)](01_closeup.jpg)

</div>

Closeup of the transmitter showing the oscillator at 29.4912 MHz, the Atmel ATTiny44a AVR microcontroller (left chip), octal buffer 74HC240 (right chip), and some status lights which blink as the code is executed.

<div class="text-center img-border">

[![](02_workstation_thumb.jpg)](02_workstation.jpg)

</div>

__This is my desk__ where I work from home. Note the styrofoam box in the background - that's where my low-power transmitter lives (the one that's spotted around the world). All I needed to build this device was a soldering iron.

<div class="text-center img-border">

[![](03_room_thumb.jpg)](03_room.jpg)

</div>

__Although I had a radio,__ it is not capable of receiving 29MHz so I was unable to test the transmitter from home. I had to take it to the university to assess its transmitting capabilities.

__I connected the leads to the output of the transmitter, shorted by a 39ohm resistor.__ By measuring the peak-to-peak voltage of the signal going into a resistor, we can measure its power.

__Here's the test setup.__ The transmitter is on the blue pad on the right, and the waveform can be seen on the oscilloscope on the upper left.

<div class="text-center img-border">

[![](06_scope_thumb.jpg)](06_scope.jpg)

</div>

__With the amplifier off__, the output power is just that of the oscillator. Although the wave should look like a sine wave, it's noisy, and simply does not. While this is unacceptable if our goal is a clean radio signal with maximum efficiency, this is good enough to be heard at our target frequency. The PPV (peak-to-peak voltage) as seen on the screen is about 100mV. Since I'm using a x10 probe, this value should be multiplied by 10 = 1V. 1V PPV into 39 ohms is about __3 milliwatts!__ ((1/(2\*2^.5))^2/39\*1000=3.2). For the math, see [this post](http://www.swharden.com/blog/2010-05-28-measuring-qrp-radio-output-power-with-an-oscilliscope/)

__With the amplifier,__ the output is much more powerful. At 600mV peak-to-peak with a 10x probe (actually 6V peak-to-peak, expected because that's the voltage of the 4xAAA battery supply we're using) into 39 ohms we get __115 millivolts!__ (6/(2\*2^.5))^2/39\*1000=115.38.

__Notes about power:__ First of all, the actual power output isn't 115mW. The reason is that the math equations I used work only for pure sine waves. Since our transmitter has multiple waves in it, less than that power is going to produce our primary signal. It's possible that only 50mW are going to our 29MHz signal, so the power output assessment is somewhat qualitative. Something significant however is the difference between the measured power with and without the amplifier. The 6x increase in peak-to-peak voltage results in a 36x (6^2) increase in power, which is very beneficial. I'm glad I added this amplifier! A 36 times increase in power will certainly help.

<div class="text-center img-border">

[![](balloon_transmitter_final_thumb.jpg)](balloon_transmitter_final.png)

</div>

# 6/14/2010 - THE BUILD

__Last week I spoke with a student in the UF aerospace engineering department who told me he was working with a group of high school students to add a payload to a high-altitude balloon being launched at (and tracked by) NASA.__ We tossed around a few ideas about what to put on it, and we decided it was worth a try to add a transmitter. I'll slowly add to this post as the project unfolds, but with only 2 days to prepare (wow!) I picked a simplistic design which should be extremely easy to understand by everyone. Here's the schematic:

<div class="text-center img-border">

[![](balloon_transmitter_thumb.jpg)](balloon_transmitter.png)

</div>

__The code is as simple as it gets.__ It sends some Morse code ("go gators"), then a long tone (about 15 seconds) which I hope can be measured QRSS style. I commented virtually every line so it should be easy to understand how the program works.

```c
#include <avr/io.h>
#include <util/delay.h>

char call[] = {2, 2, 1, 0, 2, 2, 2, 0, 0, 2, 2, 1, 0, 1, 2, 0, 2, 0, 2, 2, 2, 0, 1, 2, 1, 0, 1, 1, 1, 0, 0};
// 0 for space, 1 for dit, 2 for dah

void sleep()
{
    _delay_ms(100);      // sleep for a while
    PORTA ^= (1 << PA1); // "flip" the state of the TICK light
}

void ON()
{
    PORTB = 255;          // turn on transmitter
    PORTA |= (1 << PA3);  // turn on the ON light
    PORTA &= ~(1 << PA2); // turn off the ON light
}

void OFF()
{
    PORTB = 0;            // turn off transmitter
    PORTA |= (1 << PA2);  // turn on the OFF light
    PORTA &= ~(1 << PA3); // turn off the OFF light
}

void ID()
{
    for (char i = 0; i < sizeof(call); i++)
    {
        if (call[i] == 0)
        {
            OFF();
        } // space
        if (call[i] == 1)
        {
            ON();
        } // dot
        if (call[i] == 2)
        {
            ON();
            sleep();
            sleep();
        } // dash
        sleep();
        OFF();
        sleep();
        sleep(); // between letters
    }
}

void tone()
{
    ON(); // turn on the transmitter
    for (char i = 0; i < 200; i++)
    { // do this a lot of times
        sleep();
    }
    OFF();
    sleep();
    sleep();
    sleep(); // a little pause
}

int main(void) // PROGRAM STARTS HERE
{
    DDRB = 255; // set all of port B to output
    DDRA = 255; // set all of port A to output
    PORTA = 1;  // turn on POWER light

    while (1)
    {           // loop forever
        ID();   // send morse code ID
        tone(); // send a long beep
    }
}
```

__I'm now wondering if I should further amplify this signal's output power.__ Perhaps a 74HC240 can handle 9V? ... or maybe it would be better to use 4 AAA batteries in series to give me about 6V. \[ponders\] [this](http://www.SWHarden.com/blog/images/balloon_transmitter_amplified.png) is the schematic I'm thinking of building.

**UPDATE:** This story was featured on [Hack-A-Day](http://hackaday.com/2010/07/27/200-mile-rf-transmitter-and-high-altitude-balloon/)! Way to go everyone!

<div class="text-center img-border">

[![](hackaday_swharden_thumb.jpg)](hackaday_swharden.png)

</div>

Pages