define wiring in separate file
[challenge-bot] / 3d-printables / sonar-binder-clip-holder-data.scad
index 42b1d408baf4d2abc0e2ed5fdaf2c22e65ea324c..d9b20eacb8f1bdedd5c9f924981c8456bfee764e 100644 (file)
   of it.
 */
 
-$fn = 30;
+/*
+ *  * TODO make hole for thing between cans
+ *  * TODO make hole for screws in corners of pcb
+ */
+
+$fn = 150;
 
 sonar_diameter_measured = 15.82;
-sonar_diameter_print_fudge = 0.5;
+sonar_diameter_print_fudge = 0.4;
 sonar_diameter = sonar_diameter_measured + sonar_diameter_print_fudge;
 sonar_radius = sonar_diameter / 2;
 
-module sonar_binder_clip_holder(sonar_radius) {
-       circle(sonar_radius);
-}
+between_sonar_cans = 10.82;
+between_sonar_centers = sonar_diameter + between_sonar_cans;
+
+// the sonar cylinders are placed on the pcb at slightly different positions
+//  from one sensor to the next, so this allows for that variance.
+between_sonar_centers_variation = 2;
+
+wall_thickness = 4;
+
+screw_diameter_measured = 3.45;
+screw_radius_measured = screw_diameter_measured / 2;
+screw_radius_print_fudge = 0.4;
+screw_radius = screw_radius_measured + screw_radius_print_fudge;
+
+sonar_binder_clip_holder_height = 3;
+
+/*
+  sonar holder
+    sonar holder outline
+    sonar holder holes
+  binder clip holder
+    binder clip holder outline
+    binder clip holder holes
+  sonar binder clip joiner
+ */
+
+module sonar_holder_holes_2d(sonar_radius,
+                             between_sonar_centers,
+                             between_sonar_centers_variation) {
+  hull(){
+    circle(sonar_radius);
+    translate([between_sonar_centers_variation, 0]){
+      circle(sonar_radius); } }
+  translate([between_sonar_centers, 0]) {
+    circle(sonar_radius); } }
+
+module sonar_holder_outline_2d(holder_radius,
+                               between_sonar_centers) {
+  smaller_radius = holder_radius / 4;
+  inside_radius = holder_radius - smaller_radius;
+  hull() {
+    offset(r = smaller_radius){
+      square([inside_radius * 2, inside_radius * 2], center=true); }
+    translate([between_sonar_centers, 0]) {
+      circle(holder_radius); } } }
+
+module sonar_holder_2d(holder_radius,
+                       between_sonar_centers,
+                       sonar_radius,
+                       between_sonar_centers_variation) {
+  difference() {
+    sonar_holder_outline_2d(holder_radius,
+                            between_sonar_centers);
+    sonar_holder_holes_2d(sonar_radius,
+                          between_sonar_centers,
+                          between_sonar_centers_variation); } }
+
+module binder_clip_holder_holes_2d(screw_radius) {
+  circle(screw_radius); }
+
+module binder_clip_holder_outline_2d(holder_radius) {
+  smaller_radius = holder_radius / 4;
+  inside_radius = holder_radius - smaller_radius;
+  offset(r = smaller_radius){
+    square([inside_radius * 2, inside_radius * 2], center=true); } }
+
+module binder_clip_holder_2d(holder_radius,
+                             screw_radius) {
+  difference() {
+    binder_clip_holder_outline_2d(holder_radius);
+    binder_clip_holder_holes_2d(screw_radius); } }
+
+module binder_clip_holder(holder_radius,
+                          screw_radius,
+                          sonar_binder_clip_holder_height) {
+  linear_extrude(height = sonar_binder_clip_holder_height) {
+    binder_clip_holder_2d(holder_radius,
+                          screw_radius); } }
+
+module sonar_binder_clip_holder_2d(sonar_radius,
+                                   between_sonar_centers,
+                                   between_sonar_centers_variation,
+                                   screw_radius,
+                                   wall_thickness) {
+     holder_radius = sonar_radius + wall_thickness;
+     sonar_holder_2d(holder_radius,
+                     between_sonar_centers,
+                     sonar_radius,
+                     between_sonar_centers_variation);
+     arm_length = between_sonar_centers + 2 * holder_radius;
+     difference() {
+          translate([0, -holder_radius]) {
+               square([arm_length, holder_radius * 2]); }
+          sonar_holder_outline_2d(holder_radius, between_sonar_centers);
+          translate([arm_length, 0]) {
+               binder_clip_holder_outline_2d(holder_radius); } }
+     translate([arm_length, 0]) {
+          binder_clip_holder_2d(holder_radius, screw_radius); } }
+
+module sonar_binder_clip_holder(sonar_radius,
+                                between_sonar_centers,
+                                between_sonar_centers_variation,
+                                screw_radius,
+                                wall_thickness,
+                                sonar_binder_clip_holder_height) {
+  linear_extrude(height = sonar_binder_clip_holder_height) {
+    sonar_binder_clip_holder_2d(sonar_radius,
+                                between_sonar_centers,
+                                between_sonar_centers_variation,
+                                screw_radius,
+                                wall_thickness); } }
 
 /*
   This file is part of challenge-bot.