Giter Site home page Giter Site logo

lathecode's Introduction

lathecode

Text format for lathe parts and other objects with circular symmetry. Defines stock dimensions and substractions that should be made from it right-to-left just like a part is processed in a typical lathe. Allows to specify tools, pass depths and speeds. Supports conversion to GCode and STL.

Try it in the online editor.

The shape of the object is defined in segments. Each segment can be straight, angled, or circular, and its position is relative to the segment before it. For example, in lathecode, a simple cylinder is defined in one segment. A cylinder with a length of 7mm and a diameter of 6mm is described as:

L7 D6
L7 D6

A cylinder with a shoulder would be described in two segments, essentially defining two cylinders one after the other. For example:

L2 D4
L7 D6

This description represents an object with an outer diameter of 6mm, a total length of 2 + 7 = 9mm, and a shoulder on the right side 2mm wide and 1mm deep.

L2 D4 L7 D6

Stock

Stock size should be specified in the first line via radius or diameter e.g. STOCK D10 and STOCK R5 both declare the stock do have a diameter of 10mm. When stock is not specified, part maximum diameter is taken as stock diameter.

Cones

Instead of specifying diameter as D, specify diameter-start as DS and diameter-end as DE - or use radiuses as RS and RE.

; specify start and end diameter or radius
; MT2 to B16 arbor can be specified like
DEPTH CUT1
L80 DS14.9 DE17.78
L2 DS17.78 DE15.733; spacer
L24 DS15.733 DE14.5

image

Spheres

; sphere with a diameter of 10mm
L5 DS0 DE10 CONV
L5 DS10 DE0 CONV

image

Ellipses

; whirlgig
L1 DS0 DE2 CONV
L14 DS2 DE20 CONC
L0.5 DS20 DE21 CONV
L0.5 DS21 DE20 CONV
L8 DS20 DE2 CONC
L3.1 D2

image

Tools

Tool is assumed to be zeroed on the centerline, touching the stock from the right.

To use a standard cut-off tool e.g. MGMN200, specify TOOL RECT R0.2 L2 where R stands for the corner radius and L defines the width of the tool.

If you use a round insert like RPMT10, define that with TOOL ROUND R5 where R stands for corner radius.

To use a tool with a nose angle e.g. DCGT 070202, specify the tool radius, edge length, rotation and nose angle as follows:

TOOL ANG R0.2 L7.75 A30 NA55

See this tool table for common inserts and ready-to-use lathecode TOOL lines.

Depth of cut and finish pass

Default pass depth is 0.5mm and can be changed to e.g. 1mm. Default finish pass is 0.1mm.

DEPTH CUT1 FINISH0.2

Feeds and speeds

Default cutting speed is 50mm/min, parting speed 10mm/min, move speed 200mm/min. This can be adjusted with a FEED line:

FEED MOVE200 PASS50 PART10 ; speeds mm/min

Batch processing

You can define and cut more than one part:

STOCK D20

L5 R5
L3 R9
L3

L5 R5
L3 R9
L3

L5 R5
L3 R9
L3

image

For developers

If you'd like to edit the online editor code e.g. to modify the online editor, use npm run dev for local runs, npm test to run tests and npm run build to build the docs/index.html all-in-one editor webpage.

PEG.js grammar

start =
comment* units?
comment* stock?
comment* tool?
comment* depth?
comment* feed?
(comment* lathe)*
(comment* inside (comment* lathe)+)?
comment*

units = "UNITS" spaces unitType comment
unitType = "MM" / "CM" / "M" / "FT" / "IN"

stock = "STOCK" spaces stockParams comment
stockParams = ("R" / "D") float ("A" float)?

tool = "TOOL" spaces toolType spaces toolParams comment
toolType = "RECT" / "ROUND" / "ANG"
toolParams =
("R" float)?
("L" float)? // length
("H" float)? // height
("A" float)? // angle at which the tool is rotated CCW, default 0
("NA" float)? // nose angle for ANG tools

depth = "DEPTH" spaces depthParams comment
depthParams = ("CUT" float)? ("FINISH" float)?

feed = "FEED" spaces feedParams comment
feedParams = ("MOVE" float)? ("PASS" float)? ("PART" float)?

inside = "INSIDE" comment

lathe =
"L" float comment /
"L" float ("D" / "R") float comment /
"L" float ("DS" / "RS") float ("DE" / "RE") float curveType? comment
curveType = "CONV" / "CONC"

comment = spaces a:(";" (!eol .)*)? eol { return text().substring(1).trim() }
float = digits ("." digits)? spaces { return parseFloat(text()); }
digits = digit+
digit = [0-9]
spaces = space* { return null }
space = " "
eol = ("\r")? "\n"

lathecode's People

Contributors

kachurovskiy avatar fmw626 avatar

Stargazers

 avatar Sönke J. Peters avatar René Aguirre avatar Falkoni avatar  avatar  avatar  avatar  avatar  avatar Bob Ross avatar

Watchers

 avatar  avatar  avatar

lathecode's Issues

[Bug] Local Storage issue

At the moment when you click more under the lathe code to be able to save and load to local storage it will show anything in local storage in the list. This could include local storage from plugins and extensions etc.

To fix this I think maybe the names in local storage should be prefixed with latheCode_{name of save}

And when loading the page iterate only over those that has latheCode_ prefix.

Tool shapes

Loving the tool so far it makes designing gcode an absolute breeze.

However my best tools are actually diamond shaped, I use ground sharp inserts designed for aluminium. But they work great on everything.

But with latheCode I can only define a rectangular or circular shaped tool.

I use DCMT and CCMT normally when facing:

https://www.shop-apt.co.uk/carbide-inserts-for-turning-uni-tip/dcgt-070202-alu-ak10-carbide-inserts-for-turning-ground-and-polished-for-aluminium-uni-tip.html
https://www.shop-apt.co.uk/carbide-inserts-for-turning-uni-tip/ccgt-060202-alu-ak10-carbide-inserts-for-turning-ground-and-polished-for-aluminium-uni-tip.html

with these tools

https://www.shop-apt.co.uk/apt-93-sdjcrl-lathe-turning-tools-for-dcmt-inserts/sdjcr-1010-f07-apt-lathe-turning-tool-for-dcmt-0702-inserts.html
-

So ideally I want to be able to specify this diamond type tool so that it doesnt generate plunge cuts.

So essentially if diamond tool is selected do lots of surfacing and facing to get to dimension

[Question] Z axis co ordinates facing wrong way?

It seems on the Nano ELS the Z axis moves towards the chuck in the positive direction, same for the generated lathe code.

But as far as im aware the Z axis positive should always be facing the tailstock:

image

This issue was highlighted when I started trying to generate gcode with fusion 360.

[Suggestion] Prefer profiling cuts

I wonder if there is a way we could specify a preferncing to doing profiling cuts for long features.

For example take this:

UNITS MM
STOCK D15

TOOL RECT R0.2 L2

L0.5
L3 D1.93
L3 DS2.5 DE6 CONC
L1.73 D12.55
L2.2 D9.5
L33.5 D12.55
L2 D0

It results in a lot of cuts into the work, and a lot of retractions.

For bringing down the outer diameter I think doing a long profile cut would be quick as it results in fewer retractions.

The material im using a brass so it would be quite for giving to profiling cuts that are maybe a bit deeper than normal.

I can kinda simulate what I want by making a the finishing pass very deep:

UNITS MM
STOCK D15

TOOL RECT R0.2 L2
DEPTH CUT1 FINISH2

L0.5
L3 D1.93
L3 DS2.5 DE6 CONC
L1.73 D12.55
L2.2 D9.5
L33.5 D12.55
L2 D0

But this problem here is I dont think my tools could take that. So ideally this would be done over several passes

[Bug] Finishing pass not being applied.

Take this:

UNITS MM
STOCK D16
TOOL RECT R0.2 L2 ; Using a rectangular grooving tool
DEPTH CUT0.5 FINISH0.2

L0.5 D0
L5 D10
L5 D15

When I look at the generated gcode using my visualiser I can see that it only cuts as deep as 5.2mm ABS. Which means its not completing the finishing passes.

https://festivejelly.github.io/LatheGcodeVisualiser/

image

I can see on the planner it looks like it knew it should do it:

image

But it didnt generate the toolpath for it.

[Bug] Parting off before other moves

So I made this demo shape:

UNITS MM
STOCK D16
TOOL RECT R0.2 L2 ; Using a rectangular grooving tool
FEED MOVE200 PASS100 PART10 ; speeds mm/min

L0.5 D0
L5 D10
L5 D15
L2 D0

And weirdly it generates gcode that parts off the part before it does a finishing pass. So it essentially finishes in mid air.

I guess best practice would be to leave a tiny bit of of stock to hold the part and then part it off later.

[Bug] Chamfers in one direction not completing properly

Im getting an odd issue where chamfers moving from right to left dont seem to be getting cut, but chamfers moving left to right look fine

Here is a model to reproduce:

UNITS MM
STOCK D16.9
TOOL RECT R0.2 L2 ; Using a rectangular grooving tool

L0.5 DS14.5 DE15.5
L12 D15.5
L0.5 DS15.5 DE14.5
L5 D10
L0.5 DS14.5 DE15.5
L8.5 D15.5
L0.5 DS15.5 DE14.5
L3 D10

Is it a case of the tool dimension might not be 100% accurate?
image

[Feature Request] Checkbox to disable preview rotation

It would be quite handy to have a checkbox on the lathe code page to disable the automatic rotation of the model. It can be a bit frustrating when entering code to constantly having to re rotate the model.

Love the tool though, its so useful.

Finishing pass seems to be ignored

UNITS MM
STOCK D15.9

TOOL RECT R0.2 L2
DEPTH CUT0.5 FINISH0.2

L0.5 D0
L0.1 DS13.3 DE13.5
L0.8 D13.5
L0.1 DS13.5 DE13.3
L6.3 D10.5
L0.1 DS10.5 DE10.3
L2 D7

As you can see no finishing pass is made. It cuts in to the end diameter of 10.5 but the finishing pass is at the same depth. So the cutting should probably going into 10.7 diameter then doing the finishing pass to take it to 10.5mm

Bug: Clicking zoom blocks entire page

When clicking zoom in on the generated paths sometimes it blocks the entire page and you cant scroll down to the close button. I suggest limiting the size of the container to a percentage of the screen size and have it dynamically scale. That way the button will never be outside of the viewport.

I'll have a crack at fixing it on my side when I get a chance and raise a PR but I thought I should mention it to keep track of it.

Ball end G-code generator - eliptic curve

Hi Maxim,

I am trying to generate a ball end, but my input seems to generate an unevan curve on the left side.
STOCK D10
TOOL ROUND R0.2 L1.5

L4 DS0 DE8 CONV

L3.464 DS8 DE4 CONV ; 3.464 is the legth from center where the diameter = 4
L4 D4

[Question] Internal operations

Hi, me again :) Does this tool support internal operations? The code seemed to elude to "inside" but the documentation is a bit sparse.

I have a few grooving tools that this would be ideal for.

Id bore the holes normally with an endmill because im lazy. But I have a 1.5mm grooving tool that I use to cut out a recess for orings inside a bore.

It would be great to be able to automate this.

[Bug] Axial vs radial finishing pass contour

The finishing contour is only calculated radially (X) and not axially (Y), which results in a poor finish for face features. I do not know what fixing this behavior would imply in terms of programming, if it is an easy fix or a huge can of worms.

Note that the finishing pass lines only offset to the roughing passes on X and not Y:

finishing pass

Here is a real world example:

;FMW TEST PAWN

STOCK D20
TOOL ANG R0.4 L11.1 A20.5 NA35
; see https://docs.google.com/spreadsheets/d/1Tj3v0c-DxfOColeAaKtqCuPuzpS3YvOxvTCyOrsoGRw/edit?usp=sharing

DEPTH CUT0.4 FINISH0.2; default depth of cut is 0.5mm
FEED MOVE100 PASS15 PART3 ; speeds mm/min

L0.5
L4 DS0 DE9 CONV
L4 DS9 DE0 CONV
L1 DS4 DE10
L0.5 D10
L1.26 DS10 DE7
L4 DS7 DE7.7
L3.8 DS7.7 DE16 CONC
L1 D16
L1.8 DS16 DE19.6 CONV
L4 D19.6
Pawn 3d

Pawn

in this video you can see that during the finishing pass the tool doesn't engage for face features:

20240123_FMWA74_5472.mp4

Pecking when parting

I was making this today:

UNITS MM
STOCK D12

TOOL RECT R0.2 L2
DEPTH CUT0.5 FINISH0.2

L0.5
L5.5 DS0 DE4
L0.2 DS7.8 DE8
L1.3 D8
L0.2 DS10.3 DE10.5
L0.7 D10.5
L0.2 DS10.5 DE10.3
L2

Its a stainless steel cone. And it was all going great until I went to part it. Then my whole lathe shook to pieces! I had to slow the RPM right down to like 250 and manually peck away.

Is there a way we can define a pecking routine for parting or deep grooves?

Also notice that the fillet at the back edge doesnt get cut, but if you do:

UNITS MM
STOCK D12

TOOL RECT R0.2 L2
DEPTH CUT0.5 FINISH0.2

L0.5
L5.5 DS0 DE4
L0.2 DS7.8 DE8
L1.3 D8
L0.2 DS10.3 DE10.5
L0.7 D10.5
L0.2 DS10.5 DE10.3
L2 D5

Then it does cut it.

[Suggestion] Defining internal stock shape

It would be super handy to be able to specify the internal stock geometry.

At the moment if I want to do internal operations the tool assumes that I want to use the to cut all of it I think?

Take this model

; Machining Operations on 17mm Stock
; Using a 3mm wide parting off tool

UNITS MM
STOCK D17
TOOL RECT R0.1 L1.5 ; Using a rectangular grooving tool

INSIDE
L1.75 D11
L1.5 D13.4
L6.75 D11

On paper this looks okay, the model looks like how I want it... but it actual fact it doesnt need to bore out the 11mm hole because thats already there. It just needs to cut the groove thats 1.5mm long. But the gcode that this generates does not look right.

[Suggestion] Link G-code speeds to spindle speed

Aligning with the regular H4 operations, I believe ensuring real-time monitoring of spindle speed and expressing G-code movements as a function of the spindle speed is important. This approach offers several advantages:

  • Adaptability to user's spindle speed: The system automatically adjusts to the spindle speed chosen by the user, accommodating variations based on the lathe model or material properties.
  • On-the-fly speed adjustments: Permits adjustments to the spindle speed during operations, such as increasing speed for more efficient roughing cuts.
  • Gradual speed changes to and from 0: Gradual adjustments of both spindle speed and G-code movements to bring them to a stop offer a safer alternative to the recent method of employing a "stop code when spindle speed is 0." This ensures a consistent finish while the cutter is engaged. This would help for instance to safely clear aluminum string nests.

It would also be possible to introduce a SPINDLE line setting in lathecode. Users would be able to input their anticipated spindle speed, enabling the system to still provide a G-code runtime estimation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.