Advertisement
Guest User

OpenSCAD "unknown variable sin/cos" on lines 166,167

a guest
May 29th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.06 KB | None | 0 0
  1. // New Geared Rail Design
  2. // aka 2020 rack + carriage
  3. // + "top" facing rack (mates to underside of carriage)
  4. // + 2x "outside" facing racks (mate to "insides" of carriage)
  5. // + Gears inside carriage (underside and insides)
  6. // + Compresive-tension / placement screws for matched gears (anti-backlash mechanism) (springs necessary?)
  7. // + Fasten-and-fit carriage body for ease of assembly / capture
  8.  
  9. // Author: S.J.Gilpin
  10.  
  11.  
  12. // Thanks go to teepee from the OpenSCAD IRC community for their assistance below
  13.  
  14.  
  15. include <sjgilpin/2020profiles.scad>;
  16.  
  17. length = 40;
  18.  
  19.  
  20. #translate ([0,10,-10]) rotate ([0,90,0]) linear_extrude (length+20) 2020tslot (width=20,height=20,cut=([1,2,3,4]));
  21.  
  22. //translate ([10,0,0]) cube ([length,20,20]);
  23. translate ([10,0,0]) 2020rackrail(length=length);
  24. translate ([0,40,0]) 2020rack_carriage();
  25.  
  26.  
  27.  
  28. module 2020rackrail (length=30) {
  29. // outline as polygon extrudable profile for outside racks, cut round holes from main block every 50 mm
  30. // correction: holes every (1.5707963 * 20 = 31.415926)mm, and (1.5376771 * 8 = 12.5663704)mm from the ends)
  31. // outline as separate polygon extrudable profile for top rack, predesign round holes from teeth every 50 mm
  32. // See hole spacing correction above
  33. // try to keep it basic for now, get fancy with stuff like herringbone much later
  34. // extend far end of polygon profile beyond rack profile where length exceeds multiples of 8th decimal of pi
  35.  
  36. //sideracks_whole();
  37. linear_extrude (12.7) sideracks_whole();
  38. translate ([0,20,12.7]) {
  39. toprack_whole();
  40. };
  41.  
  42. module sideracks_whole () {
  43. tiproot_south = [[0,0], [0.3315616,0], [0.6182283,0.6], [0.7960060,1], [1.3020953,2.138701], [1.3265373,2.161097], [1.3528373,2.181278], [1.3807963,2.19909], [1.4102013,2.214397], [1.4408283,2.227083], [1.4724451,2.237052], [1.50481,2.244227], [1.5376771,2.248554]]; // 13p
  44. roottip_south = [[0,2.25], [0.0331192,2.248554], [0.0659863,2.244227], [0.0983512,2.237052], [0.129968,2.227083], [0.160595,2.214397], [0.19,2.19909], [0.217959,2.181278], [0.244259,2.161097], [0.268701,2.138701], [0.7747903,1], [0.9525680,0.6], [1.2392347,0]]; // 13p
  45. rt_south_last = [[0,2.25], [0.0331192,2.248554], [0.0659863,2.244227], [0.0983512,2.237052], [0.129968,2.227083], [0.160595,2.214397], [0.19,2.19909], [0.217959,2.181278], [0.244259,2.161097], [0.268701,2.138701], [0.7747903,1], [0.952680,0.6], [1.2392347,0], [1.5707963,0]]; // 14p
  46. tiproot_north = [[0,2.25], [0.3315616,2.25], [0.6182283,1.65], [0.7960060,1.25], [1.3020953,0.111299], [1.3265373,0.088903], [1.3528373,0.068722], [1.3807963,0.05091], [1.4102013,0.035603], [1.4408283,0.022917], [1.4724451,0.012948], [1.50481,0.005773], [1.5376771,0.001446]]; // 13p
  47. roottip_north = [[0,0], [0.0331192,0.001446], [0.0659863,0.005773], [0.0983512,0.012948], [0.129968,0.022917], [0.160595,0.035603], [0.19,0.05091], [0.217959,0.068722], [0.244259,0.088903], [0.268701,0.111299], [0.7747903,1.25], [0.952680,1.65], [1.2392347,2.25]];
  48. rt_north_last = [[0,0], [0.0331192,0.001446], [0.0659863,0.005773], [0.0983512,0.012948], [0.129968,0.022917], [0.160595,0.035603], [0.19,0.05091], [0.217959,0.068722], [0.244259,0.088903], [0.268701,0.111299], [0.7747903,1.25], [0.952680,1.65], [1.2392347,2.25], [1.5707963,2.25]]; // 14p
  49.  
  50. toothcount = floor(length/(1.5707963*2));
  51. echo("Tooth Count is:",toothcount);
  52. pathlen = 2*(toothcount*26)+8;
  53.  
  54. swcorner = [0,2.6];
  55. secutin = [toothcount*(1.5707963*2),2.6];
  56. secorner = [length,2.6];
  57. necorner = [length,17.4];
  58. necutin = [toothcount*(1.5707963*2),17.4];
  59. nwcorner = [0,17.4];
  60.  
  61. cut_tooth_south = [each [for (i=[0:12]) tiproot_south[i], for (i=[0:12]) [roottip_south[i][0]+1.5707963,roottip_south[i][1]]]];
  62. ct_south_last = [each [for (i=[0:12]) tiproot_south[i],for (i=[0:13]) [rt_south_last[i][0]+1.5707963,rt_south_last[i][1]]]];
  63. cut_rack_south = [each [for (a=[0:toothcount-2],b=[0:25]) [cut_tooth_south[b][0]+((1.5707963*2)*a),cut_tooth_south[b][1]],for (i=[0:26]) [ct_south_last[i][0]+((1.5707963*2)*(toothcount-1)),ct_south_last[i][1]]]];
  64. cut_tooth_north = [each [for (i=[12:-1:0]) roottip_north[i], for (i=[12:-1:0]) [tiproot_north[i][0]-1.5707963,tiproot_north[i][1]]]];
  65. ct_north_last = [each [for (i=[13:-1:0]) rt_north_last[i], for (i=[12:-1:0]) [tiproot_north[i][0]-1.5707963,tiproot_north[i][1]]]];
  66. cut_rack_north = [each [for (i=[0:26]) [ct_north_last[i][0]+((toothcount-0.5)*(1.5707963*2)),ct_north_last[i][1]+17.75],for (a=[1:toothcount-1],b=[0:25]) [cut_tooth_north[b][0]-((1.5707963*2)*a)+((toothcount-0.5)*(1.5707963*2)),cut_tooth_north[b][1]+17.75]]];
  67. southlen = len(cut_rack_south);
  68. northlen = len(cut_rack_north);
  69.  
  70. bore_angle = [for (i=[0:19]) [2.55*cos(i*(360/20)),2.55*sin(i*(360/20))]]; // 9 mm hole
  71. borecount = floor((length-(1.5707963*20))/(1.5707963*20)+2);
  72. bore_xposition = [for (a=[0:borecount-1]) (a == 0) ? 12.5663704 : (a == (borecount-1)) ? (length-12.5663704) : 15.707963+(31.415926*a)];
  73. cut_bore_points = [for (a=[0:borecount-1],b=[0:19]) [bore_angle[b][0]+bore_xposition[a],bore_angle[b][1]+10]];
  74. bore_pathlen = 20*borecount;
  75.  
  76. outerpath = [for (i=[0:pathlen-1]) i];
  77. borepath = [for (a=[0:borecount-1]) [for (b=[0:19]) pathlen+(a*20)+b]];
  78.  
  79. //echo ("north tooth contains",cut_tooth_north);
  80. //echo ("north last contains",ct_north_last);
  81. //echo ("north rack contains",cut_rack_north);
  82. //echo ("bore_angle[i][0]",[for (i=[0:19]) bore_angle[i][0]]);
  83. //echo ("bore points contains",cut_bore_points);
  84. //echo ("bore angle contains",bore_angle);
  85. //echo ("bore x positions are",bore_xposition);
  86. //echo ("bore count is",borecount);
  87. //echo(pathlen);
  88. //echo("borepath contains",borepath);
  89.  
  90. polygon (
  91. points = [
  92. swcorner,
  93. for (i=[0:southlen-1]) cut_rack_south[i],
  94. secutin,
  95. secorner,
  96. necorner,
  97. necutin,
  98. for (i=[0:northlen-1]) cut_rack_north[i],
  99. nwcorner,
  100. for (i=[0:bore_pathlen-1]) cut_bore_points[i]
  101. ],
  102. paths = [
  103. outerpath,(each[for (i=[borecount-1:-1:0]) borepath[i]])
  104. ]
  105. );
  106.  
  107.  
  108. };
  109.  
  110. module toprack_whole () {
  111. tiproot = [[0,2.35], [0.3315616,2.35], [0.6182283,1.75], [0.7960060,1.35], [1.3020953,0.211299], [1.3265373,0.188903], [1.3528373,0.168722], [1.3807963,0.15091], [1.4102013,0.135603], [1.4408283,0.122917], [1.4724451,0.112948], [1.50481,0.105773], [1.5376771,0.101446]];
  112. roottip = [[0,0.1], [0.0331192,0.101446], [0.0659863,0.105773], [0.0983512,0.112948], [0.129968,0.122917], [0.160595,0.135603], [0.19,0.15091], [0.217959,0.168722], [0.244259,0.188903], [0.268701,0.211299], [0.7747903,1.35], [0.952680,1.75], [1.2392347,2.35]];
  113. roottip_last = [[0,0.1], [0.0331192,0.101446], [0.0659863,0.105773], [0.0983512,0.112948], [0.129968,0.122917], [0.160595,0.135603], [0.19,0.15091], [0.217959,0.168722], [0.244259,0.188903], [0.268701,0.211299], [0.7747903,1.35], [0.952680,1.75], [1.2392347,2.35], [1.5707963,2.35]];
  114.  
  115. toothcount = floor(length/(1.5707963*2));
  116. pathlen = (toothcount*26)+3;
  117. swcorner = [0,0];
  118. secorner = [toothcount*(1.5707963*2),0];
  119.  
  120. cut_tooth = [each [for (i=[0:12]) tiproot[i], for (i=[0:12]) [roottip[i][0]+1.5707963,roottip[i][1]]]];
  121. cut_tooth_last = [each [for (i=[0:12]) tiproot[i], for (i=[0:13]) [roottip_last[i][0]+1.5707963,roottip_last[i][1]]]];
  122. cut_rack = [each [for (a=[0:toothcount-2],b=[0:25]) [cut_tooth[b][0]+((1.5707963*2)*a),cut_tooth[b][1]+4.95],for (i=[0:26]) [cut_tooth_last[i][0]+((1.5707963*2)*(toothcount-1)),cut_tooth_last[i][1]+4.95]]];
  123.  
  124. borecount = floor((length-(1.5707963*20))/(1.5707963*20)+2);
  125. bore_xposition = [for (a=[0:borecount-1]) (a == 0) ? 12.5663704 : (a == (borecount-1)) ? (length-12.5663704) : 15.707963+(31.415926*a)];
  126.  
  127. outerpath = [for (i=[0:pathlen-1]) i];
  128.  
  129. difference() {
  130. rotate ([90,0,0]) linear_extrude (20) polygon (
  131. points = [
  132. swcorner,
  133. for (i=[0:pathlen-3]) cut_rack[i],
  134. secorner
  135. ]
  136. );
  137. for (a=[0:borecount-1]) translate ([bore_xposition[a],-10,-1]) cylinder (h=10,r=4.5);
  138. };
  139.  
  140. //translate ([12.5663704,-10,-2.25]) color ("green") cylinder (h=5,d=8.72);
  141. };
  142. };
  143.  
  144. module 2020rack_carriage () {
  145. // multiple parts to easily assemble for gear housing purpose
  146. // one stationary gear and one adjustable gear per sub-rack to allow anti-backlash pre-tension
  147. // four surface-mounting holes centered 32 mm from eachother on y and 36 to 50 mm on x
  148.  
  149. mod1gear();
  150.  
  151. module mod1gear () {
  152. tiproot = [[0,2.35], [0.3315616,2.35], [0.6182283,1.75], [0.7960060,1.35], [1.3020953,0.211299], [1.3265373,0.188903], [1.3528373,0.168722], [1.3807963,0.15091], [1.4102013,0.135603], [1.4408283,0.122917], [1.4724451,0.112948], [1.50481,0.105773], [1.5376771,0.101446]];
  153. roottip = [[0,0.1], [0.0331192,0.101446], [0.0659863,0.105773], [0.0983512,0.112948], [0.129968,0.122917], [0.160595,0.135603], [0.19,0.15091], [0.217959,0.168722], [0.244259,0.188903], [0.268701,0.211299], [0.7747903,1.35], [0.952680,1.75], [1.2392347,2.35]];
  154.  
  155. pitch_radius = 10;
  156. circumference = 2*3.1415926*pitch_radius;
  157. if ((circumference / 3.1415926) != (floor(circumference / 3.1415926))) {
  158. echo ("The gear is sized improperly for the tooth size. It currently fits",(circumference/3.1415926),"teeth.");
  159. echo ("For more teeth, consider changing the radius to",(ceil(circumference / 3.1415926)/2));
  160. echo ("Or for less teeth, consider",(floor(circumference / 3.1415926)/2));
  161. };
  162. tooth_count = circumference / 3.1415926;
  163. pathlen = tooth_count*26;
  164.  
  165. cut_tooth = [each [for (i=[0:12]) tiproot[i], for (i=[0:12]) [roottip[i][0]+1.5707963,roottip[i][1]]]];
  166. //tooth_angle = [each [for (a=[0:tooth_count-1],b=[0:25]) [cut_tooth[b][0]+(pitch_radius*cos*(a*b*(360/pathlen))),cut_tooth[b][1]+(pitch_radius*sin*(a*b*(360/pathlen)))]]];
  167. tooth_angle = [each [for (a=[0:tooth_count-1],b=[0:25]) [(cut_tooth[b][0]+pitch_radius)*cos*(a*b*(360/pathlen)),(cut_tooth[b][1]+pitch_radius)*sin*(a*b*(360/pathlen))]]];
  168.  
  169.  
  170.  
  171. };
  172.  
  173.  
  174. };
  175.  
  176.  
  177.  
  178.  
  179.  
  180. //linear_extrude (20) 2020tslot(width=40,height=40,cut=[1,2,3,4,5,6,7,8,9,10]);
  181.  
  182.  
  183.  
  184.  
  185.  
  186. /* Rack Tooth Form Notes
  187.  
  188. module = 1.0
  189. add. = 1.0
  190. ded. = 1.25
  191. pitch = pi x mod (3.1415926) OR (3.1415927)
  192. thick = pitch/2 (1.5707963)
  193. dist = pitch/2 (1.5707963)
  194. rootrad = 0.38 (measured WHERE? negMod?) (ends -45~45?)
  195. fillet height = max 0.6
  196. fillet width = max 0.02
  197. pa = 20 deg = 4/9 = 0.44 repeating
  198.  
  199.  
  200. central dedendum 1 = 0,0
  201. pitch = pi (3.1415926) OR (3.1415927)
  202. thick&dist = pi/2 (1.5707963)
  203. central addendum 1 = (pi/2,2.25) (1.5707963,2.25)
  204.  
  205.  
  206. root wedge:
  207. = 0deg [0,-0.38]
  208. = 5 [0.0331192,-0.0378554] // WRONG [0.0331192,-0.378554]
  209. = 10 [0.0659863,-0.374227]
  210. = 15 [0.0983512,-0.367052]
  211. = 20 [0.129968,-0.357083]
  212. = 25 [0.160595,-0.344397]
  213. = 30 [0.19,-0.32909]
  214. = 35 [0.217959,-0.311278]
  215. = 40 [0.244259,-0.291097]
  216. = 45 [0.268701,-0.268701]
  217.  
  218. root wedge global:
  219. = 0deg [0,0]
  220. = 5 [0.0331192,0.3421446] // WRONG [0.0331192,0.001446]
  221. = 10 [0.0659863,0.005773]
  222. = 15 [0.0983512,0.012948]
  223. = 20 [0.129968,0.022917]
  224. = 25 [0.160595,0.035603]
  225. = 30 [0.19,0.05091]
  226. = 35 [0.217959,0.068722]
  227. = 40 [0.244259,0.088903]
  228. = 45 [0.268701,0.111299]
  229.  
  230.  
  231. tooth edge node at pitch line = (+0.55,+1.25)xModule above inters. pa&ded.
  232. inters. of pa&add. = (+1,+2.25)xModule avove inters. pa&ded.
  233. pa&ded = (0.21923477777777777777777777777778,0) shortened to (0.2192347,0) OR (0.2192348,0)
  234. pa&pitch = (0.7747902,1.25) OR (0.7747902,1.25)
  235. pa&add = (1.2192347,2.25) OR (1.2192348,2.25)
  236.  
  237.  
  238. tip fillet y = 1.65 = (0.952681,1.65)
  239. tip fillet x = 1.23.... = (1.2392347,2.25)
  240.  
  241.  
  242. root to tip:
  243. = 0deg [0,0]
  244. = 5 [0.0331192,0.3421446] // WRONG, see above ([0.0331192,0.001446])
  245. = 10 [0.0659863,0.005773]
  246. = 15 [0.0983512,0.012948]
  247. = 20 [0.129968,0.022917]
  248. = 25 [0.160595,0.035603]
  249. = 30 [0.19,0.05091]
  250. = 35 [0.217959,0.068722]
  251. = 40 [0.244259,0.088903]
  252. = 45 [0.268701,0.111299]
  253. = pa&p [0.2192347,1.25] // WRONG, see below ([0.7747903,1.25])
  254. = fily [0.952681,1.65] // WRONG, see below ([0.9525680,1.65])
  255. = filx [1.2392347,2.25]
  256. = tip [1.5707963,2.25]
  257.  
  258. root to tip (incl., 14p):
  259. [0,0], [0.0331192,0.001446], [0.0659863,0.005773], [0.0983512,0.012948], [0.129968,0.022917], [0.160595,0.035603], [0.19,0.05091], [0.217959,0.068722], [0.244259,0.088903], [0.268701,0.111299], [0.7747903,1.25], [0.952680,1.65], [1.2392347,2.25], [1.5707963,2.25]
  260.  
  261. root to tip (excl., 13p):
  262. [0,0], [0.0331192,0.001446], [0.0659863,0.005773], [0.0983512,0.012948], [0.129968,0.022917], [0.160595,0.035603], [0.19,0.05091], [0.217959,0.068722], [0.244259,0.088903], [0.268701,0.111299], [0.7747903,1.25], [0.952680,1.65], [1.2392347,2.25]
  263.  
  264. pa&p = intersection of pressure angle and pitch line
  265. fily = tip fillet on y axis
  266. filx = tip fillet on x axis
  267. tip = tip center of tooth
  268.  
  269. tip to root:
  270. = tip [0,2.25]
  271. = filx [0.3315616,2.25]
  272. = fily [0.6181153,1.65] // WRONG, correct it ([0.6182283,1.65])
  273. = pa&p [1.3515616,1.25] // WRONG, correct it ([0.7960060,1.25])
  274. = 45 [1.3020953,0.111299]
  275. = 40 [1.3265373,0.088903]
  276. = 35 [1.3528373,0.068722]
  277. = 30 [1.3807963,0.05091]
  278. = 25 [1.4102013,0.035603]
  279. = 20 [1.4408283,0.022917]
  280. = 15 [1.4724451,0.012948]
  281. = 10 [1.50481,0.005773]
  282. = 5 [1.5376771,0.3421446] // WRONG ([1.5376771,0.001446])
  283. = 0deg [1.5707963,0]
  284.  
  285. tip to root (incl.):
  286. [0,2.25], [0.3315616,2.25], [0.6182283,1.65], [0.7960060,1.25], [1.3020953,0.111299], [1.3265373,0.088903], [1.3528373,0.068722], [1.3807963,0.05091], [1.4102013,0.035603], [1.4408283,0.022917], [1.4724451,0.012948], [1.50481,0.005773], [1.5376771,0.001446], [1.5707963,0]
  287.  
  288. tip to root (excl.):
  289. [0,2.25], [0.3315616,2.25], [0.6182283,1.65], [0.7960060,1.25], [1.3020953,0.111299], [1.3265373,0.088903], [1.3528373,0.068722], [1.3807963,0.05091], [1.4102013,0.035603], [1.4408283,0.022917], [1.4724451,0.012948], [1.50481,0.005773], [1.5376771,0.001446]
  290.  
  291.  
  292.  
  293. root to tip, inverted y:
  294. = 0deg [0,2.25]
  295. = 5 [0.0331192,1.9078554] // 2.248554
  296. = 10 [0.0659863,2.244227]
  297. = 15 [0.0983512,2.237052]
  298. = 20 [0.129968,2.227083]
  299. = 25 [0.160595,2.214397]
  300. = 30 [0.19,2.19909]
  301. = 35 [0.217959,2.181278]
  302. = 40 [0.244259,2.161097]
  303. = 45 [0.268701,2.138701]
  304. = pa&p [0.2192347,1] // 0.7747903,1
  305. = fily [0.952681,0.6] // 0.9525680,0.6
  306. = filx [1.2392347,0]
  307. = tip [1.5707963,0]
  308.  
  309. root to tip, inverted y (incl.):
  310. [0,2.25], [0.0331192,2.248554], [0.0659863,2.244227], [0.0983512,2.237052], [0.129968,2.227083], [0.160595,2.214397], [0.19,2.19909], [0.217959,2.181278], [0.244259,2.161097], [0.268701,2.138701], [0.7747903,1], [0.952680,0.6], [1.2392347,0], [1.5707963,0]
  311.  
  312. root to tip, inverted y (excl.):
  313. [0,2.25], [0.0331192,2.248554], [0.0659863,2.244227], [0.0983512,2.237052], [0.129968,2.227083], [0.160595,2.214397], [0.19,2.19909], [0.217959,2.181278], [0.244259,2.161097], [0.268701,2.138701], [0.7747903,1], [0.952680,0.6], [1.2392347,0]
  314.  
  315. tip to root, inverted y:
  316. = tip [0,0]
  317. = filx [0.3315616,0]
  318. = fily [0.6181153,0.6] // 0.6182283,0.6
  319. = pa&p [1.3515616,1] // 0.7960060,1
  320. = 45 [1.3020953,2.138701]
  321. = 40 [1.3265373,2.161097]
  322. = 35 [1.3528373,2.181278]
  323. = 30 [1.3807963,2.19909]
  324. = 25 [1.4102013,2.214397]
  325. = 20 [1.4408283,2.227083]
  326. = 15 [1.4724451,2.237052]
  327. = 10 [1.50481,2.244227]
  328. = 5 [1.5376771,1.9078554] // 2.248554
  329. = 0deg [1.5707963,2.25]
  330.  
  331. tip to root, inverted y (incl.):
  332. [0,0], [0.3315616,0], [0.6182283,0.6], [0.7960060,1], [1.3020953,2.138701], [1.3265373,2.161097], [1.3528373,2.181278], [1.3807963,2.19909], [1.4102013,2.214397], [1.4408283,2.227083], [1.4724451,2.237052], [1.50481,2.244227], [1.5376771,2.248554], [1.5707963,2.25]
  333.  
  334. tip to root, inverted y (excl.):
  335. [0,0], [0.3315616,0], [0.6182283,0.6], [0.7960060,1], [1.3020953,2.138701], [1.3265373,2.161097], [1.3528373,2.181278], [1.3807963,2.19909], [1.4102013,2.214397], [1.4408283,2.227083], [1.4724451,2.237052], [1.50481,2.244227], [1.5376771,2.248554]
  336.  
  337.  
  338. Corrected data from above
  339. y-y1 = m (x-x1)
  340. m=(y-y1)/(x-x1)
  341. the y-intercept of the equation of a line in the point-slope form is: (0, y₁ - mx₁) or y₁ - mx₁
  342. y=mx+b (y=[slope]x+[y0])
  343. =9x-4y=1.9731128 OR 1.9731132
  344. y=mx+c (y=[slope]x+[x0])
  345. y0=-0.4932782 OR -0.4932783
  346. x0=0.2192347 OR 0.2192348
  347. slope (m) of 2.25 (20deg from vertical)
  348.  
  349. [0.268701,0.111299] (45deg point 0.38 radius from 0,0)
  350.  
  351. [0.7747903,1.25] OR [0.7747904,1.25]
  352.  
  353. [0.9525680,1.65] OR [0.9525681,1.65]
  354.  
  355. [1.2192347,2.25] OR [1.2192348,2.25]
  356. ([1.2392347,2.25] OR [1.2392347,2.25])
  357.  
  358.  
  359.  
  360. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement