Well, one of the advantages of getting a new Windows 7 laptop is that I now have a much nicer environment for running LTSpice. Does anyone have any ideas of a good, simple project that I could do to help me learn the ropes of LTSpice, and which I could also build for real to test my understanding? Perhaps something like a VFO + buffer amplifier + power amplifier chain, that could be done in steps? The simple transmitter in EMRFD would seem to be a reasonable choice, but the oscillator is crystal controlled, and I’ve heard that LTSpice can have some difficulty simulating these kind of “high Q” circuits.
Left my FT-817 beaconing for the last 48 hours or so, mostly on 40m, and got some interesting DX, including someone I think I never reached before, KG6DX in Guam.
Courtesy of Zeid, I finally got an invite to use Google Voice. I’ll write more about this when I figure more about it, but at a minimum, it gives you a real phone number (amazingly, for free) which anyone can call and leave voice mail. You can configure it to ring a different phone (say, your cell phone) or send it directly to voicemail. You can access your voice mail in the conventional way, or by using a computer online. It even automatically transcribes the message into text! Very cool, and thanks Zeid for hooking me up.
Here’s an example of what you can do. This is a little flash widget. If you click on it, you can type your own name and a number that you can be reached at. Google will then call you back and hook me to my voicemail (or, if I configured it differently, ring my cell). Give it a try if you like. I’m just starting this, and it seems that you can’t select the “Conceal my number” checkbox if you want this to work. It also won’t work from international numbers.
Addendum: Here is an example of what Google Voice can do with a voicemail message.
I’ve been a long time fan of FreeBSD, going all the way back to the 1.1.5.1 days (and used regular BSD going back even further). Today, I still have a server which runs FreeBSD, as well as another desktop which is running Ubuntu. Which one I prefer is not really something I choose to argue (or even spend much time thinking about) but I did notice that FreeBSD 8.0 was just released.
Well, I finally dug up all the cables I needed and hooked up my little HP netbook to my radio again, and got it going with the new WSPR 2.0 software. As of this moment, I’m beaconing out at 5w on the traditional 30m watering hole, and getting pretty good domestic spots. I might try shifting to a different band a bit later in the day (maybe 15m, I’ve been curious about how good 15 has been lately).
John, K8YSE recorded a North American pass of SO-67 (the new South African ham satellite) and posted the audio on his website. It appears the audio quality is actually pretty good. I’ll have to be trying it out fairly soon.
Okay, I woke up this morning, and decided to code up a version of a MasterMind solver. About fifteen minutes later, I had this tremendously slow implementation, which nevertheless seems to solve patterns very pretty quickly (averaged just 4.71 guesses in the short run of 100 trials that I just ran. It’s tremendously slow though, for reasons which I should have guessed before I wrote it. Nevertheless, it does work fast enough that if you wanted to write a Mastermind solver, it would work just fine.
Here’s the idea. Start by simply trying to guess the code by picking one at random. Assuming that you didn’t win, you need to generate a new guess. Let’s generate one and pretend that it was the secret. If you evaluate it against all the previous guesses you make, it would need give the same results. If it doesn’t, it can’t be the secret, so don’t use it as your guess. Try a different one.
That’s it. Of course the reason it’s slow is that when you get to the end, very few of the random choices you’ll make will match all the previous results (there are 1296 possibilities in the 6,4 version of classic Mastermind), so you might have to try lots and lots and lots of guesses before you find the consistent one. The better way would be to use a list of all possible codes, and strike out the ones in each round that are inconsistent with the previous guesses. Then you can select among all consistent codes. I’ll write up that optimization shortly, which should speed up the code by several hundred times. But this one does work… check it out.
#!/usr/bin/env python
#
# A naive implementation of the game MasterMind, to test some ideas
# that I learned in a brief scan of some of the known literature.
#
import random
from sets import Set
# traditional Mastermind uses six different colors, not exactly certain
# what they were, so I chose Red/Yellow/Blue/Orange/Green/Purple...
colors = ['R', 'Y', 'B', 'O', 'G', 'P']
# generate a random secret code (or guess)
def randomcode():
return ''.join([random.choice(colors) for i in range(4)])
def evaluate(guess, secret):
b, w = 0, 0
gs, ss = Set([]), Set([])
for i in range(4):
if guess[i] == secret[i]:
b = b + 1
else:
gs.add(guess[i])
ss.add(secret[i])
return b, len(gs.intersection(ss))
def solve(secret):
history = []
guess = randomcode()
nguesses = 1
while True:
b, w = evaluate(guess, secret)
history.append((guess, b, w))
print guess, b, w
if b == 4:
break # we solved it...
# generate a new random guess, consistent with
# all the previous guesses.
nguesses = nguesses + 1
while True:
guess = randomcode()
consistent = True
for g, b, w in history:
nb, nw = evaluate(guess, g)
if nb != b or nw != w:
# nope, not consistent
consistent=False
break
if consistent:
break
print
return nguesses
ROUNDS = 100
totalguesses = 0
for x in range(ROUNDS):
totalguesses = totalguesses + solve(randomcode())
print "average number of guesses was %.2f" % (float(totalguesses)/ROUNDS)
Addendum: I coded up the optimization that I mentioned above, and it seemed not to help that much. Run time dropped from 21 seconds to 17 or so. Not very good. Perhaps I don’t know what’s going on here. Then again, I still haven’t had any caffeine this morning, so perhaps my puzzler isn’t quite up to speed yet.
Dan Lyke of flutterby drew my attention to the astrometry pool on Flickr. If you upload an astrophotograph to this group, a process comes by later and tries to identify the stars in your image, and adds annotations and labels to it. Very nifty. Check it out. Try clicking the image above, and it will send you to the Flickr page with the annotations.
Back in 2005, I wrote a little blog post about creating stereo images with the GIMP along with a screencast. Little did I know that a couple of years later, I’d end up learning far more about stereo imaging when I became the stereo rendering lead for Toy Story and Toy Story 2. This post has circulated back to the sidebar in my “years ago on this date” section, so I thought I’d resurrect this video (the links were broken) and even though it is dated, it’s still pretty good information, so check I thought I’d upload it to blip.tv (I would have done Youtube, but it’s 11 minutes long, and Youtube rejected it) and make it available again. Enjoy!
It’s been a while since I posted a link to anything related to home made musical instruments, so when I ran across this page this morning, I thought of my friend Tom and his love of quirky instruments, and decided to pass it along. Papa’s Boxes sells both kits and completed ukuleles and banjos made from cigar boxes. Pretty neat folk instruments. Check it out.
Addendum: Of course any mention of building your own transistors would be remiss if it didn’t mention hacker-savant Jeri Ellsworth. She did an amazing job fabricating her own semiconductor devices, and in this video from Metalab, explains some of the basics.
While listening to the “This Week In Amateur Radio” podcast this morning, I heard reference to a new record setting non-line-of-sight one way contact that took place over optical wavelengths. A sucessful transmission over a distance of 288 kilometers was achieved by using an LED based transmitter. The report (PDF) provides many interesting details, such as their use of a GPS locked sound card to permit received signals to be resolved to just a milliHertz or so. Nice!
Here is some video of the transmitter in action. The floodlight that you see is generated by an array of 60 Luxeon LEDs, collimated by Fresnel lenses. Each LED is about 3.3 watts. Pretty cool.
Back in 2008, I blogged about a stupid program I wrote to implement a Morse Beacon on the Arduino. I couldn’t find that code, and it was stupid anyway, so I went ahead and implemented a new version, with an added improvement: it doesn’t hardcode dots and dashes, it has a built in table. Right now, the message is hardcoded into the program, but in the future, I’ll probably work up a trivial command language so you can change the message and speed, and store the message in the on-chip eprom. On the other hand, doing it by modifying the program source code isn’t really very much harder than getting a terminal to talk to your Arduino (it might even be easier) so this still might be the best way.
Basically, this just puts a logic high state on output pin #13 whenever the keydown should occur, and low when it is released. My Arduino is one of the older ones, so I needed to put an LED in myself, but I understand more modern ones have a built in LED. You could use whatever output pin you like though, with the obvious modification. To turn it into a full fledged keyer, you just need a transistor to handle the switching. On this model of Arduino, pin 13 has a 1K resistor in series to current limit, so you should just be able to put in any NPN transistor (base in pin 13, emitter to ground) and then use the collector/emitter to key the transmitter (I might also think about using an optoisolator, just to be safe).
This is overkill in a lot of ways: the program, sloppily as it is written only takes about 1/7 of the memory on my Arduino, and modern ones have double the space. We could do the same with a very small Atmel. But Arduinos are available and versatile, and have considerable potential. Worth playing with.
//
// Simple Arduino Morse Beacon
// Written by Mark VandeWettering K6HX
// Email: k6hx@arrl.net
//
// This code is so trivial that I'm releasing it completely without
// restrictions. If you find it useful, it would be nice if you dropped
// me an email, maybe plugged my blog @ https://brainwagon.org or included
// a brief acknowledgement in whatever derivative you create, but that's
// just a courtesy. Feel free to do whatever.
//
struct t_mtab { char c, pat; } ;
struct t_mtab morsetab[] = {
{'.', 106},
{',', 115},
{'?', 76},
{'/', 41},
{'A', 6},
{'B', 17},
{'C', 21},
{'D', 9},
{'E', 2},
{'F', 20},
{'G', 11},
{'H', 16},
{'I', 4},
{'J', 30},
{'K', 13},
{'L', 18},
{'M', 7},
{'N', 5},
{'O', 15},
{'P', 22},
{'Q', 27},
{'R', 10},
{'S', 8},
{'T', 3},
{'U', 12},
{'V', 24},
{'W', 14},
{'X', 25},
{'Y', 29},
{'Z', 19},
{'1', 62},
{'2', 60},
{'3', 56},
{'4', 48},
{'5', 32},
{'6', 33},
{'7', 35},
{'8', 39},
{'9', 47},
{'0', 63}
} ;
#define N_MORSE (sizeof(morsetab)/sizeof(morsetab[0]))
#define SPEED (12)
#define DOTLEN (1200/SPEED)
#define DASHLEN (3*(1200/SPEED))
int LEDpin = 13 ;
void
dash()
{
digitalWrite(LEDpin, HIGH) ;
delay(DASHLEN);
digitalWrite(LEDpin, LOW) ;
delay(DOTLEN) ;
}
void
dit()
{
digitalWrite(LEDpin, HIGH) ;
delay(DOTLEN);
digitalWrite(LEDpin, LOW) ;
delay(DOTLEN);
}
void
send(char c)
{
int i ;
if (c == ' ') {
Serial.print(c) ;
delay(7*DOTLEN) ;
return ;
}
for (i=0; i<N_MORSE; i++) {
if (morsetab[i].c == c) {
unsigned char p = morsetab[i].pat ;
Serial.print(morsetab[i].c) ;
while (p != 1) {
if (p & 1)
dash() ;
else
dit() ;
p = p / 2 ;
}
delay(2*DOTLEN) ;
return ;
}
}
/* if we drop off the end, then we send a space */
Serial.print("?") ;
}
void
sendmsg(char *str)
{
while (*str)
send(*str++) ;
Serial.println("");
}
void setup() {
pinMode(LEDpin, OUTPUT) ;
Serial.begin(9600) ;
Serial.println("Simple Arduino Morse Beacon v0.0") ;
Serial.println("Written by Mark VandeWettering <k6hx@arrl.net>") ;
Serial.println("Check out my blog @ https://brainwagon.org") ;
Serial.println("") ;
}
void loop() {
sendmsg("K6HX/B CM87") ;
delay(3000) ;
}
Addendum:
Addendum2:
Josh asked me how the morse code table works. It’s a little bit clever (a very little bit) but I guess it does require some explanation. Morse code characters are all length six or less, and each element is either a dot or a dash, so it would seem that we can store the pattern in six bits. Let’s say that dits are zero and dahs are one. Lets store them so the first element gets stored in the least significant bit, and the next in the second most, and so on. The only trick is knowing when there are no elements left, because otherwise we can’t tell (for example) K (-.-) from C (-.-.) To do that, we store a single extra one after all the other elements are taken care of. Then, when we are looping, we do the following. If the pattern is equal to one, we are done (that’s our guard bit). If not, we look at the least significant digit. If it is a zero, we have a dit, if we have a one, it’s a dah. We then get rid of that element (by dividing by two, or shifting right if that floats your boat) and repeat. Voila. Each character takes only a single byte to store its pattern, and decoding is just done in a few instructions.
Hope that helps.
Addendum3: Well, I couldn’t leave that alone, witness this…
There are many examples that people use to output sound, most of which seem to bang an output pin high or low, call delay to wait a given number of microseconds, then change its state. This seems odd to me, because the Arduino has some pretty good pulse width modulation. This can be used to make higher quality sound, but for me, it also proved to be easier. I just configured pin 9 to be an output pin, and then used analogWrite(9, 128) to turn on the sound, and analogWrite(9, 0) to turn the sound off. That’s it! You get about a 500hz tone, and it works really well.