holzstopfen.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/usr/bin/env python
  2. from pync import *
  3. TOLR = 0.2
  4. ZFEED = 1000
  5. XYFEED = 5000
  6. XYFEED2 = 1000
  7. TD = 6 # Tool D
  8. TR = TD / 2.0
  9. def cpock(r, z, maxinc=TR,
  10. xyfeed=XYFEED, xyfeed2=XYFEED2, zfeed=ZFEED):
  11. c("Circular pocket: r=%f, z=%f, maxinc=%f, "
  12. "xyfeed=%f, xyfeed2=%f, zfeed=%f" %(
  13. r, z, maxinc,
  14. xyfeed, xyfeed2, zfeed))
  15. inc = r / ceil(r / maxinc)
  16. prev_r = 0
  17. cur_r = inc
  18. G1(z=z) | F(zfeed)
  19. G91()
  20. while 1:
  21. final_run = ge(cur_r, r)
  22. if final_run:
  23. G61()
  24. G1(x=cur_r-prev_r) | F(xyfeed2)
  25. G3(x=0, y=0, i=-cur_r, j=0) | F(xyfeed)
  26. if final_run:
  27. break
  28. prev_r = cur_r
  29. cur_r += inc
  30. G64(TOLR)
  31. G1(x=-cur_r)
  32. G90()
  33. def cpeg(x_center, r_start, r_end, z, maxinc=TR,
  34. xyfeed=XYFEED, xyfeed2=XYFEED2, zfeed=ZFEED):
  35. c("Circular peg: x_center=%f, r_start=%f, r_end=%f, z=%f, maxinc=%f, "
  36. "xyfeed=%f, xyfeed2=%f, zfeed=%f" %(
  37. x_center, r_start, r_end, z, maxinc,
  38. xyfeed, xyfeed2, zfeed))
  39. assert(ge(r_start, r_end))
  40. r_diff = r_start - r_end
  41. inc = r_diff / ceil(r_diff / maxinc) if r_diff else 0
  42. cur_r = r_start
  43. G0(x=r_start)
  44. G1(z=z) | F(zfeed)
  45. G91()
  46. final_run = le(cur_r, r_end)
  47. while 1:
  48. G2(x=0, y=0, i=-(cur_r-x_center), j=0) | F(xyfeed)
  49. if final_run:
  50. break
  51. prev_r = cur_r
  52. cur_r -= inc
  53. final_run = le(cur_r, r_end)
  54. if final_run:
  55. G61()
  56. G1(x=-inc) | F(xyfeed2)
  57. G64(TOLR)
  58. G90()
  59. G1(x=r_start)
  60. G64(TOLR)
  61. G0(z=25)
  62. S(2000) | M3 | F(XYFEED)
  63. bases = ((0, 0), ((34+TD+TD+1), 0))
  64. for base_x, base_y in bases:
  65. c("=== base_x=%f, base_y=%f ===" %(
  66. base_x, base_y))
  67. G0(x=base_x, y=base_y)
  68. if 1:
  69. c("-- Planfraesen --")
  70. G0(z=19)
  71. cpock(r=34/2+2+TR, z=10, maxinc=5)
  72. if 1:
  73. c("-- Tasche --")
  74. G1(z=10)
  75. cpock(r=16/2-TR, z=5, maxinc=5)
  76. if 1:
  77. c("-- Aussendurchmesser --")
  78. G0(z=11)
  79. cpeg(x_center=base_x,
  80. r_start=base_x+(34/2+1+TR),
  81. r_end=base_x+(25/2+TR),
  82. z=3)
  83. if 1:
  84. c("-- Freifraesen --")
  85. G0(x=base_x+(34/2+TR), z=3)
  86. cpeg(x_center=base_x,
  87. r_start=base_x+(34/2+TR),
  88. r_end=base_x+(34/2+TR),
  89. z=0.5,
  90. xyfeed=XYFEED2)
  91. M0() | M5
  92. G0(z=25)