About Me

Sunday, August 2, 2009

Improved automatic cat feeder

I recently set up my automatic cat feeder (http://benkrasnow.blogspot.com/2009/02/automatic-cat-feeder.html) for a long-weekend vacation. This was probably the sixth time that I have used the feeder with great results each time. I also setup a motion-activated webcam that posted frame captures to a web server so that I could see the feeder (and cat) while I was away.

One day during the trip, I checked the web server and noticed the feeder had dispensed a huge amount of food. I've never seen my cat eat his fill and walk away from a dish with food in it, but he did this time so there much have been a truly massive amount. When I returned home, I saw what had happened: The cat had knocked over the darkroom enlarger timer, and by strange chance, the timer knob was turned from 3 seconds (an interval that dispenses a single-serving of food) to 20 seconds! The feeder emptied the entire storage chamber of food into the serving dish. It's not possible the cat knew what he was doing by messing with the darkroom timer, but it's also very strange that this happened by mere chance.

I never liked the timer approach to the cat feeder because it assumes the motor turns at a constant speed, and the darkroom timer is not easy to adjust accurately in the range of 2-4 seconds. I thought about adding a shaft encoder to make the system closed-loop. I also thought about using a mechanical means to control the shaft (ie a Geneva Wheel). Finally, I decided to use a strong stepper motor in open-loop control. I also wanted to keep the same gear reduction box that was originally coupled to the food dispenser. It's torque amplification is helpful, and it has also become a structural part of the feeder, so not easy to change.

I removed the old DC motor and pulled the armature off the shaft. I cut the shaft, then built a press-fit delrin coupler to mate the stepper motor shaft to the remaining piece of original shaft (with an integral helical gear on the end). I then made some spacers out of delrin and mounted the motor to the gearbox.

I used an Atmel AT-Mega8 AVR to turn the stepper motor through four shaft rotations when power is applied. I used PN2222 transistors to switch the unipolar motor windings. The transistors are driven through resistors by half the D port in the AVR. The gear reducer's output will spin about 1/6 of a turn, which will advance the "butterfly valve" in the feeder enough to dispense a single serving. I coded the Atmel chip using Atmel's IDE in C with WinAVR. I used PonyProg to download the code into the chip via a simple parllel port interface. I would normally use an Arduino or similar microcontroller for projects like this, but this one is so simple, a full-fledge microcontroller would be overkill and too expensive. The AT-Mega8 is about $6 and needs a $1 crystal. The Arduino is around $30.

My cat stuck his head into a pile of plastic shavings the garage and managed to get a couple scraps stuck in his whiskers.

I need exactly this stepper motor set-up for a similar application. Unfortunately, I'm new to electronics and don't know much about controllers. I would like to buy the chip and transistor and build something that is exactly the same as this machine all the way from the power outlet to the "butterfly valve" shaft. Could you tell me more about the schematics and wiring of your controller?

I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading, I had to go show it to my friend and he ejoyed it as well! best automatic pet feeders