blog.kfish.org

My name is Conrad Parker, and I live in Kyoto, Japan. I am working towards a PhD in Computer Science at Kyoto University, finishing September 2009. I also work on some free software projects including the Sweep sound editor and the Annodex media system, and various smaller projects which you can read about here.

Monday, 12 February 2007

Greek, Cyber-virgins, in LaTeX

For some reason, recently I've been reading a lot of math and writing a lot of LaTeX. I was getting lost in the symbols so I wrote up a chart of the Greek alphabet in LaTeX math mode, in pretty black, white and grey. The source is annotated with instructions for Web 2.0 programmers to replace the grey with cornflower blue.

While putting this together I came across the book TeX by Topic, a TeXnician's Reference, by Victor Eijkhout. The original book, published in 1992, has been out of print for a few years, but it is avaliable from the author's web site as a 289pp PDF. Chapter 1 covers the low-level input processor and expansion, and the subsequent 269 pages go below that, into the nasty implementation details of TeX:

"The four levels [of input processing] (corresponding roughly to the 'eyes', 'mouth', 'stomach' and 'bowels' respectively in Knuth's original terminology ..."

Thanks to the quick search capabilities of my PDF reader I was able to find the details I needed about macro expansion within the few minutes of sanity that this book affords the casual reader. If you are planning to start a neo-tribalistic techno-cult, I highly recommend this book as a means of torturing hapless cyber-virgins during their last few hours before sacrifice.

And keep it real: Respect Knuth's original terminology.

Labels:

Wednesday, 7 February 2007

Atmel AVR ISP mkII, avrdude, Ubuntu

Inspired by Vik Olliver and Geoffrey Bennett at LCA 2007, and by seeing a class full of 9 year old Japanese kids building and programming robots (part of a field trip at C5 2007), I grabbed an AVR microcontroller and started playing.

This post just contains some gotchas for what seem to be common problems.

My aim tonight was just to build and program a simple test circuit, as outlined in Guido Socher's article Programming the AVR microcontroller with GCC. As I have plenty of USB ports but no parellel port, I bought a USB based in-system programmer, the AVR ISP mkII. My laptop is running Ubuntu 6.10 (Edgy), but most of the software required comes straight out of universe, ie. basically pulled directly from Debian.

  • To use the mkII rather than a parallel port programmer, refer to the pin-out for the AVR ISP header. Add a separate Vcc line to the programmer, the rest of the circuit is unchanged.
  • The cross-compiler toolchain is packaged in Debian, as is avrdude (to upload and download the code, dude):
    apt-get install binutils-avr gcc-avr avr-libc avrdude
    
    There are some buildable examples in /usr/share/doc/avr-libc/examples.
  • Guido Socher provides an updated tarball for the demo code in his tutorial. It contains a pre-built image and a useful Makefile.
  • To add an entry for the AVR ISP mkII to udev, add the following to /etc/udev/rules.d/40-permissions.rules:
    #AVRISP mkII
    SUBSYSTEM=="usb_device",SYSFS{idVendor}=="03eb",SYSFS{idProduct}=="2104",MODE="0666"
    
    (from Yuki's Linux Memo).
  • Apparently the factory setting for the clock on these chips is fairly random, so you need to set that explicitly before you try doing anything else like uploading code. If you don't do that, then you'll get a bunch of nasty timeout errors like avrdude: stk500v2_paged_write: write command failed with 128. So set the clock by dropping into the avr terminal:
    $ avrdude -c avrispmkII -P usb -p m8 -F -u -t
    avrdude> sck 10 
    >>> sck  10
    Using p = 10.37 us for SCK (param = 7)
    avrdude> quit
    >>> quit 
    
    avrdude done.  Thank you.
    

Labels: ,