Sunday, August 31, 2008

Where to buy LEDs

While on the subject of electronics, here are some good places to buy LEDs:

MPJA (www.mpja.com) - you can get 100 LEDs (red, green, or yellow) for $1.95. But, there is a $15.00 minimum order. I bought a breadboard from them recently, and the order was filled quickly, so they seem like a pretty reputable establishment.

Jameco (www.jameco.com) - item number 334052 is an orange LED that is $2.20 for 100. Other colors are more expensive, however. I've bought stuff from them in the past, and they're reputable, but their website is kind of a pain to use.

The discrepancies between what different places charge for an LED - a plain vanilla component if there ever was one - really amaze me. At Sparkfun, you pay $0.35 for a green one and $0.50 for a red or yellow. That's right, more than 10 times more expensive!

AVR microcontroller stuff

I'm pretty close to having the parts I need to start my crazy AVR microcontroller project. (Note to self: in the future, don't order parts from Thailand if you want them to arrive in a timely fashion :-) At the moment I'm just waiting for a programming cable, then I'll be off and running. I was originally going to build a programming cable, but after reflecting on my lack of soldering skills, I decided this wasn't a great idea. The one I ordered (from Sparkfun, good place to buy AVR stuff, BTW) was the AVR-PG1B, which connects to a serial port on your PC, and allegedly is supported by avrdude. I also ordered a nifty little breakout board which adapts the 10 pin AVR ISP connector (2x5 pins) to a single row of six pins which can be plugged into a breadboard. I'll need to get some help soldering it, however.

While waiting for the programmer to arrive, I've been poking around the 'net looking at various AVR tutorials. The best one I've come across is at Sparkfun:
Beginning Embedded Electronics
There's a bunch of stuff at the beginning about building a power supply circuit using a 7805 voltage regulator, but you can save that effort if you have a good switching 5V wall wart power supply. Digilent has a good one (part number SWPS). They also have a nice cable for getting the output of the power supply to a pair of leads (part number COAXPOWER). Beware though: the ends of the leads are tinned with solder, so you don't want to stick them directly into a breadboard, lest bits of solder flake off and cause shorts. A terminal block solves this problem nicely.

When I get some blinkenlights working I'll post a picture.

Friday, August 22, 2008

The rest2web template of awesomeness

Now that classes are starting again, it's time to create course web pages. As I mentioned earlier, I'm using rest2web to generate most of the course web pages.

One really nice feature of rest2web is that the template page (used as a basis for all generated web pages) can contain arbitrary chunks of python code. One thing I noticed about my site design was that the sidebar (containing navigation links) was nice for index documents, but distracting for "leaf" documents such as assignment descriptions, lecture notes, etc.

So, I put in a few lines of code to check the page being generated (available from the pagename variable: see the rest2web template documentation) to see if it's an index page, and if so, suppress the sidebar. I needed to futz a tiny bit with the CSS styles, but overall it was an extremely easy change.

My CS 200 page shows how the generated sites look. Given how much easier it is to author reStructuredText documents than HTML, I think I'm getting awfully close to web content nirvana.

Feel free to use/modify/steal my rest2web template and CSS stylesheet files.

Tuesday, August 19, 2008

Thinkpad X61 Tablet

I'm now using a Lenovo Thinkpad X61 Tablet as my main computer at school. So far, I like it a lot. I'm dual booting Windows XP and Kubuntu 8.04. I was able to get the tablet functionality working, with automatic screen rotation (nifty!), using information on the following web page:
http://www.krizka.net/2008/02/13/thinkpad-x61-tablet-automatic-screen-rotation-under-linux/
If you look down at the comments section, there's some information on running on Kubuntu (KDE) instead of Ubuntu (Gnome).

You have to have the "hdaps_ec" module loaded. I put it in my /etc/modules file.

You also have to edit /etc/X11/xorg.conf. Here's a link to the one I'm using (caveat emptor):
http://faculty.ycp.edu/~dhovemey/thinkpadX61t/xorg.conf
Finally, the "autorotate.py" script has a regular expression bug (fix is in the comments). Here's the fixed version:
http://faculty.ycp.edu/~dhovemey/thinkpadX61t/autorotate.py
The stylus is not calibrated terribly well, and the Debian/Ubuntu folks somehow forgot to include the utility that calibrates it. However, it works acceptably. I used the Xournal program to jot some notes, and while it's not exactly like writing on paper, it's not bad at all. I may try to use this in class rather than writing on the whiteboard.

Thursday, August 7, 2008

gschem vs. kicad

I have officially given up trying to use gschem. I can place components (and even create new symbols), but I have had no success connecting pins with wires. It is possible that I am an idiot, but I don't think I have to go too far out on a limb to claim that gschem isn't the most user-friendly of programs.

Fortunately, there appears to be a nice alternative called kicad. The problem of parts I need (e.g., ATtiny2313, ICM7212) not being in the default symbol library is still an issue, although some web searching did eventually turn up symbols for the parts I needed.

Update: I was able to connect VCC on the ATtiny2313 to +5V! I'm going to tentatively say that kicad rocks.

Wednesday, August 6, 2008

rest2web

I've written a lot of HTML in the past few years, especially for course web pages. I've used two basic techniques:
  1. Hand-written HTML using a text editor. Blech.
  2. Editing HTML documents using Kompozer.
Technique #1 is just too much work. CSS has moved HTML quite a bit further towards true semantic markup, so you don't have to worry too much about presentation any more when creating content. However, there's no getting around the fact that HTML (and XML) is just ugly and painful to work with by hand.

Technique #2 is better than #1, but Kompozer (which was derived from the Mozilla editor) has its own share of quirks. It's buggy, and it generates ugly HTML (it wants to put <br> tags all over the #^!%#! place). I've been willing to live with its flaws, and it's saved me a lot of time. However, it doesn't help in automating the creation of navigational elements (e.g., breadcrumbs, sidebars).

Enter reStructuredText and rest2web. The former is a wiki-like lightweight markup language: a reST document looks more or less like plain text, but can easily be turned into HTML via a nifty python utility. The latter is a site-creation tool which uses reST and some additional lightweight metadata to create complete websites from reST files. It took a couple hours to learn my way around, but I was able to produce a very spiffy-looking site from (essentially) plain text files. Sweet!

Now I just need to create some content :-)

Saturday, August 2, 2008

djboxsym - a better way to create gschem symbols

OK, after my recent frustrations trying to use tragesym to make a gschem symbol for the ICM7212, I tried out djboxsym.

To make a long story short, it took about 15 minutes to do what I needed. Sweet. I used the web interface, which is very cool because you can immediately preview your work.

For posterity, my extremely modest efforts are available:

icm7212.sym
icm7212.symdef

Caveat emptor.

Friday, August 1, 2008

The sad and alarming state of circuit design tools in Linux

So, for fun I'm playing around with microcontrollers. I want to enter a schematic for the circuit I'm designing.

I tried out Eagle CAD, but there is no symbol for the microcontroller I'm using (the Atmel ATtiny2313). There are some user-contributed libraries for Atmel parts, but I don't see that part anywhere. Bleh.
[Aside: the ATtiny2313 is only an insanely popular and widely-used part, which has only been available for 3 years now. I can totally understand why it's not in any readily-available part library.]
So, I try out gschem from the gEDA package. Free software is always better, of course. The ATtiny2313 part isn't in the library, but I find it at gedasymbols.org. Yay.

Unhappily, I don't see the ICM7212 in either the built-in library, or at gedasymbols.org.

Blech. OK, how easy is it to add a new symbol? It's a plain, boring old 40 pin DIP. How hard could this be?

Well, it wasn't as easy as I had hoped. The state of the art is described in a tutorial. Here's a brief synopsis:
  1. Download a text file and an OpenOffice spreadsheet file. (The text file is not, as far as I can see, mentioned again in the tutorial.)
  2. Edit the spreadsheet to fill in hundreds of mysterious labels.
  3. Enter the function names,pin types, etc. for each pin.
  4. Save the spreadsheet as comma-separated text.
  5. Run the CSV through a python script, which creates a schematic file.
  6. Edit the schematic file using gschem. (Why? Wish I knew.)
  7. Save it as a symbol file.
Just trying to read the tutorial makes me want to vomit with rage.

The icing on the cake is this: the spreadsheet has pre-defined spaces for only 16 pins. I'm trying to create a 40-pin part. Being a programmer, I'm not going to sit there are fill in cells one at a time (17, 18, 19, etc...). I'll just define a spreadsheet formula that will generate these pin numbers for me, and copy them into as many cells as needed. The author of the spreadsheet, helpfully, disabled support for formulas in the entire spreadsheet. I honestly didn't even know this was possible!

Someone please just shoot me, or at least jab me with something sharp.

There seems to be a simpler approach, djboxsym, which looks like it dispenses with some of the unnecessary complexity.