Tuesday, April 06, 2010

It's the thought that counts

After I finally replaced the old HP Procurve 420 Access Point at the office with an Airport Extreme, HP came up with a solution to my problem. They decided to send me, free of charge, a brand new access point (since the 420 had been end-of-lifed).

This was very kind of them and now, sitting on my desk, I have a brand new HP Procurve MSM310 Access Point. It came with all the trimmings: two antennae, a power adapter and a serious steel wall mounting bracket. Compared to the Apple device it looks seriously industrial.

Weirdly, all four parts, the access point, the power adapter, the antennae and the wall bracket, came in four separate packages. The funniest of which was the one that just contained the two small antennae. Good business for DHL I suppose.


Now, I don't know if this device actually fixes the original Bonjour problem I was having, and I'm unlikely to find out. Despite the London address, HP sent a power adapter with a US plug.

Ah well, it's the thought that counts.

Labels: ,

Thursday, March 25, 2010

Goodbye HP Procurve Access Point 420

Over a year ago I discovered a bug in an HP ProCurve Wireless Access Point 420 that we were using in our office. After being treated badly by HP I finally got support from them by blogging my frustration and ending up on the front page of Google search results for procurve support.

Eventually, weeks later, HP acknowledged the problem with the device. But this story doesn't have a happy ending.

In November 2009 HP informed me that the product was being end of lifed.

Out of curiosity I called HP Procurve Support and asked them about the status of my case and they couldn't even look up my case number. Searching around with my name they did manage to find me and my case was active and open. The latest update was on March 19, 2010 and the case had been escalated to Level 3 Support.

My previous experience with HP support wasn't good, but this time Derek was great. He tracked down the ancient case, updated me with information, updated contact information for me. An excellent experience. Unfortunately, waiting over a year for this to be fixed had become intolerable. (If anyone from HP is reading this, email me and I'll tell you Derek's email address since he deserves a special mention).

I replaced it today with an Airport Extreme. Configuration was a breeze with Apple's Airport Utility. And, here's a little known fact, the Airport Extreme can act as a level 2 bridge which means it can successfully extend our existing network without doing NAT and messing up our Bonjour packets (which were the source of the original HP bug).

And, joy of joys, it can perform WPA2 Enterprise authentication against our RADIUS server.

It's nice that HP is working to track down this bug, but 13 months is a little too long to wait for a fix. Sorry.

Labels: ,

Saturday, January 09, 2010

Simplifying my OLPC XO-1 Temperature Sensor

Back in 2008 I wrote about a little circuit to turn the OLPC XO-1 Measure application into a digital thermometer. That circuit required two 9 volt batteries, 11 components and a PCB (plus connectors)

A few weeks ago I got asked about making a commercial version of the probe which naturally led to thinking about how to simplify the circuit. I've now got the entire circuit down to a single component that costs 50p in bulk. I've eliminated all the rest (except the connectors) and the circuit is entirely powered by the OLPC itself.

I actually tried a total of four designs for this circuit.

Design 1: The Original The original circuit looked like this:


It works, but it's a bit awkward since it requires those external batteries.

Design 2: Dump the op-amp One simple thing to do is just make a parallel adder with a few resistors and a reference voltage (the original 0.45v from Design 1) from a voltage divider and not worry about all the stability that the op-amp brings.

Here's that circuit under test. It works, but it can be made even simpler.


Design 3: Diode bias After mentioning this project on Hacker News jacquesm suggested trying an even simpler circuit: the original LM35 temperature sensor with a diode inserted between its ground pin and ground to bias ground to the forward voltage drop of the diode (typically 0.6v) which would bring the output voltage for household temperatures into the range of the OLPC.

That worked nicely (I had a 1N4007 lying around which has a forward voltage of up to 1.1v) and here's the circuit.


Design 4: Switch the sensor And then I discovered that there's a pin compatible replacement for the LM35 called the TMP36 which output 0.75v at 25C with 0.01v per C. That means that at 0C it outputs 0.5v and at 100C it output 1.75v. That puts its output inside the range the OLPC can sense. And it can run on the 5V from the USB port. And it has low output impedance.

So the final circuit has a single component. Here it is under test:


And here it is soldered to a connector ready for connection to the OLPC via my original USB/Mic In connector cable.


So if you want to make a really simple temperature probe for the OLPC XO-1 then get a TMP36.

Now all I need to do is find a supplier of stainless steel probes to put the TMP36 in and I can start making them.

PS Ever since I had eye surgery and stopped wearing glasses I've been worried about splashing solder in my eyes. So I wear a pair of Panther Vision LED Lighted Safety Glasses which protect the eyes and let you see what you are doing at the same time.

Don't you wish your boyfriend was hot like me

Labels: ,

Sunday, December 27, 2009

Toy decoding: vtech Push and Ride Alphabet Train

So, it's Christmas and you end up visiting people with kids... and they've got a fancy new vtech Push and Ride Alphabet Train. Now, you're the world's worst child minder because you see it and think: how does that work?


Specifically, when you insert one of the 26 alphabet blocks into the side of the train how does it know to say the correct letter? And how does it know which side (letter or word) is facing outwards (so it can say a letter or a corresponding word: "A is for Apple" etc.).

Now it quick examination shows that there are 6 small switches in each block receptacle and that each block has corresponding bits of plastic and holes to make different binary patterns. The top bit (bit 5) seems to be used to indicate which side of the block is showing.

That leaves 5 bits for the alphabet. Of course that means there are 32 possible combinations (actually 31 since 'block not present' indicated by all switches up is important), and 26 letters in the alphabet. So which 5 binary combinations are not needed for the alphabet and what do they do?

First here's the mapping between letters and their five bit patterns. Here 0 = button is depressed by little sliver of plastic, and 1 = button is left up because there's a space in the block.

a 11010 b 00010 c 00011 d 00100 e 00101 f 00110
g 00111 h 01000 i 01001 j 01010 k 01011 l 01100
m 01101 n 01110 o 01111 p 10000 q 10001 r 10010
s 10011 t 10100 u 10101 v 10110 w 10111 x 11000
y 11001 z 00001

As I'm sure you've noticed there's something very odd about this sequence. Letters b through y follow a nice pattern, but what's up with a and z? Here's the same information using decimal to make the problem clear:

a 26 b 2 c 3 d 4 e 5 f 6
g 7 h 8 i 9 j 10 k 11 l 12
m 13 n 14 o 15 p 16 q 17 r 18
s 19 t 20 u 21 v 22 w 23 x 24
y 25 z 1

As you can see it appears that the numbers for a and z are swapped. You'd expect a to be 1 and z to be 26. Now, there could be some clever explanation for this but I'm guessing it's the work of Captain Cock-up.

When I used to write software in a hardware company it was pretty common for there to be mistakes in the hardware design or implementation that had to be fixed in software. I remember one very snowy December outside of Route 128 at an HP works debugging something nasty with an EISA card on which our code was running inside some new HP workstation (pretty sure it was a Series 700 with the native GSC bus and something called the Wax ASIC to provide an EISA bus). Turned out that our hardware wasn't latching things onto the EISA bus with quite the perfect timing that the ASIC needed and corrupt data was hitting the main bus. This is not the sort of thing you want to have happen. The fix was done in software to alter the order of writing (which was done with two 16-bit writes) and a little loop to spin around checking for stability.

So, I bet vtech had a little mistake like that. Somehow the codes for a and z got swapped in software there's a fix.

If you haven't played around with hardware much you might have been surprised that button depressed = 0 (see above). This is actually pretty common because it's typical to connect logic lines going into some logic (especially if it's TTL) to positive 5V (or similar) with a pull-up resistor.

In TTL logic an unconnected pin will float around and try to be high, and so most designers ensure that it is actually high with a pull-up. Then to change the input you connect the input pin to ground via your switch (with no resistance). Thus the input is normally high (which is typically interpreted as 1) and goes low (normally that's 0) when the switch is depressed.

Here's a typical circuit:


The only disappointed me was that the extra 5 combinations of 1s and 0s don't do anything. I was really hoping for an Easter Egg left by the developers.

Labels: ,

Monday, April 27, 2009

Adding a # key to a British keyboard on a Mac

The British keyboard layout on the Mac was not designed for programmers. Real programmers need the # key and on US keyboards it's SHIFT-3. On the British keyboard layout SHIFT-3 is the £ (pound sign).

You can access # from 3 by typing ALT-3 (which some people call OPTION-3) but that just feels weird.

Happily, British Mac keyboards have a totally useless key just to the left of 1. You know the one, the one that has § and ± on it. I cannot recall ever having needed to type the section sign (I guess that's something lawyers want) or the plus/minus sign, so that key is up for grabs.

To remap it it's possible to use the program Ukelele to alter the keyboard layout so that the # sign is typed by that useless key.

Or if you are lazy you can just download my keyboard layout and install it in /Users/<you>/Library/Keyboard Layouts and then select it from the International menu on the Finder bar.

If the menu with the British flag on it is not available you can switch it on from the Input Menu section of the International pane in System Preferences. If the new keyboard layout (called British for Programmers) is not available in the drop-down menu, select it from the Input Menu section of the International pane and click the check box.

You will need to reboot your machine after copying the file into place.

Labels: ,

Saturday, March 22, 2008

Building a temperature probe for the OLPC XO-1 laptop

I bought an OLPC XO-1 laptop through the G1G1 program and was intrigued to discover the Measure activity.

The measure activity uses the internal audio system to measure a value input on the microphone socket. With nothing connected this application reads the value of the internal microphone and displays a waveform. You can have fun just by whistling, speaking or singing with Measure running.

But since you can measure a voltage input into the microphone socket, it's possible to build sensors and connect them to th OLPC XO-1. On the Measure web site they mention building a simple temperature sensor using an LM35 temperature sensor that looks like this:

The LM35 can measure a temperature between 0 and 155 Celsius just by hooking it up to a 5v supply. It outputs 10mv per degree so a temperature of 20 Celsius corresponds to 0.200v.

Since the OLPC XO-1 has a USB port it's possible to get 5v from the laptop by hacking a USB connector, and connect 5v to the LM35 and then take the signal coming from the LM35 (the middle pin) and connect it to the microphone socket.

I did this by building two parts: a generic adapter which gives me 5v and a signal line out of a standard stereo 3.5mm jack:

The stereo jack is wired up so that the tip is +5v, the base is Gnd and the middle is the signal going to the microphone socket. The USB plug has only two wires connected (for +5v and Gnd), and the jack going to the microphone socket (which is mono) has the connected to the middle of the stereo jack, and the base is Gnd. All the grounds are joined together.

When plugged into the OLPC XO-1 it creates a generic connector for any other projects I might work on:

For the temperature sensor I simply connected the LM35 to a stereo socket with the correct connections to match up with the stereo jack plug. Then I created a probe with an old plastic pen and some waterproofing compound (so that I can do things like shove the probe in a cup of coffee without wetting the contacts on the LM35). Here it is:

Connect the two together and run the standard Measure activity and you can start to look at the output of the sensor and hence the temperature.

But there's a problem. The microphone input can only handle voltages in the range 0.3v to 1.9v (and my measurements of my OLPC XO-1 show this range to actually be 0.4v to 1.9v). So that means as is the probe can be used to measure temperatures in the range 40 Celsius to 155 Celsius. That low end is a bit high for the sorts of experimentation you can do at home (e.g. measure the temperature in the fridge, or a glass of cold water, or even the temperature inside your mouth).

So we need to scale the voltages coming from the sensor to fit better into the range that's readable by the laptop. The standard way to do that is with an operational amplifier which is used to add two voltages together: the voltage coming from the sensor and a reference voltage. Doing this will move the voltage up.

For that I used the LM1458 which in a single 8 pin package contains a pair of operational amplifiers.

Here's the circuit diagram:

The circuit has three parts: a voltage divider, a summing amplifier and an inverting amplifier.

Voltage divider: the reference voltage is created by taking the 5v available from the USB port and passing it through resistors R8 and R9. The voltage at the middle point of these two resistors is determined by the standard formula for a voltage divider of 5v * R9/(R8 + R9) = 5v * 1 / ( 10 + 1 ) = 0.45v. In my actual circuit with 1% tolerance resistors the measured voltage was 0.41v.

Summing amplifier: the middle portion of the circuit takes the two inputs and adds them together (and because of the nature of the circuit inverts the summed value). So its output going into R7 is -ve the sum of the reference voltage and the sensor voltage.

Inverting amplifier: the final part just inverts the voltage so that the output is +ve and in the range that the OLPC XO-1 can read.

One complexity is that this circuit requires +9v, Gnd and -9v to operate. I obtain that with a pair of 9v batteries linked together giving Gnd where the two are connected. Here's the final circuit with appropriate connectors to hook up to my existing probe and laptop adapter:



And here's what it looks like when it's all hooked together:

Now, this wouldn't be any fun without a bit of software and since the Measure activity can only display the voltage being presented (which is now a mixture of the sensor voltage and the reference voltage) what's needed as a new activity.

I found the developer documentation to be very hard to follow and I ended up hacking the existing Measure activity and renaming it Temperature.

The critical code is in the file drawWaveform.py where it reads self.avg (the value coming from the microphone input via the ADC) and scale it for display. I measured voltages coming from my probe for a couple of known temperatures and worked out a scale factor (The +32768 is because the self.avg ranges from -32768 to 32767):

layout.set_text("Temperature: %.1f C" % (0.00221833*(self.avg+32768)) )

Here's a screenshot of Temperature running on the laptop and measuring the ambient temperature in my office:

You can download my Temperature activity using the browser on your OLPC XO-1 to install it.

Labels: