Greetings from Kilnettle – Part 3

Having tested and placed the hall effect sensor, the next stage was to come up with an algorithm to detect the movement of the roll of tape, and to then calculate the amount of tape used.

In the episode, there are 3 phrases used (after more careful watching, there are four phrases) one each for “1 inch of sticky tape”, “2 inches of sticky tape” and “3 inches of sticky tape” (I got these lengths wrong too!). Based on this, I wanted to classify each tape usage into one of these three lengths and then play the appropriate phrase.

0 to 1 inch -> play 1 inch clip

1 to 2 inches -> play 2 inches clip

2 inches and above -> play 3 inches clip

My method of playback was going to be via a nifty module that plays back .wav and .ad4 stored on a micro SD card. The WTV020SD is readily available on ebay and is pretty cheap. There is a good library available for its use with an arduino, although it can also be used as a standalone player. The one downside, is that it requires 3.3V which means adding another regulator into the circuit if not natively available. Hooking it up to the arduino is pretty easy and I used a duemilanove as my development board and so used the 3.3V output from that to power the module during the development.

I fleshed out my algorithm idea on the whiteboard and drew up a circuit block diagram to help with the planning. You can see the picture below of the whiteboard stage, but please note the algorithm changed in the actual coding. Converting from pseudo code to actual code went pretty well considering it had been a while since I had done any programming on the arduino.


Before diving into the main program itself, I broke out some of the steps into separate chunks to test those first. By breaking the process into stages, it enabled me to simplify testing and identify quirks as there were some issues reported in the library’s thread on the arduino forum. It also allows for a more modular design in terms of approach.

First was to test the playback of the episode phrases. Using the scripts book, I had a good idea of the rough location of the¬†phrases. I then used youtube as a source for the episode audio. I would have used my brother’s dvd boxset but it was with him out of the country!

I used an add-on for firefox to scrape out the audio as an mp3, then I converted the mp3 to wav using Audacity. I used a tool from 4D that converts .wav to .ad4. The tool is available for download on their Somo-14D page as it seems to be based off the same base chip as the WTV020. The files must be numbered 0000.ad4, 0001.ad4 and so on. Once converted, I copied them to the root of a an old 64MB microSD and placed the card in the WTV020.

The library comes with an example “sketch” so I used this to test the playback of the audio clips. There was a slight issue with the playVoice call as the toggling of the busy pin was not reliable. This was noted in the library thread with some fixes noted by others but even with those fixes applied, i was still having issues with the playback. Instead I chose to go with the asyncPlayVoice call which uses the delay() call to allocate the length of time to play the clip. Given I knew the length of each clip, this wasn’t a big deal.

Using some buttons, I rigged up a circuit to trigger each clip based off a button press, i.e. press button 1 to play clip 1 etc. This worked well enough so I expanded to trigger off the hall effect sensor. I was using an extra hall sensor just plugged into the breadboard so I just added some code to read the value of the sensor and if it fell above 700 to play a sound clip. Again, this worked well enough so I was now happy I could trigger the playback of a desired clip as required.

Next up – the implementation of the logic for determining the length of tape used.




One Response to Greetings from Kilnettle – Part 3

Leave a Reply

Your email address will not be published. Required fields are marked *