feat: hugely improved tolerances

This commit is contained in:
s3lph 2025-04-08 23:45:38 +02:00
parent e17a01bc0d
commit 50e16371fb
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5
6 changed files with 48 additions and 35 deletions

View file

@ -1,5 +1,5 @@
module case(n=5, diameter=50, tolerance=0.2, $fn=60) {
module case(n=5, diameter=50, z_tolerance=0.4, xy_tolerance=0.2, $fn=60) {
union() {
translate([-8,0,0]) {
rotate([0,90,0]) {
@ -13,13 +13,13 @@ module case(n=5, diameter=50, tolerance=0.2, $fn=60) {
translate([-diameter/2+4,-1.5,-1]) {
cube([7,3,n*10+7]);
}
// cutouts for e-clips
// cutouts for rings
rotate([0,0,45]) {
for (j = [0:2]) {
rotate([0,0,120*j]) {
for (i = [0:n]) {
translate([0,diameter/4,10*i+3]) {
cube([4+2*tolerance, diameter/2, 2+2*tolerance], center=true);
cube([4+2*xy_tolerance, diameter/2, 2+2*z_tolerance], center=true);
}
}
}
@ -27,7 +27,7 @@ module case(n=5, diameter=50, tolerance=0.2, $fn=60) {
}
}
// end cap
translate([0,0,(n+1)*10-2.5]) {
translate([0,0,(n+1)*10-3]) {
cylinder(d=diameter,h=5, center=true);
}
}
@ -42,10 +42,13 @@ ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
N = 5;
DIAMETER = 50;
TOLERANCE = 0.2;
Z_TOLERANCE = 0.4;
XY_TOLERANCE = 0.2;
FN = 60;
case(
n=N,
diameter=DIAMETER,
tolerance=TOLERANCE, $fn=FN);
z_tolerance=Z_TOLERANCE,
xy_tolerance=XY_TOLERANCE,
$fn=FN);

View file

@ -1,5 +1,5 @@
module key_dial(alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ", key="C", width=7, dia=50, thick=5.5, key_width=4, key_height=3, text_depth=1, font_size=-1, antipick=1.5, tolerance = 0.2, $fn = 60) {
module key_dial(alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ", key="C", width=8, dia=50, thick=5.5, key_width=4, key_height=3, text_depth=1, font_size=-1, antipick=1, xy_tolerance = 0.2, z_tolerance = 0.4, $fn = 60) {
key_indices = search(key, alphabet, 0);
assert(len(key_indices[0]) == 1, "key character not unique");
key_index = key_indices[0][0];
@ -7,11 +7,11 @@ module key_dial(alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ", key="C", width=7, dia=50,
rotate([-0.5/len(alphabet)*360,0,0]) {
difference() {
rotate([0,90,0]) {
cylinder($fn=$fn, h=width, d=dia, center=true);
cylinder($fn=$fn, h=width-z_tolerance, d=dia, center=true);
}
// inner ring
rotate([0,90,0]) {
cylinder($fn=$fn, h=width+2, d=dia-thick*2+2*tolerance, center=true);
cylinder($fn=$fn, h=width+2, d=dia-thick*2+2*xy_tolerance, center=true);
}
// key
rotate([45+((0.5+key_index)/len(alphabet)) * 360,0,0]) {
@ -50,7 +50,8 @@ module key_dial(alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ", key="C", width=7, dia=50,
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
KEY = "C";
DIAMETER = 50;
TOLERANCE = 0.2;
XY_TOLERANCE = 0.2;
Z_TOLERANCE = 0.4;
FN = 120;
INDEX = 0;
@ -59,5 +60,7 @@ rotate([0,-90,0]) {
alphabet=ALPHABET,
key=KEY,
dia=DIAMETER,
tolerance=TOLERANCE, $fn=FN);
xy_tolerance=XY_TOLERANCE,
z_tolerance=Z_TOLERANCE,
$fn=FN);
}

View file

@ -5,7 +5,7 @@ use <case.scad>;
use <plug.scad>;
module lock(alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ", password="CHAOS", diameter=50, tolerance=0.2, $fn=60) {
module lock(alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ", password="CHAOS", diameter=50, xy_tolerance=0.2, z_tolerance=0.4, $fn=60) {
n = len(password);
key_indices=search(password, alphabet);
@ -13,7 +13,7 @@ module lock(alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ", password="CHAOS", diameter=50
for (i = [0:n-1]) {
rotate([-key_indices[i]/len(alphabet)*360,0,0]) {
translate([i*10,0,0]) {
key_dial(alphabet, key=password[i], dia=diameter, font_size=7);
key_dial(alphabet, key=password[i], dia=diameter, xy_tolerance=xy_tolerance, z_tolerance=z_tolerance);
}
}
}
@ -22,7 +22,7 @@ module lock(alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ", password="CHAOS", diameter=50
translate([-5+10*i,0,0]) {
rotate([0,0,180]) {
rotate([0,90,0]) {
ring(dia=diameter-2, clicker=i>0, alphabet_length=len(alphabet));
ring(dia=diameter-2, clicker=i>0, alphabet_length=len(alphabet), xy_tolerance=xy_tolerance, z_tolerance=z_tolerance);
}
}
}
@ -30,8 +30,8 @@ module lock(alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ", password="CHAOS", diameter=50
rotate([45,0,0]) {
case(n, diameter=diameter);
plug(n, diameter=diameter);
case(n, diameter=diameter, xy_tolerance=xy_tolerance, z_tolerance=z_tolerance);
plug(n, diameter=diameter, xy_tolerance=xy_tolerance, z_tolerance=z_tolerance);
}
}

View file

@ -1,10 +1,10 @@
module plug(n=5, diameter=50, tolerance=0.2, $fn=60) {
module plug(n=5, diameter=50, xy_tolerance=0.2, z_tolerance=0.4, $fn=60) {
union() {
// key
translate([-10,-1.25,(diameter-19)/2]) {
difference() {
cube([10*n+6.5,2.5,6]);
cube([10*n+6,2.5,6]);
// key cutouts
for (i = [0:n-1]) {
translate([i*10+6,-0.25, 3.5]) {
@ -17,7 +17,7 @@ module plug(n=5, diameter=50, tolerance=0.2, $fn=60) {
rotate([0,90,0]) {
// inner cylinder
difference() {
cylinder(h=10*n+5, d=diameter-17-2*tolerance);
cylinder(h=10*n+4.5, d=diameter-17-2*xy_tolerance);
translate([0,0,-1]) {
cylinder(h=10*n+7, d=diameter-20);
}
@ -48,10 +48,13 @@ module plug(n=5, diameter=50, tolerance=0.2, $fn=60) {
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
N = 5;
DIAMETER = 50;
TOLERANCE = 0.2;
Z_TOLERANCE = 0.4;
XY_TOLERANCE = 0.2;
FN = 60;
plug(
n=N,
diameter=DIAMETER,
tolerance=TOLERANCE, $fn=FN);
z_tolerance=Z_TOLERANCE,
xy_tolerance=XY_TOLERANCE,
$fn=FN);

View file

@ -3,10 +3,11 @@
ALPHABET=ABCDEFGHIJKLMNOPQRSTUVWXYZ
LENGTH=5
DIAMETER=50
TOLERANCE=0.2
FN=60
XY_TOLERANCE=0.2
Z_TOLERANCE=0.4
FN=120
ARGS=("--backend=manifold" "-q" "-DALPHABET=\"$ALPHABET\"" "-DN=$LENGTH" "-DDIAMETER=$DIAMETER" "-DTOLERANCE=$TOLERANCE" "-DFN=$FN")
ARGS=("--backend=manifold" "-q" "-DALPHABET=\"$ALPHABET\"" "-DN=$LENGTH" "-DDIAMETER=$DIAMETER" "-DXY_TOLERANCE=$XY_TOLERANCE" "-DZ_TOLERANCE=$Z_TOLERANCE" "-DFN=$FN")
mkdir -p out

View file

@ -1,12 +1,12 @@
module ring(alphabet_length=26, dia=48, width=3, thick=2, spoke_depth=4.5, spoke_width=9, key_depth=3, key_length=4, tolerance = 0.2, indicator=false, clicker=false, $fn=60) {
module ring(alphabet_length=26, dia=48, width=3, thick=2, spoke_depth=4.5, spoke_width=9, key_depth=3, key_length=4, xy_tolerance=0.2, z_tolerance=0.2, indicator=false, clicker=false, $fn=60) {
difference() { // halfing
union() {
// outer ring
difference() {
cylinder(d=dia, h=width-4*tolerance, center=true);
cylinder(d=dia, h=width-2*z_tolerance, center=true);
cylinder(d=dia-2*thick, h=width+1, center=true);
}
// key spokes
@ -18,36 +18,36 @@ module ring(alphabet_length=26, dia=48, width=3, thick=2, spoke_depth=4.5, spoke
translate([-dia/4,0,0]) {
cube([dia/2, spoke_width, width], center=true);
}
cylinder(d=dia, h=width-4*tolerance, center=true);
cylinder(d=dia, h=width-2*z_tolerance, center=true);
}
}
}
}
cylinder(d=dia-2*spoke_depth+tolerance, h=width+1, center=true);
cylinder(d=dia-2*spoke_depth+xy_tolerance, h=width+1, center=true);
}
// keys
for (i = [0:2]) {
rotate([0,0,120*i]) {
translate([-dia/2+spoke_depth+key_depth/2-1,0,0]) {
cube([key_depth+2, key_length, width-4*tolerance], center=true);
cube([key_depth+2, key_length, width-2*z_tolerance], center=true);
}
}
}
// indicator
translate([-dia/2,0,0]) {
cube([2, width, width-4*tolerance], center=true);
cube([2, width, width-2*z_tolerance], center=true);
}
// clicker
if (clicker) {
echo(floor(alphabet_length/3)*360/alphabet_length-45);
rotate([0,0,floor(alphabet_length/3)*360/alphabet_length-45]) {
translate([-dia/2+3,0,0]) {
cube([3, 4, width-4*tolerance], center=true);
cube([3, 4, width-2*z_tolerance], center=true);
}
translate([-dia/2+3.5,0,width/2-0.5]) {
scale([0.5,1,1]) {
rotate([0,0,45]) {
cylinder($fn=4, h=1, d1=5.6, d2=3);
cylinder($fn=4, h=z_tolerance, d1=5.6, d2=3);
}
}
}
@ -59,7 +59,7 @@ module ring(alphabet_length=26, dia=48, width=3, thick=2, spoke_depth=4.5, spoke
cube([spoke_depth+key_depth+thick,0.25, width]);
}
translate([-dia/2-0.2, 0, -width/2]) {
#cube([0.25, width/2, width]);
cube([0.25, width/2, width]);
}
}
}
@ -69,7 +69,8 @@ module ring(alphabet_length=26, dia=48, width=3, thick=2, spoke_depth=4.5, spoke
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
DIAMETER = 50;
TOLERANCE = 0.2;
XY_TOLERANCE = 0.2;
Z_TOLERANCE = 0.4;
FN = 60;
INDICATOR = false;
CLICKER = false;
@ -80,4 +81,6 @@ ring(
dia=DIAMETER-2,
indicator=INDICATOR,
clicker=CLICKER,
tolerance=TOLERANCE, $fn=FN);
xy_tolerance=XY_TOLERANCE,
z_tolerance=Z_TOLERANCE,
$fn=FN);