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.38 * batt_diam; // cube-shaped part of the body
30 lid_sep = 0.2; // the lid is made this much smaller to separate from the body
32 // sw_diam = 2.5 + 0.5;
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;
53 plus_width = 4.5; // width of the + sign
57 batt_contact_h_lid = batt_contact_h-2;
59 batt_end_h = body_top_h - 4*clip_cyl_r;;
64 translate([-batt_len/2-2*wall-cable_sep, -batt_diam/2-wall, 0])
65 cube([batt_len + 4*wall + 2*cable_sep,
66 batt_diam+2*wall, body_top_h]);
68 translate([-batt_len/2-2*wall-cable_sep, 0, 0])
70 cylinder(r=batt_diam/2+wall,
71 h = batt_len + 4*wall + 2*cable_sep);
72 translate([-infty/2, -infty/2, eps]) cube(infty);
74 translate([-front_flat_len/2,
75 batt_diam/2 - pcb_width-0.5*wall,
76 -batt_diam/2-pcb_comp_h-pcb_comp_h2-pcb_thick-wall])
77 cube([front_flat_len, pcb_width+1.5*wall, eps]);
80 for (x = [-1, 1]) translate([x*(batt_len/2-mounthole_w/2),
81 batt_diam/2+wall, 0]) {
82 translate([0, 0, -batt_diam/2-wall-pcb_comp_h-pcb_comp_h2-pcb_thick])
84 translate([0, 0, body_top_h]) // rear
91 assign(h = mounthole_h+wall)
93 translate([0, -mountcyl_w/2+mounthole_h + wall])
94 cylinder(r = mountcyl_w/2, h = mountcyl_h);
95 assign(l = 2*sqrt(h*(mountcyl_w-h)))
96 translate([-l/2, 0, mountcyl_h + mountcone_h])
104 // upper cube-shaped part
105 // rotate([20, 0, 0])
106 translate([-batt_len/2, -batt_diam/2, 0])
107 cube([batt_len, batt_diam, batt_end_h+eps]);
108 // upper longer cube-shaped part
110 translate([-batt_len/2-cable_sep-wall, -batt_diam/2, batt_end_h])
111 cube([batt_len+2*cable_sep+2*wall, batt_diam, batt_diam]);
113 for (x = [-1,1]) scale([1, x, 1])
114 translate([batt_len/6, batt_diam/2, batt_end_h + 3*clip_cyl_r])
116 cylinder(r = clip_cyl_r, h = batt_len/3, $fn=4);
119 for (x=[-1,1]) scale([x,1,1])
120 translate([batt_len/2 + 2*wall + cable_sep+10-wall, 0, 0])
121 cylinder(r1 = 7, r2 = 10, h = body_top_h + eps);
122 // battery cylinder for the lower part
123 translate([-batt_len/2, 0, 0])
125 cylinder(r=batt_diam/2, h = batt_len);
128 translate([-pcb_len/2-pcb_xoff,
129 batt_diam/2-pcb_width,
130 -batt_diam/2-pcb_thick - pcb_comp_h])
131 cube([pcb_len, pcb_width,
132 batt_diam/2 + pcb_thick + pcb_comp_h + eps]);
133 // hole above the PCB for the outgoing cable
134 translate([-pcb_len/2-pcb_xoff-2*wall-outcable_w,
135 batt_diam/2-pcb_width,
136 -batt_diam/2-pcb_comp_h])
137 cube([pcb_len, pcb_width,
138 batt_diam/2 + pcb_comp_h + eps]);
140 translate([-pcb_xoff-pcb_len/2-wall-outcable_w,
141 -pcb_width+batt_diam/2,
142 -batt_diam/2-outcable_h])
143 cube([outcable_w, infty, outcable_h]);
144 // hole under the PCB (groove)
145 translate([-pcb_len/2+pcb_groove-pcb_xoff,
146 batt_diam/2-pcb_width + pcb_groove,
147 -batt_diam/2-pcb_thick - pcb_comp_h - pcb_comp_h2])
148 cube([pcb_len-2*pcb_groove, pcb_width-2*pcb_groove,
149 batt_diam/2 + pcb_thick + pcb_comp_h2 + eps]);
150 // hole under the PCB (pcb-width)
151 translate([-pcb_len/2+2*pcb_groove-pcb_xoff,
152 batt_diam/2-pcb_width,
153 -batt_diam/2-pcb_thick - pcb_comp_h - pcb_comp_h2])
154 cube([pcb_len-4*pcb_groove, pcb_width,
155 batt_diam/2 + pcb_thick + pcb_comp_h2 + eps]);
156 // hole for prog connector
157 translate([pcb_len/2-pcb_xoff-pcb_groove-eps,
158 batt_diam/2-pcb_width/2-prg_width/2,
159 -batt_diam/2-pcb_thick - pcb_comp_h - pcb_comp_h2])
161 cube([prg_len+pcb_groove+eps, prg_width,
162 batt_diam/2 + pcb_thick + pcb_comp_h + eps]);
163 translate([prg_len/2+pcb_groove, -eps, pcb_comp_h2])
164 cube([prg_len/2+eps, prg_width+2*eps, pcb_thick]);
166 // LED and button holes
167 translate([0, batt_diam/2-pcb_width/2, -infty/2]) {
168 cylinder(r=led_diam/2, h=infty, $fn=6);
169 translate([sw_xoff, 0, 0])
170 cylinder(r=sw_diam/2, h=infty, $fn=6);
171 translate([-sw_xoff, 0, 0])
172 cylinder(r=sw_diam/2, h=infty, $fn=6);
174 // wire hole from PCB to battery contacts
176 translate([-batt_len/2-wall-cable_sep, 0, -wire_thick/2-wall/2])
177 cube([batt_len + 2*wall + 2* cable_sep, batt_diam/2 + wire_thick + wall, wire_thick]);
179 for(x=[-1,1]) scale([x, 1, 1])
180 translate([batt_len/2-mounthole_w/2, batt_diam/2+wall+mounthole_h/2, -infty/2])
181 scale([1, mounthole_h/mounthole_w, 1])
182 cylinder(r = mounthole_w/2, h = infty);
183 // holes in front of battery contacts
184 for(x=[-1,1]) scale([x, 1, 1])
185 translate([batt_len/2-eps, wall/2-batt_contact_w/2,
186 wall/2-batt_contact_h/2])
187 cube([wall+2*eps, batt_contact_w-wall, infty]);
188 // holes for battery contacts
189 for(x=[-1,1]) scale([x, 1, 1])
190 translate([batt_len/2+wall-eps, -batt_contact_w/2,
192 cube([cable_sep+2*eps, batt_contact_w, infty]);
193 // internal plus sign - vertical line
194 translate([-batt_len/2 + 0.5*wall+plus_width/2, -plus_width/2, -batt_diam/2-wall])
195 cube([wall, plus_width, infty]);
196 // internal plus and minus signs - horizontal line
197 for(x=[-1,1]) scale([x, 1, 1])
198 translate([batt_len/2 - wall - plus_width, -wall/2, -batt_diam/2-wall])
199 cube([plus_width, wall, infty]);
202 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])
203 cube([wall, plus_width, wall/2]);
204 // button +/- label - horizontal line
205 for (x=[-1, 1]) scale([x, 1, 1])
206 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])
207 cube([plus_width, wall, wall/2]);
214 // smaller outermost part
215 translate([-batt_len/2 - wall - cable_sep, -batt_diam/2, -batt_diam/2 - wall])
216 cube([batt_len + 2*wall + 2*cable_sep, batt_diam, eps]);
217 // this part goes above the main body
218 translate([-batt_len/2 - 2*wall - cable_sep, -batt_diam/2-wall, -body_top_h - lid_sep])
219 cube([batt_len + 4*wall + 2*cable_sep, batt_diam+2*wall, eps]);
221 // the part which goes inside the main body
222 translate([-batt_len/2 - wall - cable_sep + lid_sep, -batt_diam/2+lid_sep, -batt_diam/2 -wall])
223 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]);
225 for (x = [-1, 1]) scale([1, x, 1])
226 translate([batt_len/6, batt_diam/2-lid_sep, - batt_end_h - clip_cyl_r - lid_sep])
228 cylinder(r = clip_cyl_r, h = batt_len/3, $fn=4);
229 // translate([batt_len/2 + wall + cable_sep - lid_sep, batt_diam/2 - lid_sep, -batt_end_h-lid_sep-clip_cyl_r])
235 translate([-batt_len/2-lid_sep, 0, 0]) rotate([0, 90, 0])
236 cylinder(r=batt_diam/2 + lid_sep, h=batt_len+2*lid_sep);
237 // holes for battery contacts
238 for(x=[-1,1]) scale([x, 1, 1])
239 translate([batt_len/2+wall-eps, -batt_contact_w/2,
240 -batt_contact_h_lid/2])
241 cube([cable_sep+2*eps, batt_contact_w, infty]);
246 translate([0, 15, 0]) case();
247 translate([0, -15, 0]) rotate([180, 0, 0]) lid();
249 translate([0, 15, batt_diam/2+pcb_thick+pcb_comp_h+pcb_comp_h2+wall])
251 translate([0, -15, batt_diam/2+wall])