Commit f4515035 authored by William Wadsworth's avatar William Wadsworth
Browse files

move gear ratio error message

Gear ratio errors were reported by the small and large gear STL modules.
This moves the warning to the teeth calculation, so that it is picked up in all situations, including renders.
parent 5c8f7b5a
Loading
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -15,8 +15,11 @@ use <./libs/utilities.scad>

// The ratio is the ratio between the 'large' gear on the actuator and the 'small' gear on the motor.
// This means that it is a gearing down ratio.
// The standard ratio is 2. The total number of teeth on both gears is 36, which is defined by the distance between the rotation axes.
// For an integer number of teeth, allowed ratios are of the form n/(36-n). Ratios from 0.8 (16/20, 1:1.25) to 2 (24/12, 1:0.5) are expected to fit in the body
// The standard ratio is 2. The total number of teeth on both gears is 36, which gives
// reasonable size teeth given the distance between the rotation axes.

// For an integer number of teeth, allowed ratios are of the form n/(36-n).
// Ratios from 0.8 (16/20, 1:1.25) to 2 (24/12, 1:0.5) are expected to fit in the body.

// Gearing ratio for x and y axes. Ratio for z axis fixed at 2
RATIO = 2;
@@ -24,10 +27,10 @@ RATIO = 2;
printable_large_gears(ratio=RATIO);

module printable_large_gears(ratio=2){
    // check the ratio gives an integer number of teeth
    assert(floor(n_teeth_large_gear(ratio))==n_teeth_large_gear(ratio),"The number of teeth on the large gear is not integer");
    // Calculate the spacing from the gear pitch radius.
    // Add 4mm of clearance
    // Note: This will throw an error if either the ratio, or a ratio of 2, 
    // gives a non-integer number of gear teeth
    spacing = large_gear_pitch_radius(ratio) + large_gear_pitch_radius(ratio=2) + 4;
    // x and y gears
    repeat([0,2*spacing,0],2,center=true){
+10 −2
Original line number Diff line number Diff line
@@ -33,10 +33,18 @@ function total_gear_teeth() = 36;


/* Number of teeth on the small gear*/
function n_teeth_small_gear(ratio=2) = total_gear_teeth() / (ratio + 1);
function n_teeth_small_gear(ratio=2) =
    let ( n_teeth_s = total_gear_teeth() / (ratio + 1) )
    // check the ratio gives an integer number of teeth
    assert(floor(n_teeth_s)==n_teeth_s,"The number of teeth on each gear is not integer")
    n_teeth_s;

/* Number of teeth on the large gear*/
function n_teeth_large_gear(ratio=2) = n_teeth_small_gear(ratio) * ratio;
function n_teeth_large_gear(ratio=2) =
    let ( n_teeth_l = n_teeth_small_gear(ratio) * ratio )
    // check the ratio gives an integer number of teeth
    assert(floor(n_teeth_l)==n_teeth_l,"The number of teeth on each gear is not integer")
    n_teeth_l;

/* Distance from the centre of the small gear to the centre of the large gear*/
function gear_c2c_distance() = 20;
+7 −4
Original line number Diff line number Diff line
@@ -14,8 +14,11 @@ use <./libs/utilities.scad>

// The ratio is the ratio between the 'large' gear on the actuator and the 'small' gear on the motor.
// This means that it is a gearing down ratio.
// The standard ratio is 2. The total number of teeth on both gears is 36, which is defined by the distance between the rotation axes.
// For an integer number of teeth, allowed ratios are of the form n/(36-n). Ratios from 0.8 (16/20, 1:1.25) to 2 (24/12, 1:0.5) are expected to fit in the body
// The standard ratio is 2. The total number of teeth on both gears is 36, which gives
// reasonable size teeth given the distance between the rotation axes.

// For an integer number of teeth, allowed ratios are of the form n/(36-n).
// Ratios from 0.8 (16/20, 1:1.25) to 2 (24/12, 1:0.5) are expected to fit in the body.

// Gearing ratio for x and y axes. Ratio for z axis fixed at 2
RATIO = 2;
@@ -23,10 +26,10 @@ RATIO = 2;
printable_small_gears(ratio=RATIO);

module printable_small_gears(ratio=2){
    // check the ratio gives an integer number of teeth
    assert(floor(n_teeth_small_gear(ratio))==n_teeth_small_gear(ratio),"The number of teeth on the small gear is not integer");
    // Calculate the spacing from the gear pitch radius.
    // Add 4mm of clearance
    // Note: This will throw an error if either the ratio, or a ratio of 2, 
    // gives a non-integer number of gear teeth
    spacing = small_gear_pitch_radius(ratio) + small_gear_pitch_radius(ratio=2) + 4;
    // x and y gears
    repeat([0, 2*spacing, 0], 2, center=true){