Monthly Archives: August 2010

Making a soft-circuit input device for your computer

I’m intrigued by various uses for embedded processors, and so are my readers. I hadn’t seen this particular microcontroller board before, the “Teensy”, which is very similar to the Arduino, except that it is uses an ATMEL AVR chip with a direct support for USB. The link also points at a nifty interface to “soft circuit” elements, which probably has some nifty controller applications.

Make: Online : Making a soft-circuit input device for your computer.

Thoughts on the Google/Verizon net neutrality proposal…

I’ve had a few days to sit and think about the proposal that Google and Verizon have published, and I think it is time to write some of it down. If nothing else, in the future it will provide me perspective in future years, as August 12th rolls around each year, this post will circulate back to the top and I can see how prescient I was.

First of all, if you haven’t read it, you probably should. It’s only a couple of pages, so surf on over and give it a read. I’ll still be here when you get back.

Verizon-Google Legislative Framework Proposal

Okay, did it leave you with an uneasy feeling? It did me. Most of the people I respect seem to think that I should feel uneasy, but a select few seem to think that I’m overreacting. I am not sure which is right, but I’ll let you know what my specific qualms are, and then follow it with a few general comments.

First of all, the section on Consumer Protections qualifies that broadband Internet service providers should not prevent users from accessing “lawful content of their choice” or “running lawful applications and using lawful services of their choice”. IANAL, but I’m a little troubled by this concept of “lawful content” or “lawful applications”. Lots of people are whining about this provision, presumably because it prevents them from downloading copyrighted material on the Internet. I’m a bit concerned by this, because it gives the ISP a convenient excuse for nearly any modification of internet access: “we are trying to prevent trafficking of copyrighted materials”.

The section on Network Management is similarly a bit strange. I agree that ISPs need to be able to efficiently run their networks in an efficient manner, but I am a bit concerned at the idea that “any technically sound practice” can be used, without any guidance as to the underlying principles that must be followed. A technically sound practice might include simply disconnecting the top 1% of the bandwidth users to mitigate connection problems. It might even be agreed to by the majority of service providers, but it isn’t necessarily the right choice for consumers. I think it is entirely reasonable to allow ISPs to limit the total bandwidth or capacity, or to price their service according to bandwidth used, but not to pick and choose which services or which users are “managed” out side of those basic constraints.

But the section that really disturbs me is the “differentiated services”. I wonder really what those differentiated services are, and they were very coy in their proposal. Some people might think that delivering VOIP over the internet is a “differentiated service”. Or running an FTP server. Or downloading Netflix. Applications to your mobile phone. All of these things were “distinguishable in scope and purpose from broadband Internet” at some point, but now are part and parcel of what people use the Internet for every day. I cannot help but think that this is an attempt for ISPs to carve out special exceptions for neutrality on new services so that they have a preferred track to sell such services and prioritize them over the more “traditional” Internet services. This is bad for competition, and bad for consumers.

I’m also troubled by the desire for an exemption for wireless networks. There is simply no rationale given, merely the assertion that they have “unique technical and operational characteristics”, so the requirement of transparency would be required for operation over the wireless networks. I can imagine that the cellular phone networks are very happy with this provision, since they already run some of the least consumer-friendly and most lucrative networks available, and this provision is essentially carte-blanche to permit or deny any service on their networks that they like. They would have the power to be the kingmakers of the wireless internet, purely by allowing or denying companies access to consumers.

Okay, those are pretty specifically the parts that annoy me. In the end, we give up network neutrality on wireless networks, we grant the ISPs the power to differentiate their networks by selling differentiated products and we have to deal with consumer agencies who are asked to fill a law enforcement role (or who can at least hide behind it as an excuse for nearly arbitrary changes in service). We also agree to allow the industry players to decide what practices can be used to solve their networking problems. And in return consumers get….? Greater transparency, okay. And the ability to ask the FCC to investigate on a case by case basis any abuses, but without any additional rulemaking power.

I’m underwhelmed. I think you should be too.

Google is partnering with Verizon on this proposal, and I think we as consumers should be skeptical of this. After all, the wireless industry engages in all sorts of activities which are terrible for consumers, and which are antithetical to the principles that allowed the vibrant Internet growth of the last decade or more. Wireless companies uniformly try to lock consumers into long term contracts, with high penalties for early cancellation, and often include excessive activation fees for account changes. Consumers often have no protection against accidental overages, or must pay (again) excessive charges to prevent overages. Consumers pay high fees for SMS messaging, despite the nearly neglible costs associated with sending SMS because of the incredibly low amount of information sent. Consumers have to deal with phones which are locked by vendors to prevent a consumer from leaving a particular network and going to a competitor. Consumers cannot get any information about the delivered call quality, or the percentage of dropped calls.

The Verizon-Google proposal talks about the “increased competition” in the wireless arena, but even though there are probably three or four carriers that might reasonably be used in an area, often the effective number is only two or even one major carrier. When you combine this with the long contracts and high penalties for switching, this presumed “competition” simply vanishes.

Consider AT&T’s most recent filing with the SEC. As part of that filing, they had to list the risk associated with the possibility of losing the relatively lucrative exclusivity agreement with Apple and the iPhone. They downplayed this risk in a number of ways, including statements like:

As these exclusivity arrangements end, we expect to continue to offer such handsets (based on historical industry practice), and we believe our service plan offerings will help to retain our customers by providing incentives not to move to a new carrier. As noted above, more than 80 percent of our postpaid subscribers are on Family Talk® Plans and business plans that would involve moving the whole group to a new carrier. Moreover, the vast majority of our postpaid subscribers (including Family Talk® Plan users) are allowed to accumulate unused minutes (known as rollover minutes), a feature that is currently not offered by other major post-paid carriers in the United States, and users would lose these minutes if they switched carriers. As is common in the industry, most of our phones are designed to work only with our wireless technology, requiring customers who desire to move to a new carrier with a different technology to purchase a new device. In addition, many of our handsets would not work or would lose some functionality if they were used on another carrier’s network (even a carrier using GSM technology), requiring the customer to acquire another handset.

The cynic in me reads this as “the majority of our customers won’t switch because our industry has made it painful and costly to switch”.

Okay, so what is my answer? I think that we need clear separation between carriers and service providers. Carriers should not be allowed to sell services or differentiate traffic with respect to source or application. They should be required to be transparent. They should be permitted to sell Internet bandwidth in ways which allow customers to pay for the bandwidth and latency that they need. Consumers should have portability of devices, and be protected against absurd overages and upgrade fees. And the future Googles and Facebooks of the world shouldn’t be stifled by Verizon and AT&T.

Okay, back to work.

HOWTO make a simple HTTP server…

It’s occasionally useful to have a basic HTTP running to serve the files in a directory. You might want to fetch some MP3 or movie files from one machine, or in my case, a PDF document that I’m hacking on my Linux box while ssh’ed in from my Windows laptop. In the past, I have used Jef Poskanzer’s mini-httpd, but there is an even simpler way, especially if you already have Python installed.

Just “cd towhatever directory”, and then type “python -m SimpleHTTPServer”. Voila! An HTTP server running, bound to port 8000 on that machine.

Very useful.

Zounds! Sounds!

Tom and I have been discussing some early hacking efforts, probably spawned in part by my re-reading of Levy’s Hackers. A couple of days ago, this resulted in me pondering the mysteries of Minsky’s circle algorithm (still ongoing), but today it drove me to an early interesting sound algorithm documented in the legendary HAKMEM, ITEM 168, which shows a simple six instruction program that generated sounds on the PDP-1. The basic idea was pretty simple: we have two variables, A and B. Read the front panel switches from the PDP-1, and add it to A. Then take the contents of A, apply a bit-wise AND from a mask, and then add that to B. Mask off the high bit of B, and output that as the “music”. (Note: I am a bit confused by ITEM 168. The PDP-1 code there doesn’t seem to be exactly what I described, but the mnemonics they list are somewhat unfamiliar to me. In any case, the rough English description above will suffice for now…)

In any case, I didn’t have a PDP-1 lying around, so I decided to implement the thing in C, using portaudio and the GNU readline library. Here’s the code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <readline/readline.h>
#include <sndfile.h>

/*                  __             
 *    ___  ___ ____/ /__  ___  ___ 
 *   / _ \/ _ `/ _  / _ \/ _ \/ _ \
 *  / .__/\_,_/\_,_/\___/\___/ .__/
 * /_/                      /_/    
 *
 * A simple musical toy inspired by some discussions on early computer 
 * music with Tom Duff, written by Mark VandeWettering.
 * 
 * THE BASIC IDEA
 * Tom informed me that someone generated odd musical tones with a 
 * very short program on the PDP 1 that basically looked like this:
 * 
 * for (;;) {
 *    a += sw ;         some front panel switches
 *    b += a & mask ;   mask just selects some part of a...
 *    output(a>>30) ;   output a single bit square wave... 
 * }
 * 
 * So that's what this toy emulates.   
 * 
 * I've also added a tiny bit of interface to allow you to change the 
 * switch settings and the mask on the fly, to "play" the instrument.
 * 
 * I've called this program "padoop" just because I needed some vowels
 * added to "PDP".
 * 
 * Tom points out that it wouldn't be hard to implement this in 
 * hardware, completely without a processor.
 */

#include <stdint.h>
#include <portaudio.h>

#define SAMPLE_RATE     44100

typedef struct {
        uint32_t        a, b ;
        SNDFILE         *sf ;
} paMusicData ;

uint32_t        SW ;
uint32_t        MASK ;

/* 
 * Here is a very simple output filter designed by Fisher's mkfilter code.
 */

#define NZEROS 2
#define NPOLES 2
#define GAIN   3.414213562e+00

static float xv[NZEROS+1], yv[NPOLES+1];

float
filter(float inp)
{
    xv[0] = xv[1]; xv[1] = xv[2]; 
    xv[2] = inp / GAIN;
    yv[0] = yv[1]; yv[1] = yv[2]; 
    yv[2] = (xv[0] + xv[2]) + 2 * xv[1]
        + ( -0.1715728753 * yv[0]) + ( -0.0000000000 * yv[1]);
    return yv[2];
}

static int
paMusicCallback(const void * inputBuffer,
                void * outputBuffer,
                unsigned long framesPerBuffer,
                const PaStreamCallbackTimeInfo * timeInfo,
                PaStreamCallbackFlags statusFlags,              
                void * userData)
{
    paMusicData * data = (paMusicData *) userData ;
    float *out = (float *) outputBuffer, *op ;
    float f ;
    int i ;

    op = out ;
    for (i=0; i<framesPerBuffer; i++) {
        data->a += SW ;
        data->b += data->a & MASK ;
        *op++ = filter((data->b&(1L<<31))?1.0:-1.0) ;
    }

    if (data->sf != NULL) sf_write_float(data->sf, out, framesPerBuffer) ;

    return 0 ;
}

void
process_command(char *cmd) 
{
    uint32_t tmp ;

    if (strlen(cmd) > 0)
        add_history(cmd) ;
    if (strcmp(cmd, "p") == 0 || strcmp(cmd, "print") == 0) {
        fprintf(stderr, "sw 0x%08X\n", SW) ;
        fprintf(stderr, "mask 0x%08X\n", MASK) ;
    } else if (sscanf(cmd, "sw %i\n", &tmp) == 1) {
        SW = tmp ;
        fprintf(stderr, "sw 0x%08X\n", SW) ;
    } else if (sscanf(cmd, "mask %i\n", &tmp) == 1) {
        MASK = tmp ;
        fprintf(stderr, "mask 0x%08X\n", MASK) ;
    }
}

main()
{
    PaStream *stream ;
    paMusicData data ;
    PaError err = Pa_Initialize() ;
    uint32_t m1, m2 ;
    if (err != paNoError) goto error ;
    SF_INFO sfinfo ;

    data.a = data.b = 0 ;
    /* log output data to a file... */

    sfinfo.samplerate = SAMPLE_RATE ;
    sfinfo.channels = 1 ;
    sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ;
    data.sf = sf_open("padoop.wav", SFM_WRITE, &sfinfo) ;

    SW = 012345 ;
    MASK = 0x0f0f0f0f ;

    /* open the music output device... */
    err = Pa_OpenDefaultStream(&stream,
        0,              /* no input */
        1,              /* just one output */
        paFloat32,      /* output float data */
        SAMPLE_RATE,    /* at some sample rate */
        8192,           /* samples per frame */
        paMusicCallback,
        &data) ;

    if (err != paNoError) goto error ;

    /* start */
    err = Pa_StartStream(stream) ;
    if (err != paNoError) goto error ;

    for (;;) {
        char * line = readline("padoop> ") ;
        if (line == NULL) break ;
        process_command(line) ;
        free((void *) line) ;
    }
 
    err = Pa_StopStream(stream) ;
    if (err != paNoError) goto error ;

    sf_close(data.sf) ;

    err = Pa_Terminate() ;
    if (err != paNoError) goto error ;
    exit(0) ;

error:
    fprintf(stderr, "PortAudio error: %s\n", Pa_GetErrorText(err)) ;
    Pa_Terminate() ;
    exit(-1) ;
}

You’ll need to have the portaudio and readline libraries installed to me it work. When you run it, it should start making noises, and you’ll see a command line prompt. It accepts 3 commands: “print” which dumps the contents of the mask and switches, “sw” followed by a number, which sets the value of the switches, and “mask” followed by a number, which does the same for the mask. Give it a try.

Addendum: Try “sw 4096” and “mask 0xFF0F0000”. Let it run for a while. If you find some interesting settings, post them in comments.
Addendum2: I included a fairly soft output filter to round the square waves a tiny bit. I’m not sure it makes any difference at all.
Addendum3: I made a version of padoop that also logged the output audio to a WAV file, so even if you can’t compile it, you can hear some of the sounds it might make.
Output from Padoop, my PDP-1 inspired music program…
Another bit of output…
Addendum4: While editing, I got some of the escaped characters screwed up, so I reinserted with the latest version. It automatically outputs a padoop.wav file of all the output that the program creates.

Drawing “circles” ala Marvin Minsky…

In my re-reading of Levy’s book Hackers, I was reminded of an interesting bit of programming lore regarding an early display hack that Marvin Minsky did for circle drawing. It’s an interesting hack because the lore was that it was originally coded by mistake, and yet the result proved to be both interesting and even useful. I first learned of this years ago when Blinn did an article on different ways to draw a circle, but also learned that it was part of the MIT AI memo called “HAKMEM”. Here’s the basic idea:

One way that you can draw a circle is to take some point x, y on the circle, and then generate new points by rotating them around the center (let’s say that’s the origin for ease) and connecting them with lines. If you have a basic understanding of matrix math, it looks like this:

/ x' \   /  cos theta  sin theta \ / x \
|    | = |                       | |   |
\ y' /   \ - sin theta cos theta / \ y /

(I should learn how to use MathML, but you hopefully get the idea). The matrix with the cosine and sine terms in it is a rotation matrix which rotates a point around by the angle theta. Apparently Minsky tried to simplify this by noting that cos(theta) is very nearly one for small theta, and that sin(theta) can be approximated by theta (we can get this by truncating the Taylor series for both). Therefore, he thought that (I’m guessing here, but it seems logical) that we could simplify this as:

/ x' \   /   1  eps \ / x \
|    | = |          | |   |
\ y' /   \ -eps  1  / \ y /

Okay, it’s pretty obvious that this seems like a bad idea. For one thing, the “rotation” matrix isn’t a pure rotation. It’s determinant is 1 – eps^2 1 + eps^2, which means that points which are mapped move slowly toward away from the origin. Nevertheless, Minsky apparently thought that it might be interesting, so he went ahead an implemented the program. I’ll express it here is pseudo-code:

newx = oldx - eps * oldy
newy = oldy + eps * newx

Note: this program is “buggy”. The second line should (for some definition of should) read “oldy + eps * oldx“, but Minsky got it wrong. Interestingly though, this “bug” has an interesting side effect: it draws circles! If eps is a power of 2, you can even implement the entire thing in integer arithmetic, and you don’t need square roots or floating point or anything. Here’s an example of it drawing a circle of radius 1024:

Well, there is a catch: it doesn’t really draw circles. It draws ellipses. But it’s still a very interesting bit of code. The first thing to note is that if you actually write down the transformation matrix that the “wrong” equations implement, the determinant is one. That helps explain why the point doesn’t spiral in. But there is another odd thing: if you implement this in integer based arithmetic, it’s eventually periodic (it doesn’t go out of control, all the round off errors eventually cancel out, and you return to the same point again and again and again). In HAKMEM, Schroeppel proclaims that the reason for the algorithm’s stability was unclear. He notes that there are a finite number of distinct radii, which indicates that perhaps the iterative process will always eventually fill in the “band” of valid radii, but the details of that seem unclear to me as well. I’ll have to ponder it some more.

Addendum: The real reason I was looking at this was because the chapter in Hackers which talks about Spacewar! also talks about the Minskytron whose official name was TRI-POS. It apparently uses some of this idea to draw curves in an interesting way. HAKMEM item #153 also suggests an interesting display hack:

ITEM 153 (Minsky):
To portray a 3-dimensional solid on a 2-dimensional display, we can use a single circle algorithm to compute orbits for the corners to follow. The (positive or negative) radius of each orbit is determined by the distance (forward or backward) from some origin to that corner. The solid will appear to wobble rigidly about the origin, instead of simply rotating.

Might be interesting to implement.

Addendum2: I goofed up the determinant above, it should be 1 + eps^2, not 1-eps^2. Corrected.

My Thoughts on The Acceleration of Addictiveness

Paul Graham has a interesting little missive over on his website on the increasing trend toward addictiveness in our society:

The Acceleration of Addictiveness.

I don’t think it is bad as far as it goes, but I wonder why he didn’t ask what I thought was the obvious question: “why are things becoming more addicting?”

Let’s consider what we eat as an example. Hardly a day goes by when you can’t find a story about the obesity epidemic that is going on here in the United States. We’re getting fatter, and we are having fatter kids. And everyone is asking why this should be happening.

I think the answer is really quite simple: we are addicted to food. Well, not food precisely, but to things that we eat which sort of vaguely resemble food, but are engineered to be addicting.

No doubt some of you are tsk-tsking. You’ll probably post a comment which says that what we eat is a personal choice, that we have control, and that we simply don’t exercise enough and that we eat the wrong things. You probably will also look at the people you know who still smoke, and wonder why they simply don’t quit.

I’m going to say that while you are right in a sense (nobody can get you to quit except you) but you are wrong in that it is simple or easy. Nobody really likes to be overweight, if it were easy to avoid being so, they would. If you examine the rate at which people successfully lose weight and keep the weight off, you’d find it was vanishingly small. In that respect, it seems very similar to drug and alcohol addiction. The actual effectiveness of even well accepted treatment options like AA is near zero, if not actually negative. But that’s another posting…

If there is an acceleration in addictiveness, it seems to me that there is an increase in the number of suppliers of these addictive products. Let’s call them what they really are: pushers. Pushers are willing to sell products to consumers which aren’t really good for them. They are eager to reduce the cost of their product, to increase its availability, and to increase their potency. They may not start selling addictive products intentionally, but let’s face it: it’s much easier to sell products to addicts than to people who can take or leave your product.

Pushers will tell you that they are just filling a demand, and that their consumers are adults who are responsible for their own choices. At best this is denial. At worse, it’s just a lie that attempts to shift responsibility to the addict.

It astonishes me that there are still people farming tobacco and making cigarrettes. Not because it should be illegal, but because it takes an inhuman lack of respect for others to profit from selling them products which are so dangerous. I’ve begun to feel the same way about many packaged food producers and fast food purveyors, who carefully market “food” which is sadly nutritionally deficient and which maximizes the use of things like HFCS and processed white flour to reduce costs and to unnaturally manipulate appetite. And perhaps we should begin to consider companies like Facebook to be in this realm as well: they are using games and social interaction as an enticement to reveal much of your private information, and this only works if they can entice you to return again and again.

If we are concerned about our increasingly addictive, impatient, immediate gratification based society, perhaps we should all be asking ourselves whether we are becoming pushers: purveyors of behaviours which are ultimately bad for us. If we are, perhaps we should consider forgoing the profits that dealing addiction can reap, and figure out how to apply our effort and ingenuity in more productive directions.

Kite Photography

Tom and I took a quick break after work today to try lofting my Canon camera up in the air. We used the Picavet that Tom constructed, and ran a simple uBASIC script that just took a snapshot every five seconds. We shot a total of about 120 shots, about one fourth of which were reasonably acceptable. We sent the camera up about three times with the camera adjusted three ways: the best seemed to be where the camera was adjusted to aim slightly down, below the horizon.
Check out the photos linked on Picasa below.

Pictures of my first attempt at kite photography

I don’t think I am a hacker…

Today’s moment of introspection came this morning. After some time spent updating my twitter feeds and answering emails, followed by my regular commute (where I forgot to pick up my prescriptions, doh!), I realized something:

I don’t think I am a hacker.

I used to think that I was. Back in the early 1980s, I was living in Oregon, first in the Portland area, and later in Eugene as I entered the University of Oregon as an undergraduate in their CIS department. While it had a respectable program, it wasn’t particularly innovative. I took my first official class (CIS 201) which used Apple IIs running a Pascal like language called Karel, which was meant to teach you programming by directing a little synthetic robot around a grid. It was staggeringly easy (by that time, I had been programming microcomputers for about 4 years). The instructor decided that he’d give us all the assignments for the class on the first day. I completed them by the third day (could have done it in one day, but limited lab times) which freed up a substantial block of time for me to wander around, trying to find other machines I could use, reading books and magazines in the computer reading room, and generally pursuing my own interests. I took lots of dreadfully boring classes as well: on FORTRAN and COBOL (yes, I’ve taken a COBOL class) using their DEC 1091 and their IBM 4341. By midway through my sophomore year, I had exhausted the undergraduate program of anything remotely interesting, and decided on the spur of the moment to enroll in a class on compilers, taught by Professor Ginnie Lo. I had an ulterior motive: taking that class would give me access to the departments VAX 11/750, which was running Unix, about which I had heard a great deal, but had no practical experience at all. The first day, she was calling roll and came to my name. I raised my hand, and she looked at me and said “Did I give you my permission to take this class?” to which I replied truthfully “no”. To her credit, she merely went back to calling roll. I learned a lot about compilers and Unix. I developed a bit of an obsession with computer languages. I learned to program in C. I found a small number of others who shared our fascination, and we rapidly became friends and room mates. It was a great time for me intellectually, even though I was struggling with three jobs and a full class load.

Ah, back to the hacker thing….

One thing was obvious: I seemed to be different than the majority of other students. Outside of our inner circle of over-achievers, we saw lots of people who were good solid students, but which seemed to lack the inner passions that we felt, the nearly maniacal obsession to understand how we could use these machines to achieve new things. We craved access to computers, and spent a lot of our time trying to find ways to gain access to hidden computing resources, or resources that were reserved for a select few.

Amidst this, I read Steven Levy’s book “Hackers: Heroes of the Computer Revolution”. And I finally had a name for what it was we were.

Levy espoused a hacker ethic, which I’ll reproduce here from the Wikipedia page on his book:

  • Access to computers—and anything which might teach you something about the way the world works—should be unlimited and total.
  • Always yield to the Hands-on Imperative!
  • All information should be free
  • Mistrust authority—promote decentralization.
  • Hackers should be judged by their hacking, not bogus criteria such as degrees, age, race or position.
  • You can create art and beauty on a computer.
  • Computers can change your life for the better.

It’s hard to say how transformative this book was for me. I had stumbled into some of these principles more or less on my own, but now I had a name for them, and some inkling that other people were doing the same thing in exciting places elsewhere in the world. Until then, I had mostly thought that the path to success in school was to do well in my classes. While I enjoyed the extra-curricular work I did, I never saw it as anything more than a distraction. But post-Levy, I understood that my extra-curricular activities were actually the important stuff and that there was no reason to postpone doing the interesting stuff. My friends and I wrote programs, both together and as singular endeavors. We shared code and experience, and we got better. I became interested in computer graphics, and started writing ray tracing programs. I used USENET to make contact with other people interested in ray tracing, and we shared information and built on each others experience. It was awesome.

So, why don’t I think I’m a hacker?

Up until a few years ago, many self-identified “true” (in the Levy sense) hackers were irritated that the press used the term to indicate those who break into computers or computer networks. This is no doubt in no small part because of the antics of Kevin Mitnick, who was perhaps the first computer criminal to reach the attention of the general public. While some were certainly interested in computer security, it was (I suspect) initially mostly to gain access to computing resources and to measure their extent, not to commit crimes or fraud. Most of those “hackers” were actually posers whose skills were commonly fairly mundane and uninteresting. Years later, we’d have the term “script kiddie”, which is an accurate portrayal of 99% of all “hackers” of this sort.

I’m not one of those.

But in the last few years, we’ve seen another use of the term: exemplified perhaps most clearly in my head by Paul Graham. While Graham has made some interesting technical contributions, he’s widely known now as an essayist and as a venture capitalist heading Y Combinator which specializes largely funding web based startups. As a result, it has become somewhat fashionable to use the term “hacker” as synonymous with “any programmer who is working in the web space, especially on social networks, and especially in start ups”. I’m not actually a fan of his essays. Most of what he says that I think is true were said better by people like Brooks, and most of the rest I think is self-serving egotism.

I’m not like him either. Sadly, that means I’m not as wealthy either.

For me, my hacking is the internal struggle to make my brain a more interesting place to spend my life. I am interested in lots of stuff, and it turns out that a computer allows me to explore these things. In almost every case it is “boldly going where others (usually smarter) have gone before”, but the effort of actually examining the details is pleasing to me.

As an example, I have a directory on my computer which I call “play”. I use it to store most of the trivial and not so trivial programs that I enjoy writing. It’s got about 300 directories in it now (not all are code that I’ve written, some of it is code from others that I’ve found inspiring). It includes things like the original raytracer I wrote in 1986, which I occasionally still hack on, and its successor that I wrote a few years ago during the week between Christmas and New Years, and which hopefully integrates some of what I’ve learned since 1986. I’ve got a program that I wrote to count all the primes to 10**12 or one that implements bignum arithmetic using the Fast Fourier Transform. I’ve written and blogged about my checkers program Milhouse. I’ve written a library in Python for computing the location of Earth orbiting satellites. I’ve written a PDP-1 emulator to play Spacewar! I have written a small compiler that takes in scripts and outputs randomized test sessions to learn Morse code by using speech synthesis. I’ve written several simulators for the Enigma machine, including one that runs on the Atari 2600 video game. Fractal image compression. Volume rendering. Stuff that draws wireframes of globes. Extracts nice 256 entry color maps from photos. Sends and receives slow scan television. Finds and downloads tagged images on Flickr. Aligns frames from my video of Mercury transiting the surface of the sun. Computes the Ronchi pattern for testing telescope mirrors. Computes the diffraction pattern for off-axis parabolic reflectors. And dozens more.

I used to think that made me a hacker.

Perhaps the better word would be “crazy”.

Writing emulators for obscure old computers…

(Hmmm. I’m sort of on a retrocomputing kick today…)

A few years ago, I wandered into Tom’s office one day to find him typing away. I asked “whatcha doing?” and he replied “I’m writing an emulator for the PDP-1 so I can play the original Spacewar!” It tells you a lot about Tom to hear stories like this. It tells you something about me that I didn’t respond with “why?” or “that’s stupid” and instead just went back to my desk and wrote my own. I had never seen a PDP-1 (although the Computer History Museum has since completed restoration of theirs, where you can see Spacewar! running on real hardware). It took me a couple of days to tinker the emulator sufficient to run Spacewar! into shape, and I learned a lot about how to write emulators.

A couple of days ago, Eric sent out a link to his RetroChallenge project, an FPGA-ELF:



The ELF was a microcomputer based around the RCA-1802 processor, and was published back in 1976 in the pages of Popular Electronics. I remember reading this as a precocious 12 year old, but it would be four years until I got my first computer, an Atari 400. Still, these older machines seem like interesting things, so I thought I’d investigate what it would take to make a high quality emulator (or even a crappy one) for the 1802.

Here’s the first little nugget that I found. The 1802 has sixteen 16-bit registers, labelled R0-R15. One of the more interesting features that it has is that the PC isn’t a dedicated register: there is a 4 bit P register, which tells you which of the sixteen R registers serves as the PC. In each cycle, it fetches the byte pointed at by R[P], increments R[P], and then executes the instruction. I found that there is an interesting case that occurs with opcode 0x20. The high nibble of 2 indicates that it is a DEC instruction, and the low nibble specifies the register. This says “DEC R0”. But in my case, R0 was serving as the PC (P was 0 as well), so this instruction essentially undoes the normal increment, restoring its previous contents, and we have a single byte infinite loop.

At least, that’s what I think should happen. I don’t have an actual computer, so debugging this kind of stuff is what writing emulators like this is all about.

Getting the basic instruction set working shouldn’t be too hard, but there are other things like handling DMA that might be a bit trickier. Still, I’m destined to learn a lot, about a subject that is of no importance whatsoever. But then, you should expect that from me and this blog.

Addendum: Eric wrote up some nodes about his FPGA-ELF on his blog. Factoid: it runs about 100x faster than the original ELF.

A Prototype Picavet Kite Rig

I got home today, and decided to tack together a prototype picavet, mostly because I couldn’t visualize how it works.


httpvh://www.youtube.com/watch?v=LEIbac-dULs

In case you don’t know what a Picavet is, and it wasn’t clear from my somewhat rambling “demonstration” above, you can surf back to my posting about the Kite Aerial Photography Electronic Resources page, which I used as a basis for my attempt.