openscad gear worm for a repurposed sg 5010 motor 15:1 ratio


Description
though keep mind the metal gear that came with sg 5010 is kinda small so this just to repurpose the thing
also use a super strong glue
include <BOSL2/std.scad>
include <BOSL2/gears.scad>
/ [Visibility Control] /
show_worm = true;
// Set this to true to see ONLY the internal hole/shaft shape
show_worm_shaft_only = false;
show_compound = true;
show_cyan_gear = true;
show_motor = true;
/ [Primary Worm External Specs] /
worm_od = 24.0;
worm_height = 14.0;
/ [Primary Worm Internal Shaft - Manual Sizing] /
worm_bottom_hole_d = 5;
worm_bottom_hole_h = 7.0;
worm_bottom_hole_z_offset = 0.0;
worm_socket_h = 6.0;
worm_socket_z_offset = 8.0; // Sits at the top (14mm worm)
worm_top_hole_d = 5.15;
worm_top_hole_h = 10.0;
worm_top_hole_z_offset = 7.0;
/ [Cyan Gear Specs] /
cyan_gear_teeth = 15;
cyan_gear_pitch = 2.932;
cyan_gear_thick = 6.0;
cyan_gear_shave = 0.15;
cyan_shaft_d = 3.6;
/ [Secondary Gear, Worm, and Shaft] /
secondary_gear_teeth = 15;
secondary_gear_pitch = 2.932;
secondary_gear_thick = 24.0; // The "Long Spur"
secondary_worm_height = 14.0; // The gold worm part
secondary_shaft_d = 5.15; // Diameter of the central hole
/ [DC Motor Specs] /
master_shaft_d = 3.6;
motor_d = 17.0;
motor_h = 24.2;
boss_h = 1.5;
/ [Nudges - Adjust these to move the Secondary Assembly] /
compound_x_nudge = -19;
compound_y_nudge = 13.5;
compound_z_nudge = 7.0;
/ [Rendering Quality] /
$fn = 64;
// --- MATH ---
pd_worm = worm_od - (cyan_gear_pitch / PI);
// --- MAIN EXECUTION ---
move([0, 0, boss_h]) {
if (show_worm_shaft_only) {
render_worm_internal_shaft();
} else if (show_worm) {
render_stepped_worm();
}
if (show_compound) {
zrot(90)
move([compound_x_nudge, compound_y_nudge, compound_z_nudge])
xrot(90)
render_secondary_gear_worm_shaft("lime");
}
if (show_cyan_gear) {
move([0, 0, worm_socket_z_offset])
render_spur_gear("cyan");
}
if (show_motor) {
color("silver", 0.5)
move([0, 0, worm_socket_z_offset + cyan_gear_thick + motor_h + boss_h])
yrot(180)
render_dc_motor();
}
}
// --- MODULES ---
module render_secondary_gear_worm_shaft(col = "lime") {
difference() {
union() {
// The Long Spur (Secondary Gear)
color(col)
spur_gear(
circ_pitch = secondary_gear_pitch,
teeth = secondary_gear_teeth,
thickness = secondary_gear_thick,
anchor = BOTTOM
);
// The Worm (Secondary Worm)
color("gold")
move([0, 0, secondary_gear_thick])
worm(
circ_pitch = secondary_gear_pitch,
d = pd_worm,
l = secondary_worm_height,
anchor = BOTTOM
);
}
// The central hole (Secondary Shaft)
// Nudged height by +2 to ensure clean subtraction
move([0, 0, -1])
cyl(d = secondary_shaft_d, h = secondary_gear_thick + secondary_worm_height + 2, anchor = BOTTOM);
}
}
module render_worm_internal_shaft() {
color("red") {
move([0, 0, worm_bottom_hole_z_offset])
cyl(d = worm_bottom_hole_d, h = worm_bottom_hole_h, anchor = BOTTOM);
move([0, 0, worm_socket_z_offset])
spur_gear(
circ_pitch = cyan_gear_pitch,
teeth = cyan_gear_teeth,
thickness = worm_socket_h + 0.05,
shaved = cyan_gear_shave,
anchor = BOTTOM
);
move([0, 0, worm_top_hole_z_offset])
cyl(d = worm_top_hole_d, h = worm_top_hole_h, anchor = BOTTOM);
}
}
module render_stepped_worm() {
difference() {
color("gold", 0.6)
worm(circ_pitch = cyan_gear_pitch, d = pd_worm, l = worm_height, anchor = BOTTOM);
move([0, 0, -0.01])
render_worm_internal_shaft();
}
}
module render_spur_gear(col = "cyan") {
difference() {
color(col)
spur_gear(
circ_pitch = cyan_gear_pitch,
teeth = cyan_gear_teeth,
thickness = cyan_gear_thick,
anchor = BOTTOM
);
cyl(d = cyan_shaft_d + 0.15, h = cyan_gear_thick + 2, anchor = BOTTOM);
}
}
module render_dc_motor() {
cyl(d = motor_d, h = motor_h, anchor = BOTTOM);
color("gray")
move([0, 0, motor_h])
cyl(d = 6.5, h = boss_h, anchor = BOTTOM);
color("darkgray")
move([0, 0, motor_h + boss_h])
cyl(d = master_shaft_d, h = cyan_gear_thick, anchor = BOTTOM);
}