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
24 body_top_h = 0.35 * batt_diam; // cube-shaped part of the body
29 batt_end_h = wire_sep/2 + wire_thick/2 + 1.5;;
31 lid_sep = 0.2; // the lid is made this much smaller to separate from the body
35 sw_xoff = 250 * 25.4/1000; // x offset of microswitches
36 pcb_xoff = 90 * 25.4/1000; // offset of the LED from the middle of the PCB
38 prg_len = 10; // programming connector
44 // mounting cylinder + holes
47 mountcyl_w = mounthole_w + 4*wall;
49 mountcone_h = mounthole_h + 2*wall;
51 clip_pretension = 0.5;
55 translate([-batt_len/2-2*wall-cable_sep, -batt_diam/2-wall, 0])
56 cube([batt_len + 4*wall + 2*cable_sep,
57 batt_diam+2*wall, body_top_h]);
59 translate([-batt_len/2-2*wall-cable_sep, 0, 0])
61 cylinder(r=batt_diam/2+wall,
62 h = batt_len + 4*wall + 2*cable_sep);
63 translate([-infty/2, -infty/2, eps]) cube(infty);
65 translate([-front_flat_len/2,
66 batt_diam/2 - pcb_width,
67 -batt_diam/2-2*pcb_comp_h-pcb_thick-wall])
68 cube([front_flat_len, pcb_width+wall, eps]);
71 for (x = [-1, 1]) translate([x*(batt_len/2-mounthole_w/2),
72 batt_diam/2+wall, 0]) {
73 translate([0, 0, -batt_diam/2-wall-2*pcb_comp_h-pcb_thick])
75 translate([0, 0, body_top_h]) // rear
82 assign(h = mounthole_h+wall)
84 translate([0, -mountcyl_w/2+mounthole_h + wall])
85 cylinder(r = mountcyl_w/2, h = mountcyl_h);
86 assign(l = 2*sqrt(h*(mountcyl_w-h)))
87 translate([-l/2, 0, mountcyl_h + mountcone_h])
95 // upper cube-shaped part
97 translate([-batt_len/2, -batt_diam/2, 0])
98 cube([batt_len, batt_diam, batt_diam]);
100 // battery cylinder for the lower part
101 translate([-batt_len/2, 0, 0])
103 cylinder(r=batt_diam/2, h = batt_len);
106 translate([-pcb_len/2-pcb_xoff,
107 batt_diam/2-pcb_width,
108 -batt_diam/2-pcb_thick - pcb_comp_h])
109 cube([pcb_len, pcb_width,
110 batt_diam/2 + pcb_thick + pcb_comp_h + eps]);
111 // hole above the PCB for the outgoing cable
112 translate([-pcb_len/2-pcb_xoff-2*wall-outcable_w,
113 batt_diam/2-pcb_width,
114 -batt_diam/2-pcb_comp_h])
115 cube([pcb_len, pcb_width,
116 batt_diam/2 + pcb_comp_h + eps]);
118 translate([-pcb_xoff-pcb_len/2-wall-outcable_w,
119 -pcb_width+batt_diam/2,
120 -batt_diam/2-outcable_h])
121 cube([outcable_w, infty, outcable_h]);
122 // hole under the PCB
123 translate([-pcb_len/2+pcb_groove-pcb_xoff,
124 batt_diam/2-pcb_width + pcb_groove,
125 -batt_diam/2-pcb_thick - 2*pcb_comp_h])
126 cube([pcb_len-2*pcb_groove, pcb_width-2*pcb_groove,
127 batt_diam/2 + pcb_thick + pcb_comp_h + eps]);
128 // hole for prog connector
129 translate([pcb_len/2-pcb_xoff-pcb_groove-eps,
130 batt_diam/2-pcb_width/2-prg_width/2,
131 -batt_diam/2-pcb_thick - 2*pcb_comp_h])
133 cube([prg_len+pcb_groove+eps, prg_width,
134 batt_diam/2 + pcb_thick + pcb_comp_h + eps]);
135 translate([prg_len/2+pcb_groove, -eps, pcb_comp_h])
136 cube([prg_len/2+eps, prg_width+2*eps, pcb_thick]);
139 translate([0, batt_diam/2-pcb_width/2, -infty/2]) {
140 cylinder(r=led_diam/2, h=infty, $fn=6);
141 translate([sw_xoff, 0, 0])
142 cylinder(r=sw_diam/2, h=infty, $fn=6);
143 translate([-sw_xoff, 0, 0])
144 cylinder(r=sw_diam/2, h=infty, $fn=6);
146 // space under the wire holes for battery contacts
147 translate([-batt_len/2-2*wall-cable_sep-eps, 0, 0])
150 cylinder(r = batt_diam/2-wall, h = batt_len + 4*wall + 2*cable_sep + 2*eps);
151 translate([-infty/2, -infty/2, -batt_end_h])
154 // space above the wire holes for battery contacts
155 translate([-batt_len/2-2*wall-cable_sep-eps, -batt_diam/2, batt_end_h])
156 cube([batt_len + 4*wall + 2*cable_sep + 2*eps,
159 // wire holes for battery contacts
162 translate([-batt_len/2-wall-eps, x*wire_sep/2, y*wire_sep/2])
164 cylinder(r = wire_thick/2, h = batt_len + 2*wall + 2*eps, $fn=6);
165 // wire hole from PCB to battery contacts
166 // translate([-batt_len/2-wall-eps, 0, -batt_diam/2-pcb_comp_h + wire_thick/2])
168 translate([-batt_len/2-wall-eps, 0, -batt_diam/2 - wall/2 - wire_thick/2])
170 cylinder(r = wire_thick/2, h = batt_len + 2*wall + 2*eps, $fn=6);
171 // hole behind the battery contacts
173 scale([x, 1, 1]) translate([batt_len/2+wall, 0, 0]) hull() {
174 translate([0, -batt_diam/2, 0])
175 cube([wall + cable_sep + eps, batt_diam, infty]);
177 cylinder(r = batt_diam/2, h = wall+cable_sep+eps);
178 translate([0, batt_diam/2 - pcb_width,
179 -batt_diam/2-pcb_comp_h-pcb_thick])
180 cube([wall + cable_sep + eps, pcb_width, eps]);
181 translate([cable_sep, batt_diam/2 - pcb_width + wall,
182 -batt_diam/2-pcb_comp_h-pcb_thick-wall])
183 cube([wall + eps, pcb_width-2*wall, eps]);
185 // cable lead to battery contacts
186 for (x=[1, -1]) scale([x, 1, 1])
188 translate([batt_len/2+wire_thick/2, 0, batt_diam/2-2.7])
189 cylinder(r=wire_thick/2, h = 5.4);
192 for(x=[-1,1]) scale([x, 1, 1])
193 translate([batt_len/2-mounthole_w/2, batt_diam/2+wall+mounthole_h/2, -infty/2])
194 scale([1, mounthole_h/mounthole_w, 1])
195 cylinder(r = mounthole_w/2, h = infty);
198 for (x = [-1, 1]) scale([x, 1, 1]) hull () {
199 translate([batt_len/2+wall-eps, batt_diam/2-pcb_width+wall/2+lid_sep,
200 -batt_diam/2-pcb_thick-pcb_comp_h + wall + lid_sep])
201 cube([wall+eps, pcb_width-2*wall-2*lid_sep, wall]);
202 translate([batt_len/2+wall-eps, batt_diam/2-pcb_width+3*wall/2+lid_sep,
203 -batt_diam/2-pcb_thick-pcb_comp_h + 3*wall + lid_sep])
204 cube([eps, pcb_width-4*wall-2*lid_sep, eps]);
209 translate([-batt_len/2 - wall - lid_sep, -batt_diam/2+lid_sep, -batt_diam/2 -wall])
210 cube([batt_len + 2*wall + 2*lid_sep, batt_diam-2*lid_sep, batt_diam/2 - batt_end_h + wall - lid_sep]);
211 translate([-batt_len/2 - 2*wall - cable_sep, -batt_diam/2 - wall,
213 cube([batt_len + 4*wall + 2*cable_sep, batt_diam + 2*wall,
214 wall + batt_diam/2 - body_top_h - lid_sep]);
215 // clip behind the battery contacts
217 scale([x, 1, 1]) translate([batt_len/2+wall+lid_sep, 0, 0]) hull() {
218 translate([0, -batt_diam/2+lid_sep, -batt_diam/2])
219 cube([wall+cable_sep-lid_sep, batt_diam-2*lid_sep, eps]);
221 cylinder(r = batt_diam/2-lid_sep, h = wall+cable_sep-lid_sep);
222 translate([-clip_pretension, batt_diam/2 - pcb_width+lid_sep,
223 batt_diam/2+pcb_comp_h+pcb_thick-lid_sep])
224 cube([wall+cable_sep-lid_sep, pcb_width-2*lid_sep, eps]);
225 translate([cable_sep+wall/2-clip_pretension, batt_diam/2 - pcb_width + 1.5*wall +lid_sep,
226 batt_diam/2+pcb_comp_h+pcb_thick+wall/2-lid_sep])
227 cube([wall/2-lid_sep, pcb_width-2*wall-2*lid_sep, eps]);
229 translate([cable_sep+wall-lid_sep, 0, -batt_diam/2-wall]) difference() {
231 cylinder(r = batt_diam/2 - lid_sep, h = eps);
232 translate([-infty, -infty/2, -infty/2]) cube(infty);
240 translate([-batt_len/2+eps, 0, 0]) rotate([0, 90, 0])
241 cylinder(r=batt_diam/2, h=batt_len-2*eps);
244 translate([-batt_len/2-cable_sep-wall, 0, 0]) rotate([0, 90, 0])
245 cylinder(r=batt_diam/2-wall-lid_sep, h=batt_len+2*wall+2*cable_sep);
246 translate([-infty/2, -batt_diam/2, -infty-wire_sep/2-wire_thick/2])
247 cube([infty, batt_diam, infty]);
249 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])
250 cube([batt_len + 2*wall + 2* cable_sep, pcb_width-1.5*wall-1.5*lid_sep, eps]);
256 translate([0, 15, 0]) case();
257 translate([0, -15, 0]) rotate([180, 0, 0]) lid();
259 translate([0, 15, batt_diam/2+pcb_thick+2*pcb_comp_h+wall])
261 translate([0, -15, batt_diam/2+wall])