Nessuna descrizione
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

trackball.scad 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /*
  2. * Trackball
  3. * Copyright 2022 Thomas Buck - thomas@xythobuz.de
  4. *
  5. * Required parts:
  6. * - 1x Raspberry Pi Pico
  7. * - 4x Cherry MX compatible switches and keycaps
  8. * - 1x Billard ball, diameter 38mm
  9. * - 3x Si3N4 static bearing balls, diameter 3mm
  10. * - 1x PMW3360 sensor with breakout board
  11. * - 8x M2 screw, length 5mm
  12. * - 8x M2 heat melt insert, length 4mm
  13. *
  14. * For the PMW3360 breakout board get this:
  15. * https://github.com/jfedor2/pmw3360-breakout
  16. *
  17. * This program is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU General Public License as published by
  19. * the Free Software Foundation, either version 3 of the License, or
  20. * (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * See <http://www.gnu.org/licenses/>.
  28. */
  29. // https://www.thingiverse.com/thing:421524
  30. use <external/cherry_mx.scad>
  31. // https://www.printables.com/model/210898-raspberry-pi-pico-case
  32. use <external/pico_case.scad>
  33. // ######################
  34. // ## Rendering Select ##
  35. // ######################
  36. //ball_and_roller();
  37. //pico_wrap();
  38. //sensor();
  39. //mx_switch_cutout(wall);
  40. //mx_switch_test();
  41. //roller_mount_test();
  42. //roller_holder();
  43. //roller_mount_tri();
  44. //trackball_top();
  45. trackball_bottom();
  46. //assembly();
  47. //print();
  48. // #######################
  49. // #### Configuration ####
  50. // #######################
  51. $fn = 200;//42;
  52. ball_dia = 38.0;
  53. roller_dia = 3.0;
  54. roller_ball_h = ball_dia / 2 - 5;
  55. roller_count = 3;
  56. wall = 3.0;
  57. $c = 0.1;
  58. $e = 0.01;
  59. left_hand_version = false;
  60. cut_roller_holder = false;
  61. draw_supports = false;
  62. draw_ball_roller = true;
  63. draw_switches = true;
  64. draw_sensor = true;
  65. use_external_pico_model = true;
  66. // #######################
  67. // ## Raspberry Pi Pico ##
  68. // #######################
  69. pico_w = 21;
  70. pico_l = 51;
  71. pico_d = 1.0;
  72. pico_hole_d = 2.1;
  73. pico_hole_x = 4.8;
  74. pico_hole_y = 2.0;
  75. pico_hole_d_x = 11.4;
  76. pico_hole_d_y = pico_l - 2 * pico_hole_y;
  77. pico_usb_w = 8.0;
  78. pico_usb_h = 2.8;
  79. pico_usb_d = 6.0;
  80. pico_usb_off = 1.3;
  81. // ######################
  82. // ### PMW3360 Sensor ###
  83. // ######################
  84. // https://github.com/jfedor2/pmw3360-breakout
  85. sensor_w = 22;
  86. sensor_l = 34;
  87. sensor_pcb_h = 1.6;
  88. sensor_hole_dia = 2.2;
  89. sensor_hole_off_x = 3.0;
  90. sensor_hole_off_y = 3.0;
  91. sensor_hole_dist_x = 16.0;
  92. sensor_hole_dist_y = 24.5;
  93. sensor_cut_w = 8.0 + 0.5;
  94. sensor_cut_h = 17.26;
  95. sensor_cut_off_x = 7.0 - 0.25;
  96. sensor_cut_off_y = 5.27;
  97. sensor_cut_edge_to_pin1 = 2.75;
  98. sensor_edge_to_pin1 = 1.52;
  99. sensor_ball_to_lens_top = 2.4;
  100. sensor_ball_to_chip_bottom = 9.81;
  101. sensor_chip_w = 9.1;
  102. sensor_chip_l = 16.2;
  103. sensor_chip_h = 2.21;
  104. sensor_pin_w = 0.5;
  105. sensor_pin_h = 4.51;
  106. sensor_pin_d = 0.2;
  107. sensor_pin_dist = 10.7;
  108. sensor_pin_off_top = 0.5;
  109. sensor_pin_pitch = 0.89;
  110. sensor_pin1_to_optical_center = 5.66;
  111. sensor_lens_cutout_r = 2.0;
  112. sensor_lens_cutout_w = 4.0;
  113. sensor_lens_cutout_growth = 0.25;
  114. sensor_lens_cutout_to_chip = 6.71 - 1.60;
  115. sensor_lens_baseplate_h = 2.40;
  116. sensor_lens_d = 19.0 + 1.0;
  117. sensor_lens_w = 21.35 + 0.2;
  118. sensor_lens_off = 10.97;
  119. // ######################
  120. // ## MX Switch Cutout ##
  121. // ######################
  122. // https://geekhack.org/index.php?topic=70654.0
  123. mx_co_w = 14.0;
  124. mx_co_w_add = 0.8;
  125. mx_co_h = 14.0;
  126. mx_co_h_off_1 = 1.0;
  127. mx_co_h_off_2 = 3.5;
  128. mx_co_h_off_3 = mx_co_h - 2 * (mx_co_h_off_1 + mx_co_h_off_2);
  129. mx_co_r = 0.4;
  130. // https://geekhack.org/index.php?topic=71550.0
  131. mx_co_th = 1.5 - 0.1;
  132. mx_co_b_add = 1.0;
  133. mx_co_b_w = mx_co_w + mx_co_b_add;
  134. mx_co_b_h = mx_co_h + mx_co_b_add;
  135. mx_travel = 3.9;
  136. // ######################
  137. // ### Implementation ###
  138. // ######################
  139. base_dia = 62;
  140. m3_thread = 2.7;
  141. m2_thread = 1.8;
  142. roller_thread_dia = roller_dia + 5.0;
  143. roller_h = roller_dia + 7.0;
  144. roller_ball_h_off = 0.4;
  145. roller_ball_hold_off = 0.5;
  146. roller_thread_hole = roller_dia - 1;
  147. roller_small_hole = sphere_r_at_h(roller_ball_hold_off, roller_dia / 2) * 2;
  148. roller_ridge_h = 1.5;
  149. roller_mount_angle_off = 90;
  150. roller_mount_dia = roller_thread_dia + 2.0;
  151. ball_h = 15; // todo
  152. switch_test_w = 25;
  153. roller_mount_holder_gap = 0.8;
  154. sensor_pcb_mount_gap = 2.0;
  155. sensor_pcb_support_h = 1.6 + 3.4;
  156. sw1_rot_x = -5;
  157. sw1_rot_z = -30 * (left_hand_version ? -1 : 1);
  158. sw1_trans_x = 0;
  159. sw1_trans_y = -base_dia / 2 - 0;
  160. sw1_trans_z = -17;
  161. sw2_rot_x = -5;
  162. sw2_rot_z = 15 * (left_hand_version ? -1 : 1);
  163. sw2_trans_x = 0;
  164. sw2_trans_y = -base_dia / 2 - 0;
  165. sw2_trans_z = -17;
  166. sw3_rot_x = -5;
  167. sw3_rot_z = 125 * (left_hand_version ? -1 : 1);
  168. sw3_trans_x = 0;
  169. sw3_trans_y = -base_dia / 2 - 0;
  170. sw3_trans_z = -17;
  171. sw4_rot_x = -5;
  172. sw4_rot_z = -125 * (left_hand_version ? -1 : 1);
  173. sw4_trans_x = 0;
  174. sw4_trans_y = -base_dia / 2 - 0;
  175. sw4_trans_z = -17;
  176. sw_mount_w = mx_co_w + 7;
  177. sw_mount_co_l = 10;
  178. bottom_base_wall = wall + 0.5;
  179. bottom_base_below_zero = bottom_base_wall + 4.5;
  180. pico_co_w = pico_w + 1;
  181. pico_co_l = pico_l + 1;
  182. reset_button_dia = 4.0;
  183. reset_button_off_x = 7;
  184. reset_button_off_y = 12.15;
  185. pico_support_w = 6.5;
  186. pico_support_l = 5;
  187. pico_screw_depth = 6;
  188. pico_screw_d = 1.8;
  189. usb_cutout_grow_l = 10;
  190. usb_cutout_grow_x = 20;
  191. usb_cutout_grow_y = 40;
  192. usb_cutout_w_add = 1;
  193. usb_cutout_h_add = 0.6;
  194. assembly_dist = 20;
  195. function sphere_r_at_h(h, r) = r * sin(acos(h / r));
  196. function sphere_angle_at_rh(h, r) = acos(h / r);
  197. module mx_switch_cutout(h) {
  198. translate([-mx_co_w / 2 - mx_co_w_add, -mx_co_h / 2, 0]) {
  199. linear_extrude(h + 1) {
  200. translate([mx_co_w_add, 0]) {
  201. square([mx_co_w, mx_co_h]);
  202. for (x = [mx_co_r / 2, mx_co_w - mx_co_r / 2])
  203. for (y = [mx_co_r / 2, mx_co_h - mx_co_r / 2])
  204. translate([x, y])
  205. circle(r = mx_co_r);
  206. }
  207. for (x = [0, mx_co_w + mx_co_w_add])
  208. for (y = [0, mx_co_h_off_2 + mx_co_h_off_3])
  209. translate([x, mx_co_h_off_1 + y, 0])
  210. square([mx_co_w_add, mx_co_h_off_2]);
  211. }
  212. translate([mx_co_w_add - mx_co_b_add / 2, -mx_co_b_add / 2, -1])
  213. cube([mx_co_b_w, mx_co_b_h, h - mx_co_th + 1]);
  214. }
  215. }
  216. module mx_switch_test() {
  217. difference() {
  218. translate([-switch_test_w / 2, -switch_test_w / 2, 0])
  219. cube([switch_test_w, switch_test_w, wall]);
  220. mx_switch_cutout(wall);
  221. translate([0, -switch_test_w / 2 + 1, wall - 1.0])
  222. linear_extrude(1.1)
  223. text("switch test", size = 3, halign = "center");
  224. }
  225. %translate([0, 0, wall])
  226. rotate([0, 0, 180])
  227. mx_switch($t);
  228. }
  229. module pico_own() {
  230. translate([-pico_w / 2, -pico_l / 2, 0])
  231. difference() {
  232. union() {
  233. color("green")
  234. cube([pico_w, pico_l, pico_d]);
  235. translate([(pico_w - pico_usb_w) / 2, pico_l - pico_usb_d + pico_usb_off, pico_d])
  236. cube([pico_usb_w, pico_usb_d, pico_usb_h]);
  237. }
  238. for (x = [0, pico_hole_d_x])
  239. for (y = [0, pico_hole_d_y])
  240. translate([pico_hole_x + x, pico_hole_y + y, -1])
  241. cylinder(d = pico_hole_d, h = pico_d + 2);
  242. }
  243. }
  244. module pico_wrap() {
  245. //if (use_external_pico_model)
  246. translate([-pico_w / 2, -pico_l / 2, 0])
  247. pico();
  248. //else
  249. pico_own();
  250. }
  251. module sensor_lens_cutout_intern() {
  252. cylinder(d = sensor_lens_cutout_r * 2, h = $e);
  253. translate([-sensor_lens_cutout_r, 0, 0])
  254. cube([sensor_lens_cutout_r * 2, sensor_lens_cutout_w, $e]);
  255. }
  256. module rounded_cube(x, y, z, r) {
  257. hull()
  258. for (tx = [r, x - r])
  259. for (ty = [r, y - r])
  260. translate([tx, ty, 0])
  261. cylinder(d = r * 2, h = z);
  262. }
  263. module sensor_lens_cutout() {
  264. translate([0, 0, sensor_lens_cutout_to_chip])
  265. hull() {
  266. translate([0, 0, sensor_lens_baseplate_h - $e])
  267. sensor_lens_cutout_intern();
  268. scale(1 + sensor_lens_cutout_growth * sensor_lens_baseplate_h)
  269. sensor_lens_cutout_intern();
  270. }
  271. translate([-sensor_lens_d / 2, -sensor_lens_w + sensor_lens_off, 0])
  272. rounded_cube(sensor_lens_d, sensor_lens_w, sensor_lens_cutout_to_chip, 6);
  273. translate([-3 / 2, -sensor_lens_w + sensor_lens_off - 0.5, 0])
  274. cube([3, 0.5, sensor_lens_cutout_to_chip]);
  275. }
  276. module sensor() {
  277. translate([-sensor_w / 2, -sensor_l / 2, 0])
  278. difference() {
  279. color("green")
  280. cube([sensor_w, sensor_l, sensor_pcb_h]);
  281. translate([sensor_cut_off_x, sensor_cut_off_y, -1])
  282. cube([sensor_cut_w, sensor_cut_h, sensor_pcb_h + 2]);
  283. for (x = [0, sensor_hole_dist_x])
  284. for (y = [0, sensor_hole_dist_y])
  285. translate([sensor_hole_off_x + x, sensor_hole_off_y + y, -1])
  286. cylinder(d = sensor_hole_dia, h = sensor_pcb_h + 2);
  287. }
  288. color("#303030")
  289. translate([-sensor_chip_w / 2, -sensor_l / 2 - sensor_chip_l + sensor_edge_to_pin1 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1, -sensor_chip_h])
  290. cube([sensor_chip_w, sensor_chip_l, sensor_chip_h]);
  291. translate([0, -sensor_l / 2 - 15 * sensor_pin_pitch + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1, 0])
  292. for (p = [0 : 15])
  293. translate([0, p * sensor_pin_pitch, 0])
  294. for (x = [-sensor_pin_dist / 2, sensor_pin_dist / 2])
  295. if (((p % 2 == 0) && (x < 0))
  296. || ((p % 2 == 1) && (x > 0)))
  297. translate([-sensor_pin_d / 2 + x, -sensor_pin_w / 2, -sensor_chip_h + sensor_pin_off_top])
  298. cube([sensor_pin_d, sensor_pin_w, sensor_pin_h]);
  299. translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0]) {
  300. color("cyan")
  301. translate([0, 0, -sensor_chip_h + 1])
  302. cylinder(d = 0.2, h = sensor_ball_to_chip_bottom - 1);
  303. %color("blue")
  304. sensor_lens_cutout();
  305. }
  306. }
  307. module ball_and_roller() {
  308. color("red")
  309. sphere(d = ball_dia, $fn = $fn * 2);
  310. for (r = [0 : roller_count - 1])
  311. rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r])
  312. translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h])
  313. rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0])
  314. translate([0, 0, -roller_dia / 2])
  315. roller_holder();
  316. }
  317. module roller_holder() {
  318. translate([0, 0, -roller_h + roller_dia / 2])
  319. difference() {
  320. color("magenta")
  321. union() {
  322. // top screw part
  323. translate([0, 0, roller_h-roller_dia/2 + roller_ball_h_off-3])
  324. cylinder(d1 = roller_mount_dia, d2=roller_dia+1, h = 3);
  325. cylinder(d = roller_mount_dia, h = roller_h-roller_dia/2 + roller_ball_h_off-3);
  326. }
  327. translate([0, 0, -$e])
  328. cylinder(d = roller_thread_hole, h = $e+ roller_h - roller_dia / 2 + roller_ball_h_off + roller_ball_hold_off);
  329. translate([0, 0, roller_h - roller_dia / 2])
  330. sphere(d = roller_dia, $fn = $fn * 2);
  331. if (cut_roller_holder)
  332. translate([-roller_thread_dia / 2 - 1, -roller_thread_dia, -1])
  333. cube([roller_thread_dia + 2, roller_thread_dia, roller_h + 2]);
  334. }
  335. %color("blue")
  336. sphere(d = roller_dia, $fn = $fn * 2);
  337. }
  338. module roller_mount() {
  339. translate([0, 0, -1-roller_h + roller_dia / 2]) {
  340. difference() {
  341. cylinder(d=roller_mount_dia+wall,h=roller_h/2);
  342. translate([0, 0, 1])
  343. cylinder(d=roller_mount_dia+$c*2,h=roller_h/2+$e);
  344. if (cut_roller_holder)
  345. translate([-roller_thread_dia / 2 - 1, -roller_thread_dia, -1])
  346. cube([roller_thread_dia + 2, roller_thread_dia, roller_h + 2]);
  347. }
  348. }
  349. }
  350. module roller_mount_test() {
  351. roller_holder();
  352. roller_mount();
  353. }
  354. module roller_mount_tri_hull() {
  355. for (r = [0 : roller_count - 1])
  356. rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r])
  357. translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h])
  358. rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0])
  359. translate([0, 0, -roller_h])
  360. cylinder(d = roller_mount_dia + wall + 1, h = roller_h - 3);
  361. translate([0, 0, -ball_dia / 2 - 11])
  362. cylinder(d = base_dia, h = $e);
  363. }
  364. module roller_mount_tri_body() {
  365. // space for roller holder
  366. for (r = [0 : roller_count - 1])
  367. rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r])
  368. translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h])
  369. rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0])
  370. translate([0, 0, -roller_h])
  371. cylinder(d = roller_mount_dia + roller_mount_holder_gap, h = ball_dia / 2 + roller_h);
  372. // room for ball itself
  373. sphere($fn = $fn * 2, d = ball_dia + $c * 2 + 4);
  374. // grub screws
  375. for (r = [0 : roller_count - 1])
  376. rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r])
  377. translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h])
  378. rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0])
  379. translate([0, 0, -roller_h/2])
  380. rotate([0,-90,0])
  381. translate([-2, 0, 2]) {
  382. cylinder(d = m2_thread, h = ball_dia);
  383. translate([0, 0, roller_mount_dia / 4 + wall])
  384. cylinder(d = m2_thread + 1, h = ball_dia);
  385. }
  386. // sensor lens
  387. translate([0, 0, -ball_dia / 2 - ball_h])
  388. translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, ball_h + sensor_chip_h - sensor_ball_to_chip_bottom])
  389. translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0])
  390. sensor_lens_cutout();
  391. // sensor pcb
  392. translate([-1, -1, -ball_dia / 2 - ball_h])
  393. translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, ball_h + sensor_chip_h - sensor_ball_to_chip_bottom])
  394. translate([-sensor_w / 2, -sensor_l / 2, -10])
  395. cube([sensor_w + 2, sensor_l + 2, sensor_pcb_h + 10 + sensor_pcb_mount_gap]);
  396. }
  397. module roller_mount_sensor_pcb_support() {
  398. translate([-sensor_w / 2, -sensor_l / 2, sensor_pcb_h])
  399. translate([0, 0, -ball_dia / 2 - ball_h])
  400. translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, ball_h + sensor_chip_h - sensor_ball_to_chip_bottom])
  401. for (x = [0, sensor_hole_dist_x])
  402. for (y = [0, sensor_hole_dist_y])
  403. translate([sensor_hole_off_x + x, sensor_hole_off_y + y, 0])
  404. difference() {
  405. union() {
  406. color("magenta")
  407. cylinder(d = sensor_hole_dia + 1.5, h = sensor_pcb_mount_gap);
  408. if (draw_supports)
  409. color("black")
  410. translate([0, 0, -sensor_pcb_support_h])
  411. cylinder(d = sensor_hole_dia + 0.5, h = sensor_pcb_support_h);
  412. }
  413. cylinder(d = sensor_hole_dia - 0.2, h = sensor_pcb_mount_gap + 1);
  414. }
  415. if (draw_supports)
  416. color("black")
  417. for (x = [-5, 0, 5])
  418. for (y = [-8, 0, 6.5])
  419. if (((x == 0) && (y != 0)) || ((x != 0) && (y == 0)))
  420. translate([x, y + 2, -30])
  421. cylinder(d = sensor_hole_dia + 0.5, h = 8.5);
  422. if (draw_sensor)
  423. %translate([0, 0, -ball_dia / 2 - ball_h])
  424. translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, ball_h + sensor_chip_h - sensor_ball_to_chip_bottom])
  425. sensor();
  426. }
  427. // TODO holes for pcb screws not going into body!!
  428. module roller_mount_tri() {
  429. if (draw_ball_roller)
  430. %ball_and_roller();
  431. difference() {
  432. hull()
  433. roller_mount_tri_hull();
  434. roller_mount_tri_body();
  435. // TODO test cable cutout
  436. translate([-6, 0, -30.1])
  437. cube([12, 50, 2]);
  438. if (cut_roller_holder)
  439. translate([0, -base_dia / 2 - 1, -40])
  440. cube([base_dia / 2 + 1, base_dia + 2, 40]);
  441. }
  442. roller_mount_sensor_pcb_support();
  443. }
  444. module trackball_top() {
  445. translate([0, 0, ball_dia / 2 + ball_h]) {
  446. if (draw_ball_roller)
  447. %ball_and_roller();
  448. difference() {
  449. color("orange")
  450. hull() {
  451. roller_mount_tri_hull();
  452. rotate([0, 0, sw1_rot_z])
  453. translate([sw1_trans_x, sw1_trans_y, sw1_trans_z])
  454. rotate([90 + sw1_rot_x, 0, 0])
  455. translate([0, 0, -0.5])
  456. cube([sw_mount_w, sw_mount_w, 1], center = true);
  457. rotate([0, 0, sw2_rot_z])
  458. translate([sw2_trans_x, sw2_trans_y, sw2_trans_z])
  459. rotate([90 + sw2_rot_x, 0, 0])
  460. translate([0, 0, -0.5])
  461. cube([sw_mount_w, sw_mount_w, 1], center = true);
  462. rotate([0, 0, sw3_rot_z])
  463. translate([sw3_trans_x, sw3_trans_y, sw3_trans_z])
  464. rotate([90 + sw3_rot_x, 0, 0])
  465. translate([0, 0, -0.5])
  466. cube([sw_mount_w, sw_mount_w, 1], center = true);
  467. rotate([0, 0, sw4_rot_z])
  468. translate([sw4_trans_x, sw4_trans_y, sw4_trans_z])
  469. rotate([90 + sw4_rot_x, 0, 0])
  470. translate([0, 0, -0.5])
  471. cube([sw_mount_w, sw_mount_w, 1], center = true);
  472. }
  473. roller_mount_tri_body();
  474. if (cut_roller_holder)
  475. translate([0, -base_dia / 2 - 1, -40])
  476. cube([base_dia / 2 + 1, base_dia + 2, 40]);
  477. rotate([0, 0, sw1_rot_z])
  478. translate([sw1_trans_x, sw1_trans_y, sw1_trans_z])
  479. rotate([90 + sw1_rot_x, 0, 0])
  480. translate([0, 0, -sw_mount_co_l]) {
  481. mx_switch_cutout(sw_mount_co_l + 1);
  482. translate([0, 0, 2])
  483. rotate([90, 0, 0])
  484. cylinder(d = 4, h = 20);
  485. }
  486. rotate([0, 0, sw2_rot_z])
  487. translate([sw2_trans_x, sw2_trans_y, sw2_trans_z])
  488. rotate([90 + sw2_rot_x, 0, 0])
  489. translate([0, 0, -sw_mount_co_l]) {
  490. mx_switch_cutout(sw_mount_co_l + 1);
  491. translate([0, 0, 2])
  492. rotate([90, 0, 0])
  493. cylinder(d = 4, h = 20);
  494. }
  495. rotate([0, 0, sw3_rot_z])
  496. translate([sw3_trans_x, sw3_trans_y, sw3_trans_z])
  497. rotate([90 + sw3_rot_x, 0, 0])
  498. translate([0, 0, -sw_mount_co_l]) {
  499. mx_switch_cutout(sw_mount_co_l + 1);
  500. translate([0, 0, 2])
  501. rotate([90, 0, 0])
  502. cylinder(d = 4, h = 20);
  503. }
  504. rotate([0, 0, sw4_rot_z])
  505. translate([sw4_trans_x, sw4_trans_y, sw4_trans_z])
  506. rotate([90 + sw4_rot_x, 0, 0])
  507. translate([0, 0, -sw_mount_co_l]) {
  508. mx_switch_cutout(sw_mount_co_l + 1);
  509. translate([0, 0, 2])
  510. rotate([90, 0, 0])
  511. cylinder(d = 4, h = 20);
  512. }
  513. /*
  514. hull() {
  515. rotate([0, 0, sw1_rot_z])
  516. translate([sw1_trans_x, sw1_trans_y, sw1_trans_z])
  517. rotate([90 + sw1_rot_x, 0, 0])
  518. translate([0, 0, -sw_mount_co_l + 5])
  519. mx_switch_cutout(sw_mount_co_l - 10);
  520. rotate([0, 0, sw2_rot_z])
  521. translate([sw2_trans_x, sw2_trans_y, sw2_trans_z])
  522. rotate([90 + sw2_rot_x, 0, 0])
  523. translate([0, 0, -sw_mount_co_l + 5])
  524. mx_switch_cutout(sw_mount_co_l - 10);
  525. }
  526. */
  527. for (r = screw_angles)
  528. rotate([0, 0, r])
  529. translate([screw_off, 0, -ball_dia / 2 - 11 -1]) {
  530. cylinder(d = screw_insert_dia, h = screw_insert_h + 1);
  531. }
  532. }
  533. roller_mount_sensor_pcb_support();
  534. if (draw_switches) {
  535. %rotate([0, 0, sw1_rot_z])
  536. translate([sw1_trans_x, sw1_trans_y, sw1_trans_z])
  537. rotate([90 + sw1_rot_x, 0, 0])
  538. mx_switch($t);
  539. %rotate([0, 0, sw2_rot_z])
  540. translate([sw2_trans_x, sw2_trans_y, sw2_trans_z])
  541. rotate([90 + sw2_rot_x, 0, 0])
  542. mx_switch($t);
  543. %rotate([0, 0, sw3_rot_z])
  544. translate([sw3_trans_x, sw3_trans_y, sw3_trans_z])
  545. rotate([90 + sw3_rot_x, 0, 0])
  546. mx_switch($t);
  547. %rotate([0, 0, sw4_rot_z])
  548. translate([sw4_trans_x, sw4_trans_y, sw4_trans_z])
  549. rotate([90 + sw4_rot_x, 0, 0])
  550. mx_switch($t);
  551. }
  552. }
  553. }
  554. bottom_add_wall = 4;
  555. module trackball_bottom_wrap() {
  556. %rotate([0, 180, 0])
  557. pico_wrap();
  558. color("magenta")
  559. translate([0, 0, -bottom_base_below_zero])
  560. difference() {
  561. cylinder(d = base_dia, h = bottom_base_below_zero + ball_h - 11);
  562. translate([0, 0, bottom_base_wall])
  563. cylinder(d = base_dia - bottom_base_wall * 2 - bottom_add_wall, h = bottom_base_below_zero + ball_h - 11);
  564. translate([-pico_co_w / 2, -pico_co_l / 2, bottom_base_wall])
  565. cube([pico_co_w, pico_co_l, bottom_base_below_zero + ball_h - 11]);
  566. translate([pico_w / 2 - reset_button_off_x, pico_l / 2 - reset_button_off_y, -1])
  567. cylinder(d = reset_button_dia, h = bottom_base_wall + 2);
  568. if (cut_roller_holder)
  569. translate([-base_dia / 2 - 1, -base_dia / 2 - 1, -10])
  570. cube([base_dia / 2 + 1, base_dia + 2, 40]);
  571. }
  572. color("cyan")
  573. for (x = [-1, 1])
  574. for (y = [-1, 1])
  575. translate([x * (pico_co_w - pico_support_w) / 2, y * (pico_co_l - pico_support_l) / 2, 0])
  576. translate([-pico_support_w / 2, -pico_support_l / 2, -bottom_base_below_zero + bottom_base_wall])
  577. cube([pico_support_w, pico_support_l, bottom_base_below_zero - bottom_base_wall - pico_d]);
  578. color("cyan")
  579. for (r = screw_angles)
  580. rotate([0, 0, r])
  581. translate([screw_off, 0, -bottom_base_below_zero + bottom_base_wall])
  582. cylinder(d = screw_head_d + 4, h = bottom_base_below_zero + ball_h - 11 - bottom_base_wall);
  583. }
  584. module usb_cutout() {
  585. hull() {
  586. translate([-usb_cutout_w_add / 2, 0, -usb_cutout_h_add / 2])
  587. cube([pico_usb_w + usb_cutout_w_add, 1, pico_usb_h + usb_cutout_h_add]);
  588. translate([-usb_cutout_grow_x / 2, usb_cutout_grow_l, -usb_cutout_grow_y / 2])
  589. cube([pico_usb_w + usb_cutout_grow_x, 1, pico_usb_h + usb_cutout_grow_y]);
  590. }
  591. }
  592. screw_dia = 3.2;
  593. screw_off = base_dia / 2 - 10;
  594. screw_head_d = 6.0;
  595. screw_head_h = 3.5;
  596. screw_angles = [ 15, -15, 180 + 15, 180 - 15 ];
  597. screw_insert_dia = 4.8;
  598. screw_insert_h = 8.0;
  599. module trackball_bottom() {
  600. difference() {
  601. trackball_bottom_wrap();
  602. for (x = [0, pico_hole_d_x])
  603. for (y = [0, pico_hole_d_y])
  604. translate([-pico_w / 2, -pico_l / 2, 0])
  605. translate([pico_hole_x + x, pico_hole_y + y, -pico_d - pico_screw_depth])
  606. cylinder(d = pico_screw_d, h = pico_d + pico_screw_depth + 1);
  607. rotate([0, 180, 0])
  608. translate([-pico_w / 2, -pico_l / 2, 0])
  609. translate([(pico_w - pico_usb_w) / 2, pico_l - 1 + pico_usb_off, pico_d])
  610. usb_cutout();
  611. for (r = screw_angles)
  612. rotate([0, 0, r])
  613. translate([screw_off, 0, -bottom_base_below_zero - 1]) {
  614. cylinder(d = screw_dia, h = bottom_base_below_zero + 30);
  615. cylinder(d = screw_head_d, h = screw_head_h + 1);
  616. }
  617. }
  618. }
  619. module assembly() {
  620. translate([0, 0, assembly_dist / 2])
  621. trackball_top();
  622. translate([0, 0, -assembly_dist / 2])
  623. trackball_bottom();
  624. }
  625. module print() {
  626. translate([-40, 0, -4])
  627. trackball_top();
  628. translate([40, 0, bottom_base_below_zero])
  629. trackball_bottom();
  630. for (y = [-20, 0, 20])
  631. translate([0, y, 8.5])
  632. roller_holder();
  633. }