
include <involute_gears.scad>;
include <../interlocpanellib/InterlocPanelLib.scad>;
include <../ParametricRatchetLib/RatchetLib.scad>;
include <spiffsans.scad>;
//cube([100,100,1]);
//cylinder(r=1.4, h=20, center=true);
dist=sqrt(pow(35,2) + pow(35,2));
escapement_dist=sqrt(pow(35,2) + pow(35,2));
rotate([0,0,90]) {
union() {
translate([-77.75,0,12]) {
rotate([-180,0,-180]) {
rotate([0,0,6]) {
escapement_gear();
}
translate([escapement_dist,0,0]) {
rotate([0,0,0]) {
mirror([0,1,0]) {
escapement();
}
}
}
escapement_test_block();
rotate(0,0,45) {
translate([170.6,0,0]) {
// pendulum_extension();
}
translate([170.6,25,0]) {
// pendulum_extension();
}
translate([170.6,50,0]) {
// pendulum_extension();
}
translate([170.6,75,0]) {
// pendulum_extension();
}
}
}
}
translate([0,-500,0]) {
// cube([1000,1000,1000], center=true);
}
}
}
module escapement_test_block() {
translate([25,0,25]) {
mirror([0,0,1]) {
difference() {
cube([75,20,20], center=true);
translate([escapement_dist/2,0,0]) {
cylinder(r=3, h=50, center=true);
}
translate([-escapement_dist/2,0,0]) {
cylinder(r=3, h=50, center=true);
}
}
translate([escapement_dist/2,0,-10]) {
support(28, 20);
}
translate([-escapement_dist/2,0,-10]) {
support(24, 20);
}
}
}
}
module support(height=30, outer_diameter=10, inner_diameter=3, bearing_height=10) {
translate([0,0,height/2]) {
difference() {
cylinder(r=outer_diameter/2, h=height, center=true, $fn=6);
cylinder(r=inner_diameter+1, h=height-bearing_height*2, center=true, $fn=24);
translate([0,0,,(height/2-bearing_height/2)]) {
innerbearing(bearing_height);
}
translate([0,0,-(height/2-bearing_height/2)]) {
innerbearing(bearing_height);
}
}
}
}
module smallkey(border=0, height=4) {
difference() {
cube([7+border*2,7+border*2,height], center=true);
translate([22,19,0]) {
rotate([0,0,20]) {
cube([50-border*2,50-border*2,10], center=true);
}
}
translate([-22,19,0]) {
rotate([0,0,-20]) {
cube([50-border*2,50-border*2,10], center=true);
}
}
}
}
// escapement gear
module escapement_gear() {
difference() {
union() {
translate([0,0,7]) {
rotate([0,0,90]) {
wgear(9, 6);
}
}
cylinder(r=12, h=4, center=true);
translate([0,0,3]) {
cylinder(r2=8.5, r1=12, h=2, center=true);
}
cylinder(r=25, h=4, center=true, $fn=42);
mirror([0,1,0]) {
for (i=[0:29]) {
rotate([0,0,12*i]) {
translate([-30,0,0]) {
rotate([0,0,180]) {
tooth();
}
}
}
}
}
}
translate([0,0,4]) {
innerbearing(12);
}
}
}
module tooth() {
translate([-0.4,-4.12,0]) {
difference() {
translate([-1,0,0]) {
cube([12,10,4], center=true);
}
translate([5,5,0]) {
rotate([0,0,-25]) {
cube([20,10,5], center=true);
}
}
translate([5,-6.1,0]) {
rotate([0,0,-15]) {
cube([30,10,5], center=true);
}
}
}
}
}
module escapement() {
dist=sqrt(pow(35,2) + pow(35,2));
// compensate for printing inaccuracies and corner rounding
// faceadjust_a=0.2;
// faceadjust_b=0.2;
// faceadjust_a=-0.6;
// faceadjust_b=-0.8;
faceadjust_a=-0.1;
faceadjust_b=-0.4;
facets=69;
// translate([dist,0,0]) {
difference() {
union() {
difference() {
// cylinder(r=37, h=4, center=true, $fn=facets); // circular design
cylinder(r=35.5, h=4, center=true, $fn=facets); // equidistant lock
cylinder(r=32.5, h=5, center=true, $fn=facets);
translate([0,-40,0]) {
cube([80,80,80], center=true);
}
// clip circle
translate([35.7,50,0]) {
rotate([0,0,24]) {
cube([100,100,10], center=true);
}
}
// cut palette faces
translate([-74.8-faceadjust_a,22,0]) {
rotate([0,0,7]) {
cube([100,100,10], center=true);
}
}
}
difference() {
// cylinder(r=38.5, h=4, center=true, $fn=facets);
cylinder(r=38.2, h=4, center=true, $fn=facets);
// cylinder(r=33, h=5, center=true, $fn=facets); // circular design
// cylinder(r=35.5, h=5, center=true, $fn=facets); // equidistant lock
cylinder(r=35.2, h=5, center=true, $fn=facets); // equidistant lock
translate([0,30,0]) {
cube([80,80,80], center=true);
}
// clip circle
translate([35.7,-50,0]) {
rotate([0,0,-24]) {
cube([100,100,10], center=true);
}
}
translate([-26.9,-14.55+faceadjust_b,0]) {
rotate([0,0,7]) {
color([.3,.8,.5, .4]) cube([100,20,10], center=true);
}
}
}
// center
translate([0,0,2]) {
cylinder(r=5, h=8, center=true, $fn=24);
}
rotate([0,0,24]) {
translate([0,16.5,0]) {
cube([6,34,4], center=true);
}
}
rotate([0,0,156]) {
translate([0,16.5,0]) {
cube([6,38,4], center=true);
}
}
rotate([0,0,-90]) {
translate([0,26.5,0]) {
cube([8,60,4], center=true);
}
}
translate([64,0,0]) {
difference() {
rotate([0,0,90]) {
key(0,4);
}
translate([10,0,0]) {
rotate([0,0,-90]) {
smallkey(0.1,5);
}
}
}
}
}
translate([0,0,2]) {
innerbearing(8);
}
}
// }
}
module pendulum_extension() {
translate([-37,0,0]) {
difference() {
union() {
rotate([0,0,-90]) {
key(0,4);
translate([0,-10,0]) {
smallkey();
}
}
}
translate([-1,0,0]) {
cylinder(r=3, h=10, center=true);
}
}
}
rotate([0,0,-90]) {
translate([0,0,0]) {
cube([8,60,4], center=true);
}
}
translate([37,0,0]) {
difference() {
rotate([0,0,90]) {
key(0,4);
}
translate([10,0,0]) {
rotate([0,0,-90]) {
smallkey(0.1,5);
}
}
translate([1,0,0]) {
cylinder(r=3, h=10, center=true);
}
}
}
}
module wgear(teeth=20, height=4, circles=6, spokes=0) {
circular_pitch = 200;
backlash_num = 0.7;
zgear_radius = teeth * circular_pitch / 360;
ztooth_height = (zgear_radius * sin (360 / (4 * teeth)) - backlash_num / 4) * 2;
difference() {
zgear(teeth, height, circles, circular_pitch, height, backlash_num);
}
}
module innerbearing(height) {
cylinder(r=1.6, h=height+1, center=true, $fn=24);
translate([0,0,-(height/2.6)]) {
cylinder(r1=3, r2=0, h=height/2+0.1, center=true, $fn=24);
}
translate([0,0,height/2.6]) {
cylinder(r2=3, r1=0, h=height/2+0.1, center=true, $fn=24);
}
translate([0,0,height/4]) {
cylinder(r1=3, r2=0, h=height/2+0.01, center=true, $fn=24);
}
translate([0,0,-(height/4)]) {
cylinder(r2=3, r1=0, h=height/2+0.01, center=true, $fn=24);
}
}
module zgear(teeth=60, height=4, circles=6, circular_pitch=300, height=5, backlash=0) {
//twist=30;
twist=0;
pressure_angle=14.5;
gear (number_of_teeth=teeth,
circular_pitch = circular_pitch,
pressure_angle = pressure_angle,
clearance = 0.3,
gear_thickness = height/2,
rim_thickness = height/2,
rim_width = 0,
hub_thickness = height/2,
hub_diameter = 0,
bore_diameter = 0,
circles = circles,
twist = twist/teeth,
backlash = backlash);
mirror([0,0,1])
gear (number_of_teeth=teeth,
circular_pitch=circular_pitch,
pressure_angle=pressure_angle,
clearance = 0.3,
gear_thickness = height/2,
rim_thickness = height/2,
rim_width = 20,
hub_thickness = height/2,
hub_diameter = 0,
bore_diameter = 0,
circles = circles,
twist = twist/teeth,
backlash = backlash);
}