Monday, July 19, 2010
--- A demo of how the RFID door mechanism works. Normally the RFID reader is facing outward so you can wave your ID on the outside of the door to unlock it.
Last semester I was lucky enough to get an order through during Sparkfun's Free Day - $100 of free electronics - awesome! Among the things I got for free was the ID-12 RFID reader, a cute little RFID module that outputs the tag ID over a 9600 baud serial line. Naturally I needed to put it to good use, so when I was bored one night (avoiding psets) I set out to make my door unlock/open via RFID.
The biggest obstacle was the mechanical actuation of unlocking the door. My door doesn't have a deadbolt, which means the knob itself has the locking mechanism built in. Ideally I would have installed an electric strike, but unfortunately the cutout in the steel door frame was too small to install one. I also briefly considered sticking some sort of motor inside the door frame that would push the latch open (since the interlock mechanism that normally prevents this wasn't working), but that would require too much torque in a small space to be practical.
Since I couldn't figure out a way to easily release the latch itself, I decided to go for the brute force approach instead - hook up a motor to turn the actual doorknob from the inside. At first this too seemed nearly impossible; there was no good way to mechanically grip the knob, and even if you could it still requires a huge amount of torque to rotate. Of course the obvious solution, as always, was duct tape! One of my friends pointed out that the knob only has to turn about 45 degrees, so I could just wrap duct tape around the knob giving me a kind of "rope" to pull.
Next I needed a high-torque motor to act as a winch and pull down on the duct tape "rope." Conveniently I had a bunch of LEGO left over from competing in MIT's 6.270 Autonomous Robot Design Competition, so I made a nice gearbox out of lego and attached this to the duct tape. The gearbox let me use a cheap high-rpm DC motor to power the "winch" instead of having to buy an expensive high-torque motor. I mounted the gearbox/winch to the door with 3 strips of Command adhesive (one of the greatest inventions ever), which theoretically provide ~9lb of holding force.
This design also had the nice feature that the knob is still fully functional even if everything fails, so it's impossible to get trapped in my room :)
To control the motor, I hooked up an ATMega328 (Arduino) with a TA7291P motor driver. However, I needed a way for the Arduino to know how far to turn the knob and how far to turn it back afterward. I added a simple microswitch to the gearbox that could count revolutions (see picture above). The Arduino just has to turn on the motor and wait for a certain number of revolution "clicks" in order to turn the perfect amount every time. This worked great, but since I planned to use this door opener every day, I made sure to design for failure. I programmed a timeout in case something failed and the switch wasn't activated, which would leave the motor forever trying to turn the knob and eventually burn it out or blow out some other component. As it turned out, this was absolutely necessary, since the LEGO gearbox tended to jam up over time (the gears would "wander" back and forth on the axle).
Next I hooked up the ID-12 RFID reader. This was extremely simple since the package just needs 5V and ground and outputs TTL serial. Instead of hooking the serial output directly to the Arduino, I decided to feed it to my room automation server for authentication. When you swipe an ID card, the tag ID goes to the computer for verification, and if it passes the computer sends a signal to the Arduino telling it to unlock the door. This made it easier for me to update access-control since I didn't need to reprogram the Arduino all the time, and it allowed me to integrate it into my room automation system and provide a web interface so I can unlock my door from anywhere (in case I need to let someone in when I'm not around).
--- The electronics - main components: ATMega328 microcontroller, FTDI USB serial interface, TA7291P motor driver, and ID-12 RFID reader.
It's amazing how productive you can be in one night if you really don't want to do school work :)