Introduction: RFID Pet Feeder
The video shows the first version with the ID-20 as the reader.
Step 1: Materials
- Sharp GP2D120 Proximity sensor
- 125KHz RFID reader (e.g. ID-innovations ID-20, SEEED studio RDM630, Parallax)
- 1.25" diameter 125KHz RFID tag (or as large as can be worn comfortably on the animal's collar. Tag size influences read range. Bigger is better in most cases)
- Arduino Duemilanove
- 1 adafruit motorshield
- 3 Pushbuttons
- 1 Toggle Switch
- 5 100-220Ω Resistors
- 4 10kΩ Resistors
- 1 Red LED
- 1 Green LED
- The material for the enclosure (such as cardboard, wood or plastic)
Step 2: Find an Old CD-rom Player
Step 3: Add Open/close Sensors (pushbuttons)
To ensure that Arduino stops turning the motor when an open/close action has been performed, I mounted two pushbuttons in the tray, which get pressed when the door is all the way open/closed. This also helps to keep track of what state the system is in at all times. I have mounted a metal strip on the tray in such a way that when the door is all the way open, the strip pushes on one button, and when it is all the way closed, it pushes the other button.
Put the Adafruit Motorshield on top of the Arduino. Connect the motor to the motor shield. I use m3 (digital pin 5). Connect pushbuttons to Arduino analog channel 0 and 1 (in Arduino code pin 14 and 15). Add a 10K resistor between each button and ground as a pull down resistor (http://www.ladyada.net/learn/arduino/lesson5.html) and a low one (100-220 ohm) between the button and the analog channel just so the resistance is not infinitely small. The button that is actuated when the tray is extended (i.e. door closed) should be on channel 1 and the button actuated when the tray is retracted (door open) should be on channel 0.
More info about the motor shield: http://www.ladyada.net/make/mshield/faq.html.
You can test the mechanism with a bit of Arduino code that is downloadable here:
http://www.writtensound.com/arduino/cat_feeder.htm
Step 4: Add Auto/manual Mode Switch and Open/close Button
http://www.writtensound.com/arduino/cat_feeder.htm.
Step 5: Add Proximity Sensor
Code for testing the IR sensor can be found here:
http://www.writtensound.com/arduino/cat_feeder.htm
The sensor has an optimal range. Closer to, or farther away than that, the output will be low. The sensor used here (Sharp GP2D120) has a range of 4-30 cm. Mount it in such a way that when the cat is eating, his head is at a distance that makes the output reliably cross your threshold, and set the threshold at a value that doesn't give a lot of false positives. My sensor output hovers between 50 and 150 with nothing in front of it, and increases to over 230 when anything is within 10cm, so I set the threshold at 200. Also, mount it in a way that the door itself does not activate it. The code is about the same as step 4, but with the IR added. Now the door will never close whenever something is in the way.
code: http://www.writtensound.com/arduino/cat_feeder.htm
Step 6: Connect RF Reader
Connect the TX pin of the RDM630 to the RX (pin 0) of the Arduino
Connect the +5V pin of the RDM630 to the +5V of the Arduino
Connect the GND to the GND of the Arduino
I ended up using the RDM630 because I wanted to add my own antenna (see next step). However, I have also used an ID-20 (ID Innovations) which has a built-in antenna. Because of its limited range it is less tolerant to variations in the position of the tag on the animal's collar, but it still works.
If you use an ID-20 (ID-innovations):
Connect the +5V pin and RES pin of the ID-20 to the +5V of the Arduino
Connect the GND pin and FMT pin of the ID-20 to GND of the Arduino
Connect the D0 pin of the ID-20 to RX (pin 0) of the Arduino
I do not need to communicate anything back to the reader, therefore I only use pin D0.
The code for both readers is the same. I basically copied it from this source: http://www.arduino.cc/playground/Code/ID12
It is not exactly clear who wrote it. Now you can test whether the reader works by first writing an Arduino sketch that has only this function plus something that uses the output value to toggle an LED, as in the code you find here. By the way, for my application I did not need to distinguish between tags, so the door is opened for ANY tag (i.e. when RFID returns a 1), but the code does extract the actual tag value so you could modify it to do more sophisticated processing.
When you put the tag on the animal's collar, try to make it so that the plane of the tag is most likely to be in parallel to the plane of the antenna.
my code
Useful sites about using RFID readers with Arduino: http://www.tigoe.net/pcomp/code/category/PHP/347http://www.practicalarduino.com/projects/rfid-access-control-system
Step 7: Optional: Build Your Own RF Antenna
Guides for the construction of antennas are available for download on the web (e.g. http://ww1.microchip.com/downloads/en/devicedoc/51115f.pdf). They help quite a bit, but I still ended up just trying a bunch of things to see what worked best.
An antenna coil is as simple as this: http://img101.imageshack.us/i/coil2sm.jpg/, just a wire wound up a bunch of turns with the two ends connected to the RF reader.
I used 24 Ga magnet wire and a 1.25" diameter tag to test the antenna.
The following worked well (range is in distance from the plane of the coil):
Circular coil
1.6" diameter, 90-110 turns, no range measurement
3.1" diameter, 75 turns, no range measurement
4.1" diameter, 48 turns, no range measurement
6" diameter, 43 turns, range 3-3.5"
9" diameter, 35 turns, range 4"
Square coil
10" square shape, 31 turns, range 1"
So the largest range was with a 9" diameter coil. Larger than that, the range first went down to zero and then disappeared from the center. If you draw power from the Arduino, use the 9v adapter, not USB only, because the latter provides less power. Also important is when the coil is complete, the wire should be guided away from the coil.
Step 8: Put Everything Into the Enclosure, Load Final Code
Final code for this project: http://www.writtensound.com/arduino/cat_feeder7.pde