Combination Lock Solver Michael McManus, Computer Engineering Project Advisor: Dr. Anthony Richardson April 24, 2015 Evansville, Indiana Table of Contents I. II. III. IV. V. VI. Introduction Background Project Design Results Costs Conclusion References Appendices List of Figures Figure 1 – Internals of a Combination Lock Figure 2 – Combination Lock Parts Figure 3 – Intel Galileo Gen 1 Figure 4 – Software Flow Diagram Figure 5 – A4988 Stepper Motor Driver Figure 6 – Shaft Coupler Figure 7 – Push-pull Solenoid List of Tables Table 1 – Cost Breakdown I. Introduction Very commonly people find old combination locks laying around their house that they no longer know the combination to. Many people do not want to throw the lock away or buy a new one because there is nothing wrong with the one they found. It would be nearly impossible for a person to try every combination to find the proper one because of the sheer number of combinations and having to remember which ones have been tried already. I constructed a combination lock opener which will solve these problems by trying all of the combinations until it achieves the correct one. The device can easily keep track of what it has tried and will be able to try combinations faster than a person could. II. Background A combination lock consists of a number of “wheels” or “discs” with notches cut out and a lever which attempts to move when the shackle/handle is pulled as seen in Figures 1 and 2. When all notches are aligned the lever has enough room to move, opening the lock. The problem with opening a combination lock without being given the combination is that there are theoretically 60,840 possible combinations. This is due to having 40 possibilities for the first number, and 39 for the other two numbers since the previous number must be turned past, eliminating it as a possibility. If it takes three seconds to input the first digit, two seconds for the second digit, and one second for the third digit, then it would take 4.225 days to input every possible combination without stopping. A machine would be able to try possible combinations in a much shorter time span and does not require breaks. Figure 1 – Internals of a Combination Lock [1] Figure 2 – Combination Lock Parts [2] However, due to mechanical tolerances the actual number of possible combinations is much less and with some knowledge of the lock this can be exploited. Upon researching combination locks, the number of possible combinations went from 60,840 to 4,000 due to the way in which combinations were chosen. This number can be reduced even further if there is some knowledge about the combination. The overall problem can be broken down into smaller problems such as turning the dial, pulling the shackle, being able to tell when the lock has successfully opened, and outputting the correct combination to the user. Most of these are fairly small problems on their own but when combined together with time to finish and reliability make up a much larger and difficult problem. III. Project Design The solution for opening the combination lock consists of trying every possible combination for the lock until one that works is found. To successfully open the lock, the system needed devices to turn the dial, keep track of the combinations, pull/push the shackle, detect when the lock has successfully opened, and visually output the correct combination when achieved. An Intel Galileo [3], Figure 3, is serving as the brain of the system and the basic approach to the programming can be seen in the software flow diagram of Figure 4. Figure 3 – Intel Galileo Gen 1 [3] Figure 4 – Software Flow Diagram To turn the dial on the lock, the 17HS16-2004S stepper motor from StepperOnline [4] is being used. It has 200 steps per revolution, allowing 1.8 degrees of rotation per step which is more than enough to reference every number on the lock. To drive the stepper motor at its rated voltage of 12V, the A4988 Stepper Motor Driver Carrier [5], Figure 5, from Pololu is used. To connect the stepper motor to the dial of the lock, a 17 mm socket with an extension connected to it has been coupled to the shaft of the stepper motor using a 3D printed shaft coupler, which was designed specifically for this situation, similar to that of Figure 6. Figure 5 – A4988 Stepper Motor Driver [5] Figure 6 – Shaft Coupler [6] The current combination is stored in variables within the programming on the device, which are changed when a different combination is desired. In order to protect the progress of the device the last attempted combination is stored in the EEPROM on the Intel Galileo. Storing the last attempted combination in non-volatile memory allows the system to continue where it left off in a situation where it loses power. To manipulate the shackle of the lock a heavy duty door lock solenoid from Amazon [7] is used, which can be seen in Figure 7. The end of the solenoid is equipped with a 3D printed piece that hooks over the shackle, allowing it to be manipulated. The end of the solenoid also has a spring mounted to it to pull the shackle of the lock back in after a combination has been tried to allow the dial to be turned again. To determine when the lock has been successfully opened I used a momentary switch, product id 818, from Adafruit [8]. The momentary switch is mounted in such a way that it can only be triggered when the lock has been fully opened. The switch pulls one of the pins of the microcontroller low which is checked after each attempted opening. When the microcontroller detects the completed state it will stop trying combinations and output the combination to the user. Figure 7 – Push-pull Solenoid [7] To visually interface with the system a program has been constructed in addition to the program on the microcontroller, which runs on an android device. The program allow users to not only input any knowledge they have about the combination but also serves as the display for showing the combination when the lock has been successfully opened. To help keep the system more affordable and therefore practical, the code for the project has been written in the Arduino environment on the Galileo and a Bluetooth module was used instead of the mini PCI express card slot on the Galileo. Doing these things allows the user to replace the Intel Galileo with any Arduino board, which can help cut down on the cost of the system. While designing the system, the IEEE standard C2-2012-IEEE 2012 National Electrical Safety Code (NESC) [9] was referenced to make sure the hardware met all safety standards. To adhere to the standard, all wiring will is contained within the system enclosure or is shielded. This prevents any wiring being touched with bare skin. There is also be a main power switch, allowing the power to the device to be immediately cut should a safety hazard arise. All switches are of suitable voltage and ampere rating for the system. The IEEE standard 1680-2009-IEEE Standard for Environmental Assessment of Electronic Products (NESC) [10] was also taken into account. Even though this system does not have a direct impact on the environment, it is environmentally conscious through the use of a power supply which plugs into a standard outlet instead of batteries. The system will also reduce the amount of combination locks that are thrown away due to the combinations being lost. To keep the code for the system reader friendly, some of the GNU Coding Standards [11] have been utilized when writing the microcontroller code. The first standard being utilized is that every program starts with a comment stating briefly what it is for and a comment has been placed before each function describing what the function does. The second being utilized is that for function definitions, the name of the function starts in column one to help find function definition when searching a program. The third is that source lines have been restricted to 79 characters or less for max readability in the widest range of environments. The fourth and final standard is that underscores are used to separate words in a name to allow for easier reading. IV. Costs The overall cost of this project is very reasonable and its biggest expense, the Intel Galileo, can be replaced with other Arduino platforms to lower the expense. Table 1 breaks down the cost of the system below. Table 1 – Cost Breakdown Project Part Cost Intel Galileo $65 Stepper Motor $15 Stepper Motor Driver $15 Solenoid $15 Microswitch $2 Socket, Adapter, & Extension $15 Bluetooth Module $15 12 V Power Supply $25 Total $167 V. Results At the completion of this project, I have a device which can take a lock with an unknown combination and successfully open it. The device is also simple enough that someone with either no knowledge of the device or very little knowledge can successfully operate it. Finally, the device looks like a finished product and not like it still has more work to be done. The final schematic and a picture of the final project can be seen in Appendix A. The final microcontroller code for the project can be found in Appendix B and the final Android application code can be found in Appendix C. References [1] safety0ff, secondview.jpg,http://s246.photobucket.com/user/safety0ff/media/secondview.jpg.html, N.p., n.d. [Web. 12 Nov. 2014]. [2] How Products Are Made, How Combination Lock Is Made, http://www.madehow.com/Volume-1/Combination-Lock.html, N.p., n.d. [Web. 12 Nov. 2014]. [3] Arduino, Intel Galileo, http://arduino.cc/en/ArduinoCertified/IntelGalileo, N.p., n.d. [Web. 12 Nov. 2014]. [4] StepperOnline, 3D Printer Nema 17 Stepper Motor, http://www.omc-stepperonline.com/3dprinter-nema-17-stepper-motor-2a-45ncm64ozin-17hs162004s-p-16.html, N.p., n.d. [Web. 15 Apr. 2015]. [5] Pololu, A4988 Stepper Motor Driver Carrier, https://www.pololu.com/product/1182, N.p., n.d. [Web. 15 Apr. 2015]. [6] Adafruit, Aluminum Flex Shaft Coupler - 5mm to 8mm, http://www.adafruit.com/products/1176, N.p., n.d. [Web. 12 Nov. 2014]. [7] Amazon, High Power Door Lock Motor, http://www.amazon.com/gp/product/B0009SWLE6/ref=oh_aui_detailpage_o07_s00?ie= UTF8&psc=1, N.p., n.d. [Web. 29 Jan. 2015]. [8] Adafruit, Microswitch - 2 Terminal, http://www.adafruit.com/products/818, N.p., n.d. [Web. 12 Nov. 2014]. [9] IEEE Standards Association, IEEE SA C2-2012-IEEE 2012 National Electrical Safety Code, http://standards.ieee.org/findstds/standard/C2-2012.html, N.p., n.d. [Web. 10 Dec. 2014] [10] IEEE Standards Association, IEEE SA 1680-2009-IEEE Standard for Environmental Assessment of Electronic Products, https://standards.ieee.org/findstds/standard/16802009.html, N.p., n.d. [Web. 10 Dec. 2014] [11] GNU, GNU Coding Standards, https://www.gnu.org/prep/standards/standards.pdf, N.p., n.d. [Web. 10 Dec. 2014]. Appendix A – Circuit Diagram & Pictures Final Circuit Diagram Final Project Pictures Appendix B – Microcontroller Code Appendix C – Android Application Code MainActivity.java Bluetooth.java intro_screen.xml