// from https://github.com/janssen86/OpenSCAD-Getriebebibliothek
use <getriebe.scad>

/* [OpenSCAD] */
cross_section = false;

/* [Zahnrad] */
// Number of teeth in this gear
Teeth = 70; // [20,30,35,40,50,55,60,65,70,75,80,100,120]

/* [Hidden] */
$fn=120;
// Proxxon SD300 / Hobbymat MD65 use modul 1.0
Modul = 1.0; // [0.05,0.06,0.08,0.10,0.12,0.16,0.20,0.25,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.25,1.5,2,2.5,3,4,5,6,8,10,12,16,20,25,32,40,50,60]
Teeth_Limit = 500;

intersection() {

	difference() {
		H=[8,1.7]; // heights
		B=[20,32]; // bore
		union() {
			translate([0,0,-H[0]/2]) stirnrad(Modul, Teeth, H[0], 0); // center
			if (Teeth>30) translate([0,0,H[0]/2]) cylinder(d=B[1], h=H[1]);
			if (Teeth>Teeth_Limit) {
				R=(Teeth*Modul)/2*2/3;
				translate([0,R,H[0]/2]) linear_extrude(height=0.5) text(text=str(Teeth), size=3.5, halign="center", valign="center");
			}
		}
		if (Teeth>20) { // central axis
			cylinder(d=B[0], h=3*H[0], center=true); 
			translate([0,-B[0]/2,0]) cube([4,4,2*H[0]], center=true); // Notch
		}
		else {
			cylinder(d=6, h=3*H[0], center=true);
		}
		if (Teeth==30) translate([0,B[0]/2+2,H[0]/2-0.5]) 
			linear_extrude(height=0.6) text(text=str(Teeth), size=2.5, halign="center", valign="center");
		else if (Teeth<=Teeth_Limit) translate([0,B[0]/2+2.5,(H[0]+H[1])/2+0.2]) 
			linear_extrude(height=1) text(text=str(Teeth), size=3.5, halign="center", valign="center");
	}

	if (cross_section) translate([-50,0,0]) cube(100, center=true); // cross section view for debugging
	
}

// Further info: https://www.weltderfertigung.de/archiv/jahrgang-2018/ausgabe-januar-2018/wechselradberechnung-leichtgemacht.php

