Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 37fc484637
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 192 lines (164 sloc) 6.305 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
(in-package :gcode)

(defparameter *resolution* 15)
(defvar *round-steps* nil)
(defvar *cut-steps* nil)

(defun mill-rounded-edge (x1 y1 x2 y2 depth tool-diameter diameter &key (overlap 2))
  (let ((length (vector-length x1 y1 x2 y2))
(angle (vector-angle x1 y1 x2 y2)))
    (with-transform ((translation-matrix x1 y1))
      (with-transform ((rotation-matrix (- 360 angle)))
#+nil(mill-rounded-edge-normal length depth tool-diameter diameter
:overlap overlap)

(mill-rounded-edge-hack length tool-diameter)
))))

(defun mill-rounded-edge-normal (length depth tool-diameter
diameter &key (overlap 2))
   #+nil(goto-abs :z 2) ;; tool up
   #+nil(goto-abs :x 0 :y 0)
   #+nil(with-tool-down (depth)
(mill-abs :x length :y 0))
   
   (let* ((radius (/ diameter 2))
(steps (ceiling (/ length
(/ tool-diameter overlap))))
(move-by-step (/ length steps)))
     
     #+nil
     (format t "steps: ~A, move-by-step: ~A~%" steps move-by-step)
     
     (mill-abs :z *fly-height*)
     (goto-abs :x 0 :y 0)
     
     (loop for step from 0 to steps
for current-x = (* move-by-step step)
collect (mill-abs :z 1)
collect (goto-abs :x current-x
:y 0)
collect (loop for i from 0 to 90 by *resolution*
collect (mill-abs
:x current-x
:y (- radius (* radius (sin (deg-to-radians i))))
:z (- (* radius (cos (deg-to-radians i))) radius))))
     #+nil(mill-abs :z 2)
     #+nil(goto-abs :x length :y 0)
     ))

(defun mill-rounded-edge-hack (length tool-diameter)
  (mill-abs :z *fly-height*)
  (goto-abs :x 0 :y (/ tool-diameter 2))
  (with-tool-down (0.2)
    (mill-abs :x length :y (/ tool-diameter 2)))
  (mill-abs :z *fly-height*))

;;; *shiver*

(defparameter *overlap* 2)
(defparameter *step-width* 3.8)

(defun bridge-width ()
  (/ *step-width* 1.5))

(defun bridge-cut-rel (x y &key depth)
  (let ((x1 (orig-current-x))
(y1 (orig-current-y)))
    (unless depth
      (setf depth (- (tool-depth *current-tool*) 1.0)))
    (with-named-pass ("bridge-cut")
      (goto-abs :x x1 :y y1)
      (with-tool-down (depth)
(mill-rel :x x :y y)))))

(defun bridge-cut-abs (x y &key depth)
  (let ((x1 (orig-current-x))
(y1 (orig-current-y)))
    (unless depth
      (setf depth (- (tool-depth *current-tool*) 1.0)))
    (with-named-pass ("bridge-cut")
      (goto-abs :x x1 :y y1)
      (with-tool-down (depth)
(mill-abs :x x :y y)))))
  

(defun mill-bridge-rel (&key (x 0) (y 0))
  (bridge-cut-rel x y :depth (bridge-width))
  (tool-up)
  (goto-rel :x x :y y)
  (tool-down :depth *step-width*))

(defun mill-r (&optional (width *step-width*))
  (mill-rel :x width))
(defun mill-r- (&optional (width *step-width*))
  (mill-rel :x (- width (/ *tool-diameter* 2))))
(defun mill-r-- (&optional (width *step-width*))
  (mill-rel :x (- width *tool-diameter*)))
(defun mill-r+ (&optional (width *step-width*))
  (mill-rel :x (+ width (/ *tool-diameter* 2))))
(defun mill-r++ (&optional (width *step-width*))
  (mill-rel :x (+ width *tool-diameter*)))
(defun mill-bridge-r++ (&optional (width *step-width*))
  (mill-bridge-rel :x (+ width *tool-diameter*)))
  
(defun mill-l (&optional (width *step-width*))
  (mill-rel :x (- width)))
(defun mill-l- (&optional (width *step-width*))
  (mill-rel :x (- (- width (/ *tool-diameter* 2)))))
(defun mill-l-- (&optional (width *step-width*))
  (mill-rel :x (- (- width *tool-diameter*))))
(defun mill-l+ (&optional (width *step-width*))
  (mill-rel :x (- (+ width (/ *tool-diameter* 2)))))
(defun mill-l++ (&optional (width *step-width*))
  (mill-rel :x (- (+ width *tool-diameter*))))
(defun mill-bridge-l++ (&optional (width *step-width*))
  (mill-bridge-rel :x (- (+ width *tool-diameter*))))
  
(defun mill-u (&optional (width *step-width*))
  (mill-rel :y width))
(defun mill-u- (&optional (width *step-width*))
  (mill-rel :y (- width (/ *tool-diameter* 2))))
(defun mill-u-- (&optional (width *step-width*))
  (mill-rel :y (- width *tool-diameter*)))
(defun mill-u+ (&optional (width *step-width*))
  (mill-rel :y (+ width (/ *tool-diameter* 2))))
(defun mill-u++ (&optional (width *step-width*))
  (mill-rel :y (+ width *tool-diameter*)))
(defun mill-bridge-u++ (&optional (width *step-width*))
  (mill-bridge-rel :y (+ width *tool-diameter*)))
  
(defun mill-d (&optional (width *step-width*))
  (mill-rel :y (- width)))
(defun mill-d- (&optional (width *step-width*))
  (mill-rel :y (- (- width (/ *tool-diameter* 2)))))
(defun mill-d-- (&optional (width *step-width*))
  (mill-rel :y (- (- width *tool-diameter*))))
(defun mill-d+ (&optional (width *step-width*))
  (mill-rel :y (- (+ width (/ *tool-diameter* 2)))))
(defun mill-d++ (&optional (width *step-width*))
  (mill-rel :y (- (+ width *tool-diameter*))))
(defun mill-bridge-d++ (&optional (width *step-width*))
  (mill-bridge-rel :y (- (+ width *tool-diameter*))))

(defun mill-round (&key (x 0) (y 0))
  (let ((x1 (orig-current-x))
(y1 (orig-current-y)))
    (with-named-pass ("bridge-cut")
      (goto-abs :x x1 :y y1)
      (with-tool-down ((bridge-width))
(mill-rel :x x :y y)))
    
    (tool-up)
    (goto-rel :x x :y y)
    (tool-down :depth *step-width*)))

(defun s-mill-round-r (&optional (width *step-width*))
  (let* ((x1 (orig-current-x))
(y1 (orig-current-y))
(new-x (+ x1 width)))
    (with-named-pass ("rounding")
      (mill-rounded-edge x1 y1 new-x y1
*step-width* *tool-diameter* *tool-diameter* :overlap *overlap*))
    (mill-r)))

(defun s-mill-round-l (&optional (width *step-width*))
  (let* ((x1 (orig-current-x))
(y1 (orig-current-y))
(new-x (- x1 width)))
    (with-named-pass ("rounding")
      (mill-rounded-edge x1 y1 new-x y1
*step-width* *tool-diameter* *tool-diameter* :overlap *overlap*))
    (mill-l)))

(defun s-mill-round-u (&optional (width *step-width*))
  (let* ((x1 (orig-current-x))
(y1 (orig-current-y))
(new-y (+ y1 width)))
    (with-named-pass ("rounding")
      (mill-rounded-edge x1 y1 x1 new-y
*step-width* *tool-diameter* *tool-diameter* :overlap *overlap*))
    (mill-u)))

(defun s-mill-round-d (&optional (width *step-width*))
  (let* ((x1 (orig-current-x))
(y1 (orig-current-y))
(new-y (- y1 width)))
    (with-named-pass ("rounding")
      (mill-rounded-edge x1 y1 x1 new-y
*step-width* *tool-diameter* *tool-diameter* :overlap *overlap*))
    (mill-d)))

Something went wrong with that request. Please try again.