Search


Rss feeds
Posts Comments Source Code
Rating
Image to SpectrogramNontransitive DicecheaTorrentDomain ColoringiMac G5 CPU Fan view all...
Recent
Pretty GraphHypernova EngineEmergent FeedbackSDL Euclid OrchardSingularity Viewer view all...
Tags

All source code released under the BSD License unless otherwise specified
© 2010, Gavin Black

Electronic Combo Lock

Overview

Basically this makes a doorknob act as combination lock. Turn the doorknob and it changes values on display, once the proper combo is input it will trigger a solenoid to release the lock.

Electronics

The construction of the solenoid lock electronics. Cost under $10 with part of a bigger order(Unless you can't scrounge up your own power supplies). The most expensive part is the relay.

  • Cheap Trimpot, ohm rating doesn't matter as long as it goes from zero resistance to pretty much a short. Make sure the knob is secure, since it will eventually be taking alot of stress
  • LM7805 -- Linear regulator
  • Power supply for the microcontroller, needs to have around 300 mA of current.
  • Power supply for solenoid, needs about an amp of current and roughly 18V give or take
  • Pull type solenoid
  • 47 uF electrolytic capacitor, to clean up the power signal
  • Dual seven segment display
  • NPN Transistor
  • Electromagnetic Relay
  • Crystal Oscillator(I used 10 MHZ, but it doesn't matter)
  • PIC18F4520, could be any PIC with enough IO, this is just what I started with.
Below is a basic schematic. The PIC and pins differ some from the code, just because the program I used didn't have the PIC4550:
Schematic for combo lock

The circuit was quite easy, although I did have to plus up my microcontroller power supply with a 9V, to get enough current to drive the relay(I originally had a smaller display that broke, and adding the larger one sucked just enough amps to stop the relay from reliably switching).

The software is a simple analog to digital conversion, then chop off all but the upper bits to get the proper hex value. It uses a separate thread to monitor how long the number was held for. One issue that took me forever to debug is the conversion takes several cycles and the number you are storing to has no definite value at that time. Meaning if another thread interrupts in the middle and tries to read that value it will get garbage. This is easily mitigated with a temporary variable being used during the conversion.

Soldering it up was hassle free, although I had a lot of wires that were required. 2 Power supplies to the control box, then 4 wires of power to the solenoid and microcontroller, 9 wires from the microcontoller to the control box for the display, and then a phone cord was used to hook up the trim pot to the microcontroller. If I had been willing to, it would have been *much* nicer to have embedded everything into the door, control box and all, so there were only the power wires.

My crappy spaghetti wiring

Source Code

Source Tree: http://devrand.org:8080/cgi-bin/cgit/comboLock/tree/
Snapshots: http://devrand.org:8080/cgi-bin/cgit/comboLock/commit/
Git Access: git clone http://devrand.org:8080/git/comboLock

Hardware

  1. Mostly the same as the wireless lock, except the additional usage of a trimpot
  2. The door handle must be modified, since it only allows 90 degrees of freedom, and a standard trim pot is usually just shy of a full 180. It's just a matter of bending anything that hits the side upwards till it doesn't hit. This includes 2 spring ends and 2 metal tabs. I used normal needle nosed pliers and a flat tip screwdriver and got it with not too much effort. Pic below:
    Doorknob modification to allow 180 degree rotation
  3. Next a dowel needs to be cut to fit to the proper length. Should be enough to mount the trimpot inside the metal and then have it be snug against There is a picture further down when I discuss gluing that shows this better. Below is a picture of the dowel in the door(I was dumb and had to shape a circular one to work), it's sticking out a little just so I could feel how tight it was in the handle:
    Eye bolt used for catching the solenoid
  4. This is the most difficult part IMO, since it's prone to screwing up, and helps if done correctly. The end of the dowel needs to be carved to fit into the trim pot. For example if your trim pot has a straight slit for a flat tip screwdriver then you need to carve something roughly resembling a flat tip head on the dowel. I used a Dremel sanding tool to to this. In the end you should be able to control the potentiometer with the dowel.
  5. Next glue the Dowel onto the trimpot, you'll have to take off the door handle assembly entirely for this to get it straight. I originally tried epoxy but it didn't stick to the trimpot plastic so I went with hot glue which worked surprisingly well(Been using it a couple months now). Picture of it 'clamped' up below:
    Dowel rod glued to potentiometer
  6. Solder up wiring to the trim pot for later use since it will be hard to get to after it's in place.
  7. Finally put it all back on the door. You can no longer put in the latch(The middle section) since it also hinders rotation. The dowel should slide into the handle, and turning the handle should now turn the trim pot.

Conclusion

It worked well, but the trimpot ended up breaking free after a while, and I didn't bother to fix it since it was just for practice. Here's a video of it in operation:



Last Edited: 2010-10-24 15:49:26

+ Add a comment