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.

Tuesday 10 June 2014

Android App: RSS Media Grabber

My second android app is now available on the Google Play store. It's a port of a desktop Java application I wrote a while back, which will retrieve image media from RSS feeds - useful for web comics/cartoons, pic-of-the-day sites etc.







Usage
When using the app for the first time, use the menu button and select "Add New Source".
On the next screen, enter the URL for the feed, and give a folder name (this will be where the app stores the files it downloads - eg, if you enter "MyFolder", the directory will be sdcard/RSSMediaGrabber/MyFolder/)
Select OK to return to the main screen, and select menu->Load sources. This will list all the RSS feeds you've added.
Select one of the feeds to be prompted to retrieve the feed. Select OK and it will load the feed, grabbing any image media, and saving them to the folder.

You'll then be able to view the downloaded media through your photo app of choice.


Future development plans
  • Wider media selection (MP3 for podcasts etc).
  • Integrated media viewer/player
  • Scheduling to check feeds at set intervals.

Support/Feedback
As with my other apps, it's free (ad-supported), and I welcome feedback. Unfortunately I'm not in a position to offer any kind of official support for this, so use entirely at your own risk. If you have any trouble with it, then feel free to contact me on twitter/G+/leave a comment, and I'll try to help as and when I can, but I make no guarantees!

Any feedback, particularly with regard to different phone/tablet hardware and android versions is appreciated.