Tuesday 24 June 2014

Dog-controlled treat dispenser

I picked up one of these treat dispensers from Maplins on a whim - one of those "I'm-sure-I'll-find-a-use-for-this-someday" things. Subsequently I started wondering if I could train my dog, Jack, to use it (with some modifications, obviously)

An initial attempt involved simply wiring a switch to a footpedal for Jack to step on. That lasted all of 10 seconds as the plastic lid I'd repurposed as a pedal cracked under his weight.

One of the things that attracted me to the gadget in the first place was the capacitive button that it used. A quick test with my phone screen showed that dog's paws can operate capacitive switches.

Simply extending the leads alone wouldn't be enough. Although I want to give Jack the freedom to get his own treats, I still want to keep control over how many!

The touch sensors board has simple connections - just power, and leads out to the motor. I didn't really want to waste time modifying the board, as it's all small surface-mount components. Since I know the motor was only driven one direction by the board, I simply connected an optocoupler to the motor outputs. A couple of pull-up resistors later and the switch was done.

The finished capacitive button PCB with optocoupler


I connected a metal lid in place of the small capacitive disc to make it more dog-friendly.

Now onto the human's control system..

My original plan was to use something web connected such as an old android device, so that I could give Jack treats whilst out at work, but in practice, it was totally overkill, so I opted for a microcontroller based system instead.

The only controls I really need are to limit the number of available treats, set a time limit so he doesn't eat them all at once, and a way to see how many were available.

I found an old PCB with two buttons on it in my junk box. One button to add a treat, one to remove.
 
The salvaged button PCB (I believe it once belonged to a toaster...)


For a display I went with a 10-segment LED, controlled by a shift register. Due to the limitations of the shift register, the maximum treats available at any one time is 8 - which is more than enough anyway. The remaining 2 LEDs are left unused.
The 10 segment display (3 treats available) - the bottom 2 LEDs are not used.



The time limit I chose to fix at 1 hour in the microcontroller. As it's impossible to precisely measure the amount of treats that will be dispensed, the motor was set to a 3 second interval.

Finally I added a small LED module to the pedal, that lights when the timer ticks down and a treat is available, so that Jack could see when he can get a treat. According to the Pavlovian theory, he should soon learn that light=treat.

The LED module (it's just from one of those battery operated 'cupboard lights' you see in nearly every pound shop) - for this project I just connected a jumper over the button.


As with other projects I opted for using an Attiny (in this case the 2313) with the Attiny arduino cores, as they make it nice and easy to prototype with Arduino and switch to a regular AVR for the end product.

Stay tuned for part 2 - building an enclosure for it, some pictures of the completed project, source code, and hopefully some pictures/video of Jack using it.

UPDATE - Part 2 is now available here.

No comments:

Post a Comment