User:1sfoerster/enes100/fall2013/p3Combo

=Finish Description= =Conceive= 1. Market/Customer Needs To help someone open their lock, if they forget their combination.

2. Initial target goals To make an automatic combo lock pick. To have the hinge fold the lock pick to a resting position so that a new lock can be put in.

3. Project cost and schedule We all ready have all of the parts needed.

4. Be able to open a Masterlock without knowing the combination

5. Ability to easily remove abandoned locks from public lockers
 * Replace bolt cutters
 * Locks still useable after removal
 * Retrieve forgotten combination

Original project by students at Olin College: http://boingboing.net/2011/03/10/combination-lock-cra.html

Step by Step guide to how a masterlock can be opened: http://www.markedwardcampos.com/files/gimgs/13_mcamposfinal.png

=Design=
 * Tutorial of Combo Lock Pick Method Found
 * Wikihow steps for cracking a Masterlock Combo Lock.
 * Hackaday step by step guide for Masterlock.

Oldest Body Design
 File:MechanicalComboLockPick.jpg|The system 

Material List
-1 Stepper Motor

-2 Arduinos, stacked

-1 Masterlock brand combination lock

-1 small piece of wood (to serve as a base)

-1 pull tie (to fasten the motor to the wood)

-1 plastic connector piece (unknown origin, part of a pile of random plastic scrap)

Oldest Wiring Design
 File:Lockpick poster.jpg|Everything connected and working. 

Material List
1. A relay

2. A 2SD1765 transistor

3. A 22K Ohm resistor

Original Body Design
The first thing that we did was screwed two blocks off wood to the door hinge. However this became problematic because the hinge did not extend to a full 90 degrees angle. To solve this we cut the wood at a angle to get the hinge to extend to 90 degrees. The next problem was extending the wood back because the platform of the hinge was getting in the way. To fix this we cut out a block off wood where this hinge was hitting. After doing this the hinge could extend in and out with out a problem.  File:Front view of combo lock pick.png|The lock and puller have been mounted on the back piece of wood. File:Side of project.png|The lock and puller have been mounted on the back piece of wood. File:Extended view.png|The hinge allows the lock pick to be folded into a working and non-working position. 

Original Gear Structure
The next thing we did was make gear structure that will link up the the gear on the motor, and be attached to the rubber stopper. All of these pieces must spin together to work. So they all have to connected to each other.  File:Gears close up.png|Gears made to link with the one attached to the motor. File:Back of gears.png|A bolt runs through the gears that is attached to the rubber holder. File:Gears finished.png|The gears after the washer is put in.  The project needed to be raised up to prevent the hinge from making it off balance. Next we drilled a hole into the bottom board and glued a plasic holder in. We are using this to try and hold up the gear structure.  File:Hole drilled into bottom block of wood.png|This hole is drilled to put the plastic in that will be holding up the gears. File:Plastic is glued into place.png|The holder is glued into the hole. File:Height added to the lock pick.png|Blocks of wood are screwed into the bottom top add stability to the project. Also the hinge can now be put back without moving the whole project. 
 * The middle gear is used to link to the gear on the motor.
 * The washer is what will be put into the plastic holder.
 * The plastic holder will hold up the gears.

Body Re-Designed
 File:Side view of wood under the hinge.JPG|The wood pushes the hinge up to extend the hinge further to try and get it to a 90 degree angle. File:Bottom view of wood under the hinge.JPG|The wood pushes the hinge up to extend the hinge further to try and get it to a 90 degree angle. File:Both boards attached to hinge.JPG|Both boards attached to hinge. File:Board with lock.JPG|The board with the lock is attached to the upright board. The upright board isn't all the way to 90 degrees but the nuts on the back of the lock board push it out to a 90 degree angle.   File:Wood boards are added underneath.JPG|Wood boards are added underneath to hold up the project, and to keep it balanced. File:Underneath View.JPG|Underneath view of the project with new boards added to stabilize. File:Turn-able Wood Blocks.JPG|Turn-able blocks are added to prevent the project from falling back when the lock is being pulled up. File:Blocks turned to the side.JPG|Blocks turned to the side to allow the lock board to but pulled back, but the blocks are too big so the board can not be reclined. File:Side view of the turn-able blocks.JPG|Side view of the turn-able blocks. File:Upright cut blocks.JPG|The turn able blocks are cut to allow the lock board to recline. Right now they are upright to hold the board up. File:Sideways cut blocks.JPG|The turn able blocks are cut to allow the lock board to recline. File:Lock board reclined.JPG|Lock board reclined. 

Gear Structured Re-Designed
 File:Bearing to hold up gears.png|Bearing that will be used to hold up with the metal stand, while the middle can still spin File:Gears interlocked.png|Gears interlocked File:New Gear structure.png|Gears all put together File:Gear that will hook up to Motor gear.png|Gear that will hook up to Motor gear File:Bearing on Gear.png|Bearing on Gear File:Screw Through Gear.png|Screw Through Gear  <Gallery> File:Metal Holder.png|Metal holder that will hold up gears File:Metal Stand.png|Metal that will hold up gears File:Gears Held Up.png|Gears held up against lock </Gallery> <Gallery> File:Bearing inside board.JPG|Bearing inside board. This can be used to hold up the gears, but keep them turning. File:Side view of bearing in a board.JPG|Side view of bearing in a board. File:Gear that fits in bearing.JPG|Gear that fits in bearing. File:Side view of gear in bearing.JPG|Gear in bearing. File:Back of gear in bearing.JPG|Gear in bearing. File:Bearing board screwed in.JPG|Bearing board screwed in. File:Side view of bearing board screwed in.JPG|Side view of bearing board screwed in File:Bolt that is runs through all of the gears.JPG|Bolt that is runs through all of the gears. File:Screw head is filed down.JPG|The head of the screw is filed down so that the rubber piece can properly hold the lock. The head of the screw was getting inn the way. File:Gears all put together.JPG|Gears are all put together but when they are tuned the bolts loosen up. File:Gears all put together.JPG|I might add washer to try and prevent the nuts from loosening. File:Washers on gears.JPG|Washers are added to try and keep the nuts from spinning and therefor loosening or tightening the gears. File:Gears with washers.JPG|Gears assembled and linked to lock. </Gallery>
 * The back gear connects the the gear on the motor.
 * The washer is used so that the gears connect to it, so the inside of the bearing moves while the outside is glued in place.
 * The middle gear is used to connect to the bearing.
 * A bolt is running through the middle to hold everything together.
 * A metal hook is bent to hold the bearing in it.
 * We decided to use a board with a bearing in it because this is more stable then gluing a bearing onto a metal hook.
 * The board was cut and screwed into place.
 * A gear that is the same size as the hole in the bearing is put in it. The other gears fits around the fist gear and a bolt runs through the rubber stopper and all of the gears.
 * Washers are placed on both sides of the bearing, and on both ends off the gears,where the nuts are. A problem with this design is that when the gears are turned the nuts loosen and tighten. This is why the washers are added. They are supposed to prevent this. Another problem is that the screw head inside the rubber is too big. This is a problem because the rubber can not grip the lock anymore. To solve this the bolt head is filed down.

Final Working Gear Design
The final design for the project consists of a large, stable base section, raised off the ground to allow the mounting of a two-position hinge. This hinge is used to direct and control movement of an upright section, upon which are mounted the solenoid, lock, and a PVC that holds the lock in place. The motor and shaft assembly are mounted in a fixed location in front of where the lock will be in an upright position, allowing the lock and rubber stopper to engage via pressure. Behind the upright section, two small wooden blocks on pivots can be swung upwards to hold the assembly in place or downwards to allow the assembly to recline. Reclining the assembly removes the lock from in front of the motor assembly and into a position where it can be removed and replaced. The Arduino and wiring for the motor and solenoid will be located off to the side, at this point unmounted so as not to interfere with the operation or or further alteration of any other parts.

Videos of Gears Spinning
Here is a video to show the improvement we've made after brainstorming for days:
 * Before Video: http://www.youtube.com/watch?v=TGGgvnxqCQo&feature=youtu.be

Arduino Code and Wiring
Reading code written by last years' teams provided a starting point for writing our own code for using the Arduino and motor shield with the provided stepper motor. The first attempt at writing code for the project built off of the old teams' work, altering the step size and timing to match with the stepper motor provided.

We attempted a Quick Test of the code by attempting to run a shortened version of it. By attempting to loop through 16 possible combinations, it was found that the code and motor shield wiring based on previous teams' efforts had multiple errors.

The Wiring Diagram for the motor shield was also helpful in determining how to properly wire the motor to the motor shield.

At this time we located a Tutorial on how to use the motor shield properly. The wiring for the motor was also called into question and a simple test showed that it was indeed wired improperly. This led to stepping back to start with the code and wiring of the motor, Arduino, and motor shield. At this time we are working on writing new code to operate the stepper motor to follow the implied algorithm for cracking the lock.

of the LED turning on to show a matched pair of wires from the motor.


 * Tutorial of Combo Lock Pick Method Found
 * Wikihow steps for cracking a Masterlock Combo Lock.
 * Hackaday step by step guide for Masterlock.

Blink Program
Material: How to get to the blink program: <Gallery> File:Arduino Blink File.JPG|This is a file that is already made on the Arduino program on the school computer. It is the blink program. File:Blink File.JPG|I changed the blink file to activate on the arduino when the orange wire is in port 5, not 13. Because port 13 is needed for the motor program. File:Arduino Connected to computer.JPG|Arduino linked to computer to send it the program to run the solenoid. File:Wires Coming off of the power cable.JPG|The power cable connects to the solenoid and to the arduino. The red wire is the ground. The orange wire is what runs the program. File:Wires in Arduino.PNG|Red goes to the ground, and when the orange goes into the correct port it shoots up the solenoid. File:Solenoid Pulled Up.PNG|The solenoid is told by the arduino to contract up. File:Solenoid Switch.JPG|This switch could be used to mount on top of the solenoid to tell it when it hits it to stop the program because the combination has been solved. </Gallery>
 * Arduino
 * Power Switch Tail
 * Sensor
 * Solenoid
 * Engshortcut
 * Arduino
 * Ports
 * USB serial port (Com 14)
 * Blink Program

Solenoid activated using Port 13 on the Blink program:

http://www.youtube.com/watch?v=3N0Egcpq_8c&feature=youtu.be

We moved the Solenoid activation to port 5 to see what happens:

http://www.youtube.com/watch?v=w8uWqiPF8JI&feature=youtu.be

Arduino connecteed to the Solenoid:

http://www.youtube.com/watch?v=qMwK1ov807k&feature=youtu.be <Gallery> File:Power Source Plugged Into Solenoid.JPG|Power source plugged into solenoid File:Power Source Back.JPG|Power Source screwed in to the upright board. </Gallery> Video of the Combo lock relining back to change out a lock, then coming back into position:

http://www.youtube.com/watch?v=cFAW6Mqz9Vo&feature=youtu.be

After getting the Blink program, we connected the arduino to the computer and uploaded the program. if done properly the led on the board should be flashing on/off every second. next, we Plugged in the Power Switch Tail and took hold of the two wire. the red wire will be plugged in to the port labeled ground and orange wire will go into port 13 which will active the solenoid.

After playing around with the arduino program, we was able to modify the current blink program to help the solenoid snap a lot better by decreasing the High output to 50ms and increasing the Low output to 2000ms. this gave the solenoid a faster snap then a longer release when the solenoid is active.

The modify Blink code that gave the solenoid a more Natural snap: http://www.youtube.com/watch?v=JkO884DU_N4&feature=youtu.be

Mounting the Arduino
This is a broken arduino that we mounted before the one that will work with our project. We first mounted this one to ensure that we had a way to put it on the base first without attemping to put on the working arduino. <Gallery> File:Rubber pieces that will be under the arduino.JPG|These rubber pieces go under the arduino, and around the screws. File:Rubber pieces on the board.JPG|This is showing where the rubber pieces will go on the wood. File:Top view of arduino screwed into the board.JPG|Top view of arduino screwed into the board. File:Rubber under the arduino.JPG|Rubber under the arduino. File:Side view of rubber under the arduino.JPG|Side view of rubber under the arduino File:Rubber under the top two screws.JPG|Rubber under the top two screws. File:Screws with rubber through the arduino.JPG|The screws run through the arduino with the rubber on the bottom to keep the arduino from coming into contact with the wood. </Gallery>

Extending Wires
<Gallery> File:Ground wire does not reach the arduino.JPG|Ground wire does not reach the arduino. File:Wires connected before they are extended.JPG|The wires need to be extended because when the solenoid is pulled back the wires are too short to stay connected to the arduino. File:Power wire is extended.JPG|Power wire is extended by soldering an extra wire to it. File:Heat wrap on power wire.JPG|After being soldered the power wire is wrapped in a heat shrink wrap. File:Ground wire is extended.JPG|Ground wire is extended by soldering. File:Ground wire is extended again.JPG|Ground wire is extended again by soldering. </Gallery> Video of the wires being to short to stay connected while the solenoid and lock are pulled back:

http://www.youtube.com/watch?v=RnwxFWSSMJI&feature=youtu.be

Video of the solenoid and lock being pulled back, the wires stay in place:

http://www.youtube.com/watch?v=1t0uR5_pfHs&feature=youtu.be

<Gallery> File:Hole drilled for wires.JPG|a hole is drilled to channel the wires through. File:Wires running along bottom.JPG|Wires running along bottom. This makes them hidden from sight. File:Wires coming through the hole.JPG|Wires coming through the hole, but they aren't long enough. File:Wires go underneath the wood.JPG|Wires go underneath the wood. File:Wires soldered.JPG|Wires extended to reach the arduino. File:Wires coming through the bigger hole.JPG|wires are now long enough. File:Wires connected to the arduino.JPG|Wires coming through the hole and connecting to the arduino. File:Wires running under motor.JPG|Wires running under motor. File:Hook 1 holding wires in place.JPG|Hook by the hinge is holding the wires in place as they come in from the power block. File:Hook 2 holding wires in place.JPG|Second hook is placed by the the hole under the arduino. </Gallery>

the regular wire on the Optical switch was very weak. We soldered new wire on to exciting wire to increase it strength and durability. this will allow for a better connection point for the the arduino. after these connection as been made, this should give better contact points on the arduino.

Solenoid Hook
<Gallery> File:Thicker hook.JPG|A thicker hook is needed connect to the lock because the solenoid would bent the thinner one out of shape. File:New thicker hook.JPG|thicker hook connected to lock. </Gallery> Video of the thicker hook connected to the solenoid:

http://www.youtube.com/watch?v=ZnLiqRuQBjM&feature=youtu.be

Re-designing Gear Structure
<Gallery> File:Motor Connected to gear.JPG|the motor needs to connect to the gears by moving forward because there is a line hat runs through the middle of the gear. File:Gears moved forward.JPG|The bearing board is moved forward so that the gears can be pushed back so the motors gear can hook up correctly. File:New screw placed through the gear..JPG|A thinker screw is placed through the gears and rubber piece because the old screw started to slip. File:Back view of new screw.JPG|The new screw is shorter so it doesn't poke out the back. </Gallery>

Mounting Stepper Motor and Arduino
Video of gears being spun by hand:

http://www.youtube.com/watch?v=ETb02RsUdVU&feature=youtu.be <Gallery> File:Arduino mounted.JPG|The arduino with the programs is mounted to the project. File:Side view of arduino.JPG|Side view of arduino mounted. File:Wooden block that will hold up motor.JPG|Wooden block that will hold up motor File:Wooden Block screwed in.JPG|The wooden block that will hold up the motor is screwed in. File:Motor on top the block.JPG|The wood block will hold up the motor so the gear doesn't scrap the wood. File:Metal clamp.JPG|A metal clamp is used to tighten up motor. File:Motor held in place.JPG|The motor is held in place by a metal clamp that is tightened. </Gallery> Making the final mount for the motor, the 2in x 2in block is where the motor will sit so it will be next to secondary gear for the rubber mount.

Holding the Project together
<Gallery> File:Hooks on the main board.JPG|Hooks will be used to hold a string to keep the project from moving so much. File:Hooks on top and bottom.JPG|Hooks will hold the project together by the tension of a string. File:Fishing line used.JPG|Fishing line is tied and used to hold the project together. File:Steel cable connected to hook.JPG|Steel cable connected to hook. File:Cable_hooks.jpg|Both ends of the steel cable with hooks attached. File:Steal cable wrapped around hooks.JPG|The wire is wrapped around the hooks to hold the project together. </Gallery> strengthening the Structural integrity of the project board by replacing the fishing line with steel cables.

Code One
When using this code to operate the machnical switch, we were not getting any response from the led after the switch was activated. this program was suppose to label pin 13 as led, and label pin 8 as switch pin. when the switch is activated the arduino reads the signal as high and turns the led on, else the led should be low.

Code Two
For part two, the boolean was added to check the current state of the led. (boolean lastButton = LOW;) keeps track of watch the button did in the previous loop, and (boolean ledOn = false;) is used to keep track of the current state of the led. and they will help check things in the loop to help set thing to where there suppose to be.

this is the youtube video showing the problem: http://www.youtube.com/watch?v=t-3kIytQPeQ&feature=youtu.be

Code Three
Code to works, but has a bit of a problem. the led turns of and on but you can still see a dim light coming from the led. In order to solve this problem we made our own function. the function is suppose to return a boolean. (boolean debounce(boolean last)) debounce is now a function with input last, this is now define as a that determine the current value with the remaining of the program.

this is the youtube video showing the problem: http://www.youtube.com/watch?v=ib1kVmWDMzU&feature=youtu.be

Hooking up a Switch to Arduino
if your not confortable with writing you own code, the Analog in out Serial program can be found in the arduino software under (File, Example, Analog, and number three AnaloginoutSerial). this program works perfectly with the switch with now problem what so ever.

this is a video showing how Verier Photogate works with the Lab Quest tablet combine. the lab Quest takes reading in a form of a graph. when you bridge the gap between the sensor it plots points on lab quest that can easy be downloadable and analysis.
 * YouTube Video showing off the Verier Photogate: http://www.youtube.com/watch?v=v8rgyOOBPPU&feature=youtu.be

http://www.vernier.com/support/sensor-pinouts/
 * Down below you will find links to webpages giving you more information between cat5e cable and data cable. i also found a wiring diagram explain what each wire does, all you'l need to do is match them us with each other and feed them to the arduino. the wiring diagram explains both the cat5 cable and the prog cable that comes with the photogate.

https://en.wikipedia.org/wiki/Category_5_cable

http://www.vernier.com/engineering/arduino/digital-sensors/photogates/

=Implement= The code currently being used to test the function of the project is shown below. It is able to properly operate the solenoid at the end of each combination attempt and will output the combination attempted at the end of each iteration. The next step for this is to devise an algorithm to more efficiently test combinations for the lock.

=Operate= The project as it is currently assembled is shown below from both a top and side view. When testing the entire project together, it was found that activating the solenoid for too long of a period at once was causing the PVC piece to come unglued from the wooden structure.

<Gallery> File:Top_view_of_lock_picker.jpg File:Side_view_of_lock_picker.jpg File:Lock_holder_unglued.jpg </Gallery>

As the two videos below show, each part of the project functions individually, but the motor's primary gear does not mesh with the second gear properly. This results from a difference in tooth shape and pitch between the two gears. This will be addressed in the future.

<Gallery> File:Project_test1.ogv File:Motor_test2.ogv </Gallery>

=Next Steps= To push the project forward:

Arduino

 * Build off of the code provided by the motor shield tutorial found here. http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/
 * Build a switch that will work with both the Arduino and motor shield that will stop and start the program.
 * Verify proper power source for the motor and solenoid, to eliminate need to draw power from a computer.
 * Explore options for mounting and housing the Arduino and motor shield in a way which protects them from drops, dings, etc.

Body

 * Make a smaller, sturdier, compact body so that the lock pick can be moved around easier