Sunday, 3 October 2010

LaTeX Quiz

I wanted to create a quiz for a Canadian Thanksgiving party and I decided to use Latex and the Beamer Presentation package to create a PDF slide show of questions. This worked pretty well, but I wanted to create a second PDF file with the answers shown next to each question to aid with marking. Rather than copying all the files and risk the question PDF becoming out of date with the answer PDF, I decided to create some new Latex commands to dynamically insert the answers depending on presence of command line compile option.

The following code...

%Question/Answer Commands
\usepackage{color}
\usepackage{ifthen}
\newcounter{q_num}
\setcounter{q_num}{1}
\newcommand{\question}[1]{Question \arabic{q_num}: #1\stepcounter{q_num}}
\ifthenelse{\equal{\showanswers}{true}}
{%: Show the answers
\newcommand{\answer}[1]{\textcolor{red}{Answer: #1}}
}
{%: Don't show the answers
\newcommand{\answer}[1]{}
}


...defines the following latex commands:


  1. \question{<question-text>} - This appends a question number to the start of each question. The question number is incremented automatically.


  2. \answer{<answer-text>} - The answer text is only visible when \showanswers is defined as true.



An example Question/Answer slide would look like:

\begin{frame}{}
\question{What is brown and sticky?}
\answer{A stick}
\end{frame}


If \showanswers is defined as false, the output would be:

Question 1: What is brown and sticky?


If \showanswers is defined as true, the output would be:

Question 1: What is brown and sticky? Answer: A stick


There are many ways to go about defining \showanswers. For example you could just define it in your main .tex file:

\newcommand{\showanswers}{true}

Or you could pass it as a command line argument which is what I chose to do using a makefile:

questions:
pdflatex --jobname=questions '\newcommand{\showanswers}{false}\input{quiz.tex}'
answers:
pdflatex --jobname=answers '\newcommand{\showanswers}{true}\input{quiz.tex}'
#where quiz.tex is the latex file containing quiz questions


This will produce two PDFs one called questions.pdf and one called answers.pdf. Only the second one will have the answers visible

Tuesday, 27 July 2010

Linux Shutdown / Login Issues

I frequently use the shutdown command with a time delay to act as a basic 'sleep' function so I can listen to music before I fall asleep. Last night I scheduled a shutdown for 20min but 18min in I prematurely shutdown the computer, without cancelling the scheduled shutdown process. When I booted up the computer the next day I was unable to login despite using correct details: 'Authentication Failure'. I was also prevented from shutting down the system from the login screen. I switched to a different screen (tty2 etc.) and logged in as root after which I was presented with a message that the system was to shutdown in 2min. Attempts to cancel the shutdown using:

% shutdown -c


...didn't work as it couldn't identify the process id to cancel. Logging out and in again a few minutes later revealed the same 2min message. Unsure what to do I read the shutdown man page which revealed that during the last 5min of scheduled shutdown, logins are prevented. This explained the symptoms. I searched the process list but there was no trace of the shutdown utility running. Googling the symptoms revealed nothing so I tried scheduling a(nother) restart (from within root terminal) with a delay of 0min to see if this would clean up / overwrite any left over/corrupt system files:

% shutdown -r now


Fortunately, this worked. I couldn't find evidence of anyone else encountering this problem, so I figured I'd note down the solution here. Essentially I've learned that if you set up a scheduled shutdown, its safest to cancel it explicitly using the shutdown -c command, instead of hoping it will cancel itself when you pull the power.

Wednesday, 16 June 2010

Spell Checking on Fedora 13

I recently installed Fedora 13 after spending over a year with Fedora 11. So far my only disappointment is with the spell checking. Despite ticking the English (UK) option in the install it did not install the correct spell checking libraries by default. Furthermore, I found it hard to find information on how to install the UK spell checking option manually. A lot of information is outdated, suggesting installing gnome-spell. This package is now retired [1] and has been replaced with enchant. So in order to get spell checking set up in Fedora 13, i had to install the following packages:


  • aspell

  • aspell-en

  • enchant-aspell



The english dictionaries now appear for use in gnome applications such as Evolution.

Its a shame that the correct language dictionaries still aren't installed by default.


[1] https://fedorahosted.org/rel-eng/ticket/115

Wednesday, 9 June 2010

Flat hunting in Cambridge

Here are a few pictures from a recent trip to Cambridge to look for flats.




Saturday, 22 May 2010

Monkey World

Time for a non-geeky blog post. Sam & I went to Monkey World on what could be the warmest day in England this year :s








Thursday, 13 May 2010

Tuesday, 11 May 2010

Formica Expansion Board Complete

It's been a while since I've written about this project. This is because the deadline is rapidly approaching and there is still a considerable amount to do. First, here is the final thing:



View from front




View from top


The main problem we are experiencing is trying to get pictures out of the chip quick enough. At the moment we can only manage 4.6fps which is quite poor. Despite increasing the speed of the SPI link, the chip itself is holding us up the process. In returns 'invalid data' if you read it any faster than we are doing so at present.

The second problem we're having is a mechanical one. With the rather large eyes at the front, most of the robot's weight is *not* over the rear wheels, so we loose traction and consequently directional and speed control is proving tricky.

The final presentation is on Thursday and the demonstration some time next week. Busy days.

Thursday, 29 April 2010

Formica Expansion boards have vision ... almost!

Today was the fourth day of assembling and testing our Formica Expansion Boards. The final set of components arrived, enabling us to finish assembling all the boards. We spent the morning getting all of the bump sensor to work. These consist of a pair of piezo transistors, a rectifier, filter and Schmitt trigger. The conditioned analogue piezo signal and the digital signal from the Schmitt trigger are connected to the MSP430. This will allow the possibility of doing something clever with the analogue signal in software to deduce something about the nature of the collision. I'd like to see texture recognition based on this principle at some stage, although this is beyond the scope of our project.

The final, assembled expansion pack will look very similar to the ones in the photos below:





This eye sensor are not soldered on yet, because we are still prototyping how to make the aperture. The picture below has this chip soldered on it and we successfully read a pixel dump from it earlier today. Unfortunately the PCB footprint for one of the capacitors on the eye PCB was wrong, which meant 3v3->GND shorts were really easy to induce while soldering.



In order to manufacture the antennas in a sane and reproducible way, Tom constructed a jig to make them:

Tuesday, 27 April 2010

First signs of life in Formica Expansion Board

Today we gained access to some surface mount soldering tools which ECS recently purchased. This meant we could solder on some of the more complex components such as the MSP430s. Particularly enjoyable was using the hot tweezers to rapidly solder on annoyingly small capacitors and resistors.

Below is a photo of the first signs of life from one of our expansion boards.



Unfortunately, while I was designing the board layout I reordered the programming pins (GND, DIO, CLK). This means that the programming adapters I have had to make to program Student Robotics boards are incompatible (GND, CLK, DIO). To get around this I made yet another adapter board. This lead to a rather unpleasant situation involving too many adapters. Here is a photo of the horror:



I think it is time I address this!

Monday, 26 April 2010

Ducklings on Campus

First spotting of Southampton university ducks:




Formica Expansion Boards Arrive!

As part of a final year group project I have been working to develop an expansion board for the Formica Robots. Over the Easter holidays I spent a considerable amount of time designing the PCB for the project. This is the first PCB which I have fully designed and had manufactured, so it was quite exciting. The boards arrived at the end of last week and so today (Monday) was the first chance I had to look at them and see if they work.
Here is the stack of ten boards fresh from PCB Train:




The white card behind them is a standard business card, which gives you some idea of how tiny these things are. These were then promptly cut with a PCB guillotine to separate the eyes from the expansion board:



Two eyes will stand vertically at the front of each expansion board, as the following mock up demonstrates:



The first problem experienced during construction is that the reverse of the inductor (shown in photo below) has a lot of exposed contact area. This is fine, except there is some ground plane and some signal lines routed directly under it on the board. To get around this I experimented with electrical tape stuck to insulate these tracks from the inductor.

LESSON #1: If you decide not to get a solder mask, be sure that you have not routed signals underneath components such as inductors, which have exposed conductive surfaces.



I have so far assembled only the DC-DC convert sub-circuit, due to the majority of the components being held captive by `stores' (My departments woefully inefficient system for ordering parts). Nonetheless, what has been built, works. This surprised me! The photo below shows the current state of assembly:

Saturday, 24 April 2010

Pybill

The task of working out who owes who what amongst my flatmates was getting pretty complicated. There are always circular debts and bills being split amongst different groups of people. For these reasons I set about writing a program to do this for us. I have name it Pybill. It is written in Python and can be downloaded from gitorious:

git clone git://gitorious.org/pybill/pybill.git 


Or visit the project page: http://gitorious.org/pybill

The program takes a csv file (bills.csv) as an input with the format:


#comment
payee, amount, debtors


The program then outputs the minimum number of cheques required to settle all of the bills. Each person is identified by a single character and groups can be defined similarly. At present these are hard coded at the start of the pybill.py code, although I will change this to be a second CSV file soon. I am still in the process of testing the program but am confident that the algorithm to work out the payments is correct.

There are other freeware/shareware (mainly for windows) which claim to do this, along with many more websites which promise to do the same. However if you don't want all the guff that they come with, or want a simple file based solution then this may be useful.

Friday, 23 April 2010

First Barbecue of the Year

Last night my flatmates and I had our first barbecue of the year. This was the first time we used the home made barbecue that has lived in our back garden since we moved in. The barbecue itself is made from an oil drum, some door knobs off an old set of draws, an upturned shopping trolley and some chains taken off the plugs in the bathroom. We had nothing to do with the design! Of particular merit was the use of the sides from the shopping trolley as the grill.

Unfortunately, whilst it was a really good barbecue, the base of the oil drum rusted through and the legs of the shopping trolley came through it. It now has a sort of tilt to it which it didn't have before.


Playing with fire
Warmth
Hot stuff
If I've said it once, I've said it fifty times. What this barbecue needs is *more* paraffin!

Burning sticks
Shopping trolley barbecue
Good times

My trident of fire

Long exposure fun
The tilt
:D

Wednesday, 21 April 2010

Duck's Guide to 2010

Dizzy Duck
Power Tool Duck
Public service announcement duck
Scaffold duck
duck-on-a-stick
Technobooth Duck
Duck, Over!
Hacker Duck
George Duck
Ramp Duck
Duck at Home