The personal website of Scott W Harden
August 14th, 2011

High Altitude Balloon Transmitter Prototype

It's been my goal for quite some time to design a simple, easy-to-replicate transmitter for high altitude balloon telemetry transmission. I'm quite satisfied by what I came up with because it's very simple, cheap, easy to code for, and easy to change frequency. I'd say the most common alternative is a handheld amateur radio transmitter which starts around $60, requires an amateur radio license, and typically output 5W of FM on 144MHz (2m) or 440MHz (70cm). Fancier handheld radios are capable of transmitting APRS packets, and use established base station repeaters to listen to these frequencies, decode the packets, and update an internet database about current location information. Although it's quite fancy, elegant, and technical (and expensive), I desire a much simpler, cheaper, disposable option! If my balloon lands in the Atlantic ocean, I don't want to be out $100+ of radio equipment! This alternative is about $7.

Here's my solution. I don't normally build things on perf-board (I prefer sloppy Manhattan construction), but since this might go near the edge of space and be jerked around in turbulent winds, I figured it would be a nice and strong way to assemble it. Anyhow, it uses a can crystal oscillator as the frequency source. These things are pretty cool, because they're very frequency stable, even with changing temperatures.

The can oscillator (28.704MHz, selected to be in a rarely-used region of the 10m amatuer radio allocation which I'm licensed to use, call sign AJ4VD) outputs 5V square waves which I use to drive two successive class C amplifiers. The signal can be shunted to ground between the two stages by a third "control" transistor, which allows micro-controller control over the final amplifier. Although it may have seemed logical to simply supply/cut power from the oscillator to key the transmitter, I decided against it because that can oscillator takes 20ms to stabilize, and I didn't think that was fast enough for some encoding methods I wish to employ!

Although during my tests I power the device from my bench-top power supply (just a few LM3805 and LM3812 regulators in a fancy case), it's designed to be run off 3xAAA batteries (for logic) and a 9V battery (for the transmitter). I could have probably used a regulator to drop the 9V to 5V for the MCU and eliminated some extra weight, but I wonder how low the 9V will dip when I draw a heavy RF load? The 3xAAAs seemed like a sure bet, but quite at the expense of weight. I should consider the regulator option further... [ponders]

There's the device in action while it was in a breadboard. I've since wired it up in a perf board (pictured) and left it to transmit into a small string of wire inside my apartment as an antenna as I went to the UF Gator Amateur Radio Club (a few miles away) and tried to tune into it. It produced a stunningly beautiful signal! I can't wait for its first test on a high altitude balloon! Here it's transmitting CW Morse code the words "scott rocks", separated by appropriate call sign identification every 10 minutes, AJ4VD, my amateur radio license... of course!

Above is what the audio sounded like with a narrow CW filter (awesome, right?), and a 3KHz wide USB configuration. I think this should be more than enough to carry us through a mission, and aid in direction finding of a landed payload!

Notes about filtering: The output of this transmitter is quite harmonic-rich. The oscillator produces square waves for goodness' sake! The class C amplifier smooths a bit of that out, but you still need some low-pass filtering, not shown on the schematic. I think for my purposes a 3-pole Chebyshev filter will suffice, but just keep this in mind in case you replicate my design. You certainly don't want to be transmitting out of band! Below is the output of the transmitter viewed on my scope. It's suspiciously smooth, which leads me to wonder about the accuracy of my scope! I really should get a spectrum analyzer.

Markdown source code last modified on January 18th, 2021
---
title: High Altitude Balloon Transmitter Prototype
date: 2011-08-14 18:42:59
tags: amateur radio, circuit, old
---

# High Altitude Balloon Transmitter Prototype

__It's been my goal for quite some time__ to design a simple, easy-to-replicate transmitter for high altitude balloon telemetry transmission. I'm quite satisfied by what I came up with because it's very simple, cheap, easy to code for, and easy to change frequency.  I'd say the most common alternative is a handheld amateur radio transmitter which starts around $60, requires an amateur radio license, and typically output 5W of FM on 144MHz (2m) or 440MHz (70cm). Fancier handheld radios are capable of transmitting [APRS](http://en.wikipedia.org/wiki/Automatic_Packet_Reporting_System) packets, and use established base station repeaters to listen to these frequencies, decode the packets, and update an internet database about current location information. Although it's quite fancy, elegant, and technical (and expensive), I desire a much simpler, cheaper, disposable option! If my balloon lands in the Atlantic ocean, I don't want to be out $100+ of radio equipment! This alternative is about $7.

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

[![](DSCN1718_thumb.jpg)](DSCN1718.jpg)

</div>

__Here's my solution.__ I don't normally build things on perf-board (I prefer sloppy Manhattan construction), but since this might go near the edge of space and be jerked around in turbulent winds, I figured it would be a nice and strong way to assemble it.  Anyhow, it uses a can crystal oscillator as the frequency source. These things are pretty cool, because they're very frequency stable, even with changing temperatures.

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

[![](DSCN1701_thumb.jpg)](DSCN1701.jpg)

</div>

__The can oscillator (28.704MHz, selected to be in a rarely-used region of the 10m amatuer radio allocation which I'm licensed to use, call sign AJ4VD) outputs 5V square waves which I use to drive two successive class C amplifiers.__ The signal can be shunted to ground between the two stages by a third "control" transistor, which allows micro-controller control over the final amplifier. Although it may have seemed logical to simply supply/cut power from the oscillator to key the transmitter, I decided against it because that can oscillator takes 20ms to stabilize, and I didn't think that was fast enough for some encoding methods I wish to employ!

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

[![](DSCN1717_thumb.jpg)](DSCN1717.jpg)

</div>

__Although during my tests I power the device from my bench-top power supply__ (just a few LM3805 and LM3812 regulators in a fancy case), it's designed to be run off 3xAAA batteries (for logic) and a 9V battery (for the transmitter). I could have probably used a regulator to drop the 9V to 5V for the MCU and eliminated some extra weight, but I wonder how low the 9V will dip when I draw a heavy RF load? The 3xAAAs seemed like a sure bet, but quite at the expense of weight. I should consider the regulator option further... [ponders]

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

__There's the device in action while it was in a breadboard.__ I've since wired it up in a perf board (pictured) and left it to transmit into a small string of wire inside my apartment as an antenna as I went to the UF Gator Amateur Radio Club (a few miles away) and tried to tune into it. It produced a stunningly beautiful signal! I can't wait for its first test on a high altitude balloon!  Here it's transmitting CW Morse code the words "scott rocks", separated by appropriate call sign identification every 10 minutes, AJ4VD, my amateur radio license... of course!

* [cw.mp3](http://www.SWHarden.com/blog/images/cw.mp3)

* [usb.mp3](http://www.SWHarden.com/blog/images/usb.mp3)

__Above is what the audio sounded like__ with a narrow CW filter (awesome, right?), and a 3KHz wide USB configuration. I think this should be more than enough to carry us through a mission, and aid in direction finding of a landed payload!

__Notes about filtering:__ The output of this transmitter is quite harmonic-rich. The oscillator produces square waves for goodness' sake! The class C amplifier smooths a bit of that out, but you still need some low-pass filtering, not shown on the schematic. I think for my purposes a 3-pole [Chebyshev filter](http://en.wikipedia.org/wiki/Chebyshev_filter) will suffice, but just keep this in mind in case you replicate my design. You certainly don't want to be transmitting out of band! Below is the output of the transmitter viewed on my scope. It's suspiciously smooth, which leads me to wonder about the accuracy of my scope! I really should get a spectrum analyzer.

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

[![](DSCN1707_thumb.jpg)](DSCN1707.jpg)

</div>
August 6th, 2011

Ridiculously Simple AVR AM Radio Transmitter

I was brainstorming some RF circuits today and I had the desire to create a rapid transmitter/receiver pair that anyone would have around their house. I decided that AM or FM radio would be good since everyone can receive that, and pondered how best to generate the necessary radio signal and modulate it appropriately. After a few LC oscillator designs, I thought about the RC oscillators built into most micro-controllers. I grabbed an ATMEL AVR I had on hand (an ATTiny44A) and checked the datasheet. It had an 8MHz RC oscillator, which could be divided-down to 1MHz, and output on a CKOUT pin - all configurable with a few hardware fuses! Note that commercial AM radio stations are between 0.52 and 1.61 MHz, so a 1MHz signal would be smack-dab in the middle of our radio dial! I had to build a prototype to see how well it would work. Once concern was that the RC oscillator wouldn't be stable enough to produce reliable audio - boy was I wrong!

__The circuitry is textbook simple.__ Appropriately configured, the AVR generates 5V square waves from its CKOUT pin. Although a pretty shape, they're not powerful enough on their own to be heard across a room, so I needed an amplifier stage. A class C amplifier provided by a 2n7000 is commonly done in the low power amateur radio (QRP) community, so I went with it. A 2n7000 N-channel MOSFET with a 220-ohm resistor on the drain and the CKOUT directly into the gate did a fine job (I've used this design for 10MHz QRSS transmitters before), and I was able to modulate its amplitude by feeding the voltage from a MCU pin (turned on/off rapidly) through a decoupling capacitor into the drain of the MOSFET. I couldn't have asked for a simpler result!

This code sends a message in Morse code. It seems too easy! Applications are endless, as this is one heck of an easy way to send audio from a micro-controller to a radio, and possibly to a computer. Morse code is easy, and since we have the ability to dynamically generate different audio frequencies and tones, data exchange is easy too! Nothing's stopping you from adding the code to turn this into a RTTY (or Hellschreiber?) transmitter.

Again, this transmitter can be heard on a standard AM radio tuned to about 1000 kHz. This is the setup I used with great success:

Here's the code on the chip! Nothing complicated:


// designed for and tested with ATTiny44A
#include <avr/io.h>
#define F_CPU 1000000UL
#include <avr/delay.h>
#include <avr/interrupt.h>

void beep(){
    for(char i=50;i;i--){
        DDRA|=_BV(PA7);_delay_ms(1);
        DDRA&=~_BV(PA7);_delay_ms(1);
    }
}

void rest(){_delay_ms(100);}

void dot(){beep();rest();}
void dash(){beep();beep();beep();rest();}
void space(){rest();rest();}
void space2(){space();space();}

int main(){
    DDRA|=_BV(PA7);
    for(;;){
        dot();dot();dot();space();             // S
        dash();dot();dash();dot();space();     // C
        dash();dash();dash();space();          // O
        dash();space();                        // T
        dash();space();                        // T
        space2();
        dot();dash();dot();space();            // R
        dash();dash();dash();space();          // O
        dash();dot();dash();dot();space();     // C
        dash();dot();dash();space();           // K
        dot();dot();dot();space();             // S
        _delay_ms(1000); // silence
    }
    return 0;
}

THIS IS ILLEGAL to do if you exceed a certain amount of power because you're stepping on legitimate commercial broadcasters and will have to deal with the FCC. Additionally, you are transmitting on more frequencies than the primary frequency because the signal is heavy in odd harmonics. This means a 1 MHz transmitter, producing square waves, will generate tones on 1, 3, 5, 7 MHz, etc. Don't do this with much power! Heck, you probably shouldn't do it at all ;-)

Markdown source code last modified on January 18th, 2021
---
title: Ridiculously Simple AVR AM Radio Transmitter
date: 2011-08-06 19:32:44
tags: amateur radio, circuit, old
---

# Ridiculously Simple AVR AM Radio Transmitter

__I was brainstorming some RF circuits today__ and I had the desire to create a rapid transmitter/receiver pair that anyone would have around their house. I decided that AM or FM radio would be good since everyone can receive that, and pondered how best to generate the necessary radio signal and modulate it appropriately.  After a few LC oscillator designs, I thought about the RC oscillators built into most micro-controllers. I grabbed an ATMEL AVR I had on hand (an ATTiny44A) and checked the datasheet. It had an 8MHz RC oscillator, which could be divided-down to 1MHz, and output on a CKOUT pin - all configurable with a few hardware fuses! Note that commercial AM radio stations are between 0.52 and 1.61 MHz, so a 1MHz signal would be smack-dab in the middle of our radio dial! I had to build a prototype to see how well it would work. Once concern was that the RC  oscillator wouldn't be stable enough to produce reliable audio - boy was I wrong!

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

[![](schem_thumb.jpg)](schem.jpg)

</div>
__The circuitry is textbook simple.__ Appropriately configured, the AVR generates 5V square waves from its CKOUT pin. Although a pretty shape, they're not powerful enough on their own to be heard across a room, so I needed an amplifier stage. A class C amplifier provided by a 2n7000 is commonly done in the low power amateur radio (QRP) community, so I went with it. A 2n7000 N-channel MOSFET with a 220-ohm resistor on the drain and the CKOUT directly into the gate did a fine job (I've used this design for 10MHz QRSS transmitters before), and I was able to modulate its amplitude by feeding the voltage from a MCU pin (turned on/off rapidly) through a decoupling capacitor into the drain of the MOSFET. I couldn't have asked for a simpler result!

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

__This code sends a message in Morse code.__ It seems too easy!  Applications are endless, as this is one heck of an easy way to send audio from a micro-controller to a radio, and possibly to a computer. Morse code is easy, and since we have the ability to dynamically generate different audio frequencies and tones, data exchange is easy too!  Nothing's stopping you from adding the code to turn this into a RTTY (or [Hellschreiber?](http://www.swharden.com/blog/2011-08-05-i-before-e-except-after-hellschreiber/)) transmitter.


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

[![](DSCN1670_thumb.jpg)](DSCN1670.jpg)

</div>

__Again, this transmitter can be heard on a standard AM radio tuned to about 1000 kHz.__ This is the setup I used with great success:

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

[![](schem2_thumb.jpg)](schem2.jpg)

</div>

__Here's the code on the chip!__ Nothing complicated:

```c

// designed for and tested with ATTiny44A
#include <avr/io.h>
#define F_CPU 1000000UL
#include <avr/delay.h>
#include <avr/interrupt.h>

void beep(){
    for(char i=50;i;i--){
        DDRA|=_BV(PA7);_delay_ms(1);
        DDRA&=~_BV(PA7);_delay_ms(1);
    }
}

void rest(){_delay_ms(100);}

void dot(){beep();rest();}
void dash(){beep();beep();beep();rest();}
void space(){rest();rest();}
void space2(){space();space();}

int main(){
    DDRA|=_BV(PA7);
    for(;;){
        dot();dot();dot();space();             // S
        dash();dot();dash();dot();space();     // C
        dash();dash();dash();space();          // O
        dash();space();                        // T
        dash();space();                        // T
        space2();
        dot();dash();dot();space();            // R
        dash();dash();dash();space();          // O
        dash();dot();dash();dot();space();     // C
        dash();dot();dash();space();           // K
        dot();dot();dot();space();             // S
        _delay_ms(1000); // silence
    }
    return 0;
}
```

___THIS IS ILLEGAL__ to do if you exceed a certain amount of power because you're stepping on legitimate commercial broadcasters and will have to deal with the FCC. Additionally, you are transmitting on more frequencies than the primary frequency because the signal is heavy in odd harmonics. This means a 1 MHz transmitter, producing square waves, will generate tones on 1, 3, 5, 7 MHz, etc. Don't do this with much power! Heck, you probably shouldn't do it at all ;-)_
August 5th, 2011

I before E except after Hellschreiber

This post describes a project I designed which transmits strings of data from a microcontroller to a PC's screen using audio beeping in a special mode called Hellschreiber. Although these days it's almost exclusively used by amateur radio operators, I thought it would make a cool microcontroller project! The result can be accomplished with a microcontroller and a speaker as a transmitter and a PC with a microphone as a receiver and decoder, or with actual radio equipment (even toy walkie talkies) by transmitting the tones over modulated radio frequencies for long distance communication! Ideas anyone?

SPECIAL THANKS: I'd like to think Mike Seese for his brainstorming help in making this project a reality. Mike and I are working on a high altitude balloon project together, and a creative inexpensive radio link is one of our goals. Thanks Mike!

As a professional dental student by day and amateur electrical/RF engineer by night, I'm having a very strange summer. I'm developing rapidly in my experience and skills in both arenas. I finally feel like I have a working knowledge of most fundamental electrical and radio frequency concepts, and I'm starting to see patients and do procedures on humans (no more mannequins) in the student dental clinic. For legal and ethical reasons I do not write specifics about what I do with my patients, but I certainly make up for it by documenting the electronic projects I work on! My goals of doing this are to (a) inspire potential electronics tinkerers to come up with new ideas and attack new projects, and (b) receive feedback and insight from those more experienced than me to help me grow in my knowledge. My eye caught a comment a few posts ago that made me smile: You have been blessed with talent and the drive to attempt things not been tried before, keep it up, great job. --David S While I can't claim that everything I do is truly novel or never tried before, I appreciate the encouraging words. Thank you David S!

Today's project is a fun one involving vintage wartime radio equipment, amateur radio computer software, and a healthy dose of microcontrollers! My goal is to design a single chip Hellschreiber (technically Feldhellschreiber) transmitter. "Hellschreiber" translates into English as "Light Writer" and is a pun on the name of its inventor, Rudolf Hell, who built the first device in 1920. It was intended to allow messages to be transferred over poor radio links too noisy for intelligible voice or radioteletype (RTTY) communication. Its cool factor is upped by the fact that it was sometimes used by the German military in conjunction with the Enigma encryption system during World War 2! [As an aside, RTTY is still pretty sweet and dates back to the mid 1800s! Check out hardware receivers in video 1 and video 2]

Seeing a battlefield-ready Hellschreiber receiver gives you a good idea of how it works. (The video isn't mine, I found it on youtube.) The concept is relatively simple (shown above), and the receiver has only 2 moving parts. A spinning corkscrew presses a ticker tape into ink when it receives a radio signal. As the radio signal beeps on and off, the corkscrew contacts at different positions at different times, and letters are written on the ticker tape!

The designers of these things were extraordinarily creative! The picture on the right shows a Hellschreiber transmitter - basically a typewriter with mechanical wizardry that turns key presses into a series of radio tones corresponding to the pixelated shape of a character.

Almost a century later, people are still sending messages around the world using Hellschreiber! With an amateur radio license and an amateur radio transceiver you can tune around special Hellschreiber calling frequencies and engage in conversations with other people who enjoy using this unique mode. Computers have modernized the process, allowing you to send Hellschreiber text by typing on your keyboard and receive it by just looking at your screen. My favorite program (free) to do this is Digital Master 780, part of Ham Radio Deluxe.

This is the project I just completed. It takes strings of text stored (or dynamically generated) in an array on a microcontroller (I'm using an ATMega48, but the code is almost identical for any ATMEL AVR microcontroller, and easy adapted for other architectures) and turns it into an audio tone using PWM. This audio tone could be fed into a speaker and a microphone across the room could receive it and use the software to show the received data, or the audio could be fed into a radio transmitter and a PC hooked to the receiver could decode the audio. Either way, the text in the microcontroller is converted to Hellschreiber audio tones ready to be used however you see fit! Although I designed it as a resilient way to transmit GPS/altitude data from a high altitude balloon using a small, cheap, low-power radio transmitter, this project is just the foundation of a plethora of potential projects!

Here's the circuit I'm using. It's actually less complicated than shown - all those yellow wires are going to my AVR programmer! The chip just receives +5V and GND, and the audio is generated automatically and output on the OC0A pin, which happens to be pin 12 on my ATMega48. The output (audio level square waves) is fed to a crystal oscillator like this one, which generates square waves with an amplitude equal that to the input. Thus, by audio-frequency AC from the microchip, decoupled through a series capacitor, added to the power supply of the oscillator (provided by the 5V rail through a 1.8k resistor), we effectively produce an amplitude modulated (AM) radio signal!

This is the receiver I'm using. I'm lucky enough to have an all-mode, general-coverage, 100W amateur radio transceiver! It's a Yaesu 857-D and I'm completely in love with it. It's quite pricey though! You can find wide coverage receive-only radios called radio scanners (or police scanners), often for $20 or so on eBay which would do just as good a job of receiving all sorts of radio signals! Whatever you use, after tuning into the audio with the ham radio delux software, you'll be able to decode Hellschreiber like this:

A few notes about the code: Each letter is sent twice vertically and I don't think I should have done that. It's easy enough to correct by eliminating the second FOR loop in the sendChar() function, and doubling the height of the pixels transmitted by changing on(1) and off(1) to on(2) and off(2). Then again, I could be mistaken - I don't use this mode much. Also, horizontal width of characters (increase this and horizontally compress the received image to reduce the effects of noise) is controlled by a single variable, dynamically adjustable in software. Characters are created from a 3x5 grid (15 bits) and stored as an integer (16 bits, 2 bytes in AVR-GCC). Custom characters are certainly possible! This program takes 16.1% of program space (658 bytes) and 25.4% of data space (130 bytes) and certainly leaves room for optimization.

// designed for and tested with ATMega48
#include <avr/io.h>
#define F_CPU 8000000UL
#include <avr/delay.h>
#include <avr/interrupt.h>

/*
character format (3x5):
    KFA
    LGB
    MHC
    NID
    OJE

variable format:
    2-byte, 16-bit int 0b0ABCDEFGHIJKLMNO
    (note that the most significant bit is not used)
*/
#define A    0b0111111010011111
#define B    0b0010101010111111
#define C    0b0100011000101110
#define D    0b0011101000111111
#define E    0b0100011010111111
#define F    0b0100001010011111
#define G    0b0100111000101110
#define H    0b0111110010011111
#define I    0b0100011111110001
#define J    0b0111110000100011
#define K    0b0110110010011111
#define L    0b0000010000111111
#define M    0b0111110110011111
#define N    0b0011111000001111
#define O    0b0011101000101110
#define P    0b0010001010011111
#define Q    0b0111011001011110
#define R    0b0010111010011111
#define S    0b0100101010101001
#define T    0b0100001111110000
#define U    0b0111110000111111
#define V    0b0111100000111110
#define W    0b0111110001111111
#define X    0b0110110010011011
#define Y    0b0110000011111000
#define Z    0b0110011010110011
#define n0    0b0111111000111111
#define n1    0b0000011111101001
#define n2    0b0111011010110111
#define n3    0b0111111010110001
#define n4    0b0111110010011100
#define n5    0b0101111010111101
#define n6    0b0101111010111111
#define n7    0b0110001011110000
#define n8    0b0111111010111111
#define n9    0b0111111010111101
#define SP    0b0000000000000000
#define BK    0b0111111111111111
#define SQ    0b0001000111000100
#define PR    0b0000110001100011
#define AR    0b0001000111011111

volatile char width=1; // width of characters, widen to slow speed

#define spd 8300 // synchronization, incr to make it slant upward

void rest(char times){while (times){times--;_delay_us(spd);}}

void on(char restfor){OCR0A=110;rest(restfor);}
void off(char restfor){OCR0A=0;rest(restfor);}

void sendChar(int tosend){
    char w;
    char bit;
    for(w=0;w<width*2;w++){ // left column
        off(1);
        for (bit=0;bit<5;bit++){
                if ((tosend>>bit)&1) {on(1);}
                else {off(1);}
            }
        off(1);
        }
    for(w=0;w<width*2;w++){ // middle column
        off(1);
        for (bit=5;bit<10;bit++){
                if ((tosend>>bit)&1) {on(1);}
                else {off(1);}
            }
        off(1);
        }
    for(w=0;w<width*2;w++){ // right column
        off(1);
        for (bit=10;bit<15;bit++){
                if ((tosend>>bit)&1) {on(1);}
                else {off(1);}
            }
        off(1);
        }
    off(14); // letter space (1 column)
}

// CUSTOMIZE THE MESSAGE, OR GENERATE IT DYNAMICALLY!
int message[]={AR,AR,AR,S,W,H,A,R,D,E,N,PR,C,O,M,SP,R,O,C,K,S,
    SP,AR,AR,AR,SP,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,n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,BK,SP};

void sendMessage(){
    char i;
    for(i=0;i<sizeof(message)/2;i++){
        sendChar(message[i]);
    }
}

int main(){ // ### PROGRAM STARTS HERE ###

    // this sets up CPWM in CTC mode,
    // it may be slightly different for other chips
    DDRD|=255; // OC0A is now an output
    TCCR0A=0b01000010; // toggle on match, CTC mode
    TCCR0B=0B00000011; // set prescalar

    for(;;){
        width=1; // fast mode
        sendMessage();
        width=3; // slow mode
        sendMessage();
    }

    return 0;
}
Markdown source code last modified on January 18th, 2021
---
title: I before E except after Hellschreiber
date: 2011-08-05 18:52:40
tags: microcontroller, circuit, old, amateur radio
---

# I before E except after Hellschreiber

**This post describes a project I designed which transmits strings of data from a microcontroller to a PC's screen using audio beeping in a special mode called [Hellschreiber](http://en.wikipedia.org/wiki/Hellschreiber).** Although these days it's almost exclusively used by amateur radio operators, I thought it would make a cool microcontroller project! The result can be accomplished with a microcontroller and a speaker as a transmitter and a PC with a microphone as a receiver and decoder, or with actual radio equipment (even toy walkie talkies) by transmitting the tones over modulated radio frequencies for long distance communication! [Ideas anyone?](http://www.amazon.com/Midland-GXT760VP4-36-Mile-42-Channel-Two-Way/dp/B0039YON6Q/ref=sr_1_1?ie=UTF8&qid=1312588647&sr=8-1)

___SPECIAL THANKS:__ I'd like to think [Mike Seese](http://www.mikeseese.com) for his brainstorming help in making this project a reality. [Mike](http://www.mikeseese.com) and I are working on a high altitude balloon project together, and a creative inexpensive radio link is one of our goals. Thanks [Mike](http://www.mikeseese.com)!_

__As a professional dental student by day and amateur electrical/RF engineer by night, I'm having a very strange summer.__ I'm developing rapidly in my experience and skills in both arenas. I finally feel like I have a working knowledge of most fundamental electrical and radio frequency concepts, and I'm starting to see patients and do procedures on humans (no more mannequins) in the student dental clinic. For legal and ethical reasons I do not write specifics about what I do with my patients, but I certainly make up for it by documenting the electronic projects I work on! My goals of doing this are to (a) inspire potential electronics tinkerers to come up with new ideas and attack new projects, and (b) receive feedback and insight from those more experienced than me to help me grow in my knowledge. My eye caught [a comment](http://www.swharden.com/blog/2011-07-24-frequency-counter-gen2/comment-page-1/#comment-16485) a few posts ago that made me smile: _You have been blessed with talent and the drive to attempt things not been tried before, keep it up, great job. --David S_  While I can't claim that everything I do is truly novel or never tried before, I appreciate the encouraging words. Thank you David S!

__Today's project is a fun one involving vintage wartime radio equipment, amateur radio computer software, and a healthy dose of microcontrollers!__ My goal is to design a single chip Hellschreiber (technically Feldhellschreiber) transmitter. "Hellschreiber" translates into English as "Light Writer" and is a pun on the name of its inventor, Rudolf Hell, who built the first device in 1920. It was intended to allow messages to be transferred over poor radio links too noisy for intelligible voice or [radioteletype (RTTY)](http://en.wikipedia.org/wiki/Radioteletype) communication. Its cool factor is upped by the fact that it was sometimes used by the German military in conjunction with the [Enigma encryption system](http://en.wikipedia.org/wiki/Enigma_machine) during World War 2! [As an aside, RTTY is still pretty sweet and dates back to the mid 1800s! Check out hardware receivers in [video 1](http://www.youtube.com/watch?v=mN8pkJoDDfI) and [video 2](http://www.youtube.com/watch?v=Ml00ngVwrcU)]

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

__Seeing a battlefield-ready Hellschreiber receiver gives you a good idea of how it works.__ (The video isn't mine, I found it on youtube.) The concept is relatively simple (shown above), and the receiver has only 2 moving parts. A spinning corkscrew presses a ticker tape into ink when it receives a radio signal. As the radio signal beeps on and off, the corkscrew contacts at different positions at different times, and letters are written on the ticker tape! 

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

![](anaglyph-hell-GL-11.jpg)

</div>

The [designers of these things were extraordinarily creative](http://www.nonstopsystems.com/radio/hellschreiber-fonts.htm)! The picture on the right shows a Hellschreiber transmitter - basically a typewriter with mechanical wizardry that turns key presses into a series of radio tones corresponding to the pixelated shape of a character.

__Almost a century later, people are still sending messages around the world using Hellschreiber!__ With an [amateur radio license](http://en.wikipedia.org/wiki/Amateur_radio) and an amateur radio transceiver you can tune around special [Hellschreiber calling frequencies](http://www.nonstopsystems.com/radio/frank-radio-dig-mode-freqs.htm) and engage in conversations with other people who enjoy using this unique mode. Computers have modernized the process, allowing you to send Hellschreiber text by typing on your keyboard and receive it by just looking at your screen. My favorite program (free) to do this is Digital Master 780, part of [Ham Radio Deluxe](http://www.ham-radio-deluxe.com/Downloads.aspx).

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

__This is the project I just completed.__ It takes strings of text stored (or dynamically generated) in an array on a microcontroller (I'm using an ATMega48, but the code is almost identical for any ATMEL AVR microcontroller, and easy adapted for other architectures) and turns it into an audio tone using PWM. This audio tone could be fed into a speaker and a microphone across the room could receive it and use the software to show the received data, or the audio could be fed into a radio transmitter and a PC hooked to the receiver could decode the audio.  Either way, the text in the microcontroller is converted to Hellschreiber audio tones ready to be used however you see fit!  Although I designed it as a resilient way to transmit GPS/altitude data from a high altitude balloon using a small, cheap, low-power radio transmitter, this project is just the foundation of a plethora of potential projects!

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

[![](DSCN1663_thumb.jpg)](DSCN1663.jpg)

</div>

__Here's the circuit I'm using.__ It's actually less complicated than shown - all those yellow wires are going to my AVR programmer! The chip just receives +5V and GND, and the audio is generated automatically and output on the OC0A pin, which happens to be pin 12 on my ATMega48. The output (audio level square waves) is fed to a crystal oscillator [like this one](http://www.taydaelectronics.com/servlet/the-709/OSC-dsh-40M-dsh-MEC-dsh-LF-CRYSTAL-OSCILLATOR-40.00/Detail), which generates square waves with an amplitude equal that to the input. Thus, by audio-frequency AC from the microchip, decoupled through a series capacitor, added to the power supply of the oscillator (provided by the 5V rail through a 1.8k resistor), we effectively produce an amplitude modulated (AM) radio signal!

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

[![](DSCN1667_thumb.jpg)](DSCN1667.jpg)

</div>

__This is the receiver I'm using.__ I'm lucky enough to have an all-mode, general-coverage, 100W amateur radio transceiver! It's a [Yaesu 857-D](http://www.eham.net/reviews/detail/3046) and I'm completely in love with it. It's quite pricey though! You can find wide coverage receive-only radios called [radio scanners](http://en.wikipedia.org/wiki/Scanner_(radio)) (or police scanners), often for $20 or so on eBay which would do just as good a job of receiving all sorts of radio signals! Whatever you use, after tuning into the audio with the ham radio delux software, you'll be able to decode Hellschreiber like this:

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

[![](hell_thumb.jpg)](hell.png)

</div>

__A few notes about the code:__ Each letter is sent twice vertically and I don't think I should have done that. It's easy enough to correct by eliminating the second FOR loop in the sendChar() function, and doubling the height of the pixels transmitted by changing on(1) and off(1) to on(2) and off(2). Then again, I could be mistaken - I don't use this mode much.  Also, horizontal width of characters (increase this and horizontally compress the received image to reduce the effects of noise) is controlled by a single variable, dynamically adjustable in software. Characters are created from a 3x5 grid (15 bits) and stored as an integer (16 bits, 2 bytes in AVR-GCC). Custom characters are certainly possible! This program takes 16.1% of program space (658 bytes) and 25.4% of data space (130 bytes) and certainly leaves room for optimization.

```c
// designed for and tested with ATMega48
#include <avr/io.h>
#define F_CPU 8000000UL
#include <avr/delay.h>
#include <avr/interrupt.h>

/*
character format (3x5):
    KFA
    LGB
    MHC
    NID
    OJE

variable format:
    2-byte, 16-bit int 0b0ABCDEFGHIJKLMNO
    (note that the most significant bit is not used)
*/
#define A    0b0111111010011111
#define B    0b0010101010111111
#define C    0b0100011000101110
#define D    0b0011101000111111
#define E    0b0100011010111111
#define F    0b0100001010011111
#define G    0b0100111000101110
#define H    0b0111110010011111
#define I    0b0100011111110001
#define J    0b0111110000100011
#define K    0b0110110010011111
#define L    0b0000010000111111
#define M    0b0111110110011111
#define N    0b0011111000001111
#define O    0b0011101000101110
#define P    0b0010001010011111
#define Q    0b0111011001011110
#define R    0b0010111010011111
#define S    0b0100101010101001
#define T    0b0100001111110000
#define U    0b0111110000111111
#define V    0b0111100000111110
#define W    0b0111110001111111
#define X    0b0110110010011011
#define Y    0b0110000011111000
#define Z    0b0110011010110011
#define n0    0b0111111000111111
#define n1    0b0000011111101001
#define n2    0b0111011010110111
#define n3    0b0111111010110001
#define n4    0b0111110010011100
#define n5    0b0101111010111101
#define n6    0b0101111010111111
#define n7    0b0110001011110000
#define n8    0b0111111010111111
#define n9    0b0111111010111101
#define SP    0b0000000000000000
#define BK    0b0111111111111111
#define SQ    0b0001000111000100
#define PR    0b0000110001100011
#define AR    0b0001000111011111

volatile char width=1; // width of characters, widen to slow speed

#define spd 8300 // synchronization, incr to make it slant upward

void rest(char times){while (times){times--;_delay_us(spd);}}

void on(char restfor){OCR0A=110;rest(restfor);}
void off(char restfor){OCR0A=0;rest(restfor);}

void sendChar(int tosend){
    char w;
    char bit;
    for(w=0;w<width*2;w++){ // left column
        off(1);
        for (bit=0;bit<5;bit++){
                if ((tosend>>bit)&1) {on(1);}
                else {off(1);}
            }
        off(1);
        }
    for(w=0;w<width*2;w++){ // middle column
        off(1);
        for (bit=5;bit<10;bit++){
                if ((tosend>>bit)&1) {on(1);}
                else {off(1);}
            }
        off(1);
        }
    for(w=0;w<width*2;w++){ // right column
        off(1);
        for (bit=10;bit<15;bit++){
                if ((tosend>>bit)&1) {on(1);}
                else {off(1);}
            }
        off(1);
        }
    off(14); // letter space (1 column)
}

// CUSTOMIZE THE MESSAGE, OR GENERATE IT DYNAMICALLY!
int message[]={AR,AR,AR,S,W,H,A,R,D,E,N,PR,C,O,M,SP,R,O,C,K,S,
    SP,AR,AR,AR,SP,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,n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,BK,SP};

void sendMessage(){
    char i;
    for(i=0;i<sizeof(message)/2;i++){
        sendChar(message[i]);
    }
}

int main(){ // ### PROGRAM STARTS HERE ###

    // this sets up CPWM in CTC mode,
    // it may be slightly different for other chips
    DDRD|=255; // OC0A is now an output
    TCCR0A=0b01000010; // toggle on match, CTC mode
    TCCR0B=0B00000011; // set prescalar

    for(;;){
        width=1; // fast mode
        sendMessage();
        width=3; // slow mode
        sendMessage();
    }

    return 0;
}

```
July 11th, 2011

Frequency Counter Hacked to add USB Functionality

This is a multi-part blog entry added over 2 days of time documenting the progress of the addition of USB to a simple frequency counter. The final result lets me graph frequency over time on the computer, automatically, over days of time if desired. I'm quite pleased at the result, especially considering so little circuitry was required!

It looks like this will be a multi-part blog entry. I'm in the process of figuring out how to add USB functionality to this simple device, which will be a fun way for me to express my creativity and think a bit outside the box while gaining some simple electrical engineering experience! Here's the jist of what I'm planning...

After a brief trip to Orlando to visit family, I decided to stop by the house of one of my neighbors who worked at the same small engineering company I did when I was first starting college (about the time I decided to peruse biology rather than engineering). I hadn't seen him in a while and we talked about various electronics things (he's working on an impressive project currently), and before I left he offered me a brown box. "Do you have any use for a function generator?" I got excited and said "sure!" On closer inspection, it was actually a frequency counter, and he said "oh well I don't need one of those anyway" and gave it to me. I was ecstatic! Between this post, this post, this post, this post, and this final project post you can tell that building a frequency counter was really important to me, and that I was never truly satisfied with the result - it wasn't stable to the Hz! I'm excited to finally have a real counter at my workstation. (It's an instek GFC-8010H, 1-120 MHz range.) Now onto figuring out how to build a spectrum analyzer... X_x

Update (2 days later)

I never can leave things alone can I? While basking in happiness over this new acquisition I pondered how easy it would be to interface this to a PC. I would like to graph frequency drift over time directly (not using a radio receiver outputting audio which I graph, since the radio is sensitive to drift). Plus this counter allows sample sizes of 10 seconds! That's some serious resolution (compared to what I'm used to at least). First step to PC interfacing is to see what I've got to work with. I unscrewed the box and snapped some photos of the surprisingly simple device... I can't believe this costs over $175 (as listed on Amazon.com) - it's so simple!

I guess it all makes sense. AC transformer and rectifier diodes with a smoothing capacitor on the bottom left, fed into a 7805 linear voltage regulator, no doubt powering the micro-controller (big IC), logic buffer (small IC), and whatever analog circuitry is under the panel.

I'm not going to lift the panel because it's obvious what's under there. Likely some high gain, high distortion amplifier stages to provide a lot of buffering, eventually the input shape is fed to the chip for counting.

After posting and thinking about it, the curiosity got to me! I lifted the panel and this is what I found...

There's our buffer and wave shaper! The full datasheet shows it's a (triple) line driver.

Come to think of it, I'm not entirely sure about that smaller IC. It's a 74HC00N, quad NAND gate. Knee-jerk was to say it was used for dividing-down the frequency, but that's silly since it takes 2 NAND gates to make a flip flop, and that chip would be only 2 flip flops (/4), and there are flip flip chips for all that. Perhaps this has something to do with the buttons on the front panel? Perhaps something to do with square-shaping the oscillator with the 10mhz crystal? The big GFC 9701-1 IC seems to be a custom counter chip used in many Instek products. Here's a blurb from a page of their manual for a function generator they make:

The most important function of the internal counter is to show the main frequency on the display. So we take a square signal from the square shaper and change the level to TTL compatible level with a TTL shaper block (is this the role of that NAND gate?) then the signal will connect with the counter GFC-9701. Because the counter directly connects with the MPU system, the MPU can get correct frequency and show it on the display. So, it seems that chip is already outputting data ready to go into a CPU. I wonder if it's outputting some type of data on an unused pin, ripe for the picking? I can't find more ICs in this device, so it's possible no other MCU is driving the display, and this counter IC is doing that all on its own. Bah, again curiosity is getting the best of me... [unscrews front panel]

More ICs! I couldn't see them well before so I'm glad I opened up the display. The ULN2003A is a 7 channel darlington array, x2 = 14 darlingtons. The CD4511 is a common 7-segment driver - BINGO! If I'm going to interface this device by intercepting the display, this is the way to do it! The darlingtons tell me which character is selected, and the input of this chip tells me the value to be displayed. Pow!

Let's take a closer look at that main chip again... X-RAY VISION TIME! I used Image-J to extract the red channel of the image and increased contrast, inverted, then used a 10 pixel wide unsharp mask with 0.8 weight to bring-out the leads. I guess I could have just unscrewed it and looked at the bottom, but where's the fun in that? I imagine the top left pin is input of frequency. The bottom left pins go to buttons on the front, so they're for front panel input. The headers on the right go to the front panel display. The pin going to the smaller IC must be the clock input, so that NAND gate DOES do something with shaping the input clock signal. On the top fight of the image you can see the crystal connecting to that gate. The trace going in the center of the chip on top is probably +5V supply for the chip. I'm not sure about much else, and I don't feel like poking around with a continuity meter right now. UPDATE - I tested each pin with an analog o-scope. I found that pin 6 (unconnected) outputs a burst of data every time the display updates - this is my data line! If I had a logic analyzer I'd know how to read it... BAH!

What's this?! The voltage regulator with its hefty heat sink (which obviously gets quite warm) is attached to a 10.000 MHz crystal! Is this the time base crystal? Doesn't accuracy depend on thermostability of this crystal? It's not just near it - it's physically connected with it through metal! Does this imply that a loaded 7805 voltage regulator produces heat more steadily, and with a final temperature more stable than room air in a plastic enclosure??

update: The following was emailed to me in response to this puzzling issue. It's from my good friend Bill!

It may be an SC-cut crystal which is the best type for precision oscillators because the turn around inflection occurs at a much broader temperature range than the regular AT-cut, el cheapo types we often use. SC types, if carefully selected, can remain within a fraction of a ppm over a temperature range to 10 to 20 C. The turn around point temperature is pretty high, about 90 C, compared to around 25C for the at-cut. So, my guess is that the 7805 provides this really high temperature to the xtal and can be trusted to not vary by more than a few degrees, particularly in a laboratory environment. --Bill (W4HBK) Afterthought: This would make one hell of a huff-and-puff oscillator!

PROJECT COMPLETED!

I'm quite excited, the end product works wonderfully! It looks pretty spiffy too!

Here's some video showing the device at work!

Of course Python and MatPlotLib can graph it:

... but so can Excel!

UPDATE Oops, I forgot to remove the trailing zero. That's 9.9 MHz, not 99 MHz. That's easy enough to do later, so I'm not going to fix it and re-post updated images. Don't email me about it, I know ^_^

UPDATE 2 Here's some useful data! I hooked up a canned oscillator at 3.57 something MHz (very stable) and watched it as my frequency counter warmed up. The result showed that the counter takes about 2 hours to warm up!!! he shift is only about 15 Hz over 2 hours, but still it's good to know.

Once it's warm, it's stable!

Schematic

This device is very simple and specialized for my use and I have not designed a custom schematic. USB functionality is as recommended by V-USB, similar to:

For more information on the USB circuitry, view the hardware considerations page relating to the V-USB project.

CODE

Microcontroller code - Although it's hard for me, I really don't think I can release this right now. I'm working on an idiot's guide to USB connectivity with ATMEL microcontrollers, and it would cause quite a stir to post that code too early. It'll be shared soon! Here are the python scripts for the logging and for the graphing:


#This code polls the USB device and displays/logs frequency
from optparse import OptionParser
import time
import usb.core
import usb.util
import os

while True:
        print "nTrying to communicate with the Gator Keyer ...",
        dev = usb.core.find(find_all=True, idVendor=0x16c0, idProduct=0x5dc)
        if len(dev)==0: print "FAIL"
        dev=dev[0]
        dev.set_configuration()
        print "there it is!"
        break

def readVals(c):
    x=dev.ctrl_transfer(0xC0, 3, c,4,4).tolist()
    val=x[0]
    if val>9: val=0
    return val

def readDisp():
    c=[]
    for i in range(1,9):
        val=readVals(i)
        c.append(val)
        #print "char",i,"=",val
    disp="%d%d%d%d%d%d%d%d"%(c[0],c[1],c[2],c[5],c[6],c[3],c[4],c[7])
    return disp

def readFreq():
    i=0
    first=readDisp()
    while True:
        if first==readDisp():
            i+=1
            if i==5: break #we're good!
        else: #FAIL! start over...
            i=0
            first=readDisp()
    return first

### PROGRAM START ##################

start=time.time()
while True:
    line="%.02f,%s"%(time.time()-start,readFreq())
    print line
    f=open("freq.csv",'a')
    f.write(line+"n")
    f.close()
    time.sleep(1)

#This code reads the log file and graphs it with matplotlib
import matplotlib.pyplot as plt
import numpy

print "loading"
f=open("freq.csv")
raw=f.readlines()
f.close()

print raw

print "crunching"
times=numpy.array([])
data=numpy.array([])
for line in raw:
    if len(line)<10: continue
    line=line.replace("n",'').split(',')
    times=numpy.append(times,float(line[0]))
    data=numpy.append(data,float(line[1]))

#data=data/1000000.0
print times, data
print "DONE processing",len(data),"linesnn"
print "plotting..."
plt.figure()
plt.grid()
plt.plot(times,data,'-')
plt.plot(times,data,'.')
plt.show()
Markdown source code last modified on January 18th, 2021
---
title: Frequency Counter Hacked to add USB Functionality
date: 2011-07-11 17:02:33
tags: amateur radio, qrss, circuit, microcontroller, old
---

# Frequency Counter Hacked to add USB Functionality

This is a multi-part blog entry added over 2 days of time documenting the progress of the addition of USB to a simple frequency counter. The final result lets me graph frequency over time on the computer, automatically, over days of time if desired. I'm quite pleased at the result, especially considering so little circuitry was required! 

__It looks like this will be a multi-part blog entry.__ I'm in the process of figuring out how to add USB functionality to this simple device, which will be a fun way for me to express my creativity and think a bit outside the box while gaining some simple electrical engineering experience! Here's the jist of what I'm planning...

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

__After a brief trip__ to Orlando to visit family, I decided to stop by the house of one of my neighbors who worked at the same small engineering company I did when I was first starting college (about the time I decided to peruse biology rather than engineering).  I hadn't seen him in a while and we talked about various electronics things (he's working on an impressive project currently), and before I left he offered me a brown box. "Do you have any use for a function generator?" I got excited and said "sure!" On closer inspection, it was actually a frequency counter, and he said "oh well I don't need one of those anyway" and gave it to me. I was ecstatic! Between [this post](http://www.swharden.com/blog/2011-01-28-home-brew-transceiver-taking-shape/), [this post](http://www.swharden.com/blog/2011-02-04-frequency-counter-working/), [this post](http://www.swharden.com/blog/2011-02-09-minimal-radio-project-continues/), [this post](http://www.swharden.com/blog/2011-02-12-wideband-receiver-works/), and [this final project post](http://www.swharden.com/blog/2011-03-14-frequency-counter-finished/) you can tell that building a frequency counter was really important to me, and that I was never truly satisfied with the result - it wasn't stable to the Hz! I'm excited to finally have a real counter at my workstation. (It's an instek GFC-8010H, 1-120 MHz range.) Now onto figuring out how to build a spectrum analyzer... X_x

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

[![](after1_thumb.jpg)](after1.jpg)

</div>

### Update (2 days later)

__I never can leave things alone can I?__ While basking in happiness over this new acquisition I pondered how easy it would be to interface this to a PC. I would like to graph frequency drift over time directly (not using a radio receiver outputting audio which I graph, since the radio is sensitive to drift). Plus this counter allows sample sizes of 10 seconds! That's some serious resolution (compared to what I'm used to at least).  First step to PC interfacing is to see what I've got to work with. I unscrewed the box and snapped some photos of the surprisingly simple device... I can't believe [this costs over $175 (as listed on Amazon.com)](http://www.amazon.com/Instek-GFC8010H-Frequency-Counter/dp/B000I3VS0A) - it's so simple!

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

[![](DSCN1540_thumb.jpg)](DSCN1540.jpg)

</div>

__I guess it all makes sense.__ AC transformer and rectifier diodes with a smoothing capacitor on the bottom left, fed into a 7805 linear voltage regulator, no doubt powering the micro-controller (big IC), logic buffer (small IC), and whatever analog circuitry is under the panel.

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

[![](DSCN1541_thumb.jpg)](DSCN1541.jpg)

</div>

__I'm not going to lift the panel__ because it's obvious what's under there. Likely some high gain, high distortion amplifier stages to provide a lot of buffering, eventually the input shape is fed to the chip for counting.

__After posting and thinking about it,__ the curiosity got to me! I lifted the panel and this is what I found...

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

[![](DSCN1552_thumb.jpg)](DSCN1552.jpg)

</div>

__There's our buffer and wave shaper!__ The [full datasheet](http://www.onsemi.com/pub_link/Collateral/MC10H116-D.PDF) shows it's a (triple) line driver.

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

[![](DSCN1544_thumb.jpg)](DSCN1544.jpg)

</div>

__Come to think of it,__ I'm not entirely sure about that smaller IC.  It's a 74HC00N, quad NAND gate. Knee-jerk was to say it was used for dividing-down the frequency, but that's silly since it takes 2 NAND gates to make a flip flop, and that chip would be only 2 flip flops (/4), and there are flip flip chips for all that.  Perhaps this has something to do with the buttons on the front panel? Perhaps something to do with square-shaping the oscillator with the 10mhz crystal? The big GFC 9701-1 IC seems to be a custom counter chip used in many Instek products. Here's a blurb from a page of their manual for a function generator they make:

>  The most important function of the internal counter is to show the main frequency on the display. So we take a square signal from the square shaper and change the level to TTL compatible level with a TTL shaper block (is this the role of that NAND gate?) then the signal will connect with the counter GFC-9701. Because the counter directly connects with the MPU system, the MPU can get correct frequency and show it on the display.
__So, it seems__ that chip is already outputting data ready to go into a CPU. I wonder if it's outputting some type of data on an unused pin, ripe for the picking? I can't find more ICs in this device, so it's possible no other MCU is driving the display, and this counter IC is doing that all on its own. Bah, again curiosity is getting the best of me... [unscrews front panel]

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

[![](DSCN1560_thumb.jpg)](DSCN1560.jpg)

</div>

__More ICs!__ I couldn't see them well before so I'm glad I opened up the display. The ULN2003A is a 7 channel darlington array, x2 = 14 darlingtons. The CD4511 is a common 7-segment driver - BINGO! If I'm going to interface this device by intercepting the display, this is the way to do it!  The darlingtons tell me which character is selected, and the input of this chip tells me the value to be displayed. Pow!

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

[![](xray_circuit_thumb.jpg)](xray_circuit.jpg)

</div>

__Let's take a closer look at that main chip again...__ X-RAY VISION TIME! I used Image-J to extract the red channel of the image and increased contrast, inverted, then used a 10 pixel wide unsharp mask with 0.8 weight to bring-out the leads. I guess I could have just unscrewed it and looked at the bottom, but where's the fun in that? I imagine the top left pin is input of frequency. The bottom left pins go to buttons on the front, so they're for front panel input. The headers on the right go to the front panel display. The pin going to the smaller IC must be the clock input, so that NAND gate DOES do something with shaping the input clock signal. On the top fight of the image you can see the crystal connecting to that gate. The trace going in the center of the chip on top is probably +5V supply for the chip. I'm not sure about much else, and I don't feel like poking around with a continuity meter right now. UPDATE - I tested each pin with an analog o-scope. I found that pin 6 (unconnected) outputs a burst of data every time the display updates - this is my data line! If I had a logic analyzer I'd know how to read it... BAH!

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

[![](DSCN1547_thumb.jpg)](DSCN1547.jpg)

</div>

__What's this?!__ The voltage regulator with its hefty heat sink (which obviously gets quite warm) is attached to a 10.000 MHz crystal!  Is this the time base crystal? Doesn't accuracy depend on thermostability of this crystal? It's not just near it - it's physically connected with it through metal! Does this imply that a loaded 7805 voltage regulator produces heat more steadily, and with a final temperature more stable than room air in a plastic enclosure??

__update:__ The following was emailed to me in response to this puzzling issue. It's from my good friend Bill!

>  _It may be an SC-cut crystal which is the best type for precision oscillators because the turn around inflection occurs at a much broader temperature range than the regular AT-cut, el cheapo types we often use. SC types, if carefully selected, can remain within a fraction of a ppm over a temperature range to 10 to 20 C. The turn around point temperature is pretty high, about 90 C, compared to around 25C for the at-cut. So, my guess is that the 7805 provides this really high temperature to the xtal and can be trusted to not vary by more than a few degrees, particularly in a laboratory environment._ --Bill (W4HBK)
_Afterthought: This would make one hell of a huff-and-puff oscillator!_

## PROJECT COMPLETED!

__I'm quite excited__, the end product works wonderfully! It looks pretty spiffy too!

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

[![](DSCN1580_thumb.jpg)](DSCN1580.jpg)
[![](DSCN1605_thumb.jpg)](DSCN1605.jpg)
[![](DSCN1609_thumb.jpg)](DSCN1609.jpg)

</div>

__Here's some video__ showing the device at work!

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

Of course Python and MatPlotLib can graph it:

<div class="text-center">

[![](usb-frequency-counter-hack2_thumb.jpg)](usb-frequency-counter-hack2.png)

</div>

... but so can Excel!

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

[![](usb-frequency-counter-hack_thumb.jpg)](usb-frequency-counter-hack.png)

</div>

__UPDATE__ Oops, I forgot to remove the trailing zero. That's 9.9 MHz, not 99 MHz.  That's easy enough to do later, so I'm not going to fix it and re-post updated images. Don't email me about it, I know ^_^

__UPDATE 2__ Here's some useful data! I hooked up a canned oscillator at 3.57 something MHz (very stable) and watched it as my frequency counter warmed up. The result showed that the counter takes about 2 hours to warm up!!! he shift is only about 15 Hz over 2 hours, but still it's good to know.

<div class="text-center">

[![](warmup1_thumb.jpg)](warmup1.png)

</div>

Once it's warm, it's stable!

<div class="text-center">

[![](warm_thumb.jpg)](warm.png)

</div>

## Schematic

This device is very simple and specialized for my use and I have not designed a custom schematic. USB functionality is as recommended by V-USB, similar to:

<div class="text-center">

![](circuit-zoomed.gif)

</div>

For more information on the USB circuitry, view the [hardware considerations page](http://vusb.wikidot.com/hardware) relating to the [V-USB project](http://www.obdev.at/products/vusb/index.html).

## CODE

__Microcontroller code - __ Although it's hard for me, I really don't think I can release this right now. I'm working on an idiot's guide to USB connectivity with ATMEL microcontrollers, and it would cause quite a stir to post that code too early. It'll be shared soon! Here are the python scripts for the logging and for the graphing:

```python

#This code polls the USB device and displays/logs frequency
from optparse import OptionParser
import time
import usb.core
import usb.util
import os

while True:
        print "nTrying to communicate with the Gator Keyer ...",
        dev = usb.core.find(find_all=True, idVendor=0x16c0, idProduct=0x5dc)
        if len(dev)==0: print "FAIL"
        dev=dev[0]
        dev.set_configuration()
        print "there it is!"
        break

def readVals(c):
    x=dev.ctrl_transfer(0xC0, 3, c,4,4).tolist()
    val=x[0]
    if val>9: val=0
    return val

def readDisp():
    c=[]
    for i in range(1,9):
        val=readVals(i)
        c.append(val)
        #print "char",i,"=",val
    disp="%d%d%d%d%d%d%d%d"%(c[0],c[1],c[2],c[5],c[6],c[3],c[4],c[7])
    return disp

def readFreq():
    i=0
    first=readDisp()
    while True:
        if first==readDisp():
            i+=1
            if i==5: break #we're good!
        else: #FAIL! start over...
            i=0
            first=readDisp()
    return first

### PROGRAM START ##################

start=time.time()
while True:
    line="%.02f,%s"%(time.time()-start,readFreq())
    print line
    f=open("freq.csv",'a')
    f.write(line+"n")
    f.close()
    time.sleep(1)

```

```python

#This code reads the log file and graphs it with matplotlib
import matplotlib.pyplot as plt
import numpy

print "loading"
f=open("freq.csv")
raw=f.readlines()
f.close()

print raw

print "crunching"
times=numpy.array([])
data=numpy.array([])
for line in raw:
    if len(line)<10: continue
    line=line.replace("n",'').split(',')
    times=numpy.append(times,float(line[0]))
    data=numpy.append(data,float(line[1]))

#data=data/1000000.0
print times, data
print "DONE processing",len(data),"linesnn"
print "plotting..."
plt.figure()
plt.grid()
plt.plot(times,data,'-')
plt.plot(times,data,'.')
plt.show()

```
June 5th, 2011

Permeability Tuned Oscillator (PTO) Working Nicely

My last entry described my accidental discovery of the PTO for QRP purposes. I breadboarded it and was amazed at the results! I went ahead and built this carefully in an enclosure and the output is wonderful. It's strong, it's stable, and it tunes effortlessly over the same range it did before (about 1MHz). The video describes details of the action, and demonstrates the stability of the oscillator by letting you hear it audibly on a nearby receiver.

The fundamental concept and hardware is straightforward. Two nuts are soldered into an Altoids tin providing much-needed grounding for the screw (reduces shift when it's touched). Also the wire soldered over the screw is pinched firmly at the base to apply constant pressure to the screw to make it hard to turn and therefore more stable while turning. The inductor is a bunch of turns (no idea how many, about a meter of magnet wire) around a McDonalds straw.

Alltogether it's a simple colpitts oscillator with a MPF102 JFET at its heart, using a 74hc240 CMOS buffer as an amplifier. There's a voltage regulator in there too.

The result? Pretty darn stable (by CW QSO standards). That's without any regard to thermal isolation or temperature compensation. I'm quite pleased! I look forward to MUCH more experimentation now that I'm starting to feel good about designing and building simple, tunable, stable oscillators. It's always hard to nail all 3 in a single device!

Markdown source code last modified on January 18th, 2021
---
title: Permeability Tuned Oscillator (PTO) Working Nicely
date: 2011-06-05 02:21:40
tags: circuit, amateur radio, old
---

# Permeability Tuned Oscillator (PTO) Working Nicely

__My last entry described my accidental discovery of the PTO__ for QRP purposes. I breadboarded it and was amazed at the results! I went ahead and built this carefully in an enclosure and the output is wonderful. It's strong, it's stable, and it tunes effortlessly over the same range it did before (about 1MHz). The video describes details of the action, and demonstrates the stability of the oscillator by letting you hear it audibly on a nearby receiver.

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

__The fundamental concept and hardware is straightforward.__ Two nuts are soldered into an Altoids tin providing much-needed grounding for the screw (reduces shift when it's touched). Also the wire soldered over the screw is pinched firmly at the base to apply constant pressure to the screw to make it hard to turn and therefore more stable while turning. The inductor is a bunch of turns (no idea how many, about a meter of magnet wire) around a McDonalds straw.

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

[![](DSCN1350_thumb.jpg)](DSCN1350.jpg)

</div>

__Alltogether it's a simple colpitts oscillator__ with a MPF102 JFET at its heart, using a 74hc240 CMOS buffer as an amplifier. There's a voltage regulator in there too.

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

[![](DSCN1356_thumb.jpg)](DSCN1356.jpg)

</div>

__The result?__ Pretty darn stable (by CW QSO standards).  That's without any regard to thermal isolation or temperature compensation. I'm quite pleased!  I look forward to MUCH more experimentation now that I'm starting to feel good about designing and building simple, tunable, stable oscillators. It's always hard to nail all 3 in a single device!

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

[![](DSCN1357_thumb.jpg)](DSCN1357.jpg)

</div>
Pages