Tuesday, December 4, 2007

Lucky's Beepy Ball II!

UPDATE! Scroll to the bottom to see the results of the first trial run!

My dog is blind. Well, mostly blind---he can see a few feet and light and dark---but for most intents and purposes, he's blind. He's not blind in old age, but blind congenitally---he's only 3. His name is Lucky. As a golden retriever, he's obsessed with getting, keeping, carrying, fetching a ball shaped object of any sort. I set out to make a ball that beeps that he can find easily since his hearing is very acute now that he's been fully blind for a while.

I scratched my original design for the Lucky Beepy Ball that was built around a LM556 timer chip and a handful of components (four resistors, two capacitors, and two signal transistors) as being a little too heavyweight for putting inside a ball. I did a lot of head scratching, reading, and doing other builds to learn more and finally settled on a very simple design: 1 ATtiny13V microcontroller, one piezo speaker, a small battery, and a switch. You can't get too much simpler than that.

The Atmel ATtiny13V was PERFECT for this job, as it had a low pin count (it's an 8 pin ATtiny) and operated well in a wide range of voltages. It can operate normally at between 1.8v and 5.5v (the 'V' model of the ATtiny13 is the low voltage version) and is plenty fast (I run mine at 4.8MHz on the internal oscillator). Best of all, it can source and sink at least 20mA on its digital output pins, and has a nice 8 bit timer built in that is easy to program for interesting bleepy sounds.

First I prototyped my design on a small piece of breadboard. All the ATtiny13V REALLY needs is the Vcc connection on pin 8, the GND connection on pin 4, and the two legs of the piezo speaker on pins 2 and 3, but I used the breadboard as my programming harness as well so you can see the 6 pin ISP header at the top. It took a little experimentation to get the beep sound the way I wanted it.

I wanted a beep sound that was easily audible by a dog under a lot of conditions. I figured a chirp would probably work the best. It would start at a high frequency above human hearing but dog-audible, and then decrease in frequency over time until it got low enough so that the wavelength was long enough to have good travel properties through tall grass. Long wavelength sound travels greater distances and can pass through solid objects better than short wavelength sound, so I wanted to take advantage of this property. I wanted alternating periods of chirping and silence so that it was easier for Lucky to triangulate the position of the sound. With a constant chirping, I was concerned that the sound reflection would interfere with his ability to locate the source.


Here are the parts all laid out and ready to assemble. This build was going to be free-formed (point to point wiring) instead of boarded on a piece of experimenters board/veroboard since it needs to be compact and fit inside a ball or Kong ball of some kind.


After programming the ATtiny13V with my chirpy sound code, I ruthlessly hacked its legs off with a wire nipper. This was surprisingly painful for me to do... there's something about defacing a MCU that physically hurts. I wanted unused pins to be out of the way to reduce the possibility of a short and to keep them from interfering with other parts as I put everything together.


The battery I'm using is a 2.4v NiMH battery that I salvaged out of a tiny radio controlled car (one of those Hot Wheels-sized radio control cars that you dock with the transmitter to charge it.) I hadn't used the radio control car much before it broke, so I took it all apart and saved a few select pieces from it. This battery only stores 70mAh worth of charge, but then I don't anticipate that the ATtiny13V and the piezo are going to really need all that much. Plus it was the perfect size. I soldered right onto it at each end.


I brought the positive lead from the "bottom" of the battery up to the center pole on the SPDT switch so I can turn this thing off when we're done playing ball. I soldered the switch's metal housing directly to the negative side of the battery by using a little liquid solder flux (I have a solder flux pen I use for things like this) to get everything to stick.


Next, I mounted the ATtiny13V directly on the switch, soldering the Vcc pin (pin 8) directly to one side of the switch. Then I soldered the GND pin (pin 4) directly to the metal housing. Pins 2 and 3 that you can see in the right hand picture are going to be wired up to the piezo speaker.


Here the speaker is wired to the MCU and the wiring is done.


Now it's time to hot glue this mess to make it more shock resistant and to keep everything in place. I'm using a typical craft hot glue gun to turn this all into a big capsule shaped insert that I can put inside a "Kong" brand dog toy to play fetch with.


... to be continued ...


Ok, today's December 1st, and I took the Luckyball out for a test run. Results were VERY promising!

I needed to hot glue it into a capsule shape for embedding in something like this:


We have a Kong treat ball (not the one pictured) on hand that was perfect for a test run.

I made a cylindrical form to hold the glue that was slightly larger than the diameter of the device (the widest part across the device was the piezo speaker) and put a little hot glue into the bottom of it.


Then I put the device inside and filled it to the brim, giving it time to run everywhere around the device and coat it on all sides. I did only a passable job at this, as I discovered later. The main thing was to make it shock resistant and waterproof.

I left the two charging wires sticking out the top and when the hot glue was cool, I snipped the ends to prevent shorting out in dog saliva which was surely going to be the largest environmental hazard next to outright breaking from shock damage.

I also used needle-nosed pliers and a jeweler's screwdriver to dig out the switch on either side so I could throw it back and forth. It needed a little room to travel to turn the device on and off.

I turned it on and jammed in into the Kong treat ball where it fit very snugly and stayed put for the whole hike.

Then we went on a long hike and threw the ball a lot.

Here's what it looked like when we got back home and I pulled it out:


A little worse for wear, but still intact!

In fact, my estimated current draw was about 30mAh from the ATtiny13V and the piezo speaker driven directly from the digital outputs. The battery was rated at 70mAh, so I figured I'd get about an hour out of it before it started to fade and that's just about what we got.

When it finally was silent, it had shorted out from slobber---though the sound intensity had started to fade noticeably at that point. We let Lucky keep the ball and he played with it for a while---dropping it and rolling it and picking it up and bouncing it and so on. It was loud enough for him to find it if it took a bad bounce, but not loud enough to locate in the open field.

It was amazing, though. I can't describe the feeling of watching him track it down and pick it up in a place he'd NEVER normally be able to get it. It reminded me a lot of when he was a puppy and could still see out of one eye. There were times when it was too loud from wind or crunchy leaves underfoot that he needed a little hinting (walking towards it a few feet would usually get him oriented) but for the most part he was able to find it much more quickly.

With some training and getting used to using his ears more, he'll get better and better. For a trial run of the first prototype, however, I'm incredibly satisfied. ·

No comments: