The personal website of Scott W Harden

PySquelch: A Python-Based Frequency Audio Activity Monitor

I'm pretty much done with this project so it's time to formally document it. This project is a collaboration between Fred, KJ4LFJ who supplied the hardware and myself, Scott, KJ4LDF who supplied the software. Briefly, a scanner is set to a single frequency (147.120 MHz, the output of an active repeater in Orlando, FL) and the audio output is fed into the microphone hole of a PC sound card. The scripts below (run in the order they appear) detect audio activity, log the data, and display such data graphically.

Here is some sample output:

Live-running software is current available at: Fred's Site. The most current code can be found in its working directory. For archival purposes, I'll provide the code for pySquelch in ZIP format. Now, onto other things...

Markdown source code last modified on January 18th, 2021
---
title: PySquelch: A Python-Based Frequency Audio Activity Monitor
date: 2009-07-26 00:22:12
tags: python, old
---

# PySquelch: A Python-Based Frequency Audio Activity Monitor

__I'm pretty much done with this project so it's time to formally document it.__  This project is a collaboration between Fred, [KJ4LFJ](http://www.qrz.com/kj4lfj) who supplied the hardware and myself, Scott, [KJ4LDF](http://www.qrz.com/kj4ldf) who supplied the software.  Briefly, a scanner is set to a single frequency (147.120 MHz, the output of an [active repeater ](http://www.147120.com/) in Orlando, FL) and the audio output is fed into the microphone hole of a PC sound card.  The scripts below (run in the order they appear) detect audio activity, log the data, and display such data graphically.  

Here is some sample output:

<div class="text-center">

[![](test_24hr-1_thumb.jpg)](test_24hr-1.png)
[![](test_average_thumb.jpg)](test_average.png)
[![](test_alltime-1_thumb.jpg)](test_alltime-1.png)
[![](test_60min_thumb.jpg)](test_60min.png)

</div>

__Live-running software is current available at: [Fred's Site](http://kj4lfj.dyndns.org/147120/stream-data/pySquelch.html)__. The most current code can be found in its working directory.  For archival purposes, I'll provide [the code for pySquelch in ZIP format](http://www.SWHarden.com/blog/images/pysquelch.zip).  Now, onto other things...

Microcontroller-Powered Prime Number Generator

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.

Markdown source code last modified on January 18th, 2021
---
title: Microcontroller-Powered Prime Number Generator
date: 2009-07-06 10:07:56
tags: microcontroller
---

# Microcontroller-Powered Prime Number Generator

__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!

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

[![](primepic1_thumb.jpg)](primepic1.jpg)

</div>

__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!](http://primes.utm.edu/nthprime/index.php#nth)). The LCD had some history. [In December, 2003 (6 years ago) I worked with this SAME display](http://www.swharden.com/blog/2003/12/), and I even located the [blog entry on November 25'th, 2003](http://www.swharden.com/blog/2003-11-25-doh/) 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.

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

[![](primepic2_thumb.jpg)](primepic2.jpg)

</div>

__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](http://en.wikipedia.org/wiki/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 (N_test_). The last two digits of N_test_ are shown on the top left. To test a number (N_test_) for primeness, it is divided by every number from 2 to the square root of N_test_. If any divisor divides evenly (with a remainder of zero) it's assumed not to be prime, and N_test_ 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](http://thinklabs.in/shop/images/mega8.jpg) (_[What is a microcontroller?](http://en.wikipedia.org/wiki/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](http://en.wikipedia.org/wiki/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](http://www.colinfahey.com/ps2_mouse_and_basic_stamp_computer/2002june03_basicstamp_mousecircuit01_adj.jpg)) 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](http://en.wikipedia.org/wiki/C_(programming_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](http://en.wikipedia.org/wiki/Bit-banging) data through a slew of daisy-chained [shift registers](http://en.wikipedia.org/wiki/Shift_register) (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.

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

[![](primepic3_thumb.jpg)](primepic3.jpg)

</div>

Summer's End is Nearing

My favorite summer yet is reaching its end. With about a month and a half before I begin dental school, I pause to reflect on what I've done, and what I still plan to do. Unlike previous summers where my time was devoted to academic requirements, this summer involved a 9-5 job with time to do whatever I wanted after. I made great progress in the realm of microcontroller programming, and am nearing the completion of my prime number calculator. I'm very happy with its progress.

Most of the LEDs are working but I'm still missing a few shift registers. It's not that they're missing, so much as I broke them. (D'oh!) I have to wait for a dozen more to come in the mail so I can continue this project. Shift registers are also responsible for powering the binary-to-7-segment chips on the upper left, whose sockets are currently empty.

Since this project is on pause, I began work hacking a VFD I heard about at Skycraft. It's a 20x2 character display (forgot to photograph the front) and if I can make it light up, it will be gorgeous.

Here's a high resolution photo of the back panel of the VFD. I believe it used to belong to an old cash register, and it has some digital interfacing circuitry between the driver chips (the big OKI ones) and the 9-pin input connector. I think my best bet for being able to control this guy as much as I want is to attack those driver chips, with help from the Oki C1162A datasheet. It looks fairly straightforward. As long as I don't screw up my surface-mount soldering, and assuming that I come up with 65 volts to power the thing (!) I think it's a doable project.

Markdown source code last modified on January 18th, 2021
---
title: Summer's End is Nearing
date: 2009-07-01 09:40:43
tags: microcontroller
---

# Summer's End is Nearing

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

[![](scott_working_thumb.jpg)](scott_working.png)

</div>

__My favorite summer yet is reaching its end.__ With about a month and a half before I begin dental school, I pause to reflect on what I've done, and what I still plan to do. Unlike previous summers where my time was devoted to academic requirements, this summer involved a 9-5 job with time to do whatever I wanted after. I made great progress in the realm of microcontroller programming, and am nearing the completion of my prime number calculator. I'm very happy with its progress.

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

[![](wiremess_thumb.jpg)](wiremess.jpg)
[![](lightson_thumb.jpg)](lightson.jpg)

</div>

__Most of the LEDs are working__ but I'm still missing a few shift registers. It's not that they're missing, so much as I broke them. (D'oh!) I have to wait for a dozen more to come in the mail so I can continue this project. Shift registers are also responsible for powering the binary-to-7-segment chips on the upper left, whose sockets are currently empty.

Since this project is on pause, I began work hacking a [VFD](http://en.wikipedia.org/wiki/Vacuum_fluorescent_display) I heard about at Skycraft. It's a 20x2 character display (forgot to photograph the front) and if I can make it light up, it will be gorgeous.

<div class="text-center">

[![](vfd_thumb.jpg)](vfd.jpg)

</div>

__Here's a high resolution photo of the back panel of the VFD__. I believe it used to belong to an old cash register, and it has some digital interfacing circuitry between the driver chips (the big OKI ones) and the 9-pin input connector. I think my best bet for being able to control this guy as much as I want is to attack those driver chips, with help from the Oki C1162A datasheet. It looks fairly straightforward. As long as I don't screw up my surface-mount soldering, and assuming that I come up with 65 volts to power the thing (!) I think it's a doable project.

Prime Number Generator Schematics

Here's a schematic of the prime number calculator I'm working on. Last night I finished wiring all 12 shift registers for the primary display, so now it's time to start working on software. Notice that we have a lot of pins free still. This will be advantageous if I decide to go crazy adding extraneous functionality, such as fancy displays (LCD?, 7-segment LEDs?, VFD?, all 3?!) or creative input systems (how about a numerical keypad?).

After feeling the stink of paying almost $15 for 100' of yellow, 24 gauge, solid-core wire from DigiKey I was relieved (and a little embarrassed) to find I could score 1,000' of yellow, 24 gauge, threaded wire for $10 at Skycraft! Anyway, here's the current schematic.

Markdown source code last modified on January 18th, 2021
---
title: Prime Number Generator Schematics
date: 2009-06-30 12:25:14
---

# Prime Number Generator Schematics

__Here's a schematic of the prime number calculator I'm working on.__ Last night I finished wiring all 12 shift registers for the primary display, so now it's time to start working on software. Notice that we have a lot of pins free still. This will be advantageous if I decide to go crazy adding extraneous functionality, such as fancy displays (LCD?, 7-segment LEDs?, VFD?, all 3?!) or creative input systems (how about a numerical keypad?).

<div class="text-center">

[![](text5130_thumb.jpg)](text5130.png)

</div>

After feeling the stink of paying almost $15 for 100' of yellow, 24 gauge, solid-core wire from DigiKey I was relieved (and a little embarrassed) to find I could score 1,000' of yellow, 24 gauge, threaded wire for $10 at Skycraft! Anyway, here's the current schematic.

Field Day 2009

Last weekend was field day, a disaster simulation / competition for amateur radio operators. In a sentence, people are encouraged to make as many contacts as they can around the world (earning points) using emergency radio preparations (battery and solar powered radios, temporary antennas, etc) for a full 24 hours (2pm to 2pm). I spent the time with the UCF Amateur Radio Club who set up big antennas in a grassy field on campus. It was a fun experience, and the first time I ever got to see a HF rig in operation. A representative for the UCF newspaper showed up, took some interviews, and I ended-up being quoted in the article. I can also be seen in the photo, if you look close enough (yellow square).

Being that amateur radio was something I got into independently (I didn't know anyone else with a license) I was (and still am) very isolated in the hobby. I'm really thankful I found the UCF ARC, even though it wasn't until I'd already been going to UCF for 2 years and was already on my way out. Seeing (and actually get to use) a HF rig was an eye-opening experience for me, and one I'm a little regretful I participated in. Before yesterday, I had already come to terms with my situation (going to dental school in a few weeks and virtually dropping all of my hobbies) and was content with my summer accomplishments so far. My summer goal was to get into radio, and before yesterday I felt I had. I studied for my exam, got my license, learned how to use repeaters on VHF to easily make local contacts, and I was satisfied. I knew HF was out there, and that it allowed communication over thousands of miles, but I ignored it knowing I wouldn't get into it this summer (the equipment is just too expensive for me to justify purchasing). Now, after sitting in front of a rig for several hours, I wish I had the time to upgrade my license, earn a little cash to blow on a HF radio, and spend a few weeks sitting in front of it scouring the waves for random voices around the world. I know it's a little morbid, but I'd probably have to compare the feeling I'm experiencing with what an old person feels like when they realize their end is near and that they won't be able to do the things they always dreamed they would. Oh well, at least I'll be able to fill holes in teeth soon. [smiles convincingly]

After the tents, antennas, and radios were mostly set up, everyone was exhausted. I was ready to make some contacts! I fired-up my 'ol netbook and tried communicating over 40m using psk (a digital mode), a mode I've never used, with software I've never used, on a band I've never used. It wasn't working either. I spent the first several hours in frustration because what I was trying to do wasn't working, and I couldn't figure out why. This photo was taken at the height of my frustration.

Markdown source code last modified on January 18th, 2021
---
title: Field Day 2009
date: 2009-06-29 14:05:32
tags: amateur radio
---

# Field Day 2009

__Last weekend was field day__, a disaster simulation / competition for amateur radio operators. In a sentence, people are encouraged to make as many contacts as they can around the world (earning points) using emergency radio preparations (battery and solar powered radios, temporary antennas, etc) for a full 24 hours (2pm to 2pm). I spent the time with the [UCF Amateur Radio Club](http://www.k4ucf.ucf.edu) who set up [big antennas](http://www2.mmae.ucf.edu/wiki/Image:Fd2008pract_1289.jpg) in a grassy field on campus. It was a fun experience, and the first time I ever got to see a HF rig in operation. A representative for the UCF newspaper showed up, took some interviews, and I ended-up being [quoted in the article](http://www.centralfloridafuture.com/ucf-club-participates-in-ham-radio-field-day-1.1770219). I can also be seen in the photo, if you look close enough (yellow square).

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

[![](scottpaper_thumb.jpg)](scottpaper.png)

</div>

__Being that amateur radio was something I got into independently (I didn't know anyone else with a license) I was (and still am) very isolated in the hobby.__ I'm really thankful I found the UCF ARC, even though it wasn't until I'd already been going to UCF for 2 years and was already on my way out. Seeing (and actually get to use) a HF rig was an eye-opening experience for me, and one I'm a little regretful I participated in. Before yesterday, I had already come to terms with my situation (going to dental school in a few weeks and virtually dropping all of my hobbies) and was content with my summer accomplishments so far. My summer goal was to get into radio, and before yesterday I felt I had. I studied for my exam, got my license, learned how to use repeaters on VHF to easily make local contacts, and I was satisfied. I knew HF was out there, and that it allowed communication over thousands of miles, but I ignored it knowing I wouldn't get into it this summer (the equipment is just too expensive for me to justify purchasing). Now, after sitting in front of a rig for several hours, I wish I had the time to upgrade my license, earn a little cash to blow on a HF radio, and spend a few weeks sitting in front of it scouring the waves for random voices around the world. I know it's a little morbid, but I'd probably have to compare the feeling I'm experiencing with what an old person feels like when they realize their end is near and that they won't be able to do the things they always dreamed they would. Oh well, at least I'll be able to fill holes in teeth soon. \[smiles convincingly\]

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

[![](me_thumb.jpg)](me.png)

</div>

After the tents, antennas, and radios were mostly set up, everyone was exhausted. I was ready to make some contacts! I fired-up my 'ol netbook and tried communicating over 40m using psk (a digital mode), a mode I've never used, with software I've never used, on a band I've never used. It wasn't working either. I spent the first _several_ hours in frustration because what I was trying to do wasn't working, and I couldn't figure out why. This photo was taken at the height of my frustration.

Pages