1 lowres = 0; // fast rendering or fine printing with print-friendly orientation
6 wall = 1.5; // generic wall thickness
8 // 18650 is ~18mm diameter, ~65mm length,
15 front_flat_len = batt_len + 4*wall + 2*cable_sep;
17 // PCB-related dimensions
18 pcb_len = 36 + 1; // length of the board
19 pcb_width = 11 + 0.5; // width of the board
20 pcb_thick = 1.2 + 0.3; // thickness of the board
21 pcb_comp_h = 2.2; // height of the components on board
22 pcb_comp_h2 = 4.5; // height of the components on board - component side
25 body_top_h = 0.35 * batt_diam; // cube-shaped part of the body
30 batt_end_h = wire_sep/2 + wire_thick/2 + 1.5;;
32 lid_sep = 0.2; // the lid is made this much smaller to separate from the body
34 // sw_diam = 2.5 + 0.5;
37 sw_xoff = 250 * 25.4/1000; // x offset of microswitches
38 pcb_xoff = 90 * 25.4/1000; // offset of the LED from the middle of the PCB
40 prg_len = 10; // programming connector
46 // mounting cylinder + holes
49 mountcyl_w = mounthole_w + 4*wall;
51 mountcone_h = mounthole_h + 2*wall;
53 clip_pretension = 0.5;
55 plus_width = 4.5; // width of the + sign
59 translate([-batt_len/2-2*wall-cable_sep, -batt_diam/2-wall, 0])
60 cube([batt_len + 4*wall + 2*cable_sep,
61 batt_diam+2*wall, body_top_h]);
63 translate([-batt_len/2-2*wall-cable_sep, 0, 0])
65 cylinder(r=batt_diam/2+wall,
66 h = batt_len + 4*wall + 2*cable_sep);
67 translate([-infty/2, -infty/2, eps]) cube(infty);
69 translate([-front_flat_len/2,
70 batt_diam/2 - pcb_width,
71 -batt_diam/2-pcb_comp_h-pcb_comp_h2-pcb_thick-wall])
72 cube([front_flat_len, pcb_width+wall, eps]);
75 for (x = [-1, 1]) translate([x*(batt_len/2-mounthole_w/2),
76 batt_diam/2+wall, 0]) {
77 translate([0, 0, -batt_diam/2-wall-pcb_comp_h-pcb_comp_h2-pcb_thick])
79 translate([0, 0, body_top_h]) // rear
86 assign(h = mounthole_h+wall)
88 translate([0, -mountcyl_w/2+mounthole_h + wall])
89 cylinder(r = mountcyl_w/2, h = mountcyl_h);
90 assign(l = 2*sqrt(h*(mountcyl_w-h)))
91 translate([-l/2, 0, mountcyl_h + mountcone_h])
99 // upper cube-shaped part
100 // rotate([20, 0, 0])
101 translate([-batt_len/2, -batt_diam/2, 0])
102 cube([batt_len, batt_diam, batt_diam]);
104 // battery cylinder for the lower part
105 translate([-batt_len/2, 0, 0])
107 cylinder(r=batt_diam/2, h = batt_len);
110 translate([-pcb_len/2-pcb_xoff,
111 batt_diam/2-pcb_width,
112 -batt_diam/2-pcb_thick - pcb_comp_h])
113 cube([pcb_len, pcb_width,
114 batt_diam/2 + pcb_thick + pcb_comp_h + eps]);
115 // hole above the PCB for the outgoing cable
116 translate([-pcb_len/2-pcb_xoff-2*wall-outcable_w,
117 batt_diam/2-pcb_width,
118 -batt_diam/2-pcb_comp_h])
119 cube([pcb_len, pcb_width,
120 batt_diam/2 + pcb_comp_h + eps]);
122 translate([-pcb_xoff-pcb_len/2-wall-outcable_w,
123 -pcb_width+batt_diam/2,
124 -batt_diam/2-outcable_h])
125 cube([outcable_w, infty, outcable_h]);
126 // hole under the PCB (groove)
127 translate([-pcb_len/2+pcb_groove-pcb_xoff,
128 batt_diam/2-pcb_width + pcb_groove,
129 -batt_diam/2-pcb_thick - pcb_comp_h - pcb_comp_h2])
130 cube([pcb_len-2*pcb_groove, pcb_width-2*pcb_groove,
131 batt_diam/2 + pcb_thick + pcb_comp_h2 + eps]);
132 // hole under the PCB (pcb-width)
133 translate([-pcb_len/2+2*pcb_groove-pcb_xoff,
134 batt_diam/2-pcb_width,
135 -batt_diam/2-pcb_thick - pcb_comp_h - pcb_comp_h2])
136 cube([pcb_len-4*pcb_groove, pcb_width,
137 batt_diam/2 + pcb_thick + pcb_comp_h2 + eps]);
138 // hole for prog connector
139 translate([pcb_len/2-pcb_xoff-pcb_groove-eps,
140 batt_diam/2-pcb_width/2-prg_width/2,
141 -batt_diam/2-pcb_thick - pcb_comp_h - pcb_comp_h2])
143 cube([prg_len+pcb_groove+eps, prg_width,
144 batt_diam/2 + pcb_thick + pcb_comp_h + eps]);
145 translate([prg_len/2+pcb_groove, -eps, pcb_comp_h2])
146 cube([prg_len/2+eps, prg_width+2*eps, pcb_thick]);
148 // LED and button holes
149 translate([0, batt_diam/2-pcb_width/2, -infty/2]) {
150 cylinder(r=led_diam/2, h=infty, $fn=6);
151 translate([sw_xoff, 0, 0])
152 cylinder(r=sw_diam/2, h=infty, $fn=6);
153 translate([-sw_xoff, 0, 0])
154 cylinder(r=sw_diam/2, h=infty, $fn=6);
156 // space under the wire holes for battery contacts
157 translate([-batt_len/2-2*wall-cable_sep-eps, 0, 0])
160 cylinder(r = batt_diam/2-wall, h = batt_len + 4*wall + 2*cable_sep + 2*eps);
161 translate([-infty/2, -infty/2, -batt_end_h])
164 // space above the wire holes for battery contacts
165 translate([-batt_len/2-2*wall-cable_sep-eps, -batt_diam/2, batt_end_h])
166 cube([batt_len + 4*wall + 2*cable_sep + 2*eps,
169 // wire holes for battery contacts
172 translate([-batt_len/2-wall-eps, x*wire_sep/2, y*wire_sep/2])
174 cylinder(r = wire_thick/2, h = batt_len + 2*wall + 2*eps, $fn=6);
175 // wire hole from PCB to battery contacts
176 // translate([-batt_len/2-wall-eps, 0, -batt_diam/2-pcb_comp_h + wire_thick/2])
178 translate([-batt_len/2-wall-eps, 0, -batt_diam/2 - wall/2 - wire_thick/2])
180 cylinder(r = wire_thick/2, h = batt_len + 2*wall + 2*eps, $fn=6);
181 // hole behind the battery contacts
183 scale([x, 1, 1]) translate([batt_len/2+wall+cable_sep, 0, 0]) hull() {
184 translate([0, -batt_diam/2, 0])
185 cube([wall + eps, batt_diam, infty]);
187 cylinder(r = batt_diam/2, h = wall+eps);
188 translate([0, batt_diam/2 - pcb_width,
189 -batt_diam/2-pcb_comp_h-pcb_thick])
190 cube([wall + eps, pcb_width, eps]);
191 translate([0, batt_diam/2 - pcb_width + 0.5*wall,
192 -batt_diam/2-pcb_comp_h-pcb_comp_h2-pcb_thick])
193 cube([wall + eps, pcb_width-0.5*wall, eps]);
195 // inner hole behind the battery contacts
197 scale([x, 1, 1]) translate([batt_len/2+wall, 0, 0]) hull() {
198 translate([0, -batt_diam/2+wall, 0])
199 cube([cable_sep + eps, batt_diam-2*wall, infty]);
201 cylinder(r = batt_diam/2-wall, h = cable_sep+eps);
203 // cable lead to battery contacts
204 for (x=[1, -1]) scale([x, 1, 1])
206 translate([batt_len/2-eps, -wire_thick/2, batt_diam/2-2.7])
207 cube([wall+cable_sep+2*eps, wire_thick, 5.4]);
210 for(x=[-1,1]) scale([x, 1, 1])
211 translate([batt_len/2-mounthole_w/2, batt_diam/2+wall+mounthole_h/2, -infty/2])
212 scale([1, mounthole_h/mounthole_w, 1])
213 cylinder(r = mounthole_w/2, h = infty);
215 for(x=[-1,1]) scale([x, 1, 1])
216 translate([batt_len/2+cable_sep+wall+10, batt_diam/2-pcb_width/2, -batt_diam/2-pcb_comp_h-pcb_comp_h2-pcb_thick-wall-eps])
217 cylinder(r1 = 10, r2 = 10 - wall, h = wall + 2*eps);
218 // internal plus sign - vertical line
219 translate([-batt_len/2 + 0.5*wall+plus_width/2, -plus_width/2, -batt_diam/2-wall])
220 cube([wall, plus_width, infty]);
221 // internal plus and minus signs - horizontal line
222 for(x=[-1,1]) scale([x, 1, 1])
223 translate([batt_len/2 - wall - plus_width, -wall/2, -batt_diam/2-wall])
224 cube([plus_width, wall, infty]);
227 translate([sw_xoff + sw_diam/2 + wall/2 + plus_width/2, batt_diam/2-pcb_width/2-plus_width/2, -batt_diam/2-pcb_thick-pcb_comp_h-pcb_comp_h2-wall-eps])
228 cube([wall, plus_width, wall/2]);
229 // button +/- label - horizontal line
230 for (x=[-1, 1]) scale([x, 1, 1])
231 translate([sw_xoff + sw_diam/2 + wall, batt_diam/2-pcb_width/2-wall/2, -batt_diam/2-pcb_thick-pcb_comp_h-pcb_comp_h2-wall-eps])
232 cube([plus_width, wall, wall/2]);
235 for (x = [-1, 1]) scale([x, 1, 1]) hull () {
236 translate([batt_len/2+wall+cable_sep-eps, batt_diam/2-pcb_width+wall/2+lid_sep,
237 -batt_diam/2-pcb_thick-pcb_comp_h + wall + lid_sep])
238 cube([wall+eps, pcb_width-2*wall-2*lid_sep, wall]);
239 translate([batt_len/2+wall+cable_sep-eps, batt_diam/2-pcb_width+3*wall/2+lid_sep,
240 -batt_diam/2-pcb_thick-pcb_comp_h + 3*wall + lid_sep])
241 cube([eps, pcb_width-4*wall-2*lid_sep, eps]);
246 translate([-batt_len/2 - wall - cable_sep - lid_sep, -batt_diam/2+lid_sep, -batt_diam/2 -wall])
247 cube([batt_len + 2*wall + 2*cable_sep + 2*lid_sep, batt_diam-2*lid_sep, batt_diam/2 - batt_end_h + wall - lid_sep]);
249 translate([-batt_len/2 - 2*wall - cable_sep,
250 -batt_diam/2, -batt_diam/2-wall])
251 cube([batt_len + 4*wall + 2*cable_sep,
253 translate([-batt_len/2 - 3*wall - cable_sep,
254 -batt_diam/2 - wall, -body_top_h-wall/2-lid_sep])
255 cube([batt_len + 6*wall + 2*cable_sep,
256 batt_diam + 2*wall, wall/2]);
258 // clip behind the battery contacts
260 scale([x, 1, 1]) translate([batt_len/2+wall+cable_sep+lid_sep, 0, 0]) hull() {
261 translate([0, -batt_diam/2+lid_sep, -batt_diam/2])
262 cube([wall-lid_sep, batt_diam-2*lid_sep, eps]);
264 cylinder(r = batt_diam/2-lid_sep, h = wall-lid_sep);
265 translate([-clip_pretension, batt_diam/2 - pcb_width + 0.5*wall + lid_sep,
266 batt_diam/2+pcb_comp_h+pcb_comp_h2+pcb_thick-lid_sep])
267 cube([wall+clip_pretension, pcb_width-0.5*wall-1.5*lid_sep, eps]);
269 // outer part of the clip behind the battery contacts
270 for (x=[1, -1]) scale([x, 1, 1]) translate([batt_len/2+2*wall+cable_sep+lid_sep, 0, 0]) hull() {
271 translate([0, -batt_diam/2 - wall, -body_top_h-wall/2-lid_sep])
272 cube([wall-lid_sep, batt_diam + 2*wall, wall/2]);
275 sphere(batt_diam/2+wall);
276 translate([-infty/2, -infty/2, -infty-body_top_h-lid_sep+2*wall])
278 translate([-infty-clip_pretension, -infty/2, -infty/2])
281 translate([-clip_pretension,
282 batt_diam/2 - pcb_width,
283 batt_diam/2+pcb_comp_h+pcb_comp_h2+pcb_thick+wall])
284 cube([wall-lid_sep, pcb_width+wall, eps]);
291 translate([-batt_len/2+eps, 0, 0]) rotate([0, 90, 0])
292 cylinder(r=batt_diam/2, h=batt_len-2*eps);
294 for (x = [-1, 1]) scale([x, 1, 1]) hull () {
295 translate([batt_len/2+wall+cable_sep-clip_pretension, batt_diam/2-pcb_width+wall/2,
296 batt_diam/2+pcb_thick+pcb_comp_h-2*wall])
297 cube([wall+clip_pretension+eps, pcb_width-2*wall, wall]);
298 translate([batt_len/2+wall+cable_sep-eps, batt_diam/2-pcb_width+wall/2,
299 batt_diam/2+pcb_thick+pcb_comp_h-4*wall + lid_sep])
300 cube([eps, pcb_width-2*wall, eps]);
305 translate([-batt_len/2-cable_sep-wall, 0, 0]) rotate([0, 90, 0])
306 cylinder(r=batt_diam/2-wall-lid_sep, h=batt_len+2*wall+2*cable_sep);
307 translate([-infty/2, -batt_diam/2, -infty-wire_sep/2-wire_thick/2])
308 cube([infty, batt_diam, infty]);
310 translate([-batt_len/2-cable_sep-wall, batt_diam/2-pcb_width+0.5*wall+0.5*lid_sep, batt_diam/2 + pcb_comp_h+pcb_thick-wall-lid_sep])
311 cube([batt_len + 2*wall + 2* cable_sep, pcb_width-1.5*wall-1.5*lid_sep, eps]);
318 translate([0, 15, 0]) case();
319 translate([0, -15, 0]) rotate([180, 0, 0]) lid();
321 translate([0, 15, batt_diam/2+pcb_thick+pcb_comp_h+pcb_comp_h2+wall])
323 translate([0, -15, batt_diam/2+wall])