Advertisement
j0h

servo2VolumeKnob.scad

j0h
Sep 25th, 2023
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.27 KB | None | 0 0
  1. /**
  2. * Parametric servo arm generator for OpenScad
  3. * Générateur de palonnier de servo pour OpenScad
  4. *
  5. * Copyright (c) 2012 Charles Rincheval. All rights reserved.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * Last update :
  22. * https://github.com/hugokernel/OpenSCAD_ServoArms
  23. *
  24. * http://www.digitalspirit.org/
  25. */
  26.  
  27. $fn = 300;
  28.  
  29. /**
  30. * Clear between arm head and servo head
  31. * With PLA material, use clear : 0.3, for ABS, use 0.2
  32. */
  33. SERVO_HEAD_CLEAR = 0.1;
  34.  
  35. /**
  36. * Head / Tooth parameters
  37. * Futaba 3F Standard Spline
  38. * http://www.servocity.com/html/futaba_servo_splines.html
  39. *
  40. * First array (head related) :
  41. * 0. Head external diameter
  42. * 1. Head heigth
  43. * 2. Head thickness
  44. * 3. Head screw diameter
  45. *
  46. * Second array (tooth related) :
  47. * 0. Tooth count
  48. * 1. Tooth height
  49. * 2. Tooth length
  50. * 3. Tooth width
  51. */
  52. FUTABA_3F_SPLINE = [
  53. [5.92, 4, 1.1, 2.5],
  54. [25, 0.3, 0.7, 0.1]
  55. ];
  56.  
  57. module servo_futaba_3f(length, count) {
  58. servo_arm(FUTABA_3F_SPLINE, [length, count]);
  59. }
  60.  
  61. /**
  62. * If you want to support a new servo, juste add a new spline definition array
  63. * and a module named like servo_XXX_YYY where XXX is servo brand and YYY is the
  64. * connection type (3f) or the servo type (s3003)
  65. */
  66.  
  67. module servo_standard(length, count) {
  68. servo_futaba_3f(length, count);
  69. }
  70.  
  71. /**
  72. * Tooth
  73. *
  74. * |<-w->|
  75. * |_____|___
  76. * / \ ^h
  77. * _/ \_v
  78. * |<--l-->|
  79. *
  80. * - tooth length (l)
  81. * - tooth width (w)
  82. * - tooth height (h)
  83. * - height
  84. *
  85. */
  86. module servo_head_tooth(length, width, height, head_height) {
  87. linear_extrude(height = head_height) {
  88. polygon([[-length / 2, 0], [-width / 2, height], [width / 2, height], [length / 2,0]]);
  89. }
  90. }
  91.  
  92. /**
  93. * Servo head
  94. */
  95. module servo_head(params, clear = SERVO_HEAD_CLEAR) {
  96.  
  97. head = params[0];
  98. tooth = params[1];
  99.  
  100. head_diameter = head[0];
  101. head_height = head[1];
  102. //head_heigth
  103.  
  104. tooth_count = tooth[0];
  105. tooth_height = tooth[1];
  106. tooth_length = tooth[2];
  107. tooth_width = tooth[3];
  108.  
  109. % cylinder(r = head_diameter / 2, h = head_height + 1);
  110.  
  111. cylinder(r = head_diameter / 2 - tooth_height + 0.03 + clear, h = head_height);
  112.  
  113. for (i = [0 : tooth_count]) {
  114. rotate([0, 0, i * (360 / tooth_count)]) {
  115. translate([0, head_diameter / 2 - tooth_height + clear, 0]) {
  116. servo_head_tooth(tooth_length, tooth_width, tooth_height, head_height);
  117. }
  118. }
  119. }
  120. }
  121.  
  122. /**
  123. * Servo hold
  124. * - Head / Tooth parameters
  125. * - Arms params (length and count)
  126. */
  127. module servo_arm(params, arms) {
  128.  
  129. head = params[0];
  130. tooth = params[1];
  131.  
  132. head_diameter = head[0];
  133. head_height = head[1];
  134. head_thickness = head[2];
  135. head_screw_diameter = head[3];
  136.  
  137. tooth_length = tooth[2];
  138. tooth_width = tooth[3];
  139.  
  140. arm_length = arms[0];
  141. arm_count = arms[1];
  142.  
  143. /**
  144. * Servo arm
  145. * - length is from center to last hole
  146. */
  147. module arm(tooth_length, tooth_width, reinforcement_height, head_height, hole_count = 1) {
  148. arm_screw_diameter = 2;
  149.  
  150. difference() {
  151. union() {
  152. cylinder(r = tooth_width / 2, h = head_height);
  153.  
  154. linear_extrude(height = head_height) {
  155. polygon([
  156. [-tooth_width / 2, 0], [-tooth_width / 3, tooth_length],
  157. [tooth_width / 3, tooth_length], [tooth_width / 2, 0]
  158. ]);
  159. }
  160.  
  161. translate([0, tooth_length, 0]) {
  162. cylinder(r = tooth_width / 3, h = head_height);
  163. }
  164.  
  165. if (tooth_length >= 12) {
  166. translate([-head_height / 2 + 2, head_diameter / 2 + head_thickness - 0.5, -4]) {
  167. rotate([90, 0, 0]) {
  168. rotate([0, -90, 0]) {
  169. linear_extrude(height = head_height) {
  170. polygon([
  171. [-tooth_length / 1.7, 4], [0, 4], [0, - reinforcement_height + 5],
  172. [-2, - reinforcement_height + 5]
  173. ]);
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180.  
  181. // Hole
  182. for (i = [0 : hole_count - 1]) {
  183. //translate([0, length - (length / hole_count * i), -1]) {
  184. translate([0, tooth_length - (4 * i), -1]) {
  185. cylinder(r = arm_screw_diameter / 2, h = 10);
  186. }
  187. }
  188.  
  189. cylinder(r = head_screw_diameter / 2, h = 10);
  190. }
  191. }
  192.  
  193. difference() {
  194. translate([0, 0, 0.1]) {
  195. cylinder(r = head_diameter / 2 + head_thickness, h = head_height + 1);
  196. }
  197.  
  198. cylinder(r = head_screw_diameter / 2, h = 10);
  199.  
  200. servo_head(params);
  201. }
  202.  
  203. arm_thickness = head_thickness;
  204.  
  205. // Arm
  206. translate([0, 0, head_height]) {
  207. for (i = [0 : arm_count - 1]) {
  208. rotate([0, 0, i * (360 / arm_count)]) {
  209. arm(arm_length, head_diameter + arm_thickness * 2, head_height, 2);
  210. }
  211. }
  212. }
  213. }
  214.  
  215. module demo() {
  216. rotate([0, 0, 0])
  217. servo_standard(20, 0);
  218. }
  219. difference(){
  220. cylinder(20,4.1,4.1);//knob length, top dia ,bot dia
  221. difference(){
  222. cylinder(d=7, h=20);//d inner hole
  223. translate([0,50,53])
  224. cube(96, center=true);
  225. }
  226. }
  227. demo();
  228.  
  229.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement