Parametric gears

120 views
Skip to first unread message

Maze Mietner

unread,
Nov 24, 2015, 6:09:51 PM11/24/15
to IceSL
I've seen you've ported the 'parametric gears' script from thingiverse, but the created teeth are - except for straight teeth - plain wrong. So I started to write my own parametric gears, and after having much pain with OpenSCAD I tried IceSL.
At the moment it supports only straight teeth, and it's not yet complete. If you use small gears you'll see sharp gear tips, and this is not wanted. However adding basic helix support is simple...all you have to do is increase the height of the milling tool and then rotate it. Doing helix  properly is more complicated as you should do some more calculations regarding profile shift - I'll add this when I have time. Then I'll go for double helix and then for arc support. I if do't forget I'll add planetary gears as well. Then I should probably aim for bevel gears.
Support: I didn't bother to add extra support for axis/bearing, because it's not necessary - you can modify the gears before rendering (emit) them on screen.
Infill: I didn't bother adding extra holes to save material (it's done in the 'parametric gear' script from thingiverse) because every standard infill prints faster. The weakest part are the teeth anyway, I'd print with 10..25% infill only. You might want to use spokes for thin gears but that's up to you.
When I exit the application after rendering these gears it throws an error message...here's the code, it works fine for preview and slicing:

-- Spur gears, straight teeth ( involute )
-- The involute is not calculated but produced by virtual milling.

z1
= 30               -- Number of teeth for gear 1
z2
= 23                -- Number of teeth for gear 2


m
= 0.5                -- Modul (Size of teeths)
B
= 5                    -- Width
alpha
= 20             -- Pressure angle, typ. = 20°
c
= 0.167 * m        -- Tooth tip clearance, typ. 0.167


autox
= true;         -- Automatic calculation of the profile shift factor
x1
= 0                 -- profile shift factor (will be used for gear 1 if autox = false)
x2
= 0                 -- profile shift factor (will be used for gear 1 if autox = false)

-- profile shift factor calculations
if (autox == true) then
   
--Number of teeth with helical teeth
   
--TODO: helical teeth not supportet atm
    z1e
=z1
    z2e
=z2
   
--profile shift factor
    zg
= 2/(sin(alpha)*sin(alpha)) -- Grenzzähnezahl
   
if (z1e<zg) then
        x1
= 1 - z1e / zg
   
end
   
if (z2e<zg) then
        x2
= 1 - z2e / zg;
   
end
end

-- Trapezoid tool part for milling the teeth
function tool_trapezoid(m, B, alpha, c, z, x)
    p
= m * math.pi -- partition p (Distance between two teeth)
    i
= 0.5 * p/2
    j
= m/math.tan(math.rad(90-alpha))
    k
= (m+c)/math.tan(math.rad(90-alpha))

    points
= {}
    indices
= {}
    table
.insert(points,v(0-i-j, 0-m, -B/2-0.1))        --0
    table
.insert(points,v(0-i+k, 0+m+c, -B/2-0.1))  --1
    table
.insert(points,v(0+i-k, 0+m+c, -B/2-0.1))  --2
    table
.insert(points,v(0+i+j, 0-m, -B/2-0.1))       --3

    table
.insert(points,v(0-i-j, 0-m, B/2+0.1))         --4
    table
.insert(points,v(0-i+k, 0+m+c, B/2+0.1))   --5
    table
.insert(points,v(0+i-k, 0+m+c, B/2+0.1))   --6
    table
.insert(points,v(0+i+j, 0-m, B/2+0.1))       --7
    table
.insert(indices,v(0,1,2)) --bottom
    table
.insert(indices,v(2,3,0))
    table
.insert(indices,v(4,7,5)) --top
    table
.insert(indices,v(7,6,5))

    table
.insert(indices,v(0,4,1)) --side1
    table
.insert(indices,v(4,5,1))

    table
.insert(indices,v(1,5,2)) --side2
    table
.insert(indices,v(5,6,2))

    table
.insert(indices,v(2,6,3)) --side3
    table
.insert(indices,v(6,7,3))

    table
.insert(indices,v(3,7,0)) --side4
    table
.insert(indices,v(7,4,0))
   
return polyhedron(points,indices)
end

--Tool composed out of 19 trapezoid tool parts
function tool(m, B, alpha, c, z, x)
    p
= m * math.pi --partition p (Distance between two teeth)
    w
= tool_trapezoid(m, B, alpha, c, z, x)
    w
= union {
        translate
(-9*p,0,0)*w,
        translate
(-8*p,0,0)*w,
        translate
(-7*p,0,0)*w,
        translate
(-6*p,0,0)*w,
        translate
(-5*p,0,0)*w,
        translate
(-4*p,0,0)*w,
        translate
(-3*p,0,0)*w,
        translate
(-2*p,0,0)*w,
        translate
(-1*p,0,0)*w,
        w
,
        translate
(1*p,0,0)*w,
        translate
(2*p,0,0)*w,
        translate
(3*p,0,0)*w,
        translate
(4*p,0,0)*w,
        translate
(5*p,0,0)*w,
        translate
(6*p,0,0)*w,
        translate
(7*p,0,0)*w,
        translate
(8*p,0,0)*w,
        translate
(9*p,0,0)*w
   
}
   
return w
end

-- Gear blank ( cylinder )
function  gear_blank(r, B)
   
return  translate(0,0,-B/2)*cylinder(r, B)
end

--Milling of the teeth
function gear(m, B, alpha, c, z, x)
    d
= m * z --Core diameter
    V
= x * m --profile shift
    dk
= d + m + V --Tip diameter
    r
= d/2    -- Radius of the core circle
    KU
= 2 * math.pi * r  --Core circumference
    p
= m * math.pi --partition p (Distance between two teeth)

    toolposition
= 0    --X position of the virtual milling tool


    z
= gear_blank(dk/2+V, B)
    w
=  translate(0,-d/2-V,0)*tool(m, B, alpha, c, z, x)

    step_angle
= 10 --If you try 0.01 it'll crash the application (IceSL-win32 1.0.4)
    for i=0, 359, step_angle
    do

        toolposition = toolposition + step_angle*KU/360
        while (toolposition > p) do
            toolposition = toolposition - p
        end
        z = difference (
            rotate(0,0,step_angle)*z,
            translate(toolposition,0,0)*w
        )
    end
    --emit(z)
    --emit(translate(toolposition,0,0)*w)
    return z
end

gear1 = gear(m, B, alpha, c, z1, x1)
gear2 = gear(m, B, alpha, c, z2, x2)


d1 = m * z1
d2 = m * z2
V1 = x1 * m
V2 = x2 * m
wheelbase = d1/2 + V1 + d2/2 + V2
emit(translate(0,-d1/2-V1,0)*rotate(0,0,180+1/2*360/z1)*gear1)
emit(translate(0,d2/2+V2,0)*rotate(0,0,0)*gear2)


sylefeb

unread,
Nov 26, 2015, 2:10:33 AM11/26/15
to IceSL
Hi Maze,

Looking at the script - nice!

Quick performance tip: Line 75 the script creates a large union of polyhedrons  "w = union {". In this case you can replace the union by "w = merge {".

Merge is a special union for polyhedrons (and only for polyhedrons: loaded stls, linear_extrude, spheres, cones, cylinders, etc. but no CSG combinations of these). I am considering making this automatic but there are a few difficulties; but whenever possible it is a huge win to use merge.

Stephen Obuge

unread,
Apr 8, 2023, 9:40:12 AM4/8/23
to IceSL

Hello,

I need help with designing a 3-screw gear using icesl. Please how can you assist with this?
Reply all
Reply to author
Forward
0 new messages