Refactor script to use R() helper function

This commit is contained in:
Matt McWilliams 2022-10-10 14:11:54 -04:00
parent 0cf6685eb9
commit 26aa45854d
1 changed files with 29 additions and 25 deletions

View File

@ -19,7 +19,7 @@ module hex (diag = 10, h = 1) {
module motor_shaft () {
difference () {
cylinder(r = MOTOR_SHAFT_D / 2, h = MOTOR_SHAFT_H, center = true, $fn = 60);
cylinder(r = R(MOTOR_SHAFT_D), h = MOTOR_SHAFT_H, center = true, $fn = 60);
translate([MOTOR_SHAFT_D - MOTOR_SHAFT_HOBBLE, 0, 0]) cube([MOTOR_SHAFT_D, MOTOR_SHAFT_D, MOTOR_SHAFT_H + 1], center = true);
}
}
@ -36,9 +36,9 @@ module motor_mounts () {
module motor_mount_pad (D, Z) {
difference () {
cylinder(r = D / 2, h = Z, center = true, $fn = 40);
cylinder(r = R(D), h = Z, center = true, $fn = 40);
//bolt void
cylinder(r = 2.5 / 2, h = Z + 1, center = true, $fn = 40);
cylinder(r = R(2.5), h = Z + 1, center = true, $fn = 40);
}
}
@ -47,23 +47,27 @@ module magnetic_coupling (MAGNETS = 4, MAGNET_D = 8.1, MAGNET_H = 2.5) {
OFFSET = 12;
difference () {
union () {
cylinder(r = COUPLING_D / 2, h = MAGNET_H + H, center = true, $fn = 100);
translate([0, 0, -6]) cylinder(r = 12.5 / 2, h = 10, center = true, $fn = 60);
translate([0, 0, -5]) cylinder(r = 20 / 2, h = 5, center = true, $fn = 60);
cylinder(r = R(COUPLING_D), h = MAGNET_H + H, center = true, $fn = 100);
translate([0, 0, -6]) cylinder(r = R(12.5), h = 10, center = true, $fn = 60);
translate([0, 0, -5]) cylinder(r = R(20), h = 5, center = true, $fn = 60);
}
//motor shaft void
scale([1.1, 1.1, 2]) motor_shaft();
//magnet voids
for (i = [0 : MAGNETS - 1]) {
rotate([0, 0, i * (360 / MAGNETS)]) translate([0, OFFSET, H - MAGNET_H + 1.01]) cylinder(r = MAGNET_D / 2, h = MAGNET_H, center = true, $fn = 50);
rotate([0, 0, i * (360 / MAGNETS)]) {
translate([0, OFFSET, H - MAGNET_H + 1.01]) {
cylinder(r = R(MAGNET_D), h = MAGNET_H, center = true, $fn = 50);
}
}
}
//m3 nut
translate([6, 0, -9]) {
cube([2.75, 5.75, 10], center = true);
translate([0, 0, 5]) rotate([0, 90, 0]) {
cylinder(r = 6.75/2, h = 2.75, center = true, $fn = 6);
translate([0, 0, 4]) cylinder(r = 3.25/2, h = 20, center = true, $fn = 30);
translate([0, 0, 13.5]) cylinder(r = 6/2, h = 20, center = true, $fn = 30);
cylinder(r = R(6.75), h = 2.75, center = true, $fn = 6);
translate([0, 0, 4]) cylinder(r = R(3.25), h = 20, center = true, $fn = 30);
translate([0, 0, 13.5]) cylinder(r = R(6), h = 20, center = true, $fn = 30);
}
}
}
@ -72,20 +76,20 @@ module magnetic_coupling (MAGNETS = 4, MAGNET_D = 8.1, MAGNET_H = 2.5) {
module slip_coupling (MAGNET_H = 2.5) {
H = 16;
difference () {
translate([0, 0, 2]) cylinder(r = 45 / 2, h = H, center = true, $fn = 100);
translate([0, 0, 2 -(H / 2) + (MAGNET_H + 3) / 2]) cylinder(r = (COUPLING_D + 0.7) / 2, h = MAGNET_H + 3.01, center = true, $fn = 160);
translate([0, 0, 2 -(H / 2) + (MAGNET_H + 3) + (WASHER_H / 2)]) cylinder(r = WASHER_D / 2, h = WASHER_H, center = true, $fn = 160);
translate([0, 0, 2]) cylinder(r = R(45), h = H, center = true, $fn = 100);
translate([0, 0, 2 -(H / 2) + (MAGNET_H + 3) / 2]) cylinder(r = R(COUPLING_D + 0.7), h = MAGNET_H + 3.01, center = true, $fn = 160);
translate([0, 0, 2 -(H / 2) + (MAGNET_H + 3) + (WASHER_H / 2)]) cylinder(r = R(WASHER_D), h = WASHER_H, center = true, $fn = 160);
translate([0, 0, 2 + (H / 2) - (5 / 2)]) cube([25, 10, 5.01], center = true);
translate([0, 0, 2 + (H / 2) - (5 / 2)]) cube([10, 25, 5.01], center = true);
//corners with voids for M3
translate([-8.75, -8.75, 2 + (H / 2) - (5 / 2)]) {
translate([0, 0, 1]) cube([(25 - 10) / 2, (25 - 10) / 2, 5.01], center = true);
cylinder(r = 3.25 / 2, h = 20, center = true, $fn = 40);
cylinder(r = R(3.25), h = 20, center = true, $fn = 40);
translate([0, 0, -4.25]) hex(6, 2.75);
}
translate([8.75, 8.75, 2 + (H / 2) - (5 / 2)]) {
translate([0, 0, 1]) cube([(25 - 10) / 2, (25 - 10) / 2, 5.01], center = true);
cylinder(r = 3.25 / 2, h = 20, center = true, $fn = 40);
cylinder(r = R(3.25), h = 20, center = true, $fn = 40);
translate([0, 0, -4.25]) hex(6, 2.75);
}
}
@ -98,27 +102,27 @@ module daylight_spool_insert () {
cube([10 - .4, 25 - .4, 5], center = true);
translate([-8.75, -8.75, 0]) difference () {
translate([.2, .2, 1/2]) cube([(25 - 10) / 2, (25 - 10) / 2, 4], center = true);
cylinder(r = 3.25 / 2, h = 20, center = true, $fn = 40);
translate([0, 0, 2]) cylinder(r = 5.75 / 2, h = 3.5, center = true, $fn = 40);
cylinder(r = R(3.25), h = 20, center = true, $fn = 40);
translate([0, 0, 2]) cylinder(r = R(5.75), h = 3.5, center = true, $fn = 40);
}
translate([8.75, 8.75, 0]) difference () {
translate([ -.2, -.2, 1/2]) cube([(25 - 10) / 2, (25 - 10) / 2, 4], center = true);
cylinder(r = 3.25 / 2, h = 20, center = true, $fn = 40);
translate([0, 0, 2]) cylinder(r = 5.75 / 2, h = 3.5, center = true, $fn = 40);
cylinder(r = R(3.25), h = 20, center = true, $fn = 40);
translate([0, 0, 2]) cylinder(r = R(5.75), h = 3.5, center = true, $fn = 40);
}
}
}
module motor_mount_void (D, Z) {
cylinder(r = D / 2, h = Z, center = true, $fn = 40);
cylinder(r = R(D), h = Z, center = true, $fn = 40);
//bolt void
translate([0, 0, 5]) cylinder(r = 3.25 / 2, h = Z + 10, center = true, $fn = 40);
translate([0, 0, 4.75]) cylinder(r = 6 / 2, h = 3.5, center = true, $fn = 40);
translate([0, 0, 5]) cylinder(r = R(3.25), h = Z + 10, center = true, $fn = 40);
translate([0, 0, 4.75]) cylinder(r = R(6), h = 3.5, center = true, $fn = 40);
}
module mount_plate_void () {
cylinder(r = 4.25 / 2, h = 20, center = true, $fn = 40);
translate([0, 0, 0.5]) cylinder(r = 8 / 2, h = 3, center = true, $fn = 40);
cylinder(r = R(4.25), h = 20, center = true, $fn = 40);
translate([0, 0, 0.5]) cylinder(r = R(8), h = 3, center = true, $fn = 40);
}
module mount_plate () {
@ -143,7 +147,7 @@ module mount_plate () {
//motor void (centered)
translate([7, 0, 0]) {
translate([-(46 / 2) + 15 + 1, 0, 0]) cylinder(r = 15 / 2, h = 20, center = true, $fn = 60);
translate([-(46 / 2) + 15 + 1, 0, 0]) cylinder(r = R(15), h = 20, center = true, $fn = 60);
translate([(MOTOR_MOUNT_X / 2)+1, (MOTOR_MOUNT_Y / 2), 0]) motor_mount_void(D, Z);
translate([-(MOTOR_MOUNT_X / 2)+1, (MOTOR_MOUNT_Y / 2), 0]) motor_mount_void(D, Z);
translate([(MOTOR_MOUNT_X / 2)+1, -(MOTOR_MOUNT_Y / 2), 0]) motor_mount_void(D, Z);