Archive for the ‘Uncategorized’ Category

progress

this battlestation is… more operational

GE Color Effects Lights logic in Python

I’ve been playing with these holiday lights recently. They’re very neat: each bulb has RGB LEDs embedded in it and is individually addressable (albeit with only 4 bits of resolution per color channel). Some wonderfully talented folks have reverse-engineered the protocol that the light controller uses; others have written Arduino code making it possible to snip the light’s control line, connect it to an Arduino, and begin programming your own animations. Still others are doing various neat and unusual things with the result. Personally, I just want to have some interesting light displays for New Year’s.

These other folks’ work makes this possible, but not as convenient as it could be: developing new animation routines on the Arduino is a pain in the butt. To do so you write your code in the Arduino’s irritating development environment, then flash it to the chip and hope that everything worked right. There’s a small risk of damaging the lights, and a large chance of things going wrong.

So! I wrote some bridge code that moves the light control logic into Python, which can run and be manipulated on a regular ol’ computer. The state of the lights is then sent to the Arduino many times per second (though not as many as I’d like — still, only about 1FPS slower than the string’s theoretical max) and the Arduino dutifully updates the state of the lights. This should make development of animations easier, and make it simpler to trigger or modulate them in response to network events or other things that the computer can detect.

If you have any use for this code, you can find it here. For me, there are two challenges remaining: creating some interesting animations, and connecting a second string to the Arduino.

This latter issue is a bigger problem than you might think: the lights’ address space is only 6 bits — too small to simply connect the two strings together and retain the ability to control individual lights (bulbs can share addresses, but I’d rather not do that). So the two strings need to be treated as individual entities. That’s easy enough on the Arduino side. But the Arduino is going to live at one end of this double-string, not in the middle. That means that the signal to the far string will have to be transmitted along the length of the near string. This is too much distance for a fast serial connection to traverse without being spread out into illegibility.

The solution, I’m told, is to shift the serial signal to RS-422, a higher-speed and more ethernet-like standard, then back to serial at the light string (it will travel along a twisted pair of conductors that I’ll run along the already-too-heavy first string). I have the chips to do this, and it all *looks* pretty simple. Fingers crossed…

well, that was much harder than it needed to be

I just spent some time banging my head against this problem; let me save people wandering in from Google similar trouble.

So: you’re trying to use pySerial to speak to your Arduino. It’s not working. Or sometimes it is, but only when you have the Arduino Serial Monitor window open! This makes no sense.

Here’s the deal: the Arduino’s fancy “you can flash new programs onto me without pressing my reset button!” functionality works by resetting the damn thing whenever a new serial connection is made. With the serial monitor open, the connection’s already open, so no reset happens and your script might actually work. When the monitor is closed, the Arduino resets when Python connects to it — and the Arduino might still be busy booting up when your script begins shoving bits across the link.

So! You can disable this auto-reset behavior (you’ll have to ask the Arduino people about that), but it seems simplest to just make your python script long-running and wait patiently for a beat or two after opening the serial link. Here’s a dead-simple example:

1
2
3
4
5
6
7
8
9
10
import serial, sys
from time import sleep

SERIAL_PORT = '/dev/tty.usbmodem621'
SERIAL_RATE = 9600      

ser = serial.Serial(SERIAL_PORT, SERIAL_RATE)
sleep(2)
val = int(sys.argv[1])
ser.write(chr(val))

Here’s the Arduino sketch. It just blinks the LED on pin 13 however many times you sent as a byte (I’m working on sending binary-ish data over the serial link; hence the use of raw byte values):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
byte inByte = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop()
{
  if (Serial.available() > 0) {
    inByte = Serial.read();
   
    for(int i=0;i<inByte;i++) {
      digitalWrite(13, HIGH);
      delay(500);
      digitalWrite(13, LOW);
      delay(500);
    }
  }
}

There! That was irritating.

it’s a divide all right, but it’s not all that digital

This is more or less why I don’t spend a ton of time at work worrying about the digital divide.  It’s tempting to tell yourself that the reason politically marginalized populations don’t avail themselves of their representatives’ attention is that they lack access to the necessary technologies.  If only you could write your senator through an SMS interface instead of needing an expensive, Javascript-capable smartphone!

But of course this is nonsense.  To a first approximation every American can afford to use the telephone and the post office. And in urban and suburban areas, at least, libraries make computers widely available.  What marginalized people lack is time, attention and education.  Maybe they don’t have a cellular data plan either, but first things first.  Besides, to the extent that technology access is a real problem, falling electronics prices are likely to do much more to address the issue than even the most conscientiously designed interfaces (on this score, the news on smartphone penetration is very encouraging).

Still, just because projects that concentrate on technological deficits are focusing on a small and relatively unimportant part of a dauntingly large problem doesn’t mean that such efforts aren’t laudable.  There’s always room for making a difference at the margin.  And there’s something to be said for principle.  Designing our work to be inclusive and truly democratic is important — sometimes more important than maintaining a depressingly realistic appraisal of our chances for coding our way to egalitarianism.

(I should probably add that I think creating accessible interfaces for politically engaged populations that have difficulty using technology — the disabled, seniors, etc — is a very different endeavor from the broader/gloomier digital divide issue)

yet more a la carte

Matt and I have gone back and forth about this before, and I’d be lying if I said I felt completely confident in my response to the licenses-for-parks metaphor.  But I do feel confident that he’s wrong about this:

[...] Once the cable company has built the infrastructure to deliver cable to your house and given you the box, it doesn’t cost them any more money to give you 100 channels rather than 10. To be sure, building infrastructure capable of delivering more channels costs more money. But once the infrastructure’s built, it can deliver what it can deliver and there are no incremental savings to achieve by not using all the capacity. I think it’s completely true that cable television has become a questionable value proposition—it’s extremely expensive and though the infrastructure to deliver hundreds of channels to the home is impressive, it’s not actually useful since nobody watches that many channels. What we actually need is faster broadband internet. But the infrastructure’s already built. Refusing to use it doesn’t reduce the suppliers’ costs and wouldn’t save customers any money.

Two things. First, the cable company buys its content from various aggregators and producers of video product. I’m sure that the terms of these purchases vary considerably, and to some degree must be tied to consumer demand for that content. But there is marginal cost to adding a new channel even if there isn’t marginal cost to distributing it. There’s necessarily cross-subsidization going on, which means some viewers are getting a raw deal. Probably most of them, I’d argue: given the lack of choice in the market, there are strong incentives for the cable company to add new channels in order to widen their customer base; they can simply add the new features to their existing customers’ tabs. iTunes, Amazon and Netflix can be understood to be competing with cable and satellite largely on the basis of offering a non-venti option to consumers (to borrow Matt’s analogy) and they’re having a lot of success with it because many people rightly intuit that they’re not consuming $100 worth of video product every month.

Second, nearly all cable systems are now or soon will be digital, which means they’re packet-switched, which means that, to varying degrees, broadband capacity and video capacity are fungible. The actual details are, I’m sure, quite convoluted and complex, and we’re not going to be able to hash them out here without help from someone who understands the relative merits of different versions of DOCSIS. But it’s safe to say that there is one copper conductor entering your house that handles both internet and TV, and that the portion allocated to each can be changed through configuration choices made by your cable vendor.

the primal mud run

me, exhausted and covered in mud

Somehow Charles talked me into doing the Primal Mud Run on Saturday. It’s true that I’ve been adopting more of his crazed fitness strategies over the last year, but this was still an entirely new thing for me.  I’m not a very good runner, and making my 5k debut with an event that also involved mud and obstacles was daunting.  Today I’m sore and my lungs seem to still be reconfiguring themselves to a level of functional ambition they had never before considered. But I’m glad I did it.

One part was particularly interesting. The most unpleasant obstacle involved wading into a very cold pond and swimming under some barrels.  You know how when you hit your thumb with a hammer or burn your hand on the stove, and say “Ow!”, there’s some sense of volition tied to the exclamation? I mean, it’s not a deliberate act, exactly, saying “ow”.  But you could suppress it if you wanted to.

Well, each time I came up from under those barrels I was surprised to hear myself emit a sort of pathetic howl/whimper, not dissimilar to the ones tough-minded Jack Bauer might have drawn from a sinister interrogation subject.  It was just completely automatic and beyond my control. It’s always interesting and horrifying when you discover some new thing your body does without asking your permission. I trudged through the rest of the event in a kind of animal stupor, and when I was done Charles had to show me where I’d left my jacket.

But this was all pathetic and ludicrous. A hundred yards away, trucks were selling beer and barbecue sandwiches. Other participants were running in halloween costumes, tutus and thrift-store suit jackets.

All of which just goes to show that I would have made a terrible Marine. And the next time you hear me speculating about strategies for surviving the collapse of civilization, you should probably roll your eyes even harder than you normally would’ve.

UPDATE: Charles found some photos.

if I can pester you about just one obscure topic we talk about at work…

Let it be this one.

As is probably obvious, I think there are good reasons to be excited about information technology’s capacity to improve governance. For the small stuff, it already has — I can get a new recycling bin delivered just by visiting a website!

But for the really big stuff — like keeping track of how we award multi-million dollar contracts, or how we regulate polluters, or how we track the political influence economy — there are significant barriers to applying automated analysis. A lack of usable corporate identifiers is among the biggest of these problems. Citizens are expected to have trackable identifiers for their cars, and firearms, and selves. I have to surrender my SSN to a private entity just to see if I’m allowed to buy a new phone!

But for companies, the situation is quite different. Corporate registrations are held by states, which face bad incentives around making this data usable both because inaccessible registration information makes the state more attractive to registrants, and because states collect substantial sums for use of the data. Meanwhile, the federal government is wrapped in a nightmare tangle of purpose-built ID fiefdoms and one overarching public-private partnership that supplies identifier data that’s both unacceptably restricted and of unacceptably poor quality.

Attempts to improve the situation will no doubt be met with much gnashing of virtual teeth: competitiveness! Privacy! Personhood! None of these hold much water, though: not only has relevant tax return information (which would go a long way toward solving this problem) been completely public at various times in our nation’s history, but other countries impose a disclosure burden adequate to resolve the problem while still enjoying vibrant, competitive economies.

Anyway, my colleagues make this case more rigorously and persuasively both at this microsite and in this blog post (about the overall problem) and this one (about the technical considerations behind our presentation). I hope you’ll give it all a look.

advanced seltzer engineering

our office sodastreamOver the past few years, many of you have heard me evangelize the gospel of home carbonation. At work we’ve recently taken things to a new level, and I’ve had a couple of people ask me questions about it. As you can imagine, I’m delighted to answer them. But let’s begin at the beginning.

My interest is in making seltzer water — growing up we called it “bubbly water”, and my dad bought it by the case. I’m not sure why I like it so much: the slightly acid tang of the carbonic acid in solution? The cooling, quenching sensation I feel as the dissolved gas pushes the water out of my stomach, into my intestine and on to my bloodstream? I’m not sure. But I really like it.

Until recently, soda siphons were the only way to make seltzer at home. But the pricing doesn’t work: the tiny CO2 cannisters that power the things, while handy — my dad once told me that in his youth he used to stuff empties full of matchheads to create what must have been an awesomely dangerous projectile — are so expensive that you’re much better off lugging liter bottles home from the store.

My then-neighbor Rob Goodspeed was the first person I knew to have a Soda Club. It was during the golden age of PR flacks sending bloggers things for no apparent reason, and Rob had cofounded DCist, earning him rights to substantial swag. Most of these pitches were laughably inept either because the product was awful or the pitch was tone-deaf (as a technology blogger, of course I was the right person to email about custom popcorn flavoring powders). It didn’t feel like much of an ethical conundrum — it was all too stupid for that. But occasionally the flacks would succeed, and the original Soda Club was such a case. Rob was justifiably enthusiastic about the product, and as soon as I saw it I decided to buy one for myself. I’ve gone on to buy units for friends and parents and siblings, and I’ve talked many more people into doing the same. It’s a great product.

The company has since rebranded to SodaStream (I like to think our Club is no longer accepting new members), and is even publicly traded (as $SODA, of course). My original Soda Club carbonator is still going strong.

its operation is simple. You fill a bottle with a liter of cold water and screw it into the unit. You depress a button several times, until the overflow valve starts to make a horrible flatulent sound. The bottle leaves the machine with an infinitely satisfying chffff noise, like a tiny, refreshing alien disembarking from his pressurized spaceship. You’re then free to add flavored syrups (carbonating anything other than pure water is a big no-no). SodaStream is happy to sell you those syrups, of course — their Red Bull knockoff isn’t bad, and avoiding giant flat bottles of tonic water is worth some flavor sacrifices. But the last time I checked (2005) many of the other flavors were underwhelming. Oh well: soda’s bad for you anyway.

Even if you just want seltzer, you’ll need SodaStream to sell you replacement CO2. This was their real innovation: the carbonator units contain replaceable cannisters of compressed gas that are much larger than those used by soda siphons. A refill costs $25 or $30 bucks (there are two sizes — I strongly recommend the larger) and can either be delivered to your home or, as of late last year, picked up from most Bed Bath & Beyond or Ace Hardware stores. I go through two or three of the larger cannisters per year.

As you might imagine, there’s a bit of a markup on the gas. Quite a bit, in fact, though it’s still a great deal compared to the alternatives that used to exist. Still…

I work with a number of fellow seltzer enthusiasts, and more than a few of them are also people who don’t like the idea of business models based on lock-in. So once we had resolved to get a SodaStream for the office, it wasn’t long until we came across co2doctor.com.

Compressed CO2 is easy to buy, as I found out in college when I built a kegerator. Any welding supply shop will be happy to sell you the stuff — the good old boys in the Charlottesville shop asked if I was “makin’ some suds” (I was). And like any good industrial byproduct, it’s cheap: refilling one of tanks those guys use costs about the same amount as a SodaStream refill, but provides many times as much CO2.

Siphon TankSodaStream’s gas cannisters — they’re properly referred to as “bottles” from here on out — aren’t designed to be refilled with standard equipment. There are booby-traps built into the valves. If you want to use bulk CO2, you need to avoid those valves. You’ve got two options for doing so:

  1. You can connect a CO2 cannister directly to your carbonator using the FreedomOne.
  2. You can replace the valve on a SodaStream bottle, then use the FillStation to refill it.

Option 1 is appealing if you’ve got the space for it (SodaStream carbonators look good on a kitchen countertop; industrial CO2 cannisters do not). Our office chose the second option in order to make it possible for staff to refill CO2 cannisters for home use.

The option you select has implications for which CO2 tank you buy. If you’re carbonating directly from the tank (option 1) you need a tank that dispenses gas. If you’re refilling bottles, you need one that dispenses liquid CO2 — a so-called siphon tank, which connects the tank valve to the bottom of the cylinder via a sort of metal straw. Either type can be acquired, full, for less than $100.

Replacing the valve was pretty easy. Discharge the bottle fully by pressing in the valve pin with a pen (do this outside; wear glasses or goggles). Find yourself a vice, or a couple of friends with excellent grip strength. You’ll need a proper wrench, but once you have one the operation is easy: the valve simply unscrews. Replace it with the FreedomValve, using the supplied o-ring. Tighten it very securely.

FillStation Pro

Refilling the bottle is also easy. Once again: eye protection. Make sure all valves are closed. Connect to the tank; connect to the bottle. Open the FillStation’s smaller valve to flush any pressure in the bottle. Close it. Open the large valve on the tank. Open the large valve on the FillStation. Listen for satisfying whooshing and gurgling. The good CO2 Doctor is very insistent that you fill your bottle by weight, and that you never overfill it — but he also acknowledges that the laws of physics make it impossible to fill it to capacity using a mere siphon tank (as opposed to the exciting machinery that presumably exists at SodaStream World HQ). We weighed the bottle carefully and filled slowly, but we found that letting pressure completely equalize between the two worked just fine and left us within safety limits. Close the FillStation valve. Close the tank valve. Disconnect the bottle (there will be whooshing!). And for pete’s sake remove the FillStation from the tank, lest it tip over, break off the valve and turn everything into an episode of MythBusters.

And that’s it! At work Scott has crunched the numbers and determined that refilling bottles for home use will entail a $4 per-bottle fee. That gets you about 80% of a full charge — not bad! The $30 valve replacement will have paid for itself in just two bottles. But if you don’t have a group that wants to share a siphon tank, you might be better off using the direct-to-tank adapter (for a breakdown of cost recovery using that method, see this post). Or hell, just use SodaStream’s bottle refill service like a sane person.

this year’s model

Omni ManIt came out pretty well, I think. The boots are off-model, but that was mostly because the paint on them needed some more time before I could put stuff on it. And parts are secured with magnets! Ah, magnets.

I won’t bore everyone with an explanation of the character (I did quite enough of that last night) but if you like superhero comics and haven’t read Invincible, you really should. It’s sort of like a reboot of everything in the big two’s universes, but without the inevitable backsliding.