3D printed Arduino Airsoft Chronograph
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. /*
  2. * Copyright (c) 2022 Thomas Buck <thomas@xythobuz.de>
  3. *
  4. * OpenChrono is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * OpenChrono is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with OpenChrono. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. outer_dia = 55;
  18. inner_dia = 8.5;
  19. height = 100;
  20. body_gap = 0.1;
  21. body_screw_off = 10;
  22. body_screw_pos = 20;
  23. body_screw_dia = 3.3;
  24. body_screw_head = 6.0;
  25. body_screw_depth = 3.2;
  26. body_screw_insert_dia = 4.8;
  27. body_screw_insert_height = 12.0;
  28. lcd_pcb_w = 29.0;
  29. lcd_pcb_h = 29.0;
  30. lcd_pcb_d = 5.2;
  31. lcd_hole_dia = 1.9;
  32. lcd_hole_w = 6.0;
  33. lcd_hole_h = 2.5;
  34. lcd_off = 10.0;
  35. lcd_hole_off_x = 23.1;
  36. lcd_hole_off_y = 23.65;
  37. lcd_hole_off_y_total = 0.4;
  38. lcd_hole_screw_len = 10.0;
  39. arduino_w = 19.0;
  40. arduino_h = 46.5 + 10;
  41. arduino_d = 10.0;
  42. bat_w = 11.5;
  43. bat_l = 45.5;
  44. bat_tab_w = 9.5;
  45. bat_tab_h = 8.5;
  46. bat_tab_d = 2.5; // TODO?
  47. bat_tab_con_w = 5.0; // TODO?
  48. bat_tab_con_h = 6.5; // TODO?
  49. bat_spring_w = 7.5; // TODO?
  50. bat_spring_dist = 7.5; // TODO?
  51. bat_wall = 1.0;
  52. bat_angle = 48;
  53. led_dia = 3.3;
  54. led_l = 4.5;
  55. led_off = 15;
  56. led_ridge_dia = 4.2;
  57. led_ridge_h = 1.6;
  58. switch_w = 12.0;
  59. switch_h = 6.5;
  60. switch_d = 10.0;
  61. switch_plate_w = 20.5;
  62. switch_plate_h = switch_h;
  63. switch_dia = 2.4;
  64. switch_screw_l = 10.0;
  65. switch_screw_d = 15.0;
  66. switch_off = 15;
  67. // 1911
  68. thread_profile_1911 = [
  69. true, // type is_male
  70. 12.0, // diameter
  71. 1.0, // pitch
  72. 0.0, // offset
  73. 9.0, // length
  74. 0.0, // offset dia
  75. 9.1, // inner hole
  76. true, // is cw thread
  77. ];
  78. // M14x1.0 CW female thread
  79. thread_profile_m14_cw = [
  80. false, // type is_male
  81. 14.0, // diameter
  82. 1.0, // pitch
  83. 0.0, // offset
  84. 12.0, // length
  85. 0.0, // offset dia
  86. 8.5, // inner hole
  87. true, // is cw thread
  88. ];
  89. // M14x1.0 CCW female thread
  90. thread_profile_m14_ccw = [
  91. false, // type is_male
  92. 14.0, // diameter
  93. 1.0, // pitch
  94. 0.0, // offset
  95. 12.0, // length
  96. 0.0, // offset dia
  97. 8.5, // inner hole
  98. false, // is cw thread
  99. ];
  100. // ASG / KWC Cobray Ingram M11 CO2 NBB 6mm
  101. thread_profile_mac11 = [
  102. false, // type is_male
  103. 16.5, // diameter
  104. 1.5, // pitch
  105. 9.0, // offset
  106. 10.0, // length
  107. 20.0, // offset dia
  108. 8.5, // inner hole
  109. true, // is cw thread
  110. ];
  111. thread_profile_giant = [
  112. false, // type is_male
  113. 34.0, // diameter
  114. 1.0, // pitch
  115. 0.0, // offset
  116. 10.0, // length
  117. 0.0, // offset dia
  118. 8.5, // inner hole
  119. true, // is cw thread
  120. ];
  121. thread_profiles = [
  122. thread_profile_1911,
  123. thread_profile_m14_cw,
  124. thread_profile_m14_ccw,
  125. thread_profile_mac11,
  126. thread_profile_giant
  127. ];
  128. thread_base = 5.0;
  129. test_bat_w = 47;
  130. test_bat_h = 59;
  131. test_bat_d = 15;
  132. test_bat_dia = 2.9;
  133. test_bat_off = 30.5;
  134. test_bat_l = 8;
  135. thread_adapter_screw_inset = 5;
  136. thread_adapter_in_body = 5;
  137. thread_adapter_h = body_screw_insert_height - thread_adapter_in_body;
  138. text1 = [
  139. "OpenChrono",
  140. "Liberation Sans:style=Bold",
  141. 12.0,
  142. 2.0,
  143. 55
  144. ];
  145. text2 = [
  146. "by xythobuz.de",
  147. "Liberation Sans:style=Bold",
  148. 9.0,
  149. 2.0,
  150. -60
  151. ];
  152. text3 = [
  153. "OpenChrono",
  154. "Liberation Sans:style=Bold",
  155. 12.0 - 4,
  156. 1.0,
  157. 70
  158. ];
  159. text4 = [
  160. "by xythobuz.de",
  161. "Liberation Sans:style=Bold",
  162. 9.0 - 2,
  163. 1.0,
  164. -70
  165. ];
  166. texts_left = [ text1, text2 ];
  167. texts_lipo = [ text3, text4 ];
  168. lipo_lid_height = 65;
  169. lipo_lid_width = 80;
  170. lipo_lid_d = 3.0;
  171. lipo_lid_gap = 0.5;
  172. lipo_lid_gap_d = 0.2;
  173. lipo_lid_screw_d_small = 2.8;
  174. lipo_lid_screw_d_big = 3.3;
  175. lipo_lid_screw_area = 10;
  176. lipo_lid_screw_len = 10.0;
  177. lipo_lid_screw_off = 5.0;
  178. lipo_lid_compartment_d = 15.0;
  179. lipo_lid_compartment_w = lipo_lid_width - 2 * lipo_lid_screw_area - 5;
  180. lipo_pcb_w = 18.0;
  181. lipo_pcb_h = 29.0;
  182. lipo_pcb_d = 5.0;
  183. lipo_pcb_usb_w = 9.0;
  184. lipo_pcb_usb_h = 3.6;
  185. lipo_pcb_usb_off = 1.4;
  186. lipo_pcb_usb_wall = 1.5;
  187. lipo_pcb_led_dia = 2.0;
  188. lipo_pcb_led_dist = 5.0;
  189. lipo_pcb_led_off_x = 1.75;
  190. lipo_pcb_led_off_z = 7.0;
  191. lipo_w = 30.0;
  192. lipo_h = 43.0;
  193. lipo_d = 9.0;
  194. enable_gap_support = true;
  195. include_uv_leds = true;
  196. lipo_lid_angle = circum_angle(lipo_lid_width - lipo_lid_gap * 2, outer_dia);
  197. lipo_lid_angle_hole = circum_angle(lipo_lid_width, outer_dia);
  198. lipo_lid_angle_compartment = circum_angle(lipo_lid_compartment_w, outer_dia);
  199. bat_h = bat_l + bat_spring_dist + 2 * bat_wall + 2 * bat_tab_d;
  200. $fn = 42;
  201. echo("sensor_distance", height - 2 * led_off);
  202. if (include_uv_leds)
  203. echo("uv_led_distance", led_off / 2);
  204. // https://dkprojects.net/openscad-threads/
  205. include <extern/threads.scad>
  206. // how deep things on the outside have to be set in
  207. function circle_offset_deviation(off, dia) =
  208. dia * (1 - sin(acos(off * 2 / dia))) / 2;
  209. // circumference to angle
  210. function circum_angle(width, dia) = width / dia * 180 / 3.141;
  211. // from https://3dprinting.stackexchange.com/questions/10638/creating-pie-slice-in-openscad
  212. module pie_slice(r, a) {
  213. intersection() {
  214. circle(r = r);
  215. square(r);
  216. rotate(a - 90)
  217. square(r);
  218. }
  219. }
  220. module lcd_cutout() {
  221. difference() {
  222. cube([lcd_pcb_w, lcd_pcb_h, lcd_pcb_d + 10]);
  223. for (x = [0, lcd_pcb_w - lcd_hole_w])
  224. for (y = [0, lcd_pcb_h - lcd_hole_w])
  225. translate([x, y, -1])
  226. cube([lcd_hole_w, lcd_hole_w, lcd_hole_h + 1]);
  227. // TODO hacky
  228. if (enable_gap_support)
  229. translate([0, (lcd_pcb_w - 1) / 2, 1])
  230. cube([lcd_pcb_w, 1, 8]);
  231. }
  232. for (x = [0, lcd_hole_off_x])
  233. for (y = [0, lcd_hole_off_y])
  234. translate([x + lcd_hole_w / 2, y + lcd_hole_w / 2 - lcd_hole_off_y_total, lcd_hole_h - lcd_hole_screw_len])
  235. cylinder(d = lcd_hole_dia, h = lcd_hole_screw_len + 1);
  236. }
  237. module arduino_cutout() {
  238. cube([arduino_w, arduino_h, arduino_d]);
  239. }
  240. module bat_cutout() {
  241. // battery
  242. translate([0, 0, bat_tab_d + bat_wall])
  243. cube([bat_w, bat_w, bat_l + bat_spring_dist]);
  244. // negative terminal
  245. for (z = [0, bat_l + bat_spring_dist + 2 * bat_wall + bat_tab_d])
  246. translate([(bat_w - bat_tab_w) / 2, (bat_w - bat_tab_h) / 2, z])
  247. cube([bat_tab_w, bat_tab_h + (bat_w - bat_tab_h) / 2, bat_tab_d]);
  248. // spring
  249. for (z = [bat_tab_d, bat_l + bat_spring_dist + bat_wall + bat_tab_d])
  250. translate([(bat_w - bat_spring_w) / 2, (bat_w - bat_spring_w) / 2, z - 0.1])
  251. cube([bat_spring_w, bat_spring_w + (bat_w - bat_spring_w) / 2, bat_wall + 0.2]);
  252. }
  253. module switch_cutout() {
  254. translate([-switch_w / 2, -10, -switch_h / 2])
  255. cube([switch_w, switch_d + 10, switch_h]);
  256. translate([-switch_plate_w / 2, -switch_d, -switch_plate_h / 2])
  257. cube([switch_plate_w, 10, switch_plate_h]);
  258. for (x = [1, -1])
  259. scale([x, 1, 1])
  260. translate([-switch_screw_d / 2, -10, 0])
  261. rotate([-90, 0, 0])
  262. cylinder(d = switch_dia, h = switch_screw_l + 10);
  263. }
  264. module thread(profile, thread_draw) {
  265. if (profile[0]) {
  266. // male thread
  267. difference() {
  268. union() {
  269. cylinder(d = outer_dia, h = thread_base + body_screw_depth);
  270. scale([1, profile[7] ? 1 : -1, 1])
  271. metric_thread(profile[1], profile[2], profile[4] + thread_base + body_screw_depth, test=!thread_draw);
  272. }
  273. translate([0, 0, -1])
  274. cylinder(d = profile[6], h = profile[4] + thread_base + body_screw_depth + 2);
  275. }
  276. } else {
  277. // female thread
  278. difference() {
  279. cylinder(d = outer_dia, h = thread_base + body_screw_depth + profile[4] + profile[3]);
  280. translate([0, 0, -1])
  281. scale([1, profile[7] ? 1 : -1, 1])
  282. metric_thread(profile[1], profile[2], profile[4] + thread_base + body_screw_depth + 2, true, test=!thread_draw);
  283. translate([0, 0, thread_base + body_screw_depth + profile[4]])
  284. cylinder(d = profile[5], h = profile[3] + 1);
  285. translate([0, 0, -1])
  286. cylinder(d = profile[6], h = profile[4] + thread_base + profile[3] + 2);
  287. }
  288. }
  289. }
  290. module thread_profile_adapter(profile, draw_profile) {
  291. difference() {
  292. thread(profile, draw_profile);
  293. for (r = [45, -45])
  294. for (r2 = [0, 180])
  295. rotate([0, 0, r + r2])
  296. translate([0, (outer_dia - body_screw_insert_dia) / 2 - thread_adapter_screw_inset, 0]) {
  297. translate([0, 0, -1])
  298. cylinder(d = body_screw_dia, h = 50);
  299. translate([0, 0, thread_base])
  300. cylinder(d = body_screw_head, h = 50);
  301. }
  302. }
  303. }
  304. module mac11_extender() {
  305. difference() {
  306. cylinder(d = outer_dia, h = 15);
  307. translate([0, 0, -1])
  308. cylinder(d = 20, h = 15 + 2);
  309. for (r = [45, -45])
  310. for (r2 = [0, 180])
  311. rotate([0, 0, r + r2])
  312. translate([0, (outer_dia - body_screw_insert_dia) / 2 - thread_adapter_screw_inset, 0]) {
  313. translate([0, 0, -1])
  314. cylinder(d = body_screw_dia, h = 50);
  315. }
  316. }
  317. }
  318. module thread_adapter() {
  319. difference() {
  320. cylinder(d = outer_dia, h = thread_adapter_h);
  321. translate([0, 0, -1])
  322. cylinder(d = inner_dia, h = thread_adapter_h + 2);
  323. for (r = [45, -45])
  324. rotate([0, 0, r])
  325. translate([0, (outer_dia - body_screw_insert_dia) / 2 - thread_adapter_screw_inset, -thread_adapter_in_body])
  326. cylinder(d = body_screw_insert_dia, h = body_screw_insert_height + 1);
  327. }
  328. }
  329. module half_body(right_side) {
  330. difference() {
  331. union() {
  332. // body
  333. cylinder(d = outer_dia, h = height);
  334. translate([0, 0, height])
  335. thread_adapter();
  336. }
  337. // inner tube
  338. translate([0, 0, -1])
  339. cylinder(d = inner_dia, h = height + 2);
  340. // remove half of cylinder
  341. translate([-outer_dia / 2 - 1, -outer_dia + body_gap / 2, -1])
  342. cube([outer_dia + 2, outer_dia, height + 2]);
  343. // led cutouts
  344. for (x = [1, -1])
  345. scale([x, 1, 1])
  346. for (z = [led_off, height - led_off])
  347. translate([inner_dia / 2 - 1, 0, z])
  348. rotate([0, 90, 0]) {
  349. cylinder(d = led_dia, h = led_l + led_ridge_h + 1);
  350. translate([0, 0, led_l + 1])
  351. cylinder(d = led_ridge_dia, h = led_ridge_h);
  352. }
  353. if (include_uv_leds)
  354. for (x = [1, -1])
  355. scale([x, 1, 1])
  356. translate([inner_dia / 2 - 1, 0, led_off / 2])
  357. rotate([0, 90, 0]) {
  358. cylinder(d = led_dia, h = led_l + led_ridge_h + 1);
  359. translate([0, 0, led_l + 1])
  360. cylinder(d = led_ridge_dia, h = led_ridge_h);
  361. }
  362. // TODO hacky sensor cable, arduino side
  363. for (z = [1, -1])
  364. translate([0, 0, height / 2])
  365. scale([right_side ? -1 : 1, 1, z])
  366. translate([0, 0, height / 2 - led_off])
  367. hull() {
  368. for (x = [0, 5])
  369. translate([-inner_dia / 2 - led_l - led_ridge_h - x, 0, 0])
  370. rotate([0, 90, 0])
  371. cylinder(d = led_ridge_dia, h = led_ridge_h);
  372. translate([-inner_dia / 2 - led_l - led_ridge_h - 5, 0, -10])
  373. cylinder(d = led_ridge_dia, h = led_ridge_h);
  374. if (include_uv_leds)
  375. if (z < 0)
  376. for (x = [0, 5])
  377. translate([-inner_dia / 2 - led_l - led_ridge_h - x, 0, led_off / 2])
  378. rotate([0, 90, 0])
  379. cylinder(d = led_ridge_dia, h = led_ridge_h);
  380. }
  381. // TODO hacky led cable, led side
  382. for (z = [1, -1])
  383. translate([0, 0, height / 2])
  384. scale([right_side ? 1 : -1, 1, z])
  385. translate([0, 0, height / 2 - led_off])
  386. hull() {
  387. for (x = [0, 5])
  388. translate([-inner_dia / 2 - led_l - led_ridge_h - x, 0, 0])
  389. rotate([0, 90, 0])
  390. cylinder(d = led_ridge_dia, h = led_ridge_h);
  391. translate([-inner_dia / 2 - led_l - led_ridge_h - 5, 0, -height / 2 + led_off - 1])
  392. cube([led_ridge_dia + 2, led_ridge_dia - 2, led_ridge_h]);
  393. if (include_uv_leds)
  394. if (z < 0)
  395. for (x = [0, 5])
  396. translate([-inner_dia / 2 - led_l - led_ridge_h - x, 0, led_off / 2])
  397. rotate([0, 90, 0])
  398. cylinder(d = led_ridge_dia, h = led_ridge_h);
  399. }
  400. }
  401. }
  402. module screw_holes(with_head) {
  403. for (x = [body_screw_pos, -body_screw_pos])
  404. for (z = [body_screw_off, height - body_screw_off])
  405. translate([x, 0, z])
  406. rotate([-90, 0, 0]) {
  407. translate([0, 0, -1])
  408. if (with_head)
  409. cylinder(d = body_screw_dia, h = outer_dia / 2 + 2);
  410. else
  411. cylinder(d = body_screw_insert_dia, h = body_screw_insert_height);
  412. if (with_head)
  413. translate([0, 0, outer_dia / 2 - circle_offset_deviation(body_screw_pos + body_screw_head / 2, outer_dia) - body_screw_depth - 2])
  414. cylinder(d = body_screw_head, h = 50);
  415. }
  416. }
  417. module left_half() {
  418. difference() {
  419. half_body(false);
  420. translate([-outer_dia / 2 - 1, -outer_dia / 2 - 1 + body_gap / 2, height - 1])
  421. cube([outer_dia + 2, outer_dia / 2 + 1, 50]);
  422. screw_holes(false);
  423. translate([0, outer_dia / 2 - circle_offset_deviation(lcd_pcb_h / 2, outer_dia) - lcd_pcb_d, height / 2 + lcd_off])
  424. rotate([0, 90, 0])
  425. translate([lcd_pcb_w / 2, 0, -lcd_pcb_h / 2])
  426. rotate([90, 0, 180])
  427. lcd_cutout();
  428. translate([-outer_dia / 2 + ((outer_dia / 2) - (inner_dia / 2) - arduino_w) / 2, arduino_d / 2, -arduino_h / 2 + height / 2])
  429. rotate([90, 0, 0])
  430. arduino_cutout();
  431. translate([0, outer_dia / 2 - circle_offset_deviation(switch_plate_w / 2, outer_dia), height / 2 - switch_off])
  432. rotate([0, 0, 180])
  433. switch_cutout();
  434. // TODO hacky switch cable
  435. translate([-16, -10, height / 2 - switch_off])
  436. rotate([-90, 0, -27])
  437. cylinder(d = switch_h - 2, h = outer_dia);
  438. // TODO hacky lcd cable
  439. translate([-15, -10, 60])
  440. rotate([-90, 0, -12])
  441. cylinder(d = 6.0, h = outer_dia);
  442. // TODO hacky led cable
  443. translate([0, 0, height / 2 + 3]) {
  444. translate([inner_dia / 2 + led_l + led_ridge_dia / 2, led_ridge_h + inner_dia / 2 + 2, 0])
  445. rotate([90, 0, 0])
  446. cylinder(d = led_ridge_dia, h = led_ridge_h + inner_dia / 2 + 2);
  447. hull() {
  448. translate([inner_dia / 2 + led_l + led_ridge_dia / 2, led_ridge_h + inner_dia / 2 + 2, 0])
  449. rotate([90, 0, 0])
  450. cylinder(d = led_ridge_dia, h = led_ridge_h);
  451. translate([inner_dia / 2 + led_l + led_ridge_dia / 2 - 5, led_ridge_h + inner_dia / 2 + 2, 0])
  452. rotate([0, 90, 0])
  453. cylinder(d = led_ridge_dia, h = led_ridge_h + 5);
  454. }
  455. translate([inner_dia / 2 + led_l + led_ridge_dia / 2 - 25, led_ridge_h + inner_dia / 2 + 2, 0])
  456. rotate([0, 90, 0])
  457. cylinder(d = led_ridge_dia, h = led_ridge_h + 25);
  458. hull() {
  459. translate([inner_dia / 2 + led_l + led_ridge_dia / 2 - 25, led_ridge_h + inner_dia / 2 + 2, 0])
  460. rotate([90, 0, 0])
  461. cylinder(d = led_ridge_dia, h = led_ridge_h + 10);
  462. translate([inner_dia / 2 + led_l + led_ridge_dia / 2 - 25, led_ridge_h + inner_dia / 2 + 2, 0])
  463. rotate([0, 90, 0])
  464. cylinder(d = led_ridge_dia, h = led_ridge_h);
  465. }
  466. }
  467. for (t = texts_left)
  468. rotate([0, 0, -t[4]])
  469. translate([0, outer_dia / 2 - t[3], (height + thread_adapter_h) / 2])
  470. rotate([0, -90, -90])
  471. linear_extrude(height = t[3] + 1)
  472. text(t[0], size = t[2], font = t[1], halign = "center", valign="center");
  473. }
  474. }
  475. module right_half() {
  476. difference() {
  477. half_body(true);
  478. translate([-outer_dia / 2 - 1, -outer_dia / 2 - 1 + body_gap / 2, height - 1])
  479. cube([outer_dia + 2, outer_dia / 2 + 1, 50]);
  480. screw_holes(true);
  481. translate([outer_dia / 2 - arduino_w -((outer_dia / 2) - (inner_dia / 2) - arduino_w) / 2, arduino_d / 2, -arduino_h / 2 + height / 2])
  482. rotate([90, 0, 0])
  483. arduino_cutout();
  484. }
  485. }
  486. module right_half_aaa_bat() {
  487. difference() {
  488. right_half();
  489. for (a = [0, bat_angle, -bat_angle])
  490. rotate([0, 0, a])
  491. translate([-bat_w / 2, outer_dia / 2 - bat_w, (height - bat_h) / 2])
  492. bat_cutout();
  493. }
  494. }
  495. module right_halt_aa_bat() {
  496. difference() {
  497. right_half();
  498. difference() {
  499. translate([-test_bat_w / 2, outer_dia / 2 - circle_offset_deviation(test_bat_w / 2, outer_dia), (height - test_bat_h) / 2])
  500. cube([test_bat_w, test_bat_d + 1, test_bat_h]);
  501. // TODO hacky
  502. if (enable_gap_support)
  503. translate([-0.5, 14 + 1, 20])
  504. cube([1, 12, test_bat_h + 2]);
  505. }
  506. for (x = [test_bat_off / 2, -test_bat_off / 2])
  507. translate([x, outer_dia / 2 - circle_offset_deviation(test_bat_w / 2, outer_dia) - test_bat_l, height / 2])
  508. rotate([-90, 0, 0])
  509. cylinder(d = test_bat_dia, h = outer_dia / 2);
  510. // TODO hacky power cable
  511. translate([15, -10, 60])
  512. rotate([-90, 0, 12])
  513. cylinder(d = 6.0, h = outer_dia);
  514. }
  515. }
  516. module lipo_pcb_cutout() {
  517. translate([-lipo_pcb_w / 2, 0, lipo_pcb_usb_wall])
  518. cube([lipo_pcb_w, lipo_pcb_d, lipo_pcb_h]);
  519. translate([-lipo_pcb_usb_w / 2, lipo_pcb_usb_off, -1])
  520. cube([lipo_pcb_usb_w, lipo_pcb_usb_h, lipo_pcb_usb_wall + 2]);
  521. for (z = [0, lipo_pcb_led_off_z])
  522. translate([lipo_pcb_w / 2 - lipo_pcb_led_off_x, 0, lipo_pcb_usb_wall + lipo_pcb_led_off_z + z])
  523. rotate([-90, 0, 0])
  524. cylinder(d = lipo_pcb_led_dia, h = 42);
  525. }
  526. module lipo_lid() {
  527. difference() {
  528. rotate([0, 0, 90 - lipo_lid_angle / 2])
  529. linear_extrude(lipo_lid_height - lipo_lid_gap * 2)
  530. difference() {
  531. pie_slice(outer_dia / 2, lipo_lid_angle);
  532. pie_slice(outer_dia / 2 - lipo_lid_d + lipo_lid_gap_d, lipo_lid_angle);
  533. }
  534. // screw holes
  535. for (z = [0, lipo_lid_height - 2 * lipo_lid_screw_off])
  536. for (r = [1, -1])
  537. rotate([0, 0, r * (lipo_lid_angle / 2 - circum_angle(lipo_lid_screw_area / 2, outer_dia))])
  538. translate([0, outer_dia / 2 + 1, lipo_lid_screw_off - lipo_lid_gap + z])
  539. rotate([90, 0, 0])
  540. cylinder(d = lipo_lid_screw_d_big, h = lipo_lid_d + 2);
  541. }
  542. }
  543. module right_half_lipo() {
  544. difference() {
  545. right_half();
  546. // space for lid
  547. translate([0, 0, (height - lipo_lid_height) / 2])
  548. rotate([0, 0, 90 - lipo_lid_angle_hole / 2])
  549. linear_extrude(lipo_lid_height)
  550. difference() {
  551. pie_slice(outer_dia / 2 + 1, lipo_lid_angle_hole);
  552. pie_slice(outer_dia / 2 - lipo_lid_d, lipo_lid_angle_hole);
  553. }
  554. // compartment behind lid
  555. translate([0, 0, (height - lipo_lid_height) / 2])
  556. rotate([0, 0, 90 - lipo_lid_angle_compartment / 2])
  557. linear_extrude(lipo_lid_height)
  558. difference() {
  559. pie_slice(outer_dia / 2 - lipo_lid_d + 1, lipo_lid_angle_compartment);
  560. pie_slice(outer_dia / 2 - lipo_lid_d - lipo_lid_compartment_d, lipo_lid_angle_compartment);
  561. }
  562. // screw holes
  563. for (z = [0, lipo_lid_height - 2 * lipo_lid_screw_off])
  564. for (r = [1, -1])
  565. rotate([0, 0, r * (lipo_lid_angle / 2 - circum_angle(lipo_lid_screw_area / 2, outer_dia))])
  566. translate([0, outer_dia / 2, (height - lipo_lid_height) / 2 + lipo_lid_screw_off + z])
  567. rotate([90, 0, 0])
  568. cylinder(d = lipo_lid_screw_d_small, h = lipo_lid_d + lipo_lid_screw_len);
  569. // charging pcb
  570. translate([0, outer_dia / 2 - 11, 0]) {
  571. lipo_pcb_cutout();
  572. %translate([-(lipo_pcb_w - 1) / 2, 0.5, lipo_pcb_usb_wall])
  573. cube([lipo_pcb_w - 1, lipo_pcb_d - 1, lipo_pcb_h + 1]);
  574. }
  575. translate([-lipo_w / 2, outer_dia / 2 - lipo_lid_d - lipo_d - circle_offset_deviation(lipo_w / 2, outer_dia - (lipo_lid_d * 2)) - 1, 32]) {
  576. cube([lipo_w, lipo_d + 20, lipo_h]);
  577. %cube([lipo_w, lipo_d, lipo_h]);
  578. }
  579. // TODO hacky power cable
  580. translate([15, -10, 27])
  581. rotate([-90, 0, 15])
  582. cylinder(d = 6.0, h = outer_dia);
  583. for (t = texts_lipo)
  584. rotate([0, 0, -t[4]])
  585. translate([0, outer_dia / 2 - t[3], (height + thread_adapter_h) / 2])
  586. rotate([0, -90, -90])
  587. linear_extrude(height = t[3] + 1)
  588. text(t[0], size = t[2], font = t[1], halign = "center", valign="center");
  589. }
  590. // TODO hacky
  591. if (enable_gap_support) {
  592. translate([-0.5, 10, 17.5])
  593. cube([1, 17, lipo_lid_height + 1]);
  594. for (x = [-12, 11])
  595. translate([x, 10, 31])
  596. cube([1, 10, 45]);
  597. }
  598. }
  599. module assembly_right_half_lipo() {
  600. right_half_lipo();
  601. color("green")
  602. translate([0, 0, (height - lipo_lid_height) / 2 + lipo_lid_gap])
  603. lipo_lid();
  604. }
  605. module assembly_closed() {
  606. //right_half_aaa_bat();
  607. //right_halt_aa_bat();
  608. assembly_right_half_lipo();
  609. rotate([0, 0, 180])
  610. left_half();
  611. translate([0, 0, height + thread_adapter_h + 0.5])
  612. thread_profile_adapter(thread_profiles[0], false);
  613. }
  614. module assembly_opened(angle) {
  615. translate([-outer_dia / 2, 0, 0]) {
  616. rotate([0, 0, angle / 2])
  617. translate([outer_dia / 2, 0, 0])
  618. //right_half_aaa_bat();
  619. //right_halt_aa_bat();
  620. assembly_right_half_lipo();
  621. rotate([0, 0, -angle / 2])
  622. translate([outer_dia / 2, 0, 0])
  623. rotate([0, 0, 180])
  624. left_half();
  625. }
  626. }
  627. module print_all_thread_adapters() {
  628. for (p = [0 : len(thread_profiles) - 1])
  629. translate([(p - floor(len(thread_profiles) / 2)) * (outer_dia + 5), -outer_dia / 2 - 5, 0])
  630. thread_profile_adapter(thread_profiles[p], true);
  631. }
  632. module print(all_thread_adapters) {
  633. translate([outer_dia / 2 + 5, 0, 0])
  634. left_half();
  635. translate([-outer_dia / 2 - 5, 0, 0])
  636. //right_half_aaa_bat();
  637. //right_halt_aa_bat();
  638. right_half_lipo();
  639. if (all_thread_adapters)
  640. print_all_thread_adapters();
  641. }
  642. //lcd_cutout();
  643. //left_half();
  644. //right_half();
  645. //right_half_aaa_bat();
  646. //right_halt_aa_bat();
  647. //right_half_lipo();
  648. //lipo_lid();
  649. //assembly_right_half_lipo();
  650. //assembly_closed();
  651. //assembly_opened(90);
  652. //print(true);
  653. //print(false);
  654. //print_all_thread_adapters();
  655. //thread_profile_adapter(thread_profile_1911, true);
  656. //thread_profile_adapter(thread_profile_m14_cw, true);
  657. //thread_profile_adapter(thread_profile_m14_ccw, true);
  658. //thread_profile_adapter(thread_profile_giant, true);
  659. thread_profile_adapter(thread_profile_mac11, true);
  660. //mac11_extender();