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_end_h = body_top_h - 4*clip_cyl_r;;
62 translate([-batt_len/2-2*wall-cable_sep, -batt_diam/2-wall, 0])
63 cube([batt_len + 4*wall + 2*cable_sep,
64 batt_diam+2*wall, body_top_h]);
66 translate([-batt_len/2-2*wall-cable_sep, 0, 0])
68 cylinder(r=batt_diam/2+wall,
69 h = batt_len + 4*wall + 2*cable_sep);
70 translate([-infty/2, -infty/2, eps]) cube(infty);
72 translate([-front_flat_len/2,
73 batt_diam/2 - pcb_width,
74 -batt_diam/2-pcb_comp_h-pcb_comp_h2-pcb_thick-wall])
75 cube([front_flat_len, pcb_width+wall, eps]);
78 for (x = [-1, 1]) translate([x*(batt_len/2-mounthole_w/2),
79 batt_diam/2+wall, 0]) {
80 translate([0, 0, -batt_diam/2-wall-pcb_comp_h-pcb_comp_h2-pcb_thick])
82 translate([0, 0, body_top_h]) // rear
89 assign(h = mounthole_h+wall)
91 translate([0, -mountcyl_w/2+mounthole_h + wall])
92 cylinder(r = mountcyl_w/2, h = mountcyl_h);
93 assign(l = 2*sqrt(h*(mountcyl_w-h)))
94 translate([-l/2, 0, mountcyl_h + mountcone_h])
102 // upper cube-shaped part
103 // rotate([20, 0, 0])
104 translate([-batt_len/2, -batt_diam/2, 0])
105 cube([batt_len, batt_diam, batt_diam]);
106 // upper longer cube-shaped part
108 translate([-batt_len/2-cable_sep-wall, -batt_diam/2, batt_end_h])
109 cube([batt_len+2*cable_sep+2*wall, batt_diam, batt_diam]);
110 for (x = [-1,1]) scale([x, 1, 1])
111 translate([batt_len/2 + wall + cable_sep, -infty/2, batt_end_h + 3*clip_cyl_r])
113 cylinder(r = clip_cyl_r, h = infty, $fn=4);
116 for (x=[-1,1]) scale([x,1,1])
117 translate([batt_len/2 + 2*wall + cable_sep+10-wall, 0, 0])
118 cylinder(r1 = 7, r2 = 10-wall/4, h = body_top_h + eps);
119 // battery cylinder for the lower part
120 translate([-batt_len/2, 0, 0])
122 cylinder(r=batt_diam/2, h = batt_len);
125 translate([-pcb_len/2-pcb_xoff,
126 batt_diam/2-pcb_width,
127 -batt_diam/2-pcb_thick - pcb_comp_h])
128 cube([pcb_len, pcb_width,
129 batt_diam/2 + pcb_thick + pcb_comp_h + eps]);
130 // hole above the PCB for the outgoing cable
131 translate([-pcb_len/2-pcb_xoff-2*wall-outcable_w,
132 batt_diam/2-pcb_width,
133 -batt_diam/2-pcb_comp_h])
134 cube([pcb_len, pcb_width,
135 batt_diam/2 + pcb_comp_h + eps]);
137 translate([-pcb_xoff-pcb_len/2-wall-outcable_w,
138 -pcb_width+batt_diam/2,
139 -batt_diam/2-outcable_h])
140 cube([outcable_w, infty, outcable_h]);
141 // hole under the PCB (groove)
142 translate([-pcb_len/2+pcb_groove-pcb_xoff,
143 batt_diam/2-pcb_width + pcb_groove,
144 -batt_diam/2-pcb_thick - pcb_comp_h - pcb_comp_h2])
145 cube([pcb_len-2*pcb_groove, pcb_width-2*pcb_groove,
146 batt_diam/2 + pcb_thick + pcb_comp_h2 + eps]);
147 // hole under the PCB (pcb-width)
148 translate([-pcb_len/2+2*pcb_groove-pcb_xoff,
149 batt_diam/2-pcb_width,
150 -batt_diam/2-pcb_thick - pcb_comp_h - pcb_comp_h2])
151 cube([pcb_len-4*pcb_groove, pcb_width,
152 batt_diam/2 + pcb_thick + pcb_comp_h2 + eps]);
153 // hole for prog connector
154 translate([pcb_len/2-pcb_xoff-pcb_groove-eps,
155 batt_diam/2-pcb_width/2-prg_width/2,
156 -batt_diam/2-pcb_thick - pcb_comp_h - pcb_comp_h2])
158 cube([prg_len+pcb_groove+eps, prg_width,
159 batt_diam/2 + pcb_thick + pcb_comp_h + eps]);
160 translate([prg_len/2+pcb_groove, -eps, pcb_comp_h2])
161 cube([prg_len/2+eps, prg_width+2*eps, pcb_thick]);
163 // LED and button holes
164 translate([0, batt_diam/2-pcb_width/2, -infty/2]) {
165 cylinder(r=led_diam/2, h=infty, $fn=6);
166 translate([sw_xoff, 0, 0])
167 cylinder(r=sw_diam/2, h=infty, $fn=6);
168 translate([-sw_xoff, 0, 0])
169 cylinder(r=sw_diam/2, h=infty, $fn=6);
171 // wire hole from PCB to battery contacts
173 translate([-batt_len/2-wall-cable_sep, 0, -wire_thick/2-wall/2])
174 cube([batt_len + 2*wall + 2* cable_sep, batt_diam/2 + wire_thick + wall, wire_thick]);
176 for(x=[-1,1]) scale([x, 1, 1])
177 translate([batt_len/2-mounthole_w/2, batt_diam/2+wall+mounthole_h/2, -infty/2])
178 scale([1, mounthole_h/mounthole_w, 1])
179 cylinder(r = mounthole_w/2, h = infty);
180 // holes in front of battery contacts
181 for(x=[-1,1]) scale([x, 1, 1])
182 translate([batt_len/2-eps, wall/2-batt_contact_w/2,
183 wall/2-batt_contact_w/2])
184 cube([wall+2*eps, batt_contact_w-wall, infty]);
185 // holes for battery contacts
186 for(x=[-1,1]) scale([x, 1, 1])
187 translate([batt_len/2+wall-eps, -batt_contact_w/2,
189 cube([cable_sep+2*eps, batt_contact_w, infty]);
190 // internal plus sign - vertical line
191 translate([-batt_len/2 + 0.5*wall+plus_width/2, -plus_width/2, -batt_diam/2-wall])
192 cube([wall, plus_width, infty]);
193 // internal plus and minus signs - horizontal line
194 for(x=[-1,1]) scale([x, 1, 1])
195 translate([batt_len/2 - wall - plus_width, -wall/2, -batt_diam/2-wall])
196 cube([plus_width, wall, infty]);
199 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])
200 cube([wall, plus_width, wall/2]);
201 // button +/- label - horizontal line
202 for (x=[-1, 1]) scale([x, 1, 1])
203 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])
204 cube([plus_width, wall, wall/2]);
211 // smaller outermost part
212 translate([-batt_len/2 - wall - cable_sep, -batt_diam/2, -batt_diam/2 - wall])
213 cube([batt_len + 2*wall + 2*cable_sep, batt_diam, eps]);
214 // this part goes above the main body
215 translate([-batt_len/2 - 2*wall - cable_sep, -batt_diam/2-wall, -body_top_h - lid_sep])
216 cube([batt_len + 4*wall + 2*cable_sep, batt_diam+2*wall, eps]);
218 // the part which goes inside the main body
219 translate([-batt_len/2 - wall - cable_sep + lid_sep, -batt_diam/2+lid_sep, -batt_diam/2 -wall])
220 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]);
222 for (x = [-1, 1]) scale([x, 1, 1])
223 translate([batt_len/2 + wall + cable_sep - lid_sep, batt_diam/2 - lid_sep, -batt_end_h-lid_sep-clip_cyl_r])
225 cylinder(r = clip_cyl_r, h = batt_diam-2*lid_sep, $fn = 4);
231 translate([-batt_len/2-lid_sep, 0, 0]) rotate([0, 90, 0])
232 cylinder(r=batt_diam/2 + lid_sep, h=batt_len+2*lid_sep);
237 translate([0, 15, 0]) case();
238 translate([0, -15, 0]) rotate([180, 0, 0]) lid();
240 translate([0, 15, batt_diam/2+pcb_thick+pcb_comp_h+pcb_comp_h2+wall])
242 translate([0, -15, batt_diam/2+wall])