From 8f909b4dd8da5135ca3cb9ae853f7c26b50f5077 Mon Sep 17 00:00:00 2001 From: philipp schoenberger Date: Tue, 13 Nov 2018 11:46:01 +0100 Subject: [PATCH] big cleanup for 3d print model frame --- 3d/lib/aligned_cube.scad | 31 +++++ 3d/lib/triangle.scad | 13 ++ 3d/quad.scad | 255 +++++++++++++++++++++++++++++++++++++++ Copter/mgh-quad.scad | 251 -------------------------------------- 4 files changed, 299 insertions(+), 251 deletions(-) create mode 100644 3d/lib/aligned_cube.scad create mode 100644 3d/lib/triangle.scad create mode 100644 3d/quad.scad delete mode 100644 Copter/mgh-quad.scad diff --git a/3d/lib/aligned_cube.scad b/3d/lib/aligned_cube.scad new file mode 100644 index 0000000..2d1f20f --- /dev/null +++ b/3d/lib/aligned_cube.scad @@ -0,0 +1,31 @@ +module aligned_cube(size, aligned=[1,1,0]) +{ + translate(-0.5*[size[0]*aligned[0], size[1]*aligned[1], size[2]*aligned[2]]) + cube(size); +} + +module rounded_cube(size, r, aligned=[1,1,0]) +{ + translate(-0.5*[size[0]*aligned[0] -2*r, size[1]*aligned[1] -2*r, size[2]*aligned[2] -2*r]) + minkowski() { + cube([size[0] - 2*r, size[1] - 2*r, size[2]- 2*r]); + sphere(r); + } +} + +module cylinder_flange_sphere($fn=32,r1=10, r2=15, h=5) +{ + diff=abs(r1-r2); + h_off= (r1 < r2 ) ? 0 : h/2; + + + difference() + { + cylinder($fn=$fn, r=max(r2,r1),h=h); + scale([1,1,h/diff]) + rotate_extrude() + translate([diff+min(r2,r1),h_off]) + rotate([0,0,0]) + circle($fn=$fn,r=diff); + } +} diff --git a/3d/lib/triangle.scad b/3d/lib/triangle.scad new file mode 100644 index 0000000..f950a46 --- /dev/null +++ b/3d/lib/triangle.scad @@ -0,0 +1,13 @@ +module triangle(o_len=5, a_len=5, depth=1) +{ + linear_extrude(height=depth) { + polygon(points=[[0,0],[a_len,0],[0,o_len]], paths=[[0,1,2]]); + } +} +module aligned_triangle(o_len=5, a_len=5, depth=1) +{ + linear_extrude(height=depth) { + translate([-o_len/2,-a_len/2,0]) + polygon(points=[[0,0],[a_len,0],[0,o_len]], paths=[[0,1,2]]); + } +} diff --git a/3d/quad.scad b/3d/quad.scad new file mode 100644 index 0000000..37134c7 --- /dev/null +++ b/3d/quad.scad @@ -0,0 +1,255 @@ +$fn = 25; +with_props=0; +with_motor=0; +with_pcbs=1; +with_akku=0; +with_frame=1; + +name="Toolbox"; +version="v1"; +text_depth=0.75; + + + +motor_d = 8.465; +motor_r=motor_d/2; +motor_height = 20; + +motor_clamp_wall_thickness = 2.2; +motor_clamp_d= motor_d + 2*motor_clamp_wall_thickness; +motor_clamp_r= motor_clamp_d /2; +motor_clamp_cut = 3; +motor_clamp_extra_hight = 3; +motor_clamp_hight = motor_height + motor_clamp_extra_hight; + +usb_width=12; +usb_hight=8; + +motor_helper_disc = 40; +motor_helper_height = 0.2; + +motor_arm_width = 8; +motor_arm_height = 6; +motor_arm_length = 20; + +body_width = 40; +body_height = 12; +body_wall_thickness = 2; +body_bottom_flange = 5; +body_bottom_bridge = 3; + +triangle_cut_height = 10; +cable_cut_width = 3; +cable_cut_height = 3; + +akku_holder_hight = 9.1; +akku_holder_width =27; +motor_body_arm_dist = (body_width - motor_arm_width + 2) / sqrt(2); +eps=0.05; + +include ; +include ; + +module triangle_cuts(h=4) { + triangle_width= body_width / 2; + h_tri=((body_width - body_bottom_flange - body_bottom_bridge)/2 - sqrt(2)* body_wall_thickness)* sqrt(2); + for(r=[0:90:359]) + { + rotate([0,0,r]) + translate([0,body_width/2 -body_bottom_flange,0]) { + rotate([0,0,45]) + aligned_triangle(h_tri, h_tri, h); + } + } +} + +module pcb_flight_controller() { + flight_controller = [20, 28,2]; + cube(flight_controller); +} + +module pcb_rx_radio() { + rx_radio=[12,25,2]; + cube(rx_radio); +} + +module motor() { + prop_height=motor_height + 5; + color([0.8,0.2,0.2,0.5]) { + if (with_motor) { + translate([0, 0, motor_clamp_extra_hight]) + cylinder(d = motor_d, h = motor_height ); + translate([0, 0, motor_clamp_extra_hight]) + cylinder(d = 2, h = prop_height); + } + if (with_props) { + translate([0, 0, prop_height]) + cylinder(d = 66.5, h = 2); + } + } +} + +module motor_clamp() { + // motor / prop mockup + + difference() { + union () { + color("blue") + // motor stand + hull() { + cylinder(d = motor_d + motor_clamp_wall_thickness, h = motor_clamp_hight); + + translate([0, -(motor_d + motor_clamp_wall_thickness) / 2 - 2, 0]) + aligned_cube([motor_arm_width, eps, motor_arm_height]); + } + + // print support + color("green") + cylinder(d = motor_helper_disc, h = motor_helper_height); + } + + // cable hole + // motor hole + translate([0, 0, -eps]) + cylinder(d = motor_d, h = motor_height + 2 +eps); + // clamp cutout + translate([0, motor_r, -eps]) + aligned_cube([motor_clamp_cut, 2 * motor_clamp_wall_thickness, motor_clamp_hight+2*eps]); + // motor top hole + translate([0, 0, motor_clamp_hight - motor_clamp_wall_thickness+eps]) + cylinder(d = 6.5, h = motor_clamp_wall_thickness); + // angle motor top cut for better printing + translate([0, 0, motor_clamp_hight-1-eps]) + cylinder(d1=motor_d, d2=6.5, h=0.75); + } + + motor(); +} + +module motor_arm() { + difference() { + union() { + translate([0, motor_arm_length+motor_clamp_r, 0]) + motor_clamp(); + color("blue") { + aligned_cube([motor_arm_width, motor_arm_length, motor_arm_height],[1,0,0]); + } + } + cable_cuts(); + } +} +module cable_cuts() { + union() { + // vertical cut + translate([0, motor_arm_length, -eps]) + aligned_cube([cable_cut_width, cable_cut_height, motor_clamp_hight+2*eps]); + + // lower cut + translate([0, motor_arm_length , -eps]) + aligned_cube([cable_cut_width, cable_cut_height, cable_cut_height+eps],[1,0,0]); + + // horizontal cut + translate([0, -eps,motor_arm_height+eps]) + aligned_cube([cable_cut_width,motor_arm_length, , cable_cut_height],[1,0,2]); + } +} + +module body() { + arm_offset=(body_width - motor_arm_width/sqrt(2))/sqrt(2); + difference() { + union() { + // arms + for(r = [45 : 90 : 360]) { + rotate([0, 0, r]) + translate([0,arm_offset,0]) + motor_arm(); + } + + // board mount + color("red") + aligned_cube([body_width, body_width, body_height]); + } + + // board pcb cutout + translate([0,0,body_wall_thickness]) + aligned_cube([body_width- 2*body_wall_thickness, body_width-2*body_wall_thickness, body_height]); + + // cable cutouts + for(r = [45 : 90 : 360]) { + rotate([0, 0, r]) + translate([0,arm_offset,0]) + cable_cuts(); + } + // usb cutout + translate([-2, -body_width / 2 - 1, 2]) + cube([usb_width, 4, usb_hight]); + + // base triangle cut-outs + translate([0, 0, -1]) + triangle_cuts(); + + + // text stamp + union() + { + rotate([0,0,180]) + translate([0,-body_width/2+text_depth-eps,body_height/2]) + rotate([90,0,0]) + linear_extrude(height = text_depth) + { + translate([0,2,0]) + text(halign="center",valign="center", $fn=$fn, size=5,font="Linux Libertine O", name); + translate([0,-3,0]) + text(halign="center",valign="center", $fn=$fn, size=2,font="Linux Libertine Mono O", version); + } + } + + } +} + +module quad() { + if(with_frame) { + body(); + } + if(with_pcbs) { + translate([0,0, body_wall_thickness+eps]) { + translate([-3, -14, 0]) + %pcb_flight_controller(); + + translate([-16, -12.5, 0]) + %pcb_rx_radio(); + } + } + if(with_akku) { + translate([0,0,body_height]) { + akku_holder(); + } + } +} + +module akku_holder() { + color([0.5,0.8,0.4,0.5]) + difference() { + union() { + aligned_cube([body_width,body_width,akku_holder_hight]); + translate([0,0,-1]) + aligned_cube([body_width-body_wall_thickness*2, + body_width-body_wall_thickness*2, + akku_holder_hight]); + } + translate([0,0,0.01]) { + aligned_cube([akku_holder_width, + body_width+1, + akku_holder_hight+2]); + } + translate([0, 0, -2]) + triangle_cuts(h=6); + } +} + + +quad(); +//body(); +//motor_arm(); +//motor_clamp(); +//akku_holder(); diff --git a/Copter/mgh-quad.scad b/Copter/mgh-quad.scad deleted file mode 100644 index 79470d3..0000000 --- a/Copter/mgh-quad.scad +++ /dev/null @@ -1,251 +0,0 @@ -$fn = 25; -with_props=0; -with_motor=0; -with_pcbs=1; -with_akku=0; - -motor_size = 8.465; -motor_height = 21; -motor_wall_d = 2.2; -motor_clamp_cut = 3; - -usb_width=12; -usb_hight=8; - -motor_helper_disc = 40; -motor_helper_height = 0.2; - -motor_arm_width = 8; -motor_arm_height = 6; -motor_arm_length = 20; - -motor_body_len = 40; -motor_body_height = 12; -motor_body_wall = 2; - -triangle_cut_height = 10; -cable_cut_width = 3; -cable_cut_height = 3; - -akku_holder_hight = 9.1; -akku_holder_width =27; -motor_body_arm_dist = (motor_body_len - motor_arm_width + 2) / sqrt(2); -module aligned_cube(size, aligned=[1,1,0]) -{ - translate(-0.5*[size[0]*aligned[0], size[1]*aligned[1], size[2]*aligned[2]]) - cube(size); -} - -module triangle(o_len, a_len, depth) { - linear_extrude(height=depth) - polygon(points=[[0,0],[a_len,0],[0,o_len]], paths=[[0,1,2]]); -} -module triangle_cuts(h=4) { - translate([0, -motor_body_len / 3, 0]) { - triangle(triangle_cut_height, motor_body_len / 4, h); - triangle(triangle_cut_height, -motor_body_len / 4, h); - } - translate([0, motor_body_len / 3, 0]) { - triangle(-triangle_cut_height, motor_body_len / 4, h); - triangle(-triangle_cut_height, -motor_body_len / 4, h); - } - translate([-motor_body_len / 3, 0, 0]) - rotate([0, 0, -90]) { - triangle(triangle_cut_height, motor_body_len / 4, h); - triangle(triangle_cut_height, -motor_body_len / 4, h); - } - translate([motor_body_len / 3, 0, 0]) - rotate([0, 0, 90]) { - triangle(triangle_cut_height, motor_body_len / 4, h); - triangle(triangle_cut_height, -motor_body_len / 4, h); - } -} - -module fc_pcb() { - fc_width = 20; - fc_height = 28; - if(with_pcbs) - cube([fc_width, fc_height, 2]); -} - -module rx_pcb() { - rx_width = 12; - rx_height = 25; - if(with_pcbs) - cube([rx_width, rx_height, 2]); -} - -module motor() { - color([0.8,0.2,0.2,0.5]) { - if (with_motor) { - cylinder(d = motor_size, h = motor_height ); - translate([0, 0, -5]) - cylinder(d = 2, h = motor_height + 5); - } - if (with_props) { - translate([0, 0, -5]) - cylinder(d = 66.5, h = 2); - } - } -} - -module motor_clamp() { - // motor / prop mockup - - difference() { - union () { - color("blue") - // motor stand - hull() { - cylinder(d = motor_size + motor_wall_d, h = motor_height); - - translate([-motor_arm_width / 2, -(motor_size + motor_wall_d) / 2 - 2, motor_height - motor_arm_height]) - cube([motor_arm_width, 1, motor_arm_height]); - } - - // print support - color("green") - translate([0, 0, motor_height - motor_helper_height]) - cylinder(d = motor_helper_disc, h = motor_helper_height); - - color("blue") - - translate([0, 0, -2]) - cylinder(d = motor_size + motor_wall_d,h=7); - } - - // cable hole - translate([-cable_cut_width / 2, -(motor_size + motor_wall_d) / 2 - cable_cut_height, 0]) - cube([cable_cut_width, cable_cut_height, 25]); - - translate([0, -(motor_size) / 2 , motor_height- cable_cut_height]) - aligned_cube([cable_cut_width, cable_cut_height, cable_cut_height]); - - // motor hole - translate([0, 0, -1]) - cylinder(d = motor_size, h = motor_height + 2); - - // clamp cutout - translate([-motor_clamp_cut / 2, -3, -motor_size - motor_wall_d - 1]) - cube([motor_clamp_cut, motor_size + motor_wall_d + 5, motor_height + motor_size + motor_wall_d + 2]); - translate([0, 0, -motor_size - motor_wall_d - 1]) - cylinder(d=6.5, h= motor_height + motor_size + motor_wall_d + 2); - translate([0, 0, -1.75]) - cylinder(d2=motor_size,d1=6.5, h=0.75); - - //sphere(d = motor_size); - } - - %motor(); -} - -module arm() { - motor_clamp(); - - // motor arm itself - color("blue") - translate([-motor_arm_width / 2, -(motor_arm_length + ((motor_size + motor_wall_d) / 2) + 2), motor_height - motor_arm_height]) - cube([motor_arm_width, motor_arm_length, motor_arm_height]); -} - -module body() { - // arms - for(r = [45 : 90 : 360]) { - rotate([0, 0, r]) - translate([0, motor_arm_length + ((motor_size + motor_wall_d) / 2) + motor_body_arm_dist + 1, 0]) - difference() { - arm(); - - translate([-cable_cut_width / 2, -motor_arm_length - ((motor_size + motor_wall_d) / 2) - 2, motor_height - motor_arm_height-3]) - - cube([cable_cut_width, motor_arm_length + 2, cable_cut_height + 3]); - } - } - - color("red") - translate([0,0, motor_height]) - difference() { - aligned_cube([motor_body_len, motor_body_len, motor_body_height],[1,1,2]); - - for(r = [45 : 90 : 360]) { - translate([0,0, -motor_height + motor_body_height]) - rotate([0, 0, r]) - translate([0, motor_body_len / 2 * sqrt(2) - 2, cable_cut_height]) { - aligned_cube([cable_cut_width, 8, cable_cut_height ]); - } - } - } -} - -module quad() { - difference() { - translate([0, 0, motor_height]) - rotate([180, 0, 0]) - { - body(); - - translate([0,0, 15]) - { - translate([-3, -14, 0]) - %fc_pcb(); - - translate([-16, -12.5, 0]) - %rx_pcb(); - } - } - - // cut out for actual PCBs - translate([-(motor_body_len - (2 * motor_body_wall)) / 2, -(motor_body_len - (2 * motor_body_wall)) / 2, motor_body_wall]) - cube([motor_body_len - (2 * motor_body_wall), motor_body_len - (2 * motor_body_wall), motor_body_height - motor_body_wall + 1]); - - // akku cutout - akku_cut=motor_body_len - motor_body_wall*2; - translate([0,0, motor_body_height]) { - scale([1,1,1]) - rotate([0,0,45]) - //cylinder($fn=4, d1=akku_cut*1.4, d2=30, h=11); - translate([1,-12.5,0]) { - //cube([20,25,10]); - } - translate([-30,-12.5,0]) { - //cube([20,25,10]); - } - } - translate([-motor_body_len/2,-(akku_cut)/2, motor_body_height]) { - //cube([motor_body_len, akku_cut/2, 10]); - } - - // usb cutout - translate([-2, -motor_body_len / 2 - 1, 2]) - cube([usb_width, 4, usb_hight]); - - // triangle cut-outs - translate([0, 0, -1]) - triangle_cuts(); - } -} -module akku_holder() { - color([0.5,0.8,0.4,0.5]) - difference() { - union() { - aligned_cube([motor_body_len,motor_body_len,akku_holder_hight]); - translate([0,0,-1]) - aligned_cube([motor_body_len-motor_body_wall*2, - motor_body_len-motor_body_wall*2, - akku_holder_hight]); - } - translate([0,0,0.01]) { - aligned_cube([akku_holder_width, - motor_body_len+1, - akku_holder_hight+2]); - } - translate([0, 0, -2]) - triangle_cuts(h=6); - } -} - -quad(); - -translate([0,0,motor_body_height]) { - akku_holder(); -}