Uit Hack42
Ga naar: navigatie, zoeken
(+ratchet.scad)
 
(+adjWheel.scad)
 
(Een tussenliggende versie door dezelfde gebruiker niet weergegeven)
Regel 1: Regel 1:
 
==ratchet.scad==
 
==ratchet.scad==
<pre>
+
{|
module tooth2(base, height, tipl, tiph, width) {
+
|[[Bestand:Ratchet.png|thumb|left|An example of ratchet(10,6,3,5,7,1)]]
 +
|-
 +
||<pre>
 +
module tooth(base, height, tipl, tiph, width) {
 
difference() {
 
difference() {
 
intersection() {
 
intersection() {
Regel 17: Regel 20:
 
module ratchet(diam, nrteeth, height, tipl, tiph, width) {
 
module ratchet(diam, nrteeth, height, tipl, tiph, width) {
 
//moves teeth down by this distance
 
//moves teeth down by this distance
down = diam - diam * cos(180/nrteeth);
+
down = 0.01 + (diam - diam * cos(180/nrteeth));
 
//make sure tooth's height is not lower than down movement
 
//make sure tooth's height is not lower than down movement
/* if (height <= down) {
+
if (height <= down) {
nheight = down + 0.01;
+
ratchet2(diam, nrteeth, down, tipl, tiph, width, down);
 
} else {
 
} else {
nheight = height;
+
ratchet2(diam, nrteeth, height, tipl, tiph, width, down);
 
}
 
}
*/
+
}
 +
 
 +
module ratchet2(diam, nrteeth, height, tipl, tiph, width, down) {
 
// calculate tooth's base
 
// calculate tooth's base
 
base = 2 * sin(180/nrteeth) * diam;
 
base = 2 * sin(180/nrteeth) * diam;
echo(down);
 
echo(diam);
 
 
union() {
 
union() {
 
cylinder(h=width,r=diam);
 
cylinder(h=width,r=diam);
Regel 34: Regel 37:
 
for ( i = [0 : (nrteeth-1)] ) {
 
for ( i = [0 : (nrteeth-1)] ) {
 
rotate( i * 360 / nrteeth, [0, 0, 1])
 
rotate( i * 360 / nrteeth, [0, 0, 1])
translate([-(0.25*base), (diam-down), 0])
+
translate([-(0.25*base), (diam-2*down), 0]) // check the .25
tooth2(base, height, tipl, tiph, width); //height should become nheight
+
tooth(base, height, tipl, tiph, width);
 +
}
 +
}
 +
}
 +
 
 +
ratchet(10,6,3,5,7,1);
 +
</pre>
 +
|}
 +
 
 +
==adjWheel.scad==
 +
{|
 +
|[[Bestand:AdjWheel.png|thumb|left|An example of adjWheel(7,3)]]
 +
|-
 +
|<pre>
 +
module adjWheel(radius, width) {
 +
circ = 2*radius*3.14159;
 +
notch = (circ/40)*0.95;
 +
edge = (circ-(notch*20))/400;
 +
union() {
 +
difference() {
 +
cylinder(h=width,r=radius,$fs=0.01);
 +
//notches
 +
for ( i = [0:19] ) {
 +
rotate( i * 360 / 20, [0,0,1])
 +
translate([radius,0,0])
 +
cylinder(h=width+0.01,r=notch,$fs=0.01);
 +
}
 +
}
 +
//rounded edges
 +
for ( i = [0:19] ) {
 +
rotate( i * 360 / 20, [0,0,1])
 +
translate([radius-2*edge,notch+edge,0])
 +
cylinder(h=width,r=edge,$fs=0.01);
 
}
 
}
 
}
 
}
 
}
 
}
  
ratchet(10,6,2,5,7,1);
+
adjWheel(7,3);
 
</pre>
 
</pre>
 +
|}
 +
 +
==notchRing.scad==
 +
 +
__FORCETOC__

Huidige versie van 9 sep 2011 om 07:40

ratchet.scad

An example of ratchet(10,6,3,5,7,1)
module tooth(base, height, tipl, tiph, width) {
	difference() {
		intersection() {
			translate([-(base+tipl)/2,0,0]) cube([base+tipl,height,width], center = false);
			scale(v=[1,(height/(base+tipl))*2,0]) cylinder(r=(base+tipl)/2,h=width, $fs=0.01);
		}
		translate([-(base/2+tipl/2),0,0])
		  polyhedron(	points = [ [0,0,0],[0,0,width],[0,tiph,0],[0,tiph,width],[tipl,0,0],[tipl,0,width] ],
					triangles = [ [1,3,5],[0,4,2],[0,2,1],[2,3,1],[0,1,4],[4,1,5],[2,4,5],[2,5,3] ]);
	}
}

//tooth2(7,7,5,5,1);

module ratchet(diam, nrteeth, height, tipl, tiph, width) {
	//moves teeth down by this distance
	down = 0.01 + (diam - diam * cos(180/nrteeth));
	//make sure tooth's height is not lower than down movement
	if (height <= down) {
		ratchet2(diam, nrteeth, down, tipl, tiph, width, down);
	} else {
		ratchet2(diam, nrteeth, height, tipl, tiph, width, down);
	}
}

module ratchet2(diam, nrteeth, height, tipl, tiph, width, down) {
	// calculate tooth's base
	base = 2 * sin(180/nrteeth) * diam;
	union() {
		cylinder(h=width,r=diam);
		//teeth
		for ( i = [0 : (nrteeth-1)] ) {
			rotate( i * 360 / nrteeth, [0, 0, 1])
			translate([-(0.25*base), (diam-2*down), 0]) // check the .25
			tooth(base, height, tipl, tiph, width);
		}
	}
}

ratchet(10,6,3,5,7,1);

adjWheel.scad

An example of adjWheel(7,3)
module adjWheel(radius, width) {
	circ = 2*radius*3.14159;
	notch = (circ/40)*0.95;
	edge = (circ-(notch*20))/400;
	union() {
		difference() {
			cylinder(h=width,r=radius,$fs=0.01);
			//notches
			for ( i = [0:19] ) {
				rotate( i * 360 / 20, [0,0,1])
				translate([radius,0,0])
				cylinder(h=width+0.01,r=notch,$fs=0.01);
			}
		}
		//rounded edges
		for ( i = [0:19] ) {
			rotate( i * 360 / 20, [0,0,1])
			translate([radius-2*edge,notch+edge,0])
			cylinder(h=width,r=edge,$fs=0.01);
		}
	}
}

adjWheel(7,3);

notchRing.scad