/* * Trackball * Copyright 2022 Thomas Buck - thomas@xythobuz.de * Philipp Schönberger - mail@phschoen.de * * Required parts: * - 1x Raspberry Pi Pico * - 5x Cherry MX compatible switches and keycaps * - 1x Billard ball, diameter 38mm * - 3x Si3N4 static bearing balls, diameter 3mm * - 3x spring, diameter 2mm, length 10mm * - 1x PMW3360 sensor with breakout board * - 8x M2 screw, length 5mm * - 8x M2 heat melt insert, length 4mm * * For the PMW3360 breakout board get this: * https://github.com/jfedor2/pmw3360-breakout * * The "Threads" library used by this project is: * Copyright 2022 Dan Kirshner - dan_kirshner@yahoo.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * See . */ include <../config.scad> include <../constant.scad> use <../pcb/pmw3360_sensor.scad> use <../pcb/rp2040.scad> // ###################### // ## Rendering Select ## // ###################### //roller_holder(); //roller_mount_test(); //roller_mount_tri(); //ball_and_roller(); trackball(); // ####################### // #### Configuration #### // ####################### base_dia = pico_l + 9; wall = 3.0; cut_roller_holder = false; // ###################### // ## MX Switch Cutout ## // ###################### // https://geekhack.org/index.php?topic=70654.0 mx_co_w = 14.0; mx_co_w_add = 0.8; mx_co_h = 14.0; mx_co_h_off_1 = 1.0; mx_co_h_off_2 = 3.5; mx_co_h_off_3 = mx_co_h - 2 * (mx_co_h_off_1 + mx_co_h_off_2); mx_co_r = 0.4; // https://geekhack.org/index.php?topic=71550.0 mx_co_th = 1.5 - 0.1; mx_co_b_add = 1.0; mx_co_b_w = mx_co_w + mx_co_b_add; mx_co_b_h = mx_co_h + mx_co_b_add; mx_travel = 3.9; // ###################### // ### Implementation ### // ###################### roller_thread_dia = roller_dia + 5.0; roller_h = roller_dia + 7.0; roller_ball_h_off = 0.4; roller_ball_hold_off = 0.5; roller_thread_hole = roller_dia - 1; roller_small_hole = sphere_r_at_h(roller_ball_hold_off, roller_dia / 2) * 2; roller_ridge_h = 1.5; roller_mount_angle_off = 90; roller_mount_dia = roller_thread_dia + 2.0; function sphere_r_at_h(h, r) = r * sin(acos(h / r)); function sphere_angle_at_rh(h, r) = acos(h / r); module roller_holder() { echo(roller_h); translate([0, 0, -roller_h + roller_dia / 2]) difference() { color("magenta") union() { // top screw part translate([0, 0, roller_h-roller_dia/2 + roller_ball_h_off-3]) cylinder(d1 = roller_mount_dia, d2=roller_dia+1, h = 3); cylinder(d = roller_mount_dia, h = roller_h-roller_dia/2 + roller_ball_h_off-3); } translate([0, 0, -$e]) { cylinder(d = roller_thread_hole, h = $e+ roller_h - roller_dia / 2 + roller_ball_h_off + roller_ball_hold_off); } translate([0, 0, roller_h - roller_dia / 2]) sphere(d = roller_dia , $fn=$fn*4 ); if (cut_roller_holder) { translate([-roller_thread_dia / 2 - 1, -roller_thread_dia, -1]) cube([roller_thread_dia + 2, roller_thread_dia, roller_h + 2]); } } %color("blue") sphere(d = roller_dia); } module roller_mount() { echo(roller_h); translate([0, 0, -1-roller_h + roller_dia / 2]) { difference() { cylinder(d=roller_mount_dia+wall,h=roller_h/2); translate([0,0,1]) cylinder(d=roller_mount_dia+$c*2,h=roller_h/2+$e); } } } module roller_mount_test() { roller_holder(); roller_mount(); } module roller_mount_tri() { difference() { union(){ difference() { hull() { translate([0, 0, 0]) for (r = [0 : roller_count - 1]) rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r]) translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h]) rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0]) translate([0, 0, -roller_h]) cylinder(d=roller_mount_dia+wall+1,h=roller_h+1); translate([0,0,-ball_dia/2-5]) cylinder(d=base_dia,h=$e); } for (r = [0 : roller_count - 1]) rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r]) translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h]) rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0]) translate([0, 0, -roller_h]) cylinder(d=roller_mount_dia+0.2,h=ball_dia/2+roller_h); sphere($fn=$fn*4, d=ball_dia+$c*2+1); } for (r = [0 : roller_count - 1]) rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r]) translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h]) rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0]) translate([0, 0, 0]) roller_mount(); } translate([0, 0, 0]) for (r = [0 : roller_count - 1]) rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r]) translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h]) rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0]) translate([0, 0, -roller_h/2]) rotate([0,-90,0]) translate([0,0,2]) { cylinder(d=m2_thread,h=ball_dia); translate([0,0,roller_mount_dia/4+wall]) cylinder(d=m2_thread+1,h=ball_dia); } } } module ball_and_roller() { color("red") sphere(d = ball_dia, $fn = 200); for (r = [0 : roller_count - 1]) rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r]) translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h]) rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0]) translate([0, 0, -roller_dia / 2]) roller_holder(); } module trackball() { %translate([0, 0, ball_dia / 2 + ball_h]) ball_and_roller(); %rotate([0, 180, 0]) pico(); %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]) pmw3360_sensor(); translate([0, 0, ball_dia / 2 + ball_h]) for (r = [0 : roller_count - 1]) rotate([0, 0, roller_mount_angle_off + 360 / roller_count * r]) translate([sphere_r_at_h(roller_ball_h - ball_dia / 2, ball_dia / 2), 0, -ball_dia / 2 + roller_ball_h]) rotate([0, 180 + sphere_angle_at_rh(roller_ball_h - ball_dia / 2, ball_dia / 2), 0]) translate([0, 0, -roller_dia / 2]) translate([0, 0, -roller_h + roller_dia / 2 - roller_ball_h_off]) roller_mount(); color("grey") translate([0, 0, -8]) cylinder(d = base_dia, h = wall); }