12 battery_wall_unsupp = 4.0;
13 battery_wall_top_gap = 0.75;
15 battery_keeper_m_th = 4;
16 battery_keeper_m_w = 4;
17 battery_keeper_x_gap = 0.75; // each side
18 battery_keeper_y_gap_overhang = 0.75;
19 battery_keeper_y_gap_nutbox = 1.0;
20 battery_keeper_z_gap_nutbox = 0.50;
21 battery_keeper_z_gap_overhang = 0.75;
23 battery_keeper_x_th_min = 1.5 * 1.5;
24 battery_keeper_x_th_max = 2.5 * 1.5;
25 battery_keeper_x_w = 5;
26 battery_keeper_x_n = 5;
28 battery_keeper_screw_x_off = -2.5;
32 battery_nutbox = nutbox_data_M3;
36 battery_fix_sz = NutBox_outer_size(battery_nutbox);
38 battery_nutbox_z = max( battery[2] + battery_wall_top_gap,
39 NutBox_h_base(battery_nutbox) );
40 battery_keeper_overhang_z = battery[2] + battery_keeper_m_th
41 + battery_keeper_z_gap_overhang;
42 battery_keeper_overhang_wall = battery_keeper_m_w;
43 battery_keeper_overhang_th = battery_keeper_m_th;
47 battery_keeper_tab_top_z = battery_nutbox_z
48 + battery_keeper_z_gap_nutbox + battery_keeper_m_th;
49 // NB does not include screw head
51 battery_keeper_legs_top_z = battery_keeper_overhang_z
52 + battery_keeper_overhang_th;
54 battery_keeper_frame_top_z = battery[2] + battery_keeper_m_th;
57 rectfromto([ -battery[0]/2, 0 ],
58 [ +battery[0]/2, battery[1] ]);
61 module BatteryBase(){ ////toplevel
63 linextr(-0.1, battery[2] - battery_wall_top_gap, convexity=7) {
66 offset(r=battery_wall) BatteryPlan();
68 [ -(battery[0]/2 + battery_wall_unsupp), battery[1]/3 ]);
71 rectfromto([ battery_fix_sz/2 - 0.5
72 + battery_keeper_screw_x_off, -30 ],
73 [ -battery[0], battery_wire_y ]);
78 translate([battery_keeper_screw_x_off, -battery_fix_sz/2, battery_nutbox_z])
79 NutBox(battery_nutbox, battery_nutbox_z + 0.1);
81 // overhang for legs at rear
84 translate([ battery[0]/2, battery[1], 0]) {
87 battery_keeper_overhang_z
88 + battery_keeper_overhang_th,
90 rectfromto([ -battery_keeper_m_w*2, -battery_keeper_m_w ],
91 [ battery_keeper_overhang_wall, battery_wall ]);
92 linextr(-1, battery_keeper_overhang_z,
94 rectfromto([-20, -20], [0,0]);
101 module BatteryKeeper(){ ////toplevel
103 translate([0,0, battery[2]]) {
104 linextr(0, battery_keeper_m_th) {
107 translate([0, +battery[1], 0])
108 multmatrix([[ 1, -battery_keeper_screw_x_off/battery[1], 0, 0, ],
111 translate([0, -battery[1], 0])
113 multmatrix([[ 1,0,0, 0, ],
117 ( battery[0]/2 - 0.5 * battery_keeper_m_w
118 - battery_keeper_x_gap ) /
119 ( battery[1] - 0.5 * battery_keeper_m_w )
124 rectfromto([ -battery_keeper_m_w/2,
125 battery_keeper_y_gap_nutbox ],
126 [ +battery_keeper_m_w/2,
127 battery[1] - battery_keeper_y_gap_overhang ]);
130 // shape to round off the leg end corners
133 translate([ sx * ( battery[0]/2 - battery_keeper_m_w/2
134 -battery_keeper_x_gap) ,
135 battery[1] - battery_keeper_m_w/2
136 -battery_keeper_y_gap_overhang ])
137 circle(r = battery_keeper_m_w/2);
139 square(center=true, [ battery[0], 1 ]);
145 for (i=[0 : battery_keeper_x_n-1]) {
147 battery_keeper_x_th_min +
148 (battery_keeper_x_th_max - battery_keeper_x_th_min)
149 * pow( i/(battery_keeper_x_n-1)*2 - 1 , 2)
152 translate([0, battery[1] * ((i + 0.5) / battery_keeper_x_n)])
153 square(center=true, [ battery[0], battery_keeper_x_w ]);
160 // tab for screw and nutbox
161 translate([battery_keeper_screw_x_off,
163 battery_nutbox_z + battery_keeper_z_gap_nutbox])
164 linextr(0, battery_keeper_m_th, convexity=4) {
166 rectfromto([ -battery_fix_sz/2, -battery_fix_sz ],
168 0.5 * battery[1] / battery_keeper_x_n +
169 0.5 * battery_keeper_m_w ]);
170 translate([ 0, -battery_fix_sz/2 ])
171 circle(r = battery_nutbox[0]/2);
176 module BatteryDemo(){ ////toplevel
177 color("grey") BatteryBase();
178 BatteryKeeper() { union(){ } }