Automatic Pet Feeder

I recently saw a fascinating National Geographic documentary about the level of thinking and consciousness present in apes and chimpanzees. This documentary, Human Apes, used a series of clever experiments to demonstrate the great intelligence of these animals along with their inability to control their impulses. This documentary made me wonder what level of thinking was present in an animal I interact with daily– my cat. To test her basic ability to learn and perform goal oriented actions, I developed an automatic feeder that would dispense food based on the activation of a series of buttons.

I’ll describe each component in more detail below, but at a high level, there were three main parts. The buttons, the system controller, and the food dispenser. The buttons and food dispenser interfaced with the system controller to allow for intelligent processing of inputs and outputs. I wanted to be able to dynamically configure how the activation of the buttons affected the dispensing of food without needing to modify any hardware. For instance, while the cat was still learning how to use the system, I wanted the activation of any button to dispense food. As the cat grew more comfortable with the new arrangement I would begin to place additional constraints on how the button activation would lead to the food. For instance, perhaps only the button with a light on would dispense food, touching any other button would lead to no response. I also wanted to record which buttons were pressed and if it was a correct choice. If the cat was truly learning there should be some sort of learning curve and I wanted to be sure I collected enough data to show such a response.

The intent of this post is to describe the overall system. The data collection process is still on going and once I collect enough data, I hope to post the results. I should mention, that at no time did the cat ever run the risk of not getting food. She always receives twice daily canned, wet food feedings. This dispenser only controlled the access to a secondary supply of dry food.

Activation Buttons

In order for the cat to interact with the system, she needed some sort of interface mechanism. I debated what form this mechanism should take, I thought about using everything from large push-buttons to a touch screen monitor. I eventually settled on using discrete, capacitive touch buttons. This setup minimized both the mechanical housing necessary to mount the buttons, as well as the associated supporting electronics. A mechanical push button would have required some sort of rigid mounting holder to position the buttons in an easy to use manner. A touch screen monitor would have required a computer to drive and control the display. The capacitive touch button allowed me to create a single PCB with all the electronics compactly contained on one board. I decided to use three separate buttons, each button containing a dual-color LED for signaling purposes. I used a relatively inexpensive, rapid manufacturing company, Big Blue Saw to create a simple plexiglass holder to mount the buttons as well as protect the electronics from any curious felines. The setup for the buttons is shown below.

Automatic Feeder Buttons

The following shows a close up of an individual button.

The active button portion of the board is the circular region at the bottom. This is a large copper pour below the silkscreen that connects, thru a small trace, to a AT42QT1010 IC. This is a very simple to use Atmel IC that automatically detects the a capacitance change on the copper pad due to a nearby object. This IC requires only a few bypass capacitors and resistors. The circuit schematic I used is shown below.

Capacitive Touch Sensor Circuit

As you can see, the circuit is not very complicated. The syncUp resistor sets the device into the so-called fast mode which has the fastest speed response but also the highest operating power. The Cs capacitor sets the sensitivity of the detector and the Rs resistor is used for EMC purposes.

In addition to the capacitive touch IC, there is a dual-color LED on the board for signaling purposes. I decided to use a dual-color LED instead of a single color LED because I am interested in testing the ability of cats to distinguish colors. This common anode LED emits both a green and red colored light. I use a p-channel mosfet to control the current through the device. Depending on which mosfet is turned on, I can display red and green either separately or simultaneously.

At the top of the boards is an RJ-45 cable connection. I decided to use RJ-45 network cables to connect all parts of the system together. Each cable contains both power, ground, and digital signals. The output of the touch sensor as well as the LED control signals are each routed through the cable to the system control board.

Food Dispenser

To dispense the food, I used an automatic pet feeder with the internal electronics replaced with my own. A picture of the feeder is shown below.

Automatic Pet FeederThe feeder uses a flexible paddle wheel to dispense food from the reserve up top to the bowl below. When power is applied to a motor unit, the paddle wheel turns, dispensing food with every 90 degrees of rotation. The paddle wheel flips an integrated touch switch every 90 degrees of rotation, allowing control over the delivered portion size. The following picture shows the motor unit from below.

Under Side Food DispenserTo allow my system to control this feeder, I developed a simple board that could turn the motor on and off, as well as sense the state of the toggle switch. The actual board is shown below followed by the simplified circuit schematic.

The motor control circuit is very straightforward, an n-channel mosfet is used to control the current to the motor. A snubber diode across the terminals of the motor helps to contain voltage spikes due to the inductive load of the motor.

One thing I was a little worried about, was the interaction of the motor with the MCU. When the motor is switched on there is a significant increase in the overall power draw. It’s possible that this rapid increase could cause the voltage at the MCU to drop, forcing a restart of the processor. Also, the motor is a very noisy load, and the strong transients created by this load could adversely affect the overall system operation. To help eliminate these problems, I used a large number of bypass capacitors both on the motor control board and the system control board. I also ran the MCU at 3.3 volts with a LDO regulator bringing the 5 volts down to this voltage (through a ferrite bead for further isolation). This gave me a fair amount of overhead to deal with any transient voltage drops due to the motor. These steps were effective and allowed for the motor to operate without negatively affecting the MCU portion of the system.

Controller Board

The main controller board is centered around a PIC18f4525. In this application, the micro controller has three primary duties. One, it must manage the inputs from the touch buttons and the outputs to the feeder. Two, it must record information about what button was pressed and what the current state of the buttons was at the time. Three, it must provide a way for that data to be offloaded for analysis. The board used is shown below.

Automatic Cat Feeder Controller

At the top of the board you can see the RJ-45 connections to the touch buttons and the feeder control unit. On the right side of the board you can see the power distribution circuit. The board is powered through a 5V wall wart power supply that attaches to the board through a 2.1mm barrel plug. The 5V powers two separate circuits, the MCU and the motor in the feeder. The MCU runs off a 3.3v supply which is provided by the linear regulator on the bottom right of the board. The MCU is the 44-pin TQFP IC at the center of the board. Surrounding the IC is a 10 MHz oscillator to the right and a programming header below. The final IC on the board is a USB to UART converter chip, the FT232RL. I wanted to be able to use a laptop or a netbook to offload the data from the unit which precludes using RS232 for device to computer communications. This chip allows me to use RS232 on the MCU side, but USB on the computer side. I am able to communicate with the device through either a virtual comm port (just simulates an RS232 connection) or a C++ API provided by FTDI.

One peripheral I thought I about adding but ultimately decided against was an external SPI prom. I needed the controller to have the ability to store data through multiple power on-off cycles, which requires some sort of non-volatile memory. This device needed to be able to run for weeks at a time without running out of memory. The PIC18f4525 has 1024 bytes of EEPROM, which is useful for many things, but would not be enough to store the amount of data I needed. I ultimately decided to use the flash program memory on the PIC18f4525 to store the data. The 18f4525 has 48kB of program memory available. The actual program only takes up a few Kb, which leaves over 40kB for storing the data. The process of writing the data to the program memory is slow (a few mS per write) but it is plenty fast for this application. When I want to offload data from the device, I connect my laptop to the USB port on the board and request the MCU to read back the stored data. I then command the device to erase the just read data and the unit is free to begin filling up the memory again.

The USB connection was also useful for adjusting various system parameters. For instance, I instituted a timeout period after each allotment of food. I initially set this timeout to zero to help with the learning process, but as things progressed I increased this timeout to 30 minutes. Also I had a number of different running modes, no active LEDs, all green LEDs active, all red LEDs active, etc… These could all be controlled through the USB connection, allowing for rapid reconfiguration.

System Setup

Below is a picture of the initial system setup. The board was first set to allow for all buttons to activate the dispenser. I initially placed a little cat nip on the sensors to help draw the cat to the board and hasten the discovery of the connection between the buttons and getting food. The cat nip proved to be a little too enticing and caused the cat to continually roll over the sensors, not the desired response! Instead I decided to place a small piece of food on the sensors which was much more effective in eliciting the desired response.

Cat Food DispenserI placed the system control board in an old shoe box to prevent the cat from playing with this portion of the system.

This is the setup as it exists today. The cat is still learning the basic connection between the sensors and the food dispenser. At times it appears she makes the connection, but at other times it is obvious there is still some confusion. It’s definitely a slow process as she is not a young cat, but I’m hopeful that in time she’ll come around.

Here’s a video taken on my cell phone showing the feeder in action. You can see that there is some recognition that poking around in the general area of the boards will produce the desired effect, but I don’t think there is an understanding of the individual buttons.

Testing Progression

The initial setup shown above was just for the first learning stage. As the learning progresses I hope to begin testing a number of different things. Including but not limited to:

  • Allow only one of the three sensors to dispense food. Indicate the active sensor with a green LED and track the ability of the cat to correctly press the active sensor.
  • Turn on the red LED on sensors that are not active and track if the cat is still able to identify the active sensor.
  • Require sequential button presses to activate the food dispenser.
  • Separate the touch buttons from the food dispenser.

The progression through these different setups should provide some very interesting data. In the future I hope to post some of this data for those that are interested.

  1. hi, i stumbled onto your site via a google search on pic18f4525 messing about with a easypic6 board. wasn’t even thinking of cats and touch cap’s.

    but, i have two ferals that paw my sliding glass patio door every nite about the same time for me to put a bit of food out for them and now wondering if your touch cap type would work through a sliding glass door? or something?

    was it too difficult to have gotten an SPI interface to a SD card? or your current setup it was just as well to use the flash mem on the pic?

    i’d be interested in your pic code if possible. i’m just a home hobbiest tinkering a bit with pics.


    • I think the touch capacitors would probably work through the glass. Even though the glass may increase the distance between the sensor and the paw, the increased dielectric constant of the glass should make up for this.
      I didn’t actually use an SD card for this setup, I used the on-board flash memory of the pic to record the data. Interfacing with an SD card is not particularly difficult, what is more difficult is navigating the FAT table to create and destroy files. I’ll definitely post the code I used to write to and from the flash memory.


  2. hi,

    wow sorry for taking so long to get back. had thought i’d receive a tick you had responded. 😉

    yes, i would like to study the code and maybe get me two ferals to feed themselves. good input about the “dielectric constant”, not something i knew about. appreciate the education.

    you can email me the code if you would prefer.

    many thanks

  3. hi,

    do you have a control board and one pad for sell? i could get my own auto pet feeder here or online and make mods.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>