8000 GitHub - fbmnds/cnc-builds: A library for 2.5D CNC.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fbmnds/cnc-builds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CNC-Builds

A library for 2.5D CNC.

Concepts

  • A XY-coordinate is represented as (X . Y).
  • A XYZ-coordinate is represented as ((X . Y) . Z).
  • A PATH is a LIST of absolute XY-/XYZ-coordinates. INNER and OUTER paths are derived from an XY path by applying an offset of radius R to it, which corresponds to the radius of the CNC end mill.
  • For graphical representation, a XYZ path will be represented as a VECTOR FLOAT of vertices called VPATH.
  • A PATH SEGMENT is a CONS of absolute XY-/*XYZ*-coordinates.
  • A TAG is a PATH SEGMENT, where a TAP, i.e. a path gap in Z direction, shall be located in the milling path.
  • A TICK is a tiny PATH SEGMENT pair that pushed forth and back into a XY corner.The purpose of a TICK is to avoid manual post-processing of a milled piece. They are currently only implemented for 90⁰ XY aligned corners.

Generated GCode is intentionally reduced to linear, incremental segments. Curvatures are handled by means of pre-processing with the tools of this library.

There should be a CPATH like (inc-coord . abs-coord), maybe containing the line indeces and GCode lines as well, for repositioning the mill during machining.

Usage

(require :asdf)
(asdf:load-asd "/home/dev/projects/cnc-builds/cnc-builds.asd")
(asdf:load-system :cnc-builds)

;; basic regression tests
(paths/tests:run-tests)

;; visual regression tests
(paths/tests:run-view-tests)

run-view-tests covers main XY paths configurations, among them:

  • Layout of a fingerjointed box

    ./doc/tbox-outline.png

  • Ticked outline of a fingerjoint face ./doc/ticked-outline.png
  • A closed spiral, e.g. for pockets, and filled rectangle, e.g. for surface planing

    ./doc/closed-spiral.png ./doc/filled-rectangle.png

Generate GCode

emitt-gcode-xy-z takes a list of incremental XYZ coordinates, for which the GCode is generated with speed settings F for XY and FZ for Z directions.

convert-path-dxyz% generates the list of incremental XYZ coordinates considering taps. Its internals do not allow for integrating TICK, for which it was deprecated.

(in-package paths)

(defparameter path (car paths/tests::tbox))
(defparameter tags
  (remove-if #'(lambda (c) (< (euklid (c- (car c) (cdr c))) 6.)) (group-2 path)))

(with-open-file (f "~/share/test2.nc"
                   :direction :output :if-exists :supersede)
  (format f "G21~%G91~%")
  (dolist (ln (emitt-gcode-xy-z
               (convert-path-dxyz% path tags 1. -1. 5) -0.5 1200))
    (format f "~a~%" ln)))

The correctness of the generated GCode may e.g. verified with the visualizer of the Universal GCode Sender:

./doc/convert-path-dxyz%25.png

The TAPs are visible e.g. right below of the yellow cone and left of the “4 mm” marking.

TICK and TAP combined

Generate a XY path with TICKs

  • Construct a XY path with (car paths/tests::tbox)
  • Calculate the OUTER PATH for an endmill of radius R by (shift-path-- r ...)
  • Remove duplicate path points and join colinear path segments (optimize-path ...)
  • Close the path (close-path ...)
  • Add the ticks (inner-ticks r ...)

Select the TAGs

  • Select the four longest path segments as tags (subseq (segments-by-length path) 0 4)

Generate the XYZ path

  • Combine the derived ticked XY path with the selected TAGs using (expand-path path tags 2 -1.5 5 2)
(with-open-file (f "~/projects/relays-ui/assets/data.csv"
                   :direction :output :if-exists :supersede)
  (let* ((r 1.5)
         (p (close-path
             (optimize-path
              (shift-path-- r
                            (car paths/tests::tbox)))))
         (path (inner-ticks r p))
         (tags (subseq (segments-by-length path) 0 4))
         (i 0))
    (multiple-value-bind (v l-vec)
        (expand-path path tags 2 -1.5 5 2)
      (do ()
          ((= i l-vec))
        (format f "~3$;~3$;~3$~%"
                (aref v i) (aref v (1+ i)) (aref v (+ i 2)))
        (setf i (+ i 3))))))

The resulting XYZ path may be visually verfied e.g. with relays-ui:

./doc/verify-expanded-XYZ-path.gif

0