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 completely amazed at 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. Here is the data assembled in a special, annotated way!
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 launch:
This is 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)
Awesome photo.
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.
At UF I used an oscilloscope to measure the waveform of the transmitter.
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.
Here’s a closer view.
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.
The final schematic is here:
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!
It’s inexplicable, yet undeniable. I simply can’t code anything useful right now. I’m currently memorized by the idea of writing a truly powerful set of tools for scientific frequency analysis (more than just turning audio into images), and I keep starting over re-coding things from scratch. I develop too much, too quickly, and half way in I get overwhelmed and mentally blocked. I do it to myself. I’ve taken about a week off and will continue to take a few more days off to reset my mind. I’m trying to improve my coding by reading books (e-books) about advanced Python programming. Perhaps when it’s time to return, I’ll write gorgeous and functional code. I always seem to have one or the other, but never both [sigh]
The photo above is the signal of my (AJ4VD) little homemade transmitter in Gainesville, Florida, USA (using a 20-ft piece of wire inside my apartment as an antenna) detected by ON5EX in Belgium. It makes me happy. It reminds me that some of the projects I work on succeed, which gives me motivation to continue pursuing the ones which currently challenge me.
While continuing my quest into the world of linear data analysis and signal processing, I came to a point where I wanted to emphasize variations in FFT traces. While I am keeping my original data for scientific reference, visually I want to represent it emphasizing variations rather than concentrating on trends. I wrote a detrending function which I’m sure will be useful for many applications:
def detrend(data,degree=10):
detrended=[None]*degree
for i in range(degree,len(data)-degree):
chunk=data[i-degree:i+degree]
chunk=sum(chunk)/len(chunk)
detrended.append(data[i]-chunk)
return detrended+[None]*degree
However, this method is extremely slow. I need to think of a way to accomplish this same thing much faster. [ponders]
UPDATE: It looks like I’ve once again re-invented the wheel. All of this has been done already, and FAR more efficiently I might add. Simply:
I’m attempting to thoroughly re-write the data assessment portions of my QRSS VD software, and rather than rushing to code it (like I did last time) I’m working hard on every step trying to optimize the code. I came across some notes I made about Fast Fourier Transformations from the first time I coded the software, and though I’d post some code I found helpful. Of particular satisfaction is an email I received from Alberto, I2PHD, the creator of Argo (the “gold standard” QRSS spectrograph software for Windows). In it he notes:
I think that [it is a mistake to] throw away the imaginary part of the FFT. What I do in Argo, in Spectran, in Winrad, in SDRadio and in all of my other programs is compute the magnitude of the [FFT] signal, then compute the logarithm of it, and only then I do a mapping of the colors on the screen with the result of this last computation.
These concepts are simple to visualize when graphed. Here I’ve written a short Python script to listen to the microphone (which is being fed a 2kHz sine wave), perform the FFT, and graph the real FFT component, imaginary FFT component, and their sum. The output is:
Of particular interest to me is the beautiful complementarity of the two curves. It makes me wonder what types of data can be extracted by the individual curves (or perhaps their difference?) down the road. I wonder if phase measurements would be useful in extracting weak carries from beneath the noise floor?
Here’s the code I used to generate the image above. Note that my microphone device was set to listen to my stereo output, and I generated a 2kHz sine wave using the command speaker-test -t sine -f 2000 on a PC running Linux. I hope you find it useful!
import numpy
import pyaudio
import pylab
import numpy
### RECORD AUDIO FROM MICROPHONE ###
rate=44100
soundcard=1 #CUSTOMIZE THIS!!!
p=pyaudio.PyAudio()
strm=p.open(format=pyaudio.paInt16,channels=1,rate=rate,\
input_device_index=soundcard,input=True)
strm.read(1024) #prime the sound card this way
pcm=numpy.fromstring(strm.read(1024), dtype=numpy.int16)
### DO THE FFT ANALYSIS ###
fft=numpy.fft.fft(pcm)
fftr=10*numpy.log10(abs(fft.real))[:len(pcm)/2]
ffti=10*numpy.log10(abs(fft.imag))[:len(pcm)/2]
fftb=10*numpy.log10(numpy.sqrt(fft.imag**2+fft.real**2))[:len(pcm)/2]
freq=numpy.fft.fftfreq(numpy.arange(len(pcm)).shape[-1])[:len(pcm)/2]
freq=freq*rate/1000 #make the frequency scale
### GRAPH THIS STUFF ###
pylab.subplot(411)
pylab.title("Original Data")
pylab.grid()
pylab.plot(numpy.arange(len(pcm))/float(rate)*1000,pcm,'r-',alpha=1)
pylab.xlabel("Time (milliseconds)")
pylab.ylabel("Amplitude")
pylab.subplot(412)
pylab.title("Real FFT")
pylab.xlabel("Frequency (kHz)")
pylab.ylabel("Power")
pylab.grid()
pylab.plot(freq,fftr,'b-',alpha=1)
pylab.subplot(413)
pylab.title("Imaginary FFT")
pylab.xlabel("Frequency (kHz)")
pylab.ylabel("Power")
pylab.grid()
pylab.plot(freq,ffti,'g-',alpha=1)
pylab.subplot(414)
pylab.title("Real+Imaginary FFT")
pylab.xlabel("Frequency (kHz)")
pylab.ylabel("Power")
pylab.grid()
pylab.plot(freq,fftb,'k-',alpha=1)
pylab.show()
After fighting for a while long with a “shifty baseline” of the FFT, I came to another understanding. Let me first address the problem. Taking the FFT of different regions of the 2kHz wave I got traces with the peak in the identical location, but the “baselines” completely different.
Like many things, I re-invented the wheel. Since I knew the PCM values weren’t changing, the only variable was the starting/stopping point of the linear sample. “Hard edges”, I imagined, must be the problem. I then wrote the following function to shape the PCM audio like a triangle, silencing the edges and sweeping the volume up toward the middle of the sample:
After shaping the data BEFORE I applied the FFT, I made the subsequent traces MUCH more acceptable. Observe:
Now that I’ve done all this experimentation/thinking, I remembered that this is nothing new! Everyone talks about shaping the wave to minimize hard edges before taking the FFT. BAH! Another case of me re-inventing the wheel because I’m too lazy to read others’ work. However, in my defense, I learned a lot by trying all this stuff — far more than I would have learned simply by copying someone else’s code into my script. Experimentation is the key to discovery!
While it may not be perfect, it’s a whole lot better. Below is a capture from this morning of my signal (the waves near the bottom). Compare that to how it was before and you should notice a dramatic improvement! The MEPT is inside a metal box inside a 1-inch-thick Styrofoam box. Very cool!
I completed work on my first RF receiver, and for what it is it seems to work decently. It should be self-explanatory from the photos. It’s based around an SA602. As with everything, I don’t plan on posting schematics until the project is complete because I don’t want people re-creating junky circuits! It’s stationed at the University of Florida’s club station W4DFU and its spectrograph can be viewed in real time from the QRSS VD – Web Grabber – W4DFU page. Back to work!
Now that my minimalist QRSS transmitter is mostly functional, I’m shifting gears toward building a minimalist receiver. These are some early tests, but I’m amazed I managed to hack something together that actually works! Once it’s finished I’ll post schematics. For now, here are some photos. This receiver is based upon an SA602 and although there *IS* an op-amp on the board, I actually bypassed it completely! The SA602 seems to put out enough juice to make my PC microphone jack happy, and those cheap op-amps are noisy anyway, so awesome! Go minimalism!
Here it’s pictured with its power supply:
Here’s a close-up. Remember, the op-amp is there but NOT used!
Here’s the output from 7.040 MHz. Conditions are pretty bad right now, and I’m at my apartment using my crazy indoor antenna [pic1] [pic2]
This minimal Python script will convert a directory filled with tiny image captures such as this into gorgeous montages as seen below! I whipped-up this script tonight because I wanted to assess the regularity of my transmitter’s embarrassing drift. I hope you find it useful.
full-size output:
10x squished output:
Script to assemble a folder of images into a single, large image:
import os
from PIL import Image
x1,y1,x2,y2=[0,0,800,534] #crop from (x,y) 0,0 to 800x534
squish=10 #how much to squish it horizontally
### LOAD LIST OF FILES ###
workwith=[]
for fname in os.listdir('./'):
if ".jpg" in fname and not "assembled" in fname:
workwith.append(fname)
workwith.sort()
### MAKE NEW IMAGE ###
im=Image.new("RGB",(x2*len(workwith),y2))
for i in range(len(workwith)):
print "Loading",workwith[i]
im2=Image.open(workwith[i])
im2=im2.crop((x1,y1,x2,y2))
im.paste(im2,(i*x2,0))
print "saving BIG image"
im.save("assembled.jpg")
print "saving SQUISHED image"
im=im.resize((im.size[0]/10,im.size[1]),Image.ANTIALIAS)
im.save("assembled-squished.jpg")
print "DONE"
Script to download every image linked to from a webpage:
import urllib2
import os
suckFrom="http://w1bw.org/grabber/archive/2010-06-08/"
f=urllib2.urlopen(suckFrom)
s=f.read().split("'")
f.close()
download=[]
for line in s:
if ".jpg" in line and not line in download and not "thumb" in line:
download.append(line)
for url in download:
fname = url.split("/")[-1].replace(":","-")
if fname in os.listdir('./'):
print "I already downloaded",fname
else:
print "downloading",fname
output=open(fname,'wb')
output.write(urllib2.urlopen(url).read())
output.close()
PIMP MY OSCILLOSCOPE! Yeah, see that backlight? I made it. My o-scope’s backlight hasn’t worked since I got it (for $10), so I soldered-up a row of 9 orange LEDs (I had them in a big bag) and hooked them directly up to a 3v wall wart. In retrospect I wish I had a bunch of blue LEDs… but for now I can’t get over how well this worked! Compare it to the images a few posts back – you can really see the grid lines now!
I know this is super-basic stuff for a lot of you all, but I haven’t found a place online which CLEARLY documents this process, so I figured I’d toss-up a no-nonsense post which documents how I calculate the power output (in watts) of my QRP devices (i.e., QRSS MEPT) using an oscilloscope.
This is the circuit I’m trying to measure.
I think I have increased power output because I’m now powering my 74HC240 from this power supply (5v, 200A) rather than USB power (which still powers the microcontroller). Let’s see!
There’s the signal, and I haven’t calibrated the grid squares (this thing shifts wildly) so I have to measure PPV (peak-to-peak voltage) in “squares”. The PPV of this is about 5.3 squares.
I now use a function generator to create square waves at a convenient height. Using the same oscilloscope settings, I noticed that 10v square waves are about 7 squares high. My function generator isn’t extremely accurate as you can see (very fuzzy) but this is a good approximation. I now know that my signal is 5.3/7*10 volts. The rest of the math is pictured here:
140mW – cool! It’s not huge… but it’s pretty good for what it is (a 2-chip transmitter). I’d like to take it up to a full watt… we’ll see how it goes. My 74HC240 is totally mutilated. I accidentally broke off one of the legs, couldn’t solder to it anymore, and thought I destroyed the chip. After getting distraught about a $0.51 component, I ripped ALL the legs off. Later I realized I was running out of these chips, and decided to try to revive it. I used a dremel with an extremely small bit (similar to a quarter-round burr in dentistry) and drilled into the black casing of the microchip just above the metal contacts, allowing me enough surface area for solder to adhere to. I’m amazed it works! Now, to get more milliwatts and perhaps even watts…
It’s so awesome that such a small device can send such a low power signal so far away! Anyhow, the title says it all. Special thanks to G6AVK’s “part time” grabber for capturing this awesome series. That’s a 4356.4 mile trip on USB power! ha!
Yeah, that’s over 4,500 miles away! The following image was captured from ON5EX’s QRSS grabber in Belgium! Amazing. I don’t have the equipment to measure its power output, but it’s running on USB power and I’d assume it’s putting out less than 100mW. Amazingly cool!
That’s over 1,00 miles on a few milliwatts!The transmitter is the ridiculously simple one pictured below. I’m blown away! It was seen on running QRSS VD software! Awesome!!
So I’m sitting in class bored as ever and I’m sketching circuit diagrams and I wondered if I could design a primary simplest-case QRSS transmitter board with drop-in capabilities to change lowpass filters. In other words, I designed a circuit which you can drop in any crystal into and it magically transmits at that frequency, so it would make sense to have a drop-in LPF to match. This is what I came up with… I wonder how realistic this is? It would also give the ability to add different filters (3 pole, 5 pole, or more) without having to re-PCB anything.
With my limited resources I’m attempting to design, test, and build a minimalist QRSS transmitter. While working on the output filter, I’ve done a lot of reading and thinking and have determined that a pi filter (a 3 pole Chebyshev filter) will give me the low-pass characteristics I’m looking for to eliminate harmonics of the QRPP output.
This is the filter (with values and AADE-generated gain plot) I’m shooting for. It has about a 12dB reduction by the time it gets to 14m. My major goal is suppressing harmonics, but I thought I’d be polite to the 20m crew. The filter uses standard 1nF capacitors and an inductor of ~.44uH which according to this chart I can get by 12 turns around a small yellow T37-6 toroid. Although I’d like to use an air coil because of the cost savings, I’ll admit that I understand why toroids are used. That’s the filter, as modeled by AADE, software gracefully recommended to me today by David (VK2/VK6DI).
David also suggested that I not rely on standardized values, but rather measure inductance myself. While an inductance meter is out of my budget (of about $10), I was able to check-out W4DFU’s MFJ antenna analyzer, which can measure inductance. However, my readings were not as expected. In fact, with a total short (center connector directly to ground) it read a very high inductance measurement. Knowing that series inductance can be added to get total inductance, I suspected that this could still be useful. I used a T37-6 toroid I had on hand and wound it from 0-25 times, checking the inductance reading after every turn. After plotting and curve fitting, I corrected each value by subtracting the y-intercept and compared these points with those discussed in this chart and, whew! They’re a good match. To measure inductance with this meter, I have to measure inductance with the straight wire, then subtract this value from the final measurement.
All right, back to work. Dental school homework is due tomorrow [rolls eyes]
update: this is the antenna analyzer I used:
UPDATE 2 I built the proposed filter with wire randomly coiled around an unknown toroid (oh the challenge!), added a 50 ohm (51 ohm, close enough!) resistor as a dummy load, and hooked it up to the SWR analyzer. I noticed a swr minimum around 8mhz… As I unwound loop by loop, I got higher and higher… 9.15, 9.64, and finally BOOM! 10.215mhz swr 1.0. 10.140mhz swr was 1.1. I assume that a low SWR means that the filter passes maximum signal of that frequency into the dummy load, so by “tuning” this filter into a dummy load to minimize SWR by adjusting the coil at a fixed frequency, I maximized gain at that desired frequency. Here’s a photo of the completed circuit. The capacitors are “102″, 0.001uF and the toroid is unknown, but 9 turns seems best.
I found a way to quadruple the output power of my QRSS transmitter without changing its input parameters. Thanks to a bunch of people (most of whom are on the Knights QRSS mailing list) I decided to go with a push-pull configuration using 2 pairs of 4 gates (8 total) of a 74HC240. I’ll post circuit diagrams when I perfect it, but for now check out these waveforms!
First of all, this is the waveform before and after amplification with the 74HC240. I artificially weakened the input signal (top) with a resistor and fed it to the 74HC240. For the rest of the images, the input is 5v p-p and the output is similar, so amplification won’t be observed. The wave I’m starting with is the output of a microcontroller which is non-sinusoidal, but this can be fixed later with lowpass filtering.
Here you can see the test circuit I’m using. It should be self-explanatory.
Here’s the output of the microcontroller compared to the in-phase output of the 74HC240
Here are the two outputs of the 74HC240. 4 of the gates are used to create output in-phase with the input, and the other four are used to create out-of-phase wave. Here are the two side by side. The top is 0 to 5v, the bottom is 0 to -5v, so we have a push-pull thing going on… woo hoo!
The waves, when overlapped, look similar (which I guess is a good thing) with a slight (and I mean VERY slight) offset of the out-of-phase signal. I wonder if this is caused by the delay in the time it takes to trigger the 74HC240 to make the out-of-phase signal? The signal I’m working with is 1MHz.
Okay, that’s it for now. I’m just documenting my progress. 73
Haray! I’m making awesome progress with my QRSS transmitter design. Because my current transmitter (previous few posts) was randomly freezing-up (likely due to the oscillator stopping its oscillating due to being overloaded) so I moved the oscillator from in-chip to an external oscillator. It’s been made small enough to fit in an altoids tin, and I already tested it with the solar panel and it works! Awesome! Here are some photos. Again, when I perfect the design I’ll post final schematics.
Sticking out are wires for power and an antenna on each side. The goal is to hang the device between two trees by its own antenna.
That’s my new chip development board. I made it with what I needed on it. It’s so convenient! It uses 5v of power from the USB port too!
Alltogether I’ve tested the device and confirmed it transmits radio when the solar panel is illuminated. I’m thinking of making it more effective by adding more panels… but that’s it for now!
I’m so excited! This little transmitter I made and programmed to transmit my call sign (AJ4VD) and a picture of a gator got its first spotting tonight! I’m so excited. It was reported by W4HBK in Pensacola, FL. It’s only 300 miles away, but it’s a start! I’m keeping my fingers crossed and maybe someday soon I’ll hear from Europe. Note that I *JUST* got this thing working this afternoon. I’m so excited!
And again, here’s the transmitter in its glorious simplicity:
I re-wrote the code from the previous entry to do several things. Once of which was to make a gator rather than a fish. It’s more appropriate since I’m planning on housing the transmitter at the University of Florida. To do it, I drew a gator in paint and wrote a python script to convert the image into a series of points. I’ll post it later. One thing to note was that size was a SERIOUS issue. I only have two thousand bytes of code, and every point of that gator was a byte, so it was a memory hog. I helped it dramatically by using repeating segments wherever possible, and some creative math to help out the best I could (i.e., the spines on the back) Here’s what it looks like, and the code below it…
#include <avr/io.h>
#include <util/delay.h>
// front top LED - PA0
// inside top LED - PA1
// inside bot LED - PA2
// front bot LED - PA3
unsigned long int t_unit; // units of time
const int tDit = 100; //units for a dit
const int tDah = 255; //units for a dah
char fsk; // degree of frequency shift to use for CW
char fsk2; // degree of frequency shift to use for HELL
char light = 0; // which lights are on/off
void delay(){
_delay_loop_2(t_unit);
}
void blink(){
return;
if (light==0){
PORTA|=(1<<PA0); //on
PORTA|=(1<<PA1); //on
PORTA&=~(1<<PA2); //off
PORTA&=~(1<<PA3); //off
light=1;
} else {
PORTA|=(1<<PA2); //on
PORTA|=(1<<PA3); //on
PORTA&=~(1<<PA0); //off
PORTA&=~(1<<PA1); //off
light=0;
}
}
void tick(unsigned long ticks){
while (ticks>0){
delay();
delay();
ticks--;
}
}
void pwm_init() {
//Output on PA6, OC1A pin (ATTiny44a)
OCR1A = 0x00; //enter the pulse width. We will use 0x00 for now, which is 0 power.
TCCR1A = 0x81; //8-bit, non inverted PWM
TCCR1B = 1; //start PWM
}
void set(int freq, int dly){
OCR1A = freq;
tick(dly);
}
void fish(){
char mult = 3;
char f2[]={2, 3, 4, 5, 6, 7, 4, 3, 7, 4, 7, 7, 6, 5, 4, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 3, 4, 5, 6, 7, 8, 4, 9, 5, 9, 6, 9, 6, 9, 6, 9, 8, 8, 7, 7, 6, 5, 4, 3, 3, 3, 4, 5, 5};
for (int i=0;i<sizeof(f2);i++) {
OCR1A = f2[i]*mult;
blink();
tick(20);
OCR1A = 1*mult;
blink();
tick(20);
}
char f3[]={1,2,3,4,3,2};
char offset=0;
while (offset<9){
for (char j=0;j<3;j++){
for (char i=0;i<sizeof(f3);i++){
char val = (f3[i]+5-offset)*mult;
if (val<mult || val > 10*mult){val=mult;}
OCR1A = val;
blink();
tick(20);
OCR1A = 1*mult;
blink();
tick(20);
}
}
offset++;
}
}
void id(){
char f[]={0,0,1,2,0,1,2,2,2,0,1,1,1,1,2,0,1,1,1,2,0,2,1,1,0,0};
char i=0;
while (i<sizeof(f)) {
blink();
if (f[i]==0){OCR1A = 0;tick(tDah);}
if (f[i]==1){OCR1A = fsk;tick(tDit);}
if (f[i]==2){OCR1A = fsk;tick(tDah);}
blink();
OCR1A=0;
tick(tDit);
i++;
}
}
void slope(){
char i=0;
while (i<25){
OCR1A = 255-i;
i++;
}
while (i>0){
i--;
OCR1A = 255-i;
}
}
int main(void)
{
DDRA = 255;
blink();
pwm_init();
t_unit=1000;fsk=10;id(); // set to fast and ID once
//fsk=50;//t_unit = 65536; // set to slow for QRSS
t_unit=60000;
while(1){;
fish();
id();
}
return 1;
}