## 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 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 Putman 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,

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

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