Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

This page documents the progress of my MEPT (manned experimental propagation transmitter) endeavors. If you have questions, feel free to E-mail me! My contact information can be found by clicking the link on the right navigation menu.

The Soup-Can Transmitter

The Signal

The Spots

Florida – 288.3 miles away (W4HBK) May 22, 2010

Massachusetts – 1,075.5 miles away (W1BW) May 27, 2010

Belgium – 4,496.3 miles away (ON5EX) May 27, 2010

Germany- 4,869.2 miles away (DL4MGM) May 28, 2010

Essex – 4,356.4 miles away (G6AVK) May 28, 2010

New Zealand – 8,077.6 miles away (ZL2IK) May 29, 2010





Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

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;
}




Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

Finally! After a few years tumbling around in my head, a few months of reading-up on the subject, a few weeks of coding, a few days of bread-boarding, a few hours of building, a few minutes of soldering, and a few seconds of testing I’ve finally done it – I’ve created my first QRSS transmitter! I’ll describe it in more detail once I finalize the design, but for now an awesome working model. It’s all digital, consisting of 2 ICs (an ATTiny44a for the PWM-controlled frequency modulation, and an octal buffer for the pre-amplifier) followed by a simple pi low-pass filter.

My desk is a little messy. I’m hard at work! Actually, I’m thinking of building another desk. I love the glass because I don’t have to worry (as much) about fires. That sounds scary, I know.

This is the transmitter. The box is mostly empty space, but it consists of the circuit, an antenna connection, a variable capacitor for center frequency tuning, and a potentiometer for setting the degree of frequency shift modulation.

Yeah, that’s a fishy. Specifically a goldfish (the cracker). It’s made with a single tone, shifting rapidly (0.5 sec) between tones. So cool. Anyway, I’m outta here for now – getting back to the code! I think I’ll try to make a gator next…

Here’s the code that makes the fish. It sends my ID quickly, some fish, then my ID in QRSS speed using PWM.

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

const int tDit = 270/3;
const int tDah = 270;

char fsk;
unsigned long int t_unit;

void delay(){
	_delay_loop_2(t_unit);
	}

void blink(){
  	PORTA^=(1<<0);
  	PORTA^=(1<<1);
  	PORTA^=(1<<2);
  	PORTA^=(1<<3);
}

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 f[]={0,0,0,4,5,3,6,2,7,1,5,6,8,1,8,1,8,1,8,1,8,2,7,3,6,2,7,1,8,1,8,4,5,2,3,6,7,0,0,0};
	char i=0;
	while (i<sizeof(f)) {
		i++;
		OCR1A = 255-f[i]*15;
		blink();
		tick(20);
		}
}

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 = 255;tick(tDah);}
		if (f[i]==1){OCR1A = 255-fsk;tick(tDit);}
		if (f[i]==2){OCR1A = 255-fsk;tick(tDah);}
		blink();
		OCR1A = 255;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;
  	PORTA^=(1<<0);
  	PORTA^=(1<<1);
	pwm_init();

	t_unit=2300;fsk=50;id(); // set to fast and ID once

	fsk=50;t_unit = 65536; // set to slow for QRSS

	while(1){
		id();
		for (char i=0;i<3;i++){
			fish();
			}
	}

	return 1;
}




Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

My microcontroller-powered prime number calculator is complete! Although I’m planning on improving the software (better menus, the addition of sound, and implementation of a more efficient algorithm) and hardware (a better enclosure would be nice, battery/DC wall power, and a few LEDs on the bottom row are incorrectly wired), this device is currently functional therefore I met my goal!

This device generates large prime numbers (v) while keeping track of how many prime numbers have been identified (N). For example, the 5th prime number is 11. Therefore, at one time this device displayed N=5 and V=11. N and V are displayed on the LCD. In the photo the numbers mean the 16,521,486th prime is 305,257,039 (see for yourself!). The LCD had some history. In December, 2003 (6 years ago) I worked with this SAME display, and I even located the blog entry on November 25’th, 2003 where I mentioned I was thinking of buying the LCD (it was $19 at the time). Funny stuff. Okay, fast forward to today. Primes (Ns and Vs) are displayed on the LCD.

In addition to the LCD, numbers are displayed in binary: Each row of LEDs represents a number. Each row of 30 LEDs allows me to represent numbers up to 2^31-1 (2,147,483,647, about 2.15 billion) in the binary numeral system. Since there’s no algorithm to simply generate prime numbers (especially the Nth prime), the only way to generate large Nth primes is to start small (2) and work up (to 2 billion) testing every number along the way for primeness. The number being tested is displayed on the middle row (Ntest). The last two digits of Ntest are shown on the top left. To test a number (Ntest) for primeness, it is divided by every number from 2 to the square root of Ntest. If any divisor divides evenly (with a remainder of zero) it’s assumed not to be prime, and Ntest is incremented. If it can’t be evenly divided by any number, it’s assumed to be prime and loaded into the top row. In the photo (with the last prime found over 305 million) the device is generating new primes every ~10 seconds.

I’d like to emphasize that this device is not so much technologically innovative as it is creative in its oddness and uniqueness. I made it because no one’s ever made one before. It’s not realistic, practical, or particularly useful. It’s just unique. The brain behind it is an ATMEL ATMega8 AVR microcontroller (What is a microcontroller?), the big 28-pin microchip near the center of the board. (Note: I usually work with ATTiny2313 chips, but for this project I went with the ATMega8 in case I wanted to do analog-to-digital conversions. The fact that the ATMega8 is the heart of the Arduino is coincidental, as I’m not a fan of Arduino for purposes I won’t go into here).

I’d like to thank my grandmother’s brother and his wife (my great uncle and aunt I guess) for getting me interested in microcontrollers almost 10 years ago when they gave me BASIC Stamp kit (similar to this one) for Christmas. I didn’t fully understand it or grasp its significance at the time, but every few years I broke it out and started working with it, until a few months ago when my working knowledge of circuitry let me plunge way into it. I quickly outgrew it and ventured into directly programming cheaper microcontrollers which were nearly disposable (at $2 a pop, compared to $70 for a BASIC stamp), but that stamp kit was instrumental in my transition from computer programming to microchip programming.

The microcontroller is currently running at 1 MHz, but can be clocked to run faster. The PC I’m writing this entry on is about 2,100 MHz (2.1 GHz) to put it in perspective. This microchip is on par with computers of the 70s that filled up entire rooms. I program it with the C language (a language designed in the 70s with those room-sized computers in mind, perfectly suited for these microchips) and load software onto it through the labeled wires two pictures up. The microcontroller uses my software to bit-bang data through a slew of daisy-chained shift registers (74hc595s, most of the 16-pin microchips), allowing me to control over 100 pin states (on/off) using only 3 pins of the microcontroller. There are also 2 4511-type CMOS chips which convert data from 4 pins (a binary number) into the appropriate signals to illuminate a 7-segment display. Add in a couple switches, buttons, and a speaker, and you’re ready to go!

I’ll post more pictures, videos, and the code behind this device when it’s a little more polished. For now it’s technically complete and functional, and I’m very pleased. I worked on it a little bit every day after work. From its conception on May 27th to completion July 5th (under a month and a half) I learned a heck of a lot, challenged my fine motor skills to complete an impressive and confusing soldering job, and had a lot of fun in the process.

text5130






Bitwise programming techniques (manipulating the 1s and 0s of binary numbers) are simple, but hard to¬† remember if you don’t use them often. Recently I’ve needed to perform a lot of bitwise operations. If I’m storing true/false (1-bit) information in variables, it’s a waste of memory to assign a whole variable to the task (the smallest variable in C is a char, and it contains 8 bits). When cramming multiple values into individual variables, it’s nice to know how to manipulate each bit of a variable.

y = (x >> n) & 1; // stores nth bit of x in y.  y becomes 0 or 1.

x &= ~(1 << n); // forces nth bit of x to be 0.  all other bits left alone.

x &= (1 << (n + 1)) - 1; // leaves lowest n bits of x; all higher bits set to 0.

x |= (1 << n); // forces nth bit of x to be 1.  all other bits left alone.

x ^= (1 << n); // toggles nth bit of x.  all other bits left alone.

x = ~x; // toggles ALL the bits in x.