Gruenberger’s prime path

February 17, 2010 | Computer Science, Math | By: Mark VandeWettering

Here’s an interesting little mathematical morsel from the pages of the bit-player blog having to do with two topics I’ve found interesting in the past: prime numbers and random walks.

Let’s consider the sequence of prime numbers > 3. All such primes are congruent to -1 or to 1 modulo 6. So, let’s use that as the “random” variable controlling a random walk. If you consider all odd integers, you can generate a walk as follows. Take a step in the current direction. If the number is composite, you are finished. Otherwise it is a prime. If it is congruent to -1 modulo six, then turn left, otherwise turn right. You end up with a “random” walk, with several interesting questions about whether it shares properties with real “random” walks. Check the blog entry for more discussion:

bit-player » Gruenberger’s prime path.

I can visualize an interesting program written to draw these which is a modification to the segmented sieve algorithm that I’ve coded up previously. Each “segment” generates a segment of the overall path, and as long as you know the coordinates of the starting position, you can overlay and merge these points with reasonable efficiency. I might have to give that a go some time.

Addendum: In searching for more material by Gruenberger, I discovered that he was an early proponent of the educational uses of computing, and that some of his papers are available for download from the RAND corporation.

Real-Time Rendering Blog

February 16, 2010 | Computer Graphics | By: Mark VandeWettering

Back around 1984 or so, I first became interested in computer graphics. I was going to college at the University of Oregon, and we didn’t really have any graphics courses or any computers that you would think would be good at displaying graphics. Eventually they got a Tektronix 4115 terminal (which was huge, and cost about $20K in the day if memory serves), which I got hooked to our VAX 11/750, and I had my platform. I started to read and experiment with raytracing. Some early enthusiasm and guidance was provided over USENET by Eric Haines, who I must thank for helping inspire and inform me in those early years. Eric’s patience has shifted from being measured in Blinns to milli-Blinns now, and he’s authored a book called “Real-Time Rendering” and also maintains a very useful blog on the subject. Every once in a while, I glance over and realize that the world is changing, and I’m not keeping up. But if you want to keep up with developments, Eric’s blog will be a good place to start.

Real-Time Rendering · Tracking the latest developments in interactive rendering techniques.

Building an IOio satellite antenna – KJ6AKQ

February 15, 2010 | Amateur Satellite, Amateur Science | By: Mark VandeWettering

KJ6AKQ tackles a project I’ve been thinking about for quite a while: the construction of a little handheld satellite antenna:

Building an IOio satellite antenna – KJ6AKQ.

Broadcom.com – BroadVoice® Speech Codec Open Source C Code

February 14, 2010 | Amateur Radio | By: Mark VandeWettering

This month’s QST had a pointer to a potentially interesting voice codec that I hadn’t seen before. It appears that Broadcom has developed a voice codec, and released it under the terms of the GPL for royalty-free use. It’s actually two codecs: one at 32kbps, and the other at only 16kbps. I haven’t done much reading on them yet, but there are certainly a number of possible applications that I can think of where having open codecs like this would be useful. Unfortunately, we probably need a codec with a data rate more down in the 2400 baud range to make digital voice on VHF comparable to DStar, but it’s still interesting.

Check out the links:

Broadcom.com – BroadVoice® Speech Codec Open Source C Code.

Addendum: In listening to the voice samples, I must say that they seem quite good, although not perhaps any better than the already free Speex based codecs. It’d be interesting to do an apples/apples comparison of the two, but look at these Speex encoded examples which sound very good at approximately half the bitrates of the BroadVoice codecs.

Addendum2: K3NG mentions the “white elephant in the room” with respect to D-Star: namely that it uses a proprietary codec. I must admit that I’d probably own a D-Star radio if the speech codecs were open. I find it really annoying when amateur radio adopts techniques which are covered by patents: they serve only to protect business interests, and to discourage free experimentation and deployment of new radio techniques. If D-Star used a freely available audio codec, there would be less to keep other manufacturers from supplying compatible radios (they wouldn’t need to license technology or single source chips from a single manufacturer) and there would be a great deal more experimentation (echolink->D-Star gateways anyone?). As cool as D-Star is, I can’t help but think that we are sending the wrong message to equipment manufacturers by adopting them widely.

CQ WW RTTY?

February 13, 2010 | Amateur Radio | By: Mark VandeWettering

Looks like an RTTY contest is currently going on, and nothing is better for revealing band openings. I tuned up to 15m to see what was going on, and the normally quiet 15m band was alight with stations:

RTTY

Imagine what the band would look like if I had a real antenna!

Addendum: 20m is even more alight:

20mRTTY

The math of frequency demodulation…

February 13, 2010 | Amateur Radio | By: Mark VandeWettering

Here is the tiny clever bit from last night’s demodulation experiment using HF radiofax. For the purposes of this experiment, I record a single channel audio of the HF fax transmission. The audio is centered at an audio frequency of 1.9 Khz, and varies (except for start/stop pulses) between 1500 and 2300 Hz. I begin by band pass filtering using a filter designed with the applets you can find at this website, then split the signal into two halfs, and multiply one half by a sine at 1900 Hz, the other by a cosine at 1900Hz. This works just like a I/Q mixer in a software defined radio (in fact, it is just such a mixer). This frequency shifts the signal down so that now all signals occur between -400 and +400 hz.

From each pair of I, Q values, we can easily determine the squared amplitude of the signal (just I2 + Q2) or the instantaneous phase of the signal (atan(I/Q)) but we are interested in the frequency: the _change_ in phase between two samples. I’ve sen this derived before, but this way makes the most sense to me, so I thought I’d write it down.

Let’s consider two adjacent I/Q samples, I0 Q0 and I1 Q1. The question is, what is the angle that will rotate sample zero to sample one? Well, first, we must realize that they may differ in amplitude. We’re not concerned about their amplitude, so we might as well get to normalizing them. We simply divide them through by their length. That’s no problem. But then how do we compute the angle between them?

I chose to use the geometric interpretation of cross products to figure out the math. If we have two three-dimensional vectors, and compute their cross product, the resulting vector is perpendicular to both, and has length proportional to product of the length of the two vectors and the sine of the angle between them. In our case, our vectors seem like two-dimensional vectors, but let’s fix that simply: tack on an extra zero to each pair. They are now obviously both contained in the X-Y plane, we know that the normal is perpendicular to that plane so has zero components for both the X-Y entries, and the Z component contains all the interesting bits. In particular, we know that its proportional to the length of the two vectors (which are both one, since we normalized, and can be ignored) and the sine of the angle between them. Hence, we could just take the arcsine, and recover the angular change (which would be between -π/2 and &pi/2). We can then map this back into frequencies if needed (-samplerate/2 to +samplerate/2) or in our case, map that into grayscale values.

But surely you are balking at this ugly arcsine call in the middle of our program, aren’t you? Well, it’s not like we haven’t got CPU to burn. The implementation I have processes 15 minutes of recorded audio in just a few seconds, so even using an arcsine results in a program which is 100 times faster than realtime on current hardware. But you are right: it worried me a bit, so I scratched a little deeper. When you have sines and cosines in things, it’s often useful to use small angle approximations. These are derived from the Taylor series expansions for sine and cosine.





For small x (values near zero) cosine(x) is approximately one, and sine(x) is approximately x (just take the first term of each of the above equations. But, if sin(x) is just about x, that means that the asin(x) is just about x too. Thus, we can choose to not use asine at all, and instead just use the output of our cross product calculation as our frequency, and we might expect it to work just fine (it has range -1 to 1, whereas asin has range -π/2 to π/2, but the frequencies we are interested in are confined to a small portion of the audio spectrum anyway, so the error is likely to be minimal).

If you want, you could try to use more terms from the series for arcsine:



but in my experimentation, it made no difference in image quality.

Anyway, once you recover frequency, you want to map values from near -400 hz to black, and 400 to white. You need to normalize for sample rate, some clamping, and some resizing, and you are done. Okay, I haven’t covered rectification/slope correction, and the aspect ratio stuff is a bit tricky to get exactly right, but I’m still working on them.

Hope this wasn’t too boring.

Another try at an HF FAX decoder…

February 13, 2010 | Amateur Radio | By: Mark VandeWettering

About two years ago, I spent an evening and hacked together a simple program for taking recordings of HF-FAX transmissions and converting them into image files. The other day, I thought I’d dust that code off, but I couldn’t find it. So, instead, I reimplemented it from scratch. There is an interesting bit of math that I finally understood when I reimplemented it, which actually worked out rather well. I took a recording that I made of the New Orleans Coast Guard’s station broadcast, and it turned into this picture:

hffax

I’ll have to work a bit on the sync detection and scaling, as well as rectification, but it’s looking pretty good for the small amount of effort I’ve placed in it.

Google Chart Tools / Image Charts

February 12, 2010 | Amateur Radio | By: Mark VandeWettering

Wow, the Google Chart Tools api includes all sorts of interesting things you can do with a tiny bit of web programming. For instance, you can make charts or visualize maps, or even typeset nifty mathematical formulas. It isn’t hard to write little chunks of Python code that can be used to create little png images like this one:

tex

It’s late, so I am just placing this here as a placemarker, but I’ll use this more in the future.

Mathematical (TeX) Formulas – Google Chart Tools / Image Charts (aka Chart API) – Google Code

NAVTEX on 518khz

February 10, 2010 | Amateur Radio | By: Mark VandeWettering

I don’t have the right antennas or the best setup for decoding, but I can still occasionally hear some of the more local NAVTEX stations, and using MultiPSK (capable, but man, is that one program in need of a makeover) I managed to decode some of the alerts. Without further ado:

PACIFIC COAST HIGHWAY BRIDGE NAVIGATIONAL LIGHTS REPORTED 
INOPERATIONAL DUE TO A POWER OUTAGE. 

NNNN
BRK
ZCZC QA04
CCGD11 BNM D11 0110-10 
1. CALIFORNIA - GULF OF SANTA CATALINA 
OCEANSIDE DANGER BUOY (LLNR 2317) IS MISSING. 

NNNN
BRK
ZCZC QE42
DGPS BNM 133-10 
AUSTIN, NV DGPS BROADCAST SITE IS UNUSABLE AS OF 071145Z FEB 
10 UNTIL 
FURTHER NOTICE. 

NNNN
BRK
ZCZC QA64
CCGD11 BNM D11 0113-10 
1. CA-SAN CLEMENTE ISLAND 
HAZARDOUS OPERATIONS WILL TAKE PLACE AT THE FOLLOWING TIMES: 

 090800T-091200T FEB 10 
 101700T-102130T FEB 10 
IN AN AREA BOUND BY THE FOLLOWING COORDINATES: 
 32-55-00N  118-25-00W 
 32-55-00N  118-15-00W 
 32-45-00N  118-15-00W 
 32-45-00N  118-25-00W 
 TO POINT OF ORIGIN. 
MARINERS ARE ADVISED TO STAY CLEAR OF THIS AREA. 
2. CANCEL BROADCAST AT TIME//110530Z FEB 10// 

NNNN
BRK
ZCZC QA19
CCGD$1 BNM D11 0123-10 
1. CALIFORNIA - NEWPORT BAY 
NEWPORT BAY CHANNEL LIGHT 11 (LLNR 2470) HAS BEEN 
REPORTRD EXTINGUISHED. 

NNNN
BRK
ZCZC QA90
CCGD11 BNM D11 0115-10 
1. CA-SAN CLEMENTE ISLAND 
HAZARDOUS OPERATIONS WILL TAKE PLACE AT THE FOLLOWING TIMES: 

 100700T-101700T FEB 10 
 110700T-111700T FEB 10 
 120700T-120700T FEB 10 
IN AN AREA BOUND BY THE FOLLOWING COOODINATES: 
 32-55-00N  118-25-0-W 
 32-5--00N  118-15-0-W 
 32-40-00N  118-15-00W__
  2-20-_0PU  118-35-00W W
_  2-25-00N 111-35300WI_
 TOTP_INTIOFOF_ IRINJM 
MUMPNPNS ARZ AJBJSED TO A GAT_

Azimuthal Map Server

February 10, 2010 | Amateur Radio | By: Mark VandeWettering

An azimuthal map shows the compass direction for the shortest path to a given location from the place the map is centered. This can be useful to help you aim antennas. I’ve used GMT to make maps before, but if you need a custom azimuthal map for your location, try surfing over to NA3T and NV3Z’s website, and make yourself one.

AZ_PROJ at WM7D: Azimuthal Equidistant Great Circle Projection Map Server Postscript by NA3T and NV3Z.

Here is the low resolution GIF image of mine, I downloaded a PDF that I printed on our ncie color printer.

1265828041

You can see that Australia is mostly just south of west, Japan is northwest, and most of Europe is northeast. Interestingly, the tip of Africa is almost straight west, as is the panhandle of Florida.

WSPR on 15m today…

February 10, 2010 | Amateur Radio | By: Mark VandeWettering

Today is Wednesday, which means that it’s a day for trying different bands on WSPR. Today is scheduled to be 15m, which I have never tried before. I immediately saw a few RTTY stations below the WSPR sub band, which was a good sign, and two minutes later, I had my first spot, and it was a good one: EA1FAQ in grid IN71op, in Central Spain. If you have the capabilities, tune your WSPR stations onto 15 and see what you can get!

End of an Era, and The Start of a New One

February 9, 2010 | Rants and Raves | By: Mark VandeWettering

I normally read the blog of W9OY for its ham radio content, but this morning he waxed poetical on the impending cessation of human space flights here in the United States. His vantage point in sight of the Vehicle Assembly Building at the Cape make it especially poignant for him.

Software Defined Ham Radio: End of an Era.

First of all, I’m a child of the Apollo era. I remember watching launches on our old Zenith black and white. I remember dashing home from Church at age 5 to hear news of the Apollo 11 lander. My interest in science and technology was fueled by the fires of Apollo, and the idea that they could be harnessed to achieve great things for all mankind. After setting foot on the moon, who knew what the actual limit of mankind would be?

But for all that, I’m not especially broken up about the cessation of human space flights. The reasons are essentially three fold:

First, there is a cost/benefit ratio. Sending humans into space costs money, and a lot of it. Humans are capable of performing some tasks in space which are impossible for current machines (like the Hubble reservicing), but were servicing not a possibility, the money spent on it would have been channeled into other areas, perhaps equally as fruitful for scientists. Compare the budget for reservicing the HST to the total cost for the twin Keck telescopes on Mauna Kea. It is much simpler to design satellites when freed from the need to keep the soft, squishy humans inside within the a gassy envelope of the proper temperature, within G limits, and shielded from damaging radiation.

Secondly, NASA funding has essentially become a source of pork barrel jobs. Congress hands out funding not because of any particular dedication to space travel, or the development of new technologies, but because for some of them the money they hand out buys jobs in their districts, and those jobs mean re-election. Every president since Kennedy has given flowery speeches about the importance of “sending men to the stars”, and frankly they’ve all been insincere. The reality is that NASA was a vast employer, and keeping those jobs going meant political stability for the Congressmen and Senators who were the beneficiaries of this federal generosity.

Lastly, I believe that if we are to have a lasting presence in space, it must be driven by economic factors. We have lauded the pioneers of the American West as bold innovators and frontiersmen, but for the most part they were people who saw an economic opportunity that didn’t exist where they were. They left their jobs to homestead a farm, or to search for gold, or just to sell goods to those that did. The federal government didn’t manufacture this opportunity. The next stage of space exploration will be fueled by the economic opportunities exploited by individuals and companies.

I’ve visited the VAB. I’ve seen the Saturn V, and thrilled to the multimedia presentations on the Apollo 11 in their visitor’s center, which reminded me of the thrill I had at age five. Heck, I’ve even had my salary paid as part of a NASA grant back when I was in graduate school over twenty years ago. But with 40+ year history of manned space flight, a grand total of about four hundred fifty people have been in space. 18 Americans and 4 Russians died there (about 5% of those launched).

It is likely that no reasonable economic case can be made for men in space until the costs are reduced by at least one and maybe two orders of magnitude and the safety of spaceflight increased by similar orders of magnitude. That sounds difficult, but those numbers are not significantly different than the increase in reliability in conventional air travel over the last three quarters of a century. The government played a role in this, but it didn’t have to own airlines to do so. I suspect it will be the same with human spaceflight. Companies like Scaled Composites and Virgin Galactic and probably ones that have not even been formed yet will lead the way for humans to go back to space.

And, quite frankly I think we have bigger things to worry about down here on earth. Things like health care for the sick. Like education. Like feeding the hungry. Do we really want to spend billions putting a few more humans in orbit when there are so many pressing issues that Americans (and indeed, the people of the world) face every single day?

From JFK’s Inaugural Address:

To those peoples in the huts and villages across the globe struggling to break the bonds of mass misery, we pledge our best efforts to help them help themselves, for whatever period is required—not because the Communists may be doing it, not because we seek their votes, but because it is right. If a free society cannot help the many who are poor, it cannot save the few who are rich.

Indeed.

Measurements of my 40m dipole…

February 8, 2010 | Amateur Radio | By: Mark VandeWettering

I hooked up my MFJ antenna analyzer to my dipole, and wrote down the R and X measurements (resistance and reactive impedances) from 7.0 to 7.35Mhz. WIthout further comment, here is the graph.

40m

Morse Timing

February 8, 2010 | Amateur Radio | By: Mark VandeWettering

While working on my Morse practice generating program that I have tentatively called mscript, I decided that I wanted to support “Farnsworth” timing: basically sending characters at one rate, but then increasing the spacing between characters and words so that the overall rate was slower. The idea (as near as I can tell, completely untested but still probably sensible) is that by learning the sound of characters at a fast rate, you don’t plateau as readily.

It isn’t hard to figure out the timing of traditional Morse code: A dit lasts one time period. A dash is three times as long. All elemtents (dots and dashes) within a character are separated by one period. Characters are separated by three periods. Words are separated by seven periods. Using this, the word “PARIS” takes 50 time periods, so the length of each period is 1200 / WPM milliseconds when WPM denotes the desired speed in words per minute.

But how does his timing change with the Farnsworth spacing? Well, inside a given character, the timing all remains the same. We’d like to extend intra and interword spacings to slow the overall code down to a different rate. We’d also like to preserve the 3/7 ratio between those two intervals. The math was eluding me, so I did what all people do when they don’t know the answer to a question: I looked it up on the internet. And of course, if you ask the right question, you get the right answer. Mine came in the form of an article by Jon Bloom, KE3Z that appeared in QEX entitled A Standard for Morse Timing Using the Farnsworth Technique which you can get from the ARRL archive here if you are a member.

But if you can’t, here are the formulas. Let’s say that you are specifying the Farnsworth in terms of a ratio s/c, where s is the overall (slower speed) and c is the character speed in WPM. You then compute

ta = (60 c – 37.2 s) / (s * c)
tc = 3 * ta / 19
tw = 7 * ta / 19

where tc and tw are the times (in seconds) that you have between characters and words respectively.

I’ll get this hacked into mscript shortly, and post an example.

Addendum: I’ve got the code added into mscript. Here are two samples of six random five-letter groups, sent first at 20wpm, and secondly sent at 20wpm, but with character spacing increased to slow the overall rate to 10wpm.

An example of both conventional timing and Farnsworth timing.

40m dipole not really tuned for 40m… or is it?

February 8, 2010 | Amateur Radio | By: Mark VandeWettering

A while ago, I bought an MFJ antenna analzyer, but I hadn’t really done much with it. I wanted a short, simple project over the weekend, so I decided to check out my 40m dipole. A quick sweep revealed that it was resonant off the top end of 40m, around 7.350 or so, and that down at the bottom end of the CW portion of the band, it was about a 3:1 SWR. I’ll take better notes later tonight when I get home, and maybe even produce a small graph.

This dipole is actually a premanufactured one from radiowavz.com. It’s just a basic 40m dipole with balun, fed by 50 ohm coax. In my case, its mounted quite low: Its about 20 feet off the ground at one end, but it is tied to a short tree up my hill. so the middle is maybe 10 feet above ground, and the far end maybe only 6 feet.

So, the open question is: will raising the far end of the antenna lower its resonant frequency? Or is the antenna just cut wrong for the CW portion of the band?

Bets anyone?

Addendum: This website does show that as the antenna gets lower, the feedpoint impedance drops significantly, and also shows that dependent on height, the resonant frequency of the antenna can vary by more than 100khz. This suggests (unsurprisingly) that I should try to mount this antenna higher to provide an easier match in the 40m band. It also suggests that measuring an antenna close to the ground isn’t a good idea.