Sunday, August 31, 2008

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!

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:

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.

Friday, August 22, 2008

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.

Tuesday, August 19, 2008

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:

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

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.

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!

Friday, August 1, 2008

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:

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.)

Edit the spreadsheet to fill in hundreds of mysterious labels.

Enter the function names,pin types, etc. for each pin.

Save the spreadsheet as comma-separated text.

Run the CSV through a python script, which creates a schematic file.

Edit the schematic file using gschem. (Why? Wish I knew.)

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.