123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- /*
- * Copyright (c) 2022 - 2023 Thomas Buck (thomas@xythobuz.de)
- * Philipp Schönberger (mail@phschoen.de)
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
- include<config.scad>
- include<util.scad>
-
- // ######################
- // ### PMW3360 Sensor ###
- // ######################
-
- // https://github.com/jfedor2/pmw3360-breakout
- sensor_w = 22;
- sensor_l = 27.6;//34;
- sensor_r = 2;
-
- sensor_pcb_h = 1.6;
- sensor_hole_dia = 2.2;
- sensor_hole_off_x = 3.0;
- sensor_hole_off_y = 3.0;
- sensor_hole_dist_x = 16.6;
- sensor_hole_dist_y = 22.32;
- sensor_cut_w = 8.0 + 0.5;
- sensor_cut_h = 17.26;
- sensor_cut_off_x = 7.0 - 0.25;
- sensor_cut_off_y = 5.27;
- sensor_cut_edge_to_pin1 = 2.75;
- sensor_edge_to_pin1 = 1.52;
-
- sensor_ball_to_lens_top = 2.4;
- sensor_ball_to_chip_bottom = 9.81;
-
- sensor_chip_w = 9.1;
- sensor_chip_l = 16.2;
- sensor_chip_h = 2.21;
-
- sensor_pin_w = 0.5;
- sensor_pin_h = 4.51;
- sensor_pin_d = 0.2;
- sensor_pin_dist = 10.7;
- sensor_pin_off_top = 0.5;
- sensor_pin_pitch = 0.89;
-
- sensor_pin1_to_optical_center = 5.66;
-
- sensor_lens_cutout_r = 2.0;
- sensor_lens_cutout_w = 4.0;
- sensor_lens_cutout_growth = 0.25;
- sensor_lens_cutout_to_chip = 6.71 - 1.60;
- sensor_lens_baseplate_h = 2.40;
-
- sensor_lens_d = 19.0 + 1.0;
- sensor_lens_w = 21.35 + 0.2;
- sensor_lens_off = 10.97;
-
- sensor_cutout();
-
- module sensor_lens_cutout_intern()
- {
- cylinder(d = sensor_lens_cutout_r * 2, h = $e);
-
- translate([-sensor_lens_cutout_r, 0, 0])
- cube([sensor_lens_cutout_r * 2, sensor_lens_cutout_w, $e]);
- }
-
-
- module sensor_lens_cutout()
- {
- translate([0, 0, sensor_lens_cutout_to_chip])
- hull()
- {
- translate([0, 0, sensor_lens_baseplate_h - $e])
- sensor_lens_cutout_intern();
-
- scale(1 + sensor_lens_cutout_growth * sensor_lens_baseplate_h)
- sensor_lens_cutout_intern();
- }
-
- translate([-sensor_lens_d / 2, -sensor_lens_w + sensor_lens_off, 0])
- rounded_cube(sensor_lens_d, sensor_lens_w, sensor_lens_cutout_to_chip, 6);
-
- translate([-3 / 2, -sensor_lens_w + sensor_lens_off - 0.5, 0])
- cube([3, 0.5, sensor_lens_cutout_to_chip]);
- }
-
- module sensor()
- {
- translate([-sensor_w / 2, -sensor_l / 2, 0])
- difference()
- {
- color("green")
- minkowski()
- {
- translate([sensor_r,sensor_r,0])
- cube([sensor_w-sensor_r*2, sensor_l-sensor_r*2, sensor_pcb_h]);
-
- cylinder(r=sensor_r,h=$e);
- }
-
- translate([sensor_cut_off_x, sensor_cut_off_y, -1])
- cube([sensor_cut_w, sensor_cut_h, sensor_pcb_h + 2]);
-
- for (x = [0, sensor_hole_dist_x])
- for (y = [0, sensor_hole_dist_y])
- translate([sensor_hole_off_x + x, sensor_hole_off_y + y, -1])
- cylinder(d = sensor_hole_dia, h = sensor_pcb_h + 2);
- }
-
- color("#303030")
- 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])
- cube([sensor_chip_w, sensor_chip_l, sensor_chip_h]);
-
- translate([0, -sensor_l / 2 - 15 * sensor_pin_pitch + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1, 0])
- for (p = [0 : 15])
- translate([0, p * sensor_pin_pitch, 0])
- for (x = [-sensor_pin_dist / 2, sensor_pin_dist / 2])
- if (((p % 2 == 0) && (x < 0)) || ((p % 2 == 1) && (x > 0)))
- translate([-sensor_pin_d / 2 + x, -sensor_pin_w / 2, -sensor_chip_h + sensor_pin_off_top])
- cube([sensor_pin_d, sensor_pin_w, sensor_pin_h]);
-
- translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0])
- {
- color("cyan")
- translate([0, 0, -sensor_chip_h + 1])
- cylinder(d = 0.2, h = sensor_ball_to_chip_bottom - 1);
-
- %color("blue")
- sensor_lens_cutout();
- }
- }
-
- module sensor_pos() {
- rotate(angle_sensor)
- translate([0, 0, -trackball_dia / 2 ])
- translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, sensor_chip_h - sensor_ball_to_chip_bottom])
- translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0])
- sensor();
- }
-
- module sensor_cutout()
- {
- rotate(angle_sensor)
- translate([0, 0, -trackball_dia / 2 ])
- translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, sensor_chip_h - sensor_ball_to_chip_bottom])
- translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0])
- sensor_lens_cutout();
-
- // sensor pcb
- rotate(angle_sensor)
- translate([-1, -1, -trackball_dia / 2 - 20])
- translate([0, sensor_l / 2 - sensor_cut_off_y - sensor_cut_h + sensor_cut_edge_to_pin1 + sensor_pin1_to_optical_center, sensor_chip_h - sensor_ball_to_chip_bottom])
- translate([-sensor_w / 2, -sensor_l / 2, -10])
- cube([sensor_w + 2, sensor_l + 2, sensor_pcb_h + 10 + sensor_pcb_mount_gap+20]);
- }
|