### 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 00110g 00111    h 01000    i 01001    j 01010    k 01011    l 01100m 01101    n 01110    o 01111    p 10000    q 10001    r 10010s 10011    t 10100    u 10101    v 10110    w 10111    x 11000y 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  6g  7    h  8    i  9    j 10    k 11    l 12m 13    n 14    o 15    p 16    q 17    r 18s 19    t 20    u 21    v 22    w 23    x 24y 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.

Stephen said…
I've been meaning to decode this for a while: LeapFrog: Tad's Counting Farm Smart Block Book

No easter eggs again, but it uses an extra bit than actually required. I think the numbers have been used for their pattern:
1 = 0101
2 = 1010
3 = 1001
4 = 1100
5 = 0011
6 = 0110
Simon Zerafa said…
Hi,

Could the a=26 and z=1 simply be a deliberate mistake to catch out pirates?

Anyone who simply copies the hardware and duplicates the toy would then have to explain why this odd choice was used.

This is the same technique as the deliberate mistakes in log tables or on maps to catch copy-cats.

Kind Regards

Simon Zerafa
Jim M. said…
Does this reverse engineering leave you open to prosecution under the DMCA?

Looks like fun anyway, so here goes:

LeapFrog: Fridge Phonics

6 switches 1 = pressed 0 = not

A 010001 ;Skipped 010000
B 010010
C 010011
D 010101 ;Skipped 010100
E 010110
F 010111
G 011001 ;Skipped 011000
H 011010
I 011011
J 011101
K 011110
L 011111
M 100001 ;Skipped 100000
N 100010
O 100101
P 100110
Q 100111
R 101001 ;Skipped 101000
S 101010
T 101011
U 101101
V 101110
W 101111
X 110001 ;Skipped 110000
Y 110010
Z MIA Unknown

It seems to have an aversion to XXXX00. It probably needs bit 0 or 1 to activate the device.

cheers,
MLW said…
I don't know about other products, but when I programmed video games for young children, putting in Easter eggs was probably the quickest way to lose any future contracts (assuming they were discovered, of course). The designers might be far too cautious to even put a benign surprise inside :). But I'd love to hear about any examples out there if you know any.
Anonymous said…
We just got the Fridge Phonics today, and I was wondering at the odd encoding (skips) as well.
I'm kind of disappointed that the unused bytes aren't programmed for something like foreign letters. I'd be more than happy to make my own tiles.
Rainbow said…
Great post!

### Your last name contains invalid characters

My last name is "Graham-Cumming". But here's a typical form response when I enter it: Does the web site have any idea how rude it is to claim that my last name contains invalid characters? Clearly not. What they actually meant is: our web site will not accept that hyphen in your last name. But do they say that? No, of course not. They decide to shove in my face the claim that there's something wrong with my name. There's nothing wrong with my name, just as there's nothing wrong with someone whose first name is Jean-Marie, or someone whose last name is O'Reilly. What is wrong is that way this is being handled. If the system can't cope with non-letters and spaces it needs to say that. How about the following error message: Our system is unable to process last names that contain non-letters, please replace them with spaces. Don't blame me for having a last name that your system doesn't like, whose fault is that? Saying "Your

### All the symmetrical watch faces (and code to generate them)

If you ever look at pictures of clocks and watches in advertising they are set to roughly 10:10 which is meant to be the most attractive (smiling!) position for the hands . They are actually set to 10:09.14 if the hands are truly symmetrical. CC BY 2.0 image by Shinji I wanted to know what all the possible symmetrical watch faces are and so I wrote some code using Processing. Here's the output (there's one watch face missing, 00:00 or 12:00, because it's very boring): The key to writing this is to figure out the relationship between the hour and minute hands when the watch face is symmetrical. In an hour the minute hand moves through 360° and the hour hand moves through 30° (12 hours are shown on the watch face and 360/12 = 30). The core loop inside the program is this:   for (int h = 0; h <= 12; h++) {     float m = (360-30*float(h))*2/13;     int s = round(60*(m-floor(m)));     int col = h%6;     int row = floor(h/6);     draw_clock((r+f)*(2*col+1), (r+f)*(row*2+1),

### The Elevator Button Problem

User interface design is hard. It's hard because people perceive apparently simple things very differently. For example, take a look at this interface to an elevator: From flickr Now imagine the following situation. You are on the third floor of this building and you wish to go to the tenth. The elevator is on the fifth floor and there's an indicator that tells you where it is. Which button do you press? Most people probably say: "press up" since they want to go up. Not long ago I watched someone do the opposite and questioned them about their behavior. They said: "well the elevator is on the fifth floor and I am on the third, so I want it to come down to me". Much can be learnt about the design of user interfaces by considering this, apparently, simple interface. If you think about the elevator button problem you'll find that something so simple has hidden depths. How do people learn about elevator calling? What's the right amount of