Pages

Saturday, November 15, 2014

How a Collector Card Sound Player Works

Today I'm going to have a bit of fun.  Once again the local supermarket has released a set of cards with pictures of animals on them for children to collect.  I've written about certain mathematical aspects of these promotions before.


This time they've added an extra feature to the cards, when swiped through an electronic device, that's also for sale, the sound of the animal on the card is played back for the collector.  In this post I'll give a quick explanation of how the device works.

The cards come in a sealed pack of 4 so people can't pick and choose what ones they'll get, it's a random draw.  They do however have a bar code printed on the back that allows the sound player to know what card it is, and what corresponding animal sound to play.

Collector Cards
Sealed Animal Collector Card Pack
The device that reads the barcode from the card and plays the appropriate sound is a simple mass produced device that seems to be rugged and reasonably well built for a six dollar product.

Card Reader
Card Reader
I posted a rather quick teardown of the reader as soon as I bought it.  It's not very detailed but it gives you an idea of how It works, and will make the rest of the details make more sense.


The internal construction is what you'd expect from a high volume low price device.  I estimate that they probably had somewhere around 100,000 of these readers made, so it's no surprise to see a chip on board solution on a single sided PCB of medium quality.  It comes with three no name AAA batteries.  I haven't probed the board, but I can't see any voltage regulation. There's a bulk capacitor on the input and there could be a regulator under the black blob.

Electronics
Card Reader Construction
The barcode on the card is sensed by an optical reader that's located on a separate board over the swiping slot.  It's held in place by plastic studs that are melted once it's installed.  The reader seems to consist of an infra red LED and an optical sensor like a photo-diode.  As the card is drawn through the slot under the reader, the amount of light reflected from the barcode changes and can be detected.  This is how the barcode is read and the reader know what sound to play.

Card Reader
Reader Slot

PCB
Active Optical Sensor
The part I'm most interested in is the 8 pin SOIC package on the board.  It appears to be a Macronix MX25L1605D 16 Mib flash memory IC and is the most likely place to store the sounds played by the device.   I'm curious as to how the data is stored on it.  There are 108 cards and each card seems to have a unique sound, this means that there are 155 kb for each sound. If we assume a worst case scenario of 4 bit audio (It's a pretty average speaker, any more bits and you'd be wasting them), that means there are about 38 k samples per audio clip.  Clips last around 4 seconds so that would mean about 10 k samples per second.  Due to Nyquist, this would limit the maximum frequency to 5 kHz.  This is a possibility, but I'd really like to get the data off the chip and see for myself.  While I'm there I'd also like to know if I could reprogram it and maybe put different audio on it.  This post was originally going to be an attempt to do that, but the flash memory reader I ordered hasn't arrived yet.  Oh well.

PCB
Sound Card Reader/Player Circuit Board
In the meantime, if you want to impress your friends (NOTE:  if you think this will impress your friends you probably don't have any) you can show them how to read the barcodes on the back of the card to identify the number inside.

The barcode is simple binary and is made up of 13 bits.  Each bit is made of a black bar and a white bar.  If the bit is a one, the symbol will be a black bar 2 units wide followed by a white bar 1 unit wide.  If the bit is a zero, the symbol will be a black bar 1 unit wide followed by a white bar 2 units wide.  To put it simply, thin black bar = 0, wide black bar = 1.

After looking at a few cards it was obvious the last bit was always one.  Those of you familiar with serial communication will be comfortable with me calling it a stop bit.  I initially couldn't tell what the next two bits were, but it became clear that the rest of the code was the number of the card in binary.  Once again drawing on my experience with serial communication I assumed that the two bits I didn't understand were parity bits.  A pattern started to emerge, if there were an even number of wide black bars in the code these bits would be 01, if there were an odd number of wide black bars, the parity bits would be 10.

As some of the people reading this may not understand how to read binary, I've demonstrated in the image below how to easily read the code.  Starting at the bar 4th from the right, put the number 1 under it.  Under the bar 5th from the right, put the number 2, continue this pattern, doubling the number each time. i.e. 1, 2, 4, 8, 16, 32, 64, 128, 256, 1024. Once this is done you add the numbers under the wide bars together to get the number of the card.

Notes
Decoding the bar code on the cards
TADA!  Card number 108.

I've also included an ODS Spreadsheet you can use to generate your own barcodes.  Just change the number in the left column and the barcode will automatically generate for that number.

Animal Card
Animal Card

7 comments:

  1. Internesting article, thanks for the info.
    I am planning on interfacing an Arduino to the ir/sensor and then connecting a keypad that will allow you to just punch in a number of a card followed by # key and it will trick the reader into playing the sound for that card. I might even hook up a 5110 lcd and display the number, name and other info on the card, all all wraped up in a nice 3d printed casing of course.
    Currently the cards go up to 180 if i remember correctly, it will be interesting to see what I get with numbers higher than that... If I get it right I'll put up an article somewhere...

    ReplyDelete
    Replies
    1. That sounds awesome. When you do an article, send me the link. I'd still write it up even if it doesn't work. If you haven't got anywhere to post the article, take a look at http://hackaday.io/.

      Delete
    2. Cool. I spent the weekend working on this and got it to work! It ended up being quiet simple in the end, I have a keypad working to accept input and play the sound, now I'm just working on the OLED to display the info of the animal... BTW, there are sounds past 180... ;-) Ill work on a write-up this week, thanks for the link, Ill put it up there. Cheers.

      Delete
    3. Great to hear. I can't figure out how they get so many samples in that little amount of memory. I haven't checked but maybe they use the same sound for two different animals.

      Delete
    4. I haven't found any duplicate sounds. I can confirm there are 191 sounds. 190 and 191 are human voice. Create a few cards to hear them...

      Delete
    5. Wow, that's awesome. How far did you go with the numbers? It sounds like some sort of competition is/was planned. The company that makes the device is based in The Netherlands http://edison.nl/showcases/superanimals/ and that's an Australian voice, so it was intentional.

      Delete
  2. Those who wish to enhance the sound of their home theatre system will definitely need to consider investing in a new sound bar. There are going to be a lot of http://www.soundbars4u.com/ different sound bars to choose from, making it all the more important to look through the options you are going to have.

    ReplyDelete

Note: Only a member of this blog may post a comment.