-
-
Save evildaemond/59775b29ab768e17700a240b264ef3de to your computer and use it in GitHub Desktop.
Schalge 5 Cylinder Key Generatorhttps://noisebridge.net/wiki/Key_Milling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# makekey.py - A key making tool | |
# This program will accept a pin configuration for a Lockwood 6 Pin lock and produce GCode to mill out the corresponding key. | |
# | |
# For example, this will produce a bump key: | |
# $ ./makekey.py 999999 | |
# | |
# This could produce a key to something else: | |
# $ ./makekey.py 123456 | |
# | |
# My dearest apologies if that happens to be yours. | |
# | |
# This is also a real key, as there does not exist a 'missing' pin: | |
# $ ./makekey.py 000000 | |
# Modified by: evildaemond <me@evildaemond.com> | |
# Original Author: Torrie "tdfischer" Fischer <tdfischer@hackerbots.net> | |
# | |
# Made at Noisebridge 1/1/14 on visit from SYNHAK <3 | |
# https://noisebridge.net/wiki/Key_Milling | |
# | |
import sys | |
# CONFIGURATION OPTIONS | |
# granularity: How many passes you want to mill with | |
granularity = 1 | |
# invert: True if you're cutting the key upside down | |
invert = False | |
# key_thickness: How thick the key is in total | |
# useful if you're stuck without a straight edge bit | |
# Lockwood is 12mm | |
key_thickness = 0.047 | |
keyPIN = str(sys.argv[1]) | |
print(""" | |
G94 ( use inches/min feed rate) | |
G20 ( use inch for coordinates ) | |
G90 ( absolute coordinates ) | |
G64 P0.125 ( maximum deviation ) | |
S10484 ( spindle speed for brass ) | |
G0 Z0.1 ( lift up to avoid hitting the key ) | |
G0 X0 Y0 ( move to the blade, just at the edge of the shoulder ) | |
M3 ( start cutting ) | |
G1 F3000 X-0.1 ( move over to the side before cutting the side off ) | |
G1 X0 Y0 ( move into the key blade) | |
G1 Y0.05 ( move down the shoulder )""") | |
# Pin positions start at 6.10mm from sholder then have a 3.97mm spacing between each pin | |
pinPositions = [ | |
0.24, | |
0.39, | |
0.55, | |
0.70, | |
0.86, | |
1.02, | |
] | |
# A zero cut starts at 0.24mm from a LW5, and decreases by 0.38mm per step, yes I know there is an A cut, I am too lazy to modify this to suit, plus it rarely appears in lockwood | |
pinDepths = [ | |
0.0094, | |
0.0244, | |
0.0393, | |
0.0543, | |
0.0692, | |
0.0846, | |
0.0996, | |
0.1145, | |
0.1295, | |
0.1444, | |
] | |
for cutLayer in range(1, granularity+1): | |
layerDepth = key_thickness * (cutLayer / float(granularity)) | |
print("G1 Z-%s ( start layer %s )"%(layerDepth, cutLayer)) | |
for cutPass in range(1, granularity+1): | |
print("") | |
if cutPass % 2 == 0: | |
reverse = True | |
print("( start pass %s in reverse, layer %s )"%(cutPass, cutLayer)) | |
else: | |
reverse = False | |
print("( start pass %s in forward, layer %s )"%(cutPass, cutLayer)) | |
if reverse: | |
pinSet = reversed(range(0, len(keyPIN))) | |
else: | |
pinSet = range(0, len(keyPIN)) | |
for pinNumber in pinSet: | |
pinType = int(keyPIN[pinNumber]) | |
pinCenter = pinPositions[pinNumber] | |
pinDepth = pinDepths[pinType] * (cutPass / float(granularity)) | |
if invert: | |
pinDepth = -pinDepth | |
# Measured the root flat on a branded Lockwood Key as 1mm | |
pinStart = pinCenter - 0.0196 | |
pinEnd = pinCenter + 0.0196 | |
if reverse: | |
print("G1 Y%s X%s ( cut pin depth %s at position %s )"%(pinEnd, pinDepth, pinType, pinNumber)) | |
print("G1 Y%s"%(pinStart)) | |
else: | |
print("G1 Y%s X%s ( cut pin depth %s at position %s )"%(pinStart, pinDepth, pinType, pinNumber)) | |
print("G1 Y%s"%(pinEnd)) | |
if reverse: | |
print("G1 X0 Y0.05 ( move back down to the shoulder )") | |
else: | |
print("G1 Y1.17") | |
print("") | |
print("M2") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment