Friday, September 23, 2011

Bus Pirate DIY "case"

A little DIY case I threw together using a ruler, an Exacto knife, plastic from a blister pack, and some 4-40 hardware I had lying around:

It's not especially protective, but it will keep random stuff from falling on it and shorting something out.

The trick to making this is to start with the rectangular hole for the guarded probe connector because it's the hardest part to get right. Once you have cut a hole you like, use the edges of the Bus Pirate itself as a guide and lightly score the other edges one at a time to mark them. Use a straight edge to cut the marks deeper. It's faster to finish the cuts with scissors.

If you're not familiar with 4-40 hardware: 4-40 is a standard thread size. You can find 4-40 hardware in serial, parallel, and video D-sub connectors. They're often used in RC models too, judging from a quick ebay search. Sometimes the hardware store will carry 4-40 nuts and bolts.

Tuesday, September 13, 2011

NFS4 id fixes

I was having a problem with ids on an NFSv4 client:

$ ls -l /r1/bob/
drwxr-xr-x  2 4294967294 4294967294 4096 2011-05-14 19:29 junk
drwxr-xr-x  2 4294967294 4294967294 4096 2011-01-30 02:14 junk2
drwxr-xr-x 14 4294967294 4294967294 4096 2011-05-14 16:31 unsorted_junk

After fumbling around for a bit, here is the solution I'm running with now.

On both the server and the client, add this to /etc/idmapd.conf:

[Translation]
Method = nsswitch

On the client, add this /etc/rc.local:

service idmapd start
umount /r1
mount /r1

Now we're all good:

$ ls -l /r1/bob/
drwxr-xr-x  2 bob bob 4096 2011-05-14 19:29 junk
drwxr-xr-x  2 bob bob 4096 2011-01-30 02:14 junk2
drwxr-xr-x 14 bob bob 4096 2011-05-14 16:31 unsorted_junk

Monday, September 5, 2011

Boston Baked Beans

One of Mrs Squirrel's favourites, this is based on the recipe from the 1997 edition of The Joy of Cooking.

  • Total cooking time: 6-8 hours.
  • Ingredients:
    • 2 lbs white navy beans
    • 1 cup light or dark molasses
    • 8 oz salt port
    • 2 cups chopped onions
    • 2 tsp ground black pepper
    • 1/2 tsp ground cloves
    • water
  • Makes about 10 cups of baked beans, which will keep in the refrigerator up to 1 week, or frozen and enjoyed up to 6 months later.

Step 1: Cook the beans

The goal of this step is to get 2 lbs of white navy beans to the point where they are soft and creamy in the centre. Ideally, the skins should not not be frayed, nor should the beans be mushy and falling apart.

Pick over and wash 2 lbs white navy beans. Place in a pot and add 12 cups water. Boil for 2 minutes, then cover and let stand for 1 hour.

Bring the beans back to a boil and simmer for 45-60 minutes, until the beans are done, as described above.

If you're using a different species of bean, the required cooking times may differ from the above. For example, one species of small red beans required an additional 30-60 minutes simmering.

If you use red kidney beans, read the following, which I've copied from Wikipedia for convenience:

The toxic compound phytohaemagglutinin, a lectin, is present in many varieties of common bean but is especially concentrated in red kidney beans. Phytohaemagglutinin can be deactivated by cooking beans at 100 °C (212 °F) for ten minutes. However, for dry beans the U.S. Food and Drug Administration (FDA) also recommends an initial soak of at least 5 hours in water; the soaking water should be discarded.

Who said beans were boring?

While the beans are cooking, soak the salt pork to wash away some of its salt.

When the beans are done, gently strain them. Avoid shaking the colander, to prevent fraying or mushing the beans. Discard the cooking water.

Step 2: Bake the beans

In an oven proof pot, bring to a boil

  • 3 cups of water
  • 1 cup light or dark molasses
  • 2 tsp ground black pepper
  • 1/2 tsp ground cloves
  • optional: 1 tbsp salt

Gently stir in the beans along with

  • 8 oz salt port, cut into 1/2-inch cubes
  • 2 cups cupped onions

If necessary, stir in additional hot water to just cover the beans. Cover the pot and bake 4-5 hours until the liquid has thickened.

Saturday, September 3, 2011

16-segment LED from Active Surplus

Here's the pin-out of a mysterious 16-segment LED display we picked up last weekend from Active Surplus. Stamped on the top is "TR371 A 5G".

It has a common anode, at pin 18.

This is mostly for my own notes, in case I decide to do something with it later. Feel free to use at your own risk, not responsible for injuries sustained while ROFL, etc.

Wednesday, August 31, 2011

Using a 4511 to drive a 7-segment LED with an Arduino

An Arduino UNO can drive a 7 segment LED digit directly, but it takes seven output pins to do it. Additionally, your program is exposed to how the segments in the digit are wired to the Arduino.

A binary coded decimal (BCD) driver like the 4511 hides this level of detail for you. It takes 4 pins as input, another for latch, and drives the LED segments directly. You "tell" it what number to display, and it figures out which segments to light up.

The flipside to using the 4511 is you have to accept the way it draws digits like 6 and 9 without their tails. Also, it doesn't draw letters like A, b, C, d, etc. Well, using the 4511 is just an exercise, a stepping stone to a more sophisticated driver.

Anyhow, this is the code I whipped up in about an hour. I'm putting it in the public domain, so enjoy!

/*
 * Arduino UNO 4511 BCD to 7-digit LED driver
 *
 * 4511 pins 3 (lamp test), 4 (ripple blanking), and 16 (Vcc)
 * are connected to +5V on the Arduino UNO.
 *
 * 4511 pin 8 is connect to GND on the Arduino UNO.
 * The common cathode on the LED digit also connects to GND.
 * 
 * 4511 pins 9 through 15 connect to the LED digit as
 * appropriate.
 */
#define LATCH_ENABLE  13  // to pin 5 on the 4511
#define DATA1          1  // to pin 7 on the 4511
#define DATA2          2  // to pin 1 on the 4511
#define DATA3          3  // to pin 2 on the 4511
#define DATA4          4  // to pin 6 on the 4511

void setup()
{
  pinMode( LATCH_ENABLE, OUTPUT ) ;
  pinMode( DATA1, OUTPUT ) ;
  pinMode( DATA2, OUTPUT ) ;
  pinMode( DATA3, OUTPUT ) ;
  pinMode( DATA4, OUTPUT ) ;
}

// This macro tests bit 'b' in value 'v' and reports
// high or low as appropriate.
#define T(v,b)  (v & (1<<b) ? HIGH : LOW)

void show( unsigned int value )
{
  if ( value <= 9 )
  {
    // enable the latch so we can write
    digitalWrite( LATCH_ENABLE, LOW );
  
    digitalWrite( DATA1, T(value, 0) );
    digitalWrite( DATA2, T(value, 1) );
    digitalWrite( DATA3, T(value, 2) );
    digitalWrite( DATA4, T(value, 3) ); 
  
    // disable the latch now that we're done writing
    digitalWrite( LATCH_ENABLE, HIGH );
  }
}

void loop()
{
  for ( int i = 0; i <= 9; i++ )
  {
    show( i ) ;
    delay( 1000 ) ;  // msec
  }
}
The 4511 does a fine job driving a single 7-segment LED display, but it's old school compared to the MAX7219 which can drive up to eight of those displays. Here's a well written resource on the 7219. I'm going to try getting one soon.

Hitachi Z7K320

I had to make a snap decision today on whether to buy a new hard drive for my x220t. The x220t only takes 7mm drives, which are less common than the typical 9.5mm drive for most notebooks. So seeing a 7200rpm drive on sale really caught my eye.

Drive performance was my primary concern, capacity was secondary. Sadly, few people actually published benchmarks for this drive. Mostly I just found marketing hyperbole and speculation.

The folks at Red Hill were kind enough to share a formula that they found was consistently able to predict a hard drive's performance: (2 log(data transfer rate) / sqr(seek + latency)). The higher the number, the faster the drive should perform.

Since my x220t is at home, I had to guess what hard drive it actually uses. So I chose the Seagate Momentus Thin based on vague recollections and what specifications I knew (250GB, 5400rpm, 7mm thickness). (Update: yes, exactly right, the ST9250301AS.) Here are the relevant numbers:

DTR 300 MB/s
random read seek 14ms
average latency 5.6ms
calculated result 1.119

This is the drive that was on sale at newegg.ca:

Hitachi Z7K320:
DTR 300 MB/s
average read seek 13ms
average latency 4.2ms
calculated result 1.195

So a slight performance improvement, according to the forumla.

It's possible I am making an apples-to-oranges comparison because I had to use "random read seek" versus "average read seek". Also, I've seen conflicting numbers for the Momentus Thin. If its seek time is actually 11ms according to this, then it's faster than the Hitachi, which defies expectations.

After a little more searching, I found a comparison between the z7k320 against the z7k500:

*** TRAVELSTAR 7K500 ***
-----------------------------------------------------------------------
CrystalDiskMark 3.0 (C) 2007-2010 hiyohiyo
Crystal Dew World : http://crystalmark.info/ -----------------------------------------------------------------------
* MB/s = 1,000,000 byte/s [SATA/300 = 300,000,000 byte/s]

Sequential Read : 111.361 MB/s
Sequential Write : 112.255 MB/s
Random Read 512KB : 39.582 MB/s
Random Write 512KB : 49.046 MB/s
Random Read 4KB (QD=1) : 0.516 MB/s [ 126.0 IOPS]
Random Write 4KB (QD=1) : 0.772 MB/s [ 188.6 IOPS]
Random Read 4KB (QD=32) : 0.972 MB/s [ 237.4 IOPS]
Random Write 4KB (QD=32) : 0.787 MB/s [ 192.0 IOPS]

Test : 1000 MB [D: 0.0% (0.1/232.9 GB)] (x5)
Date : 2010/12/14 16:13:58
OS : Windows 7 Home Premium Edition [6.1 Build 7600] (x86)


*** TRAVELSTAR Z7K320 ***
-----------------------------------------------------------------------
CrystalDiskMark 3.0 (C) 2007-2010 hiyohiyo
Crystal Dew World : http://crystalmark.info/ -----------------------------------------------------------------------
* MB/s = 1,000,000 byte/s [SATA/300 = 300,000,000 byte/s]

Sequential Read : 107.458 MB/s
Sequential Write : 106.552 MB/s
Random Read 512KB : 43.852 MB/s
Random Write 512KB : 47.439 MB/s
Random Read 4KB (QD=1) : 0.578 MB/s [ 141.2 IOPS]
Random Write 4KB (QD=1) : 1.085 MB/s [ 264.9 IOPS]
Random Read 4KB (QD=32) : 1.037 MB/s [ 253.3 IOPS]
Random Write 4KB (QD=32) : 1.091 MB/s [ 266.3 IOPS]

Test : 1000 MB [D: 0.0% (0.1/298.1 GB)] (x5)
Date : 2010/12/16 17:01:09
OS : Windows 7 Home Premium Edition [6.1 Build 7600] (x86)

According to the xbitlabs roundup, the 7K500 was the fastest among a group of 500-750GB drives. Yet the z7k320 had higher random read and write numbers than the 500, according to the Italian benchmark. So it does look like the z7k320 is a real performer, and the answer is "GO! BUY! NOW!"

Saturday, August 27, 2011

Rohm LU-3011 LED display module

I found this at Active Surplus today for $1.50. It has eleven LA-301VL (7-segment common cathode displays) on a 2-layer pcb. Numbering the pins and digits from left to right, here's how the pins correspond to digits:
Digit1234567891011
Pin1234681012141618
With respect to the segments, here's the relationship between the segments and the pins on the PCB: I'll need to build a multiplexer to control the display. This should be interesting.