No Description
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.

common.scad 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. include <config.scad>;
  2. $fn = 42;
  3. module prism(l, w, h) {
  4. polyhedron(
  5. points = [[0,0,0], [l,0,0], [l,w,0], [0,w,0], [0,w,h], [l,w,h]],
  6. faces = [[0,1,2,3],[5,4,3,2],[0,4,5,1],[0,3,4],[5,2,1]]
  7. );
  8. }
  9. module roundedcylinder(d, h, r, top = false) {
  10. hull() // needed, otherwise rendering fails
  11. rotate_extrude(convexity = 10)
  12. translate([d / 2, 0, 0])
  13. rotate([0, 180, 0]) {
  14. if (top) {
  15. translate([0, r])
  16. square([d / 2, h - r * 2]);
  17. } else {
  18. translate([0, r])
  19. square([d / 2, h - r]);
  20. }
  21. //translate([r, 0])
  22. //square([d / 2 - r, r]);
  23. translate([r, r])
  24. circle(r = r);
  25. if (top) {
  26. translate([r, h - r])
  27. circle(r = r);
  28. //translate([r, h - r])
  29. //square([d / 2 - r, r]);
  30. }
  31. }
  32. }
  33. module rail_2020(l, n = "") {
  34. translate([0, 10, 10])
  35. difference() {
  36. translate([0, -10, -10])
  37. cube([l, 20, 20]);
  38. translate([-1, 0, 0])
  39. rotate([0, 90, 0])
  40. cylinder(d = 4.2, h = l + 2);
  41. for (i = [0, 90, 180, 270])
  42. rotate([i, 0, 0]) {
  43. translate([-1, -6.25 / 2, 10 - 4.3 - 1.8])
  44. cube([l + 2, 6.25, 4.3 + 1.8 + 1]);
  45. for (j = [-1, 1])
  46. scale([1, j, 1])
  47. translate([-1, -6.25 / 2, 10 - 1.8])
  48. rotate([45, 0, 0])
  49. cube([l + 2, 6.25, 4.3 + 1.8 + 1]);
  50. }
  51. }
  52. }
  53. module rail_2020_x(l, n = "") {
  54. echo("2020 rail", n, str(l));
  55. rail_2020(l, n);
  56. }
  57. module rail_2020_y(l, n = "") {
  58. translate([20, 0, 0])
  59. rotate([0, 0, 90])
  60. rail_2020_x(l, n);
  61. }
  62. module rail_2040_x(l, n = "") {
  63. echo("2040 rail", n, str(l));
  64. rail_2020(l, n);
  65. translate([0, 0, -20])
  66. rail_2020(l, n);
  67. }
  68. module rail_2040_y(l, n = "") {
  69. translate([20, 0, 0])
  70. rotate([0, 0, 90])
  71. rail_2040_x(l, n);
  72. }
  73. module rail_wheel() {
  74. difference() {
  75. union() {
  76. cylinder(d1 = rail_wheel_mid, d2 = rail_wheel_outer, h = (rail_wheel_height - rail_wheel_center_height) / 2);
  77. translate([0, 0, (rail_wheel_height - rail_wheel_center_height) / 2])
  78. cylinder(d = rail_wheel_outer, h = rail_wheel_center_height);
  79. translate([0, 0, (rail_wheel_height - rail_wheel_center_height) / 2 + rail_wheel_center_height])
  80. cylinder(d1 = rail_wheel_outer, d2 = rail_wheel_mid, h = (rail_wheel_height - rail_wheel_center_height) / 2);
  81. }
  82. translate([0, 0, -1])
  83. cylinder(d = rail_wheel_inner, rail_wheel_height + 2);
  84. }
  85. }
  86. module nema17_holes_face(height, length, hole) {
  87. translate([nema17_size / 2, nema17_size / 2, height - 4.5])
  88. for (i = [1, -1])
  89. for (j = [1, -1])
  90. translate([i * nema17_hole_off, j * nema17_hole_off, 0])
  91. cylinder(d = hole, h = length);
  92. }
  93. module nema17(length) {
  94. difference() {
  95. cube([nema17_size, nema17_size, length]);
  96. nema17_holes_face(length, 5.0, nema17_hole_size);
  97. }
  98. translate([nema17_size / 2, nema17_size / 2, length]) {
  99. cylinder(d = nema17_center_size, h = nema17_center_height);
  100. cylinder(d = nema17_shaft_size, h = nema17_shaft_length);
  101. }
  102. }
  103. module endstop_pcb() {
  104. difference() {
  105. cube([endstop_pcb_width, endstop_pcb_depth, endstop_pcb_height]);
  106. for (i = [0, 1])
  107. translate([endstop_pcb_hole_dist_x, -1, endstop_pcb_height - endstop_pcb_hole_dist_y - i * endstop_pcb_hole_dist])
  108. rotate([-90, 0, 0])
  109. cylinder(d = endstop_pcb_hole, h = endstop_pcb_depth + 2);
  110. }
  111. translate([0, 0, endstop_pcb_height - endstop_pcb_switchpoint])
  112. rotate([0, -90, 0])
  113. cylinder(d = endstop_pcb_hole, h = endstop_pcb_switchpoint);
  114. }
  115. module endstop_mount_v1() {
  116. %color("yellow")
  117. translate([-endstop_pcb_mount_off_w, -endstop_pcb_depth - endstop_pcb_mount_off_d, endstop_pcb_mount_off_h])
  118. endstop_pcb();
  119. color("blue")
  120. difference() {
  121. cube([endstop_mount_width, endstop_mount_depth, 40]);
  122. for (i = [0, 1])
  123. translate([endstop_mount_width / 2, -1, 10 + 20 * i])
  124. rotate([-90, 0, 0])
  125. cylinder(d = motor_mount_hole_size, h = endstop_mount_depth + 2);
  126. }
  127. color("blue")
  128. difference() {
  129. union() {
  130. hull() {
  131. translate([-endstop_mount_slot_length, 0, 40 - endstop_mount_add_height])
  132. cube([endstop_mount_slot_length, endstop_mount_depth, endstop_mount_add_height]);
  133. for (i = [0, 1])
  134. translate([0, 0, endstop_pcb_height - endstop_pcb_hole_dist_y - i * endstop_pcb_hole_dist])
  135. translate([-endstop_pcb_mount_off_w, -endstop_pcb_mount_off_d, endstop_pcb_mount_off_h - endstop_mount_slot_width / 2])
  136. cube([endstop_mount_slot_length, endstop_mount_slot_depth, endstop_mount_slot_width]);
  137. }
  138. }
  139. translate([-endstop_pcb_mount_off_w, -endstop_pcb_depth - endstop_pcb_mount_off_d, endstop_pcb_mount_off_h])
  140. for (i = [0, 1])
  141. translate([endstop_pcb_hole_dist_x, -1, endstop_pcb_height - endstop_pcb_hole_dist_y - i * endstop_pcb_hole_dist])
  142. rotate([-90, 0, 0]) {
  143. cylinder(d = endstop_pcb_hole, h = endstop_pcb_depth + 20);
  144. translate([0, 0, 1 + endstop_pcb_depth + endstop_mount_slot_depth])
  145. cylinder(d = endstop_mount_nut_hole, h = 20, $fn = 6);
  146. }
  147. }
  148. }
  149. module endstop_mount_v2() {
  150. %color("yellow")
  151. translate([-endstop_pcb_mount_off_w, -endstop_pcb_depth - endstop_pcb_mount_off_d, endstop_pcb_mount_off_h])
  152. endstop_pcb();
  153. color("blue")
  154. difference() {
  155. cube([endstop_mount_width, endstop_mount_depth, 40]);
  156. for (i = [0, 1])
  157. translate([endstop_mount_width / 2, -1, 10 + 20 * i])
  158. rotate([-90, 0, 0])
  159. cylinder(d = motor_mount_hole_size, h = endstop_mount_depth + 2);
  160. }
  161. color("blue")
  162. difference() {
  163. union() {
  164. hull() {
  165. translate([-endstop_mount_slot_length, 0, 40 - endstop_mount_add_height])
  166. cube([endstop_mount_slot_length, endstop_mount_depth, endstop_mount_add_height]);
  167. translate([0, 0, endstop_pcb_height - endstop_pcb_hole_dist_y - endstop_pcb_hole_dist])
  168. translate([-endstop_pcb_mount_off_w, -endstop_pcb_mount_off_d, endstop_pcb_mount_off_h - endstop_mount_slot_width / 2])
  169. cube([endstop_mount_slot_length, endstop_mount_slot_depth, endstop_mount_slot_width]);
  170. }
  171. hull() {
  172. for (i = [0, 1])
  173. translate([0, 0, endstop_pcb_height - endstop_pcb_hole_dist_y - i * endstop_pcb_hole_dist])
  174. translate([-endstop_pcb_mount_off_w, -endstop_pcb_mount_off_d, endstop_pcb_mount_off_h - endstop_mount_slot_width / 2])
  175. cube([endstop_mount_slot_length, endstop_mount_slot_depth, endstop_mount_slot_width]);
  176. }
  177. }
  178. translate([-endstop_pcb_mount_off_w, -endstop_pcb_depth - endstop_pcb_mount_off_d, endstop_pcb_mount_off_h])
  179. for (i = [0, 1])
  180. translate([endstop_pcb_hole_dist_x, -1, endstop_pcb_height - endstop_pcb_hole_dist_y - i * endstop_pcb_hole_dist])
  181. rotate([-90, 0, 0]) {
  182. cylinder(d = endstop_pcb_hole, h = endstop_pcb_depth + 20);
  183. translate([0, 0, 1 + endstop_pcb_depth + endstop_mount_slot_depth])
  184. cylinder(d = endstop_mount_nut_hole, h = 20, $fn = 6);
  185. }
  186. }
  187. }
  188. module endstop_mount() {
  189. if (use_endstop_mount_v2) {
  190. endstop_mount_v2();
  191. } else {
  192. endstop_mount_v1();
  193. }
  194. }
  195. module dispenser_arm() {
  196. translate([0, dispenser_arm_tab_off, dispenser_arm_tab_hole_off])
  197. rotate([90, 0, 0])
  198. cylinder(d = dispenser_arm_dia, h = dispenser_arm_len);
  199. translate([0, dispenser_arm_tab_off, dispenser_arm_tab_hole_off - dispenser_arm_height])
  200. cylinder(d = dispenser_arm_dia, h = dispenser_arm_height);
  201. translate([-dispenser_arm_handle_width / 2, dispenser_arm_tab_off - dispenser_arm_len - dispenser_arm_handle_len + dispenser_arm_handle_overlap, dispenser_arm_tab_hole_off + dispenser_arm_dia / 2])
  202. cube([dispenser_arm_handle_width, dispenser_arm_handle_len, dispenser_arm_handle_height]);
  203. }
  204. module dispenser() {
  205. difference() {
  206. cylinder(d1 = dispenser_nozzle_end_dia_1, d2 = dispenser_nozzle_end_dia_2, h = dispenser_nozzle_end_length);
  207. translate([0, 0, -0.01])
  208. cylinder(d1 = dispenser_nozzle_end_dia_1 - dispenser_wall * 2, d2 = dispenser_nozzle_end_dia_2 - dispenser_wall * 2, h = dispenser_nozzle_end_length + 0.02);
  209. }
  210. translate([0, 0, dispenser_nozzle_end_length])
  211. difference() {
  212. cylinder(d1 = dispenser_nozzle_cap_dia_1, d2 = dispenser_nozzle_cap_dia_2, h = dispenser_nozzle_cap_height);
  213. translate([0, 0, -0.01])
  214. cylinder(d1 = dispenser_nozzle_cap_dia_1 - dispenser_wall * 2, d2 = dispenser_nozzle_cap_dia_2 - dispenser_wall * 2, h = dispenser_nozzle_cap_height + 0.02);
  215. }
  216. translate([0, 0, dispenser_nozzle_end_length + dispenser_nozzle_cap_height])
  217. difference() {
  218. cylinder(d = dispenser_nozzle_mid_dia, h = dispenser_nozzle_mid_height);
  219. translate([0, 0, -0.01])
  220. cylinder(d = dispenser_nozzle_mid_dia - dispenser_wall * 2, h = dispenser_nozzle_mid_height + 0.02);
  221. }
  222. translate([0, 0, dispenser_nozzle_end_length + dispenser_nozzle_cap_height + dispenser_nozzle_mid_height])
  223. difference() {
  224. cylinder(d = dispenser_nozzle_top_dia, h = dispenser_nozzle_top_height);
  225. translate([0, 0, -0.01])
  226. cylinder(d = dispenser_nozzle_top_dia - dispenser_wall * 2, h = dispenser_nozzle_top_height + 0.02);
  227. }
  228. translate([0, 0, dispenser_nozzle_end_length + dispenser_nozzle_cap_height + dispenser_nozzle_mid_height + dispenser_nozzle_top_height])
  229. difference() {
  230. cylinder(d1 = dispenser_mid_dia, d2 = dispenser_top_dia, h = dispenser_top_height);
  231. translate([0, 0, -0.01])
  232. cylinder(d1 = dispenser_mid_dia - dispenser_wall * 2, d2 = dispenser_top_dia - dispenser_wall * 2, h = dispenser_top_height + 0.02);
  233. }
  234. translate([0, -dispenser_top_dia / 2, dispenser_nozzle_end_length + dispenser_nozzle_cap_height + dispenser_nozzle_mid_height + dispenser_nozzle_top_height + dispenser_top_height])
  235. rotate([dispenser_handle_angle, 0, 0])
  236. translate([0, 0, -dispenser_handle_dia / 2])
  237. rotate([90, 0, 0])
  238. cylinder(d = dispenser_handle_dia, h = dispenser_handle_length);
  239. translate([0, dispenser_top_dia / 2 + dispenser_arm_handle_y, dispenser_nozzle_end_length + dispenser_nozzle_cap_height + dispenser_nozzle_mid_height + dispenser_nozzle_top_height + dispenser_top_height + dispenser_arm_handle_z])
  240. rotate([dispenser_arm_angle_bottom + (-anim_pos_extruder + 1) * (dispenser_arm_angle_top - dispenser_arm_angle_bottom), 0, 0])
  241. dispenser_arm();
  242. }
  243. //endstop_pcb();
  244. endstop_mount();
  245. //dispenser();