chiark / gitweb /
adafruit-powerboost: wip common
[reprap-play.git] / nutbox.scad.m4
1 // -*- C -*-
2 // edit nutbos.scad.m4, not nutbos.scad!
3 // shaft, nut_across, nut_thick, nut_recess, wall, ceil
4
5 nutbox_data_M4 = [
6                    4.0 + 0.5,
7                    6.89 + 0.45,
8                    3.10 + 0.75,
9                    0.75,
10                    2.0,
11                    2.5
12                    ];
13
14 nutbox_data_M3 = [
15                    3.0 + 0.5,
16                    5.48 + 0.45,
17                    2.26 + 0.75,
18                    0.75,
19                    1.8,
20                    2.0
21                    ];
22
23 m4_define(shaft,      (nutbox_data[0]))
24 m4_define(nut_across, (nutbox_data[1]))
25 m4_define(nut_thick,  (nutbox_data[2]))
26 m4_define(nut_recess, (nutbox_data[3]))
27 m4_define(wall,       (nutbox_data[4]))
28 m4_define(ceil,       (nutbox_data[5]))
29
30 m4_define(nut_dia, (nut_across / cos(30)))
31 m4_define(outer_size, (nut_dia + wall * 2))
32 m4_define(h_base, (ceil + nut_thick + nut_recess))
33
34 function NutBox_shaft(nutbox_data) = shaft;
35 function NutBox_outer_size(nutbox_data) = outer_size;
36 function NutBox_h_base(nutbox_data) = h_base;
37 function NutBox_wall(nutbox_data) = wall; // not sure why anyone needs this
38
39 module NutBox(nutbox_data, h, h_above_extra=0) {
40   // origin is centre of top of mount
41   // entrance is to positive y
42   // height is h which must be at least h_base
43   // can be mad extra tall (with hole all the way through) with h_above_extra
44   w = outer_size;
45   difference(){
46     mirror([0,0,1]) translate([-w/2,-w/2, -h_above_extra])
47       cube([w,w, h + h_above_extra]);
48     mirror([0,0,1]) translate([0,0,-1 -h_above_extra])
49       cylinder(r = shaft/2, h = h+2 + h_above_extra, $fn=20);
50     for (offset = [ [0,0, -nut_recess],
51                     [0, outer_size, 0] ]) {
52       hull(){
53         for (toffset = [[0,0,0], offset]) {
54           translate(toffset)
55             translate([0,0, -ceil])
56             mirror([0,0,1])
57             rotate([0,0, 360/6/2])
58             cylinder(r = nut_dia/2,
59                      h = nut_thick,
60                      $fn = 6);
61         }
62       }
63     }
64   }
65 }