# Lathe design/ngc questions

13 Aug 2013 01:40 #37597
Admitted newbie here. I designed and constructed a small (12x12x4") desktop CNC and implemented it using LinuxCNC, and with the exception of some wonkiness in my Z axis design, it all came off simple, easy, and just-works. I've learned a bunch in the two weeks since I started, but for two days I've been looking for information on building a lathe, and not having a lot of luck. So I'm gonna drop a comment in the forum and see if someone can point me to the resources I'm missing.

I envision a lathe with a long axis of rotation (well, in desktop terms - I'm thinking 30" or so ), with 2" of Z radius. I want to be able to cut patterns on the surface of cylinders and tapers. My original idea was to have a horizontally mounted spindle driven along the zero line of the lathe's axis of rotation. I was imagining a stepper motor driving a fairly large (say, 1 rotation of the workpiece = 20 rotations of the stepper, to line up with my current 1/4-20tpi lead screws just to make the math easier), and of course, steppers driving 1/4-20 lead screws on both the long (X?) axis and the plunge (Z?) axis. This seems to introduce problems in ngc design, because rotation is in "degrees" rather than "inches" - or, to put it differently, I see that over a taper, designs will be distorted because a .25 radius and a .75 radius have radically different circumferences. I want to be able to cut spirals, stars, etc, at any point on a tapered shaft, and have them remain the proper aspect ratio.

I had the idea of swapping Z and X and using polar co-ordinates. So my angle would be Y and the distance would be what's normally Z, and I'd have (essentially) a 30 inch Z axis. This makes programming easier for me to visualize, but I can't find any tool that could model/visualize this idea.

Can anyone point me to documentation on how to pull this off? I know people have done it (Dewey Garret comes to mind from another post I read on the forum) but I can't find any technical docs on how they manage it.

13 Aug 2013 15:20 - 13 Aug 2013 15:30 #37608 by ArcEye
Replied by ArcEye on topic Lathe design/ngc questions
Hi

Try contacting Bill Ooms, he is an ornamental turner who has converted to CNC, does some very nice work.

www.billooms.com/

He is a forum member but not logged in for some months so perhaps try him direct through his site.
Even if what he is doing is not quite what you envisage, it should give some ideas to see how he does it.

Dewey has his own site too and does some stunning ornamental stuff

www.deweygarrett.com/

Between the two they should be able to point you in the right direction

regards
Last edit: 13 Aug 2013 15:30 by ArcEye.
The following user(s) said Thank You: jstevewhite

13 Aug 2013 19:28 #37619 by andypugh
Replied by andypugh on topic Lathe design/ngc questions

I want to be able to cut spirals, stars, etc, at any point on a tapered shaft, and have them remain the proper aspect ratio

A simple way to do this (that won't work) is simply to connect the Y-position commands to the rotary axis.

As you have noticed, that won't correct for radius. However, you can quite possibly simply multiply Y and Z together in HAL and pass that value to the rotary stepgen.

This would normally be done in a custom kinematics file, though all that would happen in there is multiplication of Y by Z to give the motor (joint) position command.

Scale factors and the complexities of machine-absolute and relative coordinate systems have been omitted from this discussion.

Be aware that in this scenario moves are not commutative. A move to a given Y position with a different Z height won't return to the same position at a different Z height.

Better might be a kinematics that takes a taper value as input and calculates Y and Z as a function of X.
The following user(s) said Thank You: jstevewhite

13 Aug 2013 19:59 #37622
Thanks, I'll look into it. I looked at Dewey's stuff, and it's pretty amazing. He's got some videos that show probing irregular surfaces to profile them and talks about linuxcnc, but nothing in-depth.

13 Aug 2013 20:13 #37623

I want to be able to cut spirals, stars, etc, at any point on a tapered shaft, and have them remain the proper aspect ratio

A simple way to do this (that won't work) is simply to connect the Y-position commands to the rotary axis.

As you have noticed, that won't correct for radius. However, you can quite possibly simply multiply Y and Z together in HAL and pass that value to the rotary stepgen.

I had actually considered doing exactly that, working on a flat surface to design the gcode files, then writing a pre-processor to "wrap" the profile and scale accordingly. That's what I was thinking of with the polar co-ordinates and the rotary axis aligned with Z rather than Y. I didn't know I could do math in the HAL.

This would normally be done in a custom kinematics file, though all that would happen in there is multiplication of Y by Z to give the motor (joint) position command.

Scale factors and the complexities of machine-absolute and relative coordinate systems have been omitted from this discussion.

RIght - I've already run afoul of relative co-ordinate confusion once and screwed up a bit

Be aware that in this scenario moves are not commutative. A move to a given Y position with a different Z height won't return to the same position at a different Z height.

Better might be a kinematics that takes a taper value as input and calculates Y and Z as a function of X.

Mmm... the implications of your statement there made me realize that it could also result in deeper cuts being angled rather than straight. But it looks like I could change co-ordinate systems for cuts that aren't aspect-ratio dependent, right? I mean, I've been messing with gcode for a total of two weeks, but it looks like I can use multiple co-ordinate systems. Can the HAL differentiate? Could I, say, apply compensation when in polar-co-ordinate mode (I like the idea of polar co-ordinate mode because I can cut complex spiral patterns that way programmatically), and turn it off when I switch back to cartesian mode? Then if I need a 1/8" slot a 2" from 0, I can just cut it cartesian, but if I'm cutting a star, I can use polar co-ordinates and compensation?

Thanks for the food for thought. I'll dig into the HAL documentation and see what I can come up with.

Any hints on visualization? I'm pretty good in 2-d math, but writing a 3d visualizer is beyond my level of dedication

13 Aug 2013 22:32 #37627 by BigJohnT
Replied by BigJohnT on topic Lathe design/ngc questions
For taper cuts on a lathe I just use ngcgui and input the values for the operation.

JT

14 Aug 2013 00:07 #37631 by andypugh
Replied by andypugh on topic Lathe design/ngc questions

I had actually considered doing exactly that, working on a flat surface to design the gcode files, then writing a pre-processor to "wrap" the profile and scale accordingly.

I think this approach is the most likely to consistently do what you expect.

it looks like I can use multiple co-ordinate systems. Can the HAL differentiate? Could I, say, apply compensation when in polar-co-ordinate mode (I like the idea of polar co-ordinate mode because I can cut complex spiral patterns that way programmatically), and turn it off when I switch back to cartesian mode? Then if I need a 1/8" slot a 2" from 0, I can just cut it cartesian, but if I'm cutting a star, I can use polar co-ordinates and compensation?

The "coordinate systems" are just sets of offsets, not alternative geometries.

G-code accepts XYZABCUVW as position commands. Typically XYZ are position in space and ABC are rotations about XY and Z respectively. UVW are typically linear moves in the rotated system.

None of this is written in stone. You can connect the axis.N.motor-position-cmd HAL pin to absolutely anything you want, and that thing will see whatever number your X word requests, if you are using a trivial kinematics.

Using a non-trivial kinematics (such as a rotary-jointed robot) a move command in just X might change the value of every HAL pin from axis.0.motor-position-cmd to axis.8.motor-position-cmd. (And, in the forthcoming version of LinuxCNC I think you may be able to have more than 9 "joints" even if G-code semantics limits you to 9 "axes")

Then as a further complication you can issue G-code moves in the format G0 @20 ^45 which uses polar coordinates in the XY plane.
www.linuxcnc.org/docs/2.4/html/gcode_main.html#r1_1

14 Aug 2013 01:00 #37632

I had actually considered doing exactly that, working on a flat surface to design the gcode files, then writing a pre-processor to "wrap" the profile and scale accordingly.

I think this approach is the most likely to consistently do what you expect.

It's also probably the easiest, but I really like the idea of being able to generate mathematical spirals using polar coordinates, because it's fun to do and looks cool. I suppose I could project them onto a flat plane and wrap/compensate.

The "coordinate systems" are just sets of offsets, not alternative geometries.

Ah, ok. That makes sense.

G-code accepts XYZABCUVW as position commands. Typically XYZ are position in space and ABC are rotations about XY and Z respectively. UVW are typically linear moves in the rotated system.

Oh, I see! Thanks for that bit, it clears a lot up. So I might have Y along the spindle, Z as distance from spindle, and "A" as rotation around the Y axis? I mean, by convention.

None of this is written in stone. You can connect the axis.N.motor-position-cmd HAL pin to absolutely anything you want, and that thing will see whatever number your X word requests, if you are using a trivial kinematics.

Using a non-trivial kinematics (such as a rotary-jointed robot) a move command in just X might change the value of every HAL pin from axis.0.motor-position-cmd to axis.8.motor-position-cmd. (And, in the forthcoming version of LinuxCNC I think you may be able to have more than 9 "joints" even if G-code semantics limits you to 9 "axes")

Then as a further complication you can issue G-code moves in the format G0 @20 ^45 which uses polar coordinates in the XY plane.
www.linuxcnc.org/docs/2.4/html/gcode_main.html#r1_1

Thanks for taking the time to explain all of this. You cleared up a couple of things for me that I'd read about but not quite put together.

I saw the polar co-ordinates in the XY plane, which was why I thought about making X the distance from the lathe center (depth of cut), Y the angle of rotation, and Z along the axis of rotation of the lathe. I'll have to play with the math and see which one is easiest to represent. I'm assuming that using polar co-ordinates does a mod 360, so you could say 2880 degrees and get 8 turns around the spindle?

In the end, I think I'm going to have to build the doggone thing FIRST so I can experiment with configs and software. I was just trying to make some good design decisions first. In that vein - where can a person buy cog belts and pulleys? LOL

thanks again!

14 Aug 2013 02:02 #37634

For taper cuts on a lathe I just use ngcgui and input the values for the operation.

JT

Does ngcgui lathe support curves for taper profiles? It didn't look like it when I ran the sim version. Did I miss something? I need complex taper profiles with some curves involved, like, straight from 12mm D to 13mm D, then a 24" inside radius curve to 18mm D, then a 45" outside radius curve out to 28mm D, then straight to 31mm D. (I'm pulling those radius numbers out of my hat right now because I haven't sat down and calculated the actual radius).

Thanks!

14 Aug 2013 02:14 #37635 by andypugh
Replied by andypugh on topic Lathe design/ngc questions

So I might have Y along the spindle, Z as distance from spindle, and "A" as rotation around the Y axis? I mean, by convention.

By convention Z is along the spindle axis. So a lathe has diameter on X and length on Z. (and no Y).
If the lathe spindle can be set to an angle then that is conventionally a C-axis.

In the end, I think I'm going to have to build the doggone thing FIRST so I can experiment with configs and software.

You could experiment with a virtual machine. (but won't be able to see the results).
Fire up Linuxcnc and in the config picker look at sample-configurations -> scara -> scara for an example of a virtual machine setup.

where can a person buy cog belts and pulleys?

I make my own pulleys (I have a hobbing setup) but I understand that McMaster Carr are useful in the US. Alternatively, have a look on eBay.
The following user(s) said Thank You: jstevewhite