Saturday, December 19, 2009

Ubuntu and a Thinkpad. A Beautiful Duo!

After another hour getting my dev tools setup on the Thinkpad I'm even happier with the hardware and software.

The Ubuntu community has high quality docs for all, of the few topics I've wanted help on. For example I now have middle-mouse-button scrolling working; something I missed from my last Thinkpad over three years ago.

Compared to Windows and even OSX, having a truly free OS and free software is liberating. Without question, both Synaptic and the new Ubuntu Software Center make finding and installing software incredibly easy. There are no restarts or system slowdowns. You can queue up several packages and they'll seamlessly download and install in the background. From low bandwidth at a web cafe.

As a developer this freedom and availability is key. If you're on the fence I say go for it!

Thinkpad T400 First Impressions and Ubuntu Linux Install

Just two days ago my new Thinkpad T400 arrived. I chose the base config with the WXGA+ LED screen option and webcam. In short, this thing is great.

After three years of a Macbook Pro (current and previous generation), it's good to be back to a thinkpad for development. The keyboard is amazing. Personally I really like the trackpoint, mouse button feel, and having 3 dedicated mouse buttons. This will be far better for programming and IDE environments etc.

Now to installing Ubuntu for dual-boot. Microsoft Windows 7 was preinstalled and I didn't want to remove it entirely. The Windows partition manager is a joke, skip right over it. It would only shrink the windows partition to ~80G even though only ~20G were used. So I installed Ubuntu via USB stick (more on that in a sec) and then used GParted. Note, you  will also have to install ntfstools for GParted to be able to read and shrink the NTFS partition. After shrinking Windows to ~50G I actually installed Ubuntu a second time to make repartitioning easier.

For the Ubuntu install I had a 4G USB drive by OCZ. I used the Windows compatible uNetBootin program to copy the standard Ubuntu 9.10 ISO over to the drive and make it bootable. That took all of five minutes and was really easy. Simply plug the drive into the lenovo and on startup, hold down F12. Alternatively you can use the blue ThinkVantage button for a list of options. F12 lets you do a one-time boot from a different medium. Thanks Lenovo folks for doing this - so much more convenient than changing permanent BIOS options back and forth.

Live boot and install was amazingly smooth. It was the easiest and fastest OS install I've ever done. Out of the box, Ubuntu recognized all hardware on the T400 that I thought of testing. Webcam, High res screen, Trackpad with scroll areas, Wifi, Sound, Volume and Brightness controls, etc. Amazing. I connected to our home Wifi in a matter of seconds with great signal. The Installer runs from a shortcut on the live boot desktop and is very easy. It takes about 2 minutes of manual input (keyboard layout, timezone, etc), and then installs in about 10 minutes.

Later on I tried hibernation. It works!

In short:
Thinkpad T400 I give a rating of 9/10. The 1/10th ding is for a few creaky noises on opening the screen and carrying it. I hear this is normal so am not worried but, for example, the battery can jiggle a bit.

Ubuntu 9.10 I give 10/10. Amazing live install experience. I would recommend this to anyone. IMHO if you have a friend or family member who doesn't need MS Office or IE, I would now for the first time recommend Linux (Ubuntu) on the desktop.

Sunday, August 23, 2009

Open Hardware: Getting started with Arduino

Ever since attending the Maker Faire and subscribing to Make Magazine, I've been reading and seeing more and more prototypes using Arduino. Arduino is a collaborative Open-Source hardware prototyping platform including a free Software integrated development environment (IDE).

Speaking metaphorically, Arduino is to electronics hardware prototyping as Ubuntu is to computers. While there are several other linux distributions, there too are other open areas of hardware prototyping. None however are as friendly, clear, and obvious as Arduino. There is a vibrant forum community hosted at http://www.arduino.cc/, in addition to tons of high quality reference material on the IDE / language, hardware interfacing, and low level details.

The toughest part of getting started was deciding what to purchase and from where. Since Arduino is open source, there are several third-party fully compatible "clones" meeting the same specs. For someone just getting into hardware (it's been 10 years since I touched a resistor or an LED), you'll also have to buy some necessities depending on what you want to start with. I pieced-out my first purchases to www.sparkfun.com, ebay, and www.digikey.com. If I had to do it all over again, I would probably get everything from SparkFun and DigiKey. While ebay looked cheaper, after shipping on each item, I ended up paying either the same, or $0.05 less than DigiKey/SparkFun and had to deal with more packages, payments, etc. It's no fun to have your Arduino arrive while you're missing a breadboard or anything else to interface with :)

Here are the components I bought, with comments:
SparkFun:

  • COM-00682 LED Matrix - Dual Color - Medium x1         $6.95
    • I should have gotten the small. Bigger is not better. The medium doesn't fit on a single breadboard, and the pins are spaced so that you have to customize full-size or get two small breadboards. Thus, I ended up getting two lower quality / appearance full-size breadboards just to detach one of the power rails to get this to fit. Also, it's pretty big compared to (a) the number of pins it uses and (b) other small electronic components.
  • DEV-00666 Arduino USB Board   x1         $29.95
    • Perfect! Nice packaging, high quality, I should have ordered sooner :)
  • COM-09288 Potentiometer - Linear x1         $0.95
    • Very useful for getting started. Makes it really easy to adjust timing without having to change code and re-upload / wait for Arduino to reset.
DigiKey: (format: part-num, manufacturer part-num, unit-cost, extended price (unit x quantity)


  • ULN2003APG-ND ULN2003APG(5,M) 0.55000 $0.55
    • Not everyone needs this. It's a darlington array which might be helpful working with a 595 shift register to power/drain current from an led array or matrix.
  • 150QBK-ND CFR-25JB-150R 150O RESISTORS 0.06000 $0.60
    • I wasn't sure exactly on the resistor sizes I needed, and 150Ohm seemed like a common value for working with LEDs.
  • P833-ND ECE-A1CKA101 100UF CAP 0.15000 $0.45
    • Looks like I'll need this for a Max7221 matrix led driver which I ordered, to buffer the power supply against noise. Not 100% sure this is correct, but it's the correct farad value (100uF).
  • 493-1095-ND UVR1H0R1MDD 100NF CAP 0.18000 $0.54
    • Second power buffering cap. Same, not sure, but it's 100nF.
  • P3K1103-ND EVU-F2LFL3B14 VERTICAL POT 10K OHM 1.19000 $2.38
    • I got two more vertical potentiometers, which are basically identical to the one from SparkFun at 10kOhm. This is a great size for tuning values. I got three so that I could build an Audino synthesizer which uses pots to control pitch and other features of the generated sound. See http://nomeist.com/audino/134 for a great video.
  • 160-1066-ND LTA-1000HR RED 10SEG BAR 1.05000 $1.05
    • I figured a nice looking, pre-built led array would be nicer and cleaner than individual leds. Verdict: Yes! It's very nice looking and easy to use.
  • 160-1067-ND LTA-1000G GREEN 10SEG BAR 1.05000 $1.05
    • Same as above. These are also quite bright, even at a ~10% PWM duty cycle. Very fun for making sweepers.
  • 24KH-ND CFR-50JB-24K 0.05000 $0.25
  • 30KH-ND CFR-50JB-30K 0.05000 $0.25
    • 24k and 30k Ohm resistors purchased to control the Max7221 LED driver. The resistor value is used to control the current used to drive the array. I found some decent documentation on this and it looks like either value will work, but I wanted the ability to fine-tune the brightness a bit.
  • 240H-ND CFR-50JB-240R 0.05000 $0.50
    • I got 10x 240 Ohm resistors for led control. These turned out to work great with the above LED arrays. Perhaps due to working with them at night, but at 5V (from Arduino) and 10% duty cycle, the 240o resistors still let plenty of current through for the LED array to be bright.
  • 4608X-2-151LF-ND 4608X-102-151LF ISOLATED RESISTOR ARRAY 8SIP 150O 0.32000 $0.64
    • These looked convenient for working with a large LED array. They are basically 8 resistors in a single array that insert together into the breadboard. Note: I should have read this more carefully - there are fully isolated modules (what I got two of) and bussed modules. Bussed gives you more resistors in a smaller space, but have only one discreet sink. I.e. If all of your inputs need just Input -> Resistor -> GND, you can use bussed. This is the common LED use case. No big deal / will still use this, but bussed may have saved a bit of breadboard space.
  • 296-1600-5-ND SN74HC595N 0.66000 $1.98
    • A 595 shift register. These allow you to use 4 Arduino pins to drive 8 digital outputs, and can be chained together to conserve pins. As I'm interested in driving up-to an 8x8 RGB LED array, but only purchased an 8x8 dual-color to start with, it seemed like 3x of these would be plenty. I.e. I can use two to drive the inputs to to the R/G side, while using the third to control the ULN2003A to sink columns of the matrix. Side note: Reading the spec-sheet now, I see that these can only drive ~6ma of current, which is only ~20% of the current spec on the LEDs. Thus, may need to purchase more ULN2003As, but will see.

Ebay:


  • Pre-cut prototyping wires x75 of various sizes. Very useful and cheap, and well worth the money.
  • A 830 pin breadboard for $6 shipped. Also useful, but next time I'd probably buy one of the larger boards so it's more solid and easier to add a bunch of components (i.e. the large led matrix). Note: larger also means easier to spread out and possibly protect your components.
    -------------------------------------------------------------------

    Connecting / Starting Up:
      Since I tried saving just a few $ by ordering from separate suppliers, my Arduino arrived first and I didn't have any other components. Fortunately, Pin 13 is a built-in SMD (tiny, sufrace-mount) LED which you can drive like any other digital output. I installed the IDE which was trivial, and worked seamlessly on Vista x64 (64 bit Vista). Vista recognized the USB->UART (usb to serial) chip on the Arduino as soon as I connected it, auto-downloaded a driver, and it worked without a restart. Within the IDE you can easily load many samples, and I took one of the basic LED control samples and changed it to work on pin 13. One click and ... wait for it ... my little Arduino had a blinking led. It really is that easy, far easier and faster than ordering the components. Really.

      Two days later, all of the goodies arrived and I started unpacking / identifying / organizing the gear. Note: I bought a small, $8 adjustable storage bin, and will probably return it for a larger one. It's really nice to put things away cleanly, and you probably won't use each of the dozen+ components all the time. The one I got is about 1.5in x 5in x 11in, and is much too small.

      On to building the LED array sweeper, the fun part!
    1. Insert LED array into breadboard, with pins on both sides of the center channel. Note the pin-zero / the first pin. The front of the array has a notch identifying pin zero. On the one I purchased, this is an Anode which will get connected to positive.
    2. Bridge each cathode pin (all on the same side, opposite pin-zero), to Ground (GND), with a 240ohm resistor. A bussed SIP resister would make this much cleaner next time.
    3. Connect pins 3-12 of your Arduino to pins 0-7 (Anodes) of your LED array. Note: I first used pins 0-9, but pins 0 and 1 can't be connected to power during code upload (they are serial comm pins).
    4. Connect positive power (5v pin) and GND to the breadboard red/+ and black/- channel/strip where you connected the resistors in step 2.
    5. Upload code and watch your sweeper!
    Next post: Extending to include a pot for time control, and code for the sweeper including basic PWM brightness/dimmer control.