Brak opisu
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.

sensor_pmw3360.scad 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Copyright (c) 2022 - 2023 Thomas Buck (thomas@xythobuz.de)
  3. * Philipp Schönberger (mail@phschoen.de)
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * See <http://www.gnu.org/licenses/>.
  16. */
  17. include<config.scad>
  18. include<util.scad>
  19. // ######################
  20. // ### PMW3360 Sensor ###
  21. // ######################
  22. // https://github.com/jfedor2/pmw3360-breakout
  23. sensor_w = 22;
  24. sensor_l = 27.6;//34;
  25. sensor_r = 2;
  26. sensor_pcb_h = 1.6;
  27. sensor_hole_dia = 2.2;
  28. sensor_hole_off_x = 3.0;
  29. sensor_hole_off_y = 3.0;
  30. sensor_hole_dist_x = 16.6;
  31. sensor_hole_dist_y = 22.32;
  32. sensor_cut_w = 8.0 + 0.5;
  33. sensor_cut_h = 17.26;
  34. sensor_cut_off_x = 7.0 - 0.25;
  35. sensor_cut_off_y = 5.27;
  36. sensor_cut_edge_to_pin1 = 2.75;
  37. sensor_edge_to_pin1 = 1.52;
  38. sensor_ball_to_lens_top = 2.4;
  39. sensor_ball_to_chip_bottom = 9.81;
  40. sensor_chip_w = 9.1;
  41. sensor_chip_l = 16.2;
  42. sensor_chip_h = 2.21;
  43. sensor_pin_w = 0.5;
  44. sensor_pin_h = 4.51;
  45. sensor_pin_d = 0.2;
  46. sensor_pin_dist = 10.7;
  47. sensor_pin_off_top = 0.5;
  48. sensor_pin_pitch = 0.89;
  49. sensor_pin1_to_optical_center = 5.66;
  50. sensor_lens_cutout_r = 2.0;
  51. sensor_lens_cutout_w = 4.0;
  52. sensor_lens_cutout_growth = 0.25;
  53. sensor_lens_cutout_to_chip = 6.71 - 1.60;
  54. sensor_lens_baseplate_h = 2.40;
  55. sensor_lens_d = 19.0 + 1.0;
  56. sensor_lens_w = 21.35 + 0.2;
  57. sensor_lens_off = 10.97;
  58. sensor_cutout();
  59. module sensor_lens_cutout_intern()
  60. {
  61. cylinder(d = sensor_lens_cutout_r * 2, h = $e);
  62. translate([-sensor_lens_cutout_r, 0, 0])
  63. cube([sensor_lens_cutout_r * 2, sensor_lens_cutout_w, $e]);
  64. }
  65. module sensor_lens_cutout()
  66. {
  67. translate([0, 0, sensor_lens_cutout_to_chip])
  68. hull()
  69. {
  70. translate([0, 0, sensor_lens_baseplate_h - $e])
  71. sensor_lens_cutout_intern();
  72. scale(1 + sensor_lens_cutout_growth * sensor_lens_baseplate_h)
  73. sensor_lens_cutout_intern();
  74. }
  75. translate([-sensor_lens_d / 2, -sensor_lens_w + sensor_lens_off, 0])
  76. rounded_cube(sensor_lens_d, sensor_lens_w, sensor_lens_cutout_to_chip, 6);
  77. translate([-3 / 2, -sensor_lens_w + sensor_lens_off - 0.5, 0])
  78. cube([3, 0.5, sensor_lens_cutout_to_chip]);
  79. }
  80. module sensor()
  81. {
  82. translate([-sensor_w / 2, -sensor_l / 2, 0])
  83. difference()
  84. {
  85. color("green")
  86. minkowski()
  87. {
  88. translate([sensor_r,sensor_r,0])
  89. cube([sensor_w-sensor_r*2, sensor_l-sensor_r*2, sensor_pcb_h]);
  90. cylinder(r=sensor_r,h=$e);
  91. }
  92. translate([sensor_cut_off_x, sensor_cut_off_y, -1])
  93. cube([sensor_cut_w, sensor_cut_h, sensor_pcb_h + 2]);
  94. for (x = [0, sensor_hole_dist_x])
  95. for (y = [0, sensor_hole_dist_y])
  96. translate([sensor_hole_off_x + x, sensor_hole_off_y + y, -1])
  97. cylinder(d = sensor_hole_dia, h = sensor_pcb_h + 2);
  98. }
  99. color("#303030")
  100. 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])
  101. cube([sensor_chip_w, sensor_chip_l, sensor_chip_h]);
  102. translate([0, -sensor_l / 2 - 15 * sensor_pin_pitch + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1, 0])
  103. for (p = [0 : 15])
  104. translate([0, p * sensor_pin_pitch, 0])
  105. for (x = [-sensor_pin_dist / 2, sensor_pin_dist / 2])
  106. if (((p % 2 == 0) && (x < 0)) || ((p % 2 == 1) && (x > 0)))
  107. translate([-sensor_pin_d / 2 + x, -sensor_pin_w / 2, -sensor_chip_h + sensor_pin_off_top])
  108. cube([sensor_pin_d, sensor_pin_w, sensor_pin_h]);
  109. translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0])
  110. {
  111. color("cyan")
  112. translate([0, 0, -sensor_chip_h + 1])
  113. cylinder(d = 0.2, h = sensor_ball_to_chip_bottom - 1);
  114. %color("blue")
  115. sensor_lens_cutout();
  116. }
  117. }
  118. module sensor_pos() {
  119. rotate(angle_sensor)
  120. translate([0, 0, -trackball_dia / 2 ])
  121. 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])
  122. translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0])
  123. sensor();
  124. }
  125. module sensor_cutout()
  126. {
  127. rotate(angle_sensor)
  128. translate([0, 0, -trackball_dia / 2 ])
  129. 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])
  130. translate([0, -sensor_l / 2 + sensor_cut_off_y + sensor_cut_h - sensor_cut_edge_to_pin1 - sensor_pin1_to_optical_center, 0])
  131. sensor_lens_cutout();
  132. // sensor pcb
  133. rotate(angle_sensor)
  134. translate([-1, -1, -trackball_dia / 2 - 20])
  135. 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])
  136. translate([-sensor_w / 2, -sensor_l / 2, -10])
  137. cube([sensor_w + 2, sensor_l + 2, sensor_pcb_h + 10 + sensor_pcb_mount_gap+20]);
  138. }