Author Topic: Maths help please: Approximating a Flat Iteratively  (Read 13238 times)

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Maths help please: Approximating a Flat Iteratively
« on: June 12, 2019, 04:03:27 PM »
I want to cut spanner flats on round stock in my CNC lathe. I can position the chuck in 1 degree increments and approach the stock with an axially mounted end mill.

I envision positioning the chuck, feeding the end mill a certain X feed, withdrawing it, rotating the chuck to the next angular position and feeding the end mill in a calculated but different X feed then repeating the process.

Now this will make approximations to  flats which are actually a series of scallops with size of scallop depending on end mill diameter and the fine or coarseness of the increments of chuck rotation.

Note: the lathe only can move the cutter in Z (ie towards the chuck) and X (ie towards the axis of rotation) there is no Y movement which would make life so much simpler !

But I can't get my head around the maths of developing a 'general case' that will allow me to write an algorithm with parameters to define the variables. As I see it the parameters are:

a/ Cutter diameter
b/ Angular increment of chuck position
c/ Distance of flat from axis of rotation
d/ Length of flat

My brain hurts, can anyone help?

Andrew Mawson
East Sussex

Offline Sea.dog

  • Full Member
  • ***
  • Posts: 232
  • Country: gb
  • Up Spirits!
Re: Maths help please: Approximating a Flat Iteratively
« Reply #1 on: June 12, 2019, 04:12:47 PM »

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #2 on: June 12, 2019, 04:23:45 PM »
That's a very interesting link Seadog, but the two case they show one has a Y axis and the other has a continuously rotatable C axis allowing milling while, unlike mine that the chuck can be rotated to position and locked for milling at that angular place.
Andrew Mawson
East Sussex

Offline Sea.dog

  • Full Member
  • ***
  • Posts: 232
  • Country: gb
  • Up Spirits!
Re: Maths help please: Approximating a Flat Iteratively
« Reply #3 on: June 12, 2019, 05:41:23 PM »
Knowing nothing about G code I had no idea if there was anything of use there.

Thinking on, I'm wondering about how to generate a cam profile for a specific path, from a radiused follower. My gut intinct is, that for a point, it would travel as an inverse of the diametric portion bounded by the chord (i.e. one of the flats).

That's as far as my brain has let me go, so far. This link is relevant to the problem I believe.

https://www.cs.cmu.edu/~rapidproto/mechanisms/chpt6.html


Offline efrench

  • Full Member
  • ***
  • Posts: 213
Re: Maths help please: Approximating a Flat Iteratively
« Reply #4 on: June 12, 2019, 09:16:27 PM »
I suspect you can use the Pathagorean theorem.  a = distance from the center of the rod to the midpoint of the flat plus the radius of the cutter. b = distance from the midpoint of the the flat to the center of the cutter.  c = distance from the center of the rod to the center of the cutter.  Rotation angle for each cut can be determined from the above. 

For example: If the length of the flat is 10mm, then for the first cut at the edge of the flat, b = 5mm.

I'd post a diagram, but Photobucket says I can only have 250 images and I need to delete 400  :(

p.s. There are quite a few sites for determining cusp height.

p.s.p.s The a,b, and c in my post are not the same as the a,b, and c in the first post   :palm:
« Last Edit: June 13, 2019, 01:26:01 AM by efrench »

Offline chipenter

  • Hero Member
  • *****
  • Posts: 909
  • Country: gb
Re: Maths help please: Approximating a Flat Iteratively
« Reply #5 on: June 13, 2019, 01:34:34 AM »
Spanner flats are hex normally , 360/6 = 60 degrees , af/2 - difference in dia/2 or radius = infeed , length of cut is dependant on the cutter size and hex size .
Jeff

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #6 on: June 13, 2019, 05:56:58 AM »
OK I've had a few more brain cells recover over night - let me simplify the issue:

Using the notation in the attached sketch, I have a bar of stock Radius R, I want to cut a flat of across flats size 2 x S so S = half the AF size

(You have to imagine the whole sketch rotating about the centre of the circle so keeping the cutter travel on the X axis but tilting the required spanner flat)

By rotating the stock in finite increments between +A degrees and -A degrees the axially mounted cutter will approach along the X axis for a travel of  X mm which will vary from a maximum of X = R to a minimum of S (no allowance for cutter diameter but that's easy)

So between the limits of +A degrees and -A degrees I need to evaluate X for any given angle (B in the sketch) to which the bar has been rotated

Now I think that  the 'half chord length'  C is given by:

C= Square Root{R*R - S*S)

But going from there to solving X for any angle of B within those limits is eluding me at the moment  :scratch:
Andrew Mawson
East Sussex

Offline djc

  • Jr. Member
  • **
  • Posts: 85
Re: Maths help please: Approximating a Flat Iteratively
« Reply #7 on: June 13, 2019, 06:45:31 AM »
As I see it the parameters are:
a/ Cutter diameter
b/ Angular increment of chuck position
c/ Distance of flat from axis of rotation
d/ Length of flat

At the beginning, simplify the problem and forget cutter diameter (or assume it is zero). Work out the x-coordinate of the polygon side as it rotates from vertical to having its vertex aligned with x-axis.

Then add in correction for cutter diameter.

Your last two (c & d) are not independent parameters; one is derived from the other.

(1) Call number of polygon sides n. Hence interior angle subtended by the chord (polygon side) is 360/n and interior half angle is 180/n (e.g. 90 and 45 degrees for a square). Call radius of circumscribed circle of polygon r. As we will see later, this does not necessarily have to be your stock diameter.

(2) With stock rotational axis at (0,0), when one side of polygon is vertical, edge of polygon has x-coord = r cos(180/n). Call this m. When vertex of polygon lies along x-axis, 'side' of polygon has x-coord = r.

So that gives you two (three, due to symmetry) points along the side of the polygon. The challenge is to work out the intermediate points.

(3) Rotate your polygon side clockwise about (0,0) some angle a (limits/bounds of a are + or - 180/n as above). Draw the perpendicular bisector of your rotated polygon side, which should pass through (0,0). The distance from the midpoint of your polygon side to your rotational axis is m as above. The (horizontal) distance x from the rotational centre to the intersection of the polygon side with the x-axis is x = m/cos a.

This is the general formula for the intersection of the polygon side with the x-axis. Check it works by putting in a = 0 [x = m = r cos (180/n)] and a = 180/n [x = r].

(4) Now you have to add in an additional dx to cater for cutter diameter. Draw a circle centred on the x-axis of radius c (cutter radius). Draw a tangent to that circle on the left hand side of the circle, such that the angle between the tangent and the x-axis is acute above the axis. Call this angle 90 - a. Now draw a line from the centre of the circle to the point of tangency (of length c). The angle of this line with the x-axis is a.

The extra offset required due to the cutter is dx = c / cos a.

So for any angle a, the x-coord of the cutter (of radius c) is x + dx.

(5) This works up to the point where the vertex of the polygon is tangent to the cutter. This will always be at an angle a less than 180/n. If your stock diameter is bigger than the circumscribed circle of your polygon, you now have to roll the cutter around the vertex of the polygon in order to complete its shape. The maths here becomes more involved, so we will leave it there just for now and assume our stock diameter equals the circumscribed circle of the polygon.

(6) I think you can show that the vertex of the polygon is tangent to the cutter when tan a = (r sin (180/n))/ (m + C). This means that if your stock is exactly the diameter of the circumscribed circle of the polygon, you can stop at this point (i.e. you do not have to keep incrementing a until it reaches 180/n) as any further angular increment of the rotational axis will only cut air.

The bigger the cutter diameter, the less the scallops will be.

Could I ask you a favour in return? Please work out a formula relating cutter diameter, cut spacing and scallop height.

Other homework: consider what happens for n < 3. Consider what happens when n is not an integer.

Doing maths like this is how I imagine long division was in Roman times. I can send diagrams if you pm me your email address.


Offline efrench

  • Full Member
  • ***
  • Posts: 213
Re: Maths help please: Approximating a Flat Iteratively
« Reply #8 on: June 13, 2019, 02:43:55 PM »
Here's the diagram.  For any position of the cutter, the distance from the center is simply a squared + b squared. Note: The relationship between a, b, and c doesn't change when the diagram is rotated so the center of the cutter is on the centerline.

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #9 on: June 13, 2019, 03:28:32 PM »
Thanks for the suggestions chaps but there are too many differing letter systems now in this thread. Sticking to the letters on my last diagram in post #6 I need to evaluate the length X for varying angles B as the stock is rotated between it's limits.

X will have a minimum where X = S and a maximum where X =R as the stock rotates. Don't worry about cutter diameter etc that is the easy bit.

I'll repeat the sketch below
Andrew Mawson
East Sussex

Offline efrench

  • Full Member
  • ***
  • Posts: 213
Re: Maths help please: Approximating a Flat Iteratively
« Reply #10 on: June 13, 2019, 04:03:50 PM »
Your 'X' is my 'c'.   A right triangle is always formed from a line perpendicular to the center of the flat, the end of the flat, and the axis of the lathe. As the cutter is moved tangent to the flat, the distance 'b' changes, but 'a' doesn't.  'b' varies by the stepover amount.  'c' squared is simply 'a' squared plus 'b' squared.  Use sine/cos to determine the spindle angle.

Offline RussellT

  • Hero Member
  • *****
  • Posts: 520
  • Country: gb
Re: Maths help please: Approximating a Flat Iteratively
« Reply #11 on: June 13, 2019, 04:19:30 PM »
My mathematician son says

"The last post in the thread (from early this morning) I don't fully follow, I think because it's assuming more understanding of the setup than I have, but the penultimate post seems fairly clear or at least the question in the diagram does and simple trig on the two right angled triangles with common edge L and angles A and B leads me to believe

X = R (cos A/cos B)

Does that help?"

I did discuss the setup briefly with him because I'm not convinced by your suggestion that allowance for cutter diameter is easy, it's complicated by the fact that the cutter doesn't just cut on the centre line and so you need to align a tangent of the cutter with the spanner flats.

Russell
Common sense is unfortunately not as common as its name suggests.

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #12 on: June 13, 2019, 04:50:00 PM »
Russell please thank your son, I think he's cracked it  :thumbup:

I need to model the cutter / tangent issue and get my head round that bit, but to my simplistic way of thinking an infinitely small cutter just slides along the flat with no issue so a 10 mm cutter just slides along 5 mm further in so X needs 5 mm adding  :scratch:
Andrew Mawson
East Sussex

Offline djc

  • Jr. Member
  • **
  • Posts: 85
Re: Maths help please: Approximating a Flat Iteratively
« Reply #13 on: June 14, 2019, 04:07:57 AM »
I need to model the cutter /
tangent issue and get my head round that bit, but to my simplistic way of thinking an infinitely small cutter just slides along the flat with no issue so a 10 mm cutter just slides along 5 mm further in so X needs 5 mm adding

Your diagram, whether enhanced or no, does not capture what is going on because your polygon edge is always vertical. This will not be so. It means the terms you want us to use are not helpful. This is also why you are incorrect in your constant cutter offset.

Your part geometry is rotating around your coordinate system (which is fixed). Your cutter is not rotating relative to your coordinate system.

I am sure you have CAD. Draw a pentagon with its right side vertical inscribed in a circle. Draw the perpendicular bisector of this vertical line, starting at the line and going to the centre (so there are six lines so far on the drawing). Draw your cutter touching the edge of the pentagon. Draw a standard set of axes over this in a different colour. Lock the axis layer. Rotate the six lines on the pentagon layer some arbitrary angle (if your software will do rotate and copy at the same time, so much the better). Move the cutter circle horizontally only until it touches the edge of the pentagon again. The point of tangency will now be above the horizontal centreline of the cutter.

PDF attached. Diagram numbers relate to previous post.

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #14 on: June 14, 2019, 05:58:42 AM »
I do take your point, but I suspect that at a practical level (and particularly where the cutter diameter is small in comparison the the stock diameter) the error between tangential contact and diametrical contact will be acceptable.

This is a work in progress and entirely experimental, and I suspect that I would do best to get the simple case working then apply any sophisticated corrections later as things evolve dependant on the results that I get. And those corrections will probably be based on your calculations for which I thank you  :thumbup:

In built into the Siemens 820T controller (1990 remember) is an arcane mathematical series of '@' commands that theoretically should allow for all the trig required, but is a nightmare to get going and understand, and I suspect that they will take a considerable proportion of the controls CPU time so best to keep it minimalistic initially !

Andrew Mawson
East Sussex

Offline RussellT

  • Hero Member
  • *****
  • Posts: 520
  • Country: gb
Re: Maths help please: Approximating a Flat Iteratively
« Reply #15 on: June 14, 2019, 07:04:31 AM »
Hi Andrew

I will pass on your thanks.

djc's diagram shows exactly what I was referring to with cutters, where the cutter is shown in his diagram it isn't cutting on the centre line.  I understand your point about tool diameter, as you mention earlier an infinitely small cutter would solve the problem.  The trouble with infinitely small cutters is that they're difficult to find and quite fragile. :lol:  Of course an infinitely large cutter would also solve the problem but you may struggle to fit it in the lathe. :D

As a more serious question from my position of knowing very little about the capabilities of CNC lathes could this be done with a conventional lathe tool?  I have in mind moving the tool in and out 6 times for each rotation of the work.

Russell
Common sense is unfortunately not as common as its name suggests.

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #16 on: June 14, 2019, 07:05:55 AM »
I've tried graphically to estimate the real life error using a piece of 25 mm stock and a 10 mm end mill. Cutting a hexagon, so six sided, the worst case occurs when the wanted flat is inclined at  75 degrees.

The discrepancy between tangential cutting and diametrical cutting works out at 0.1711 mm and obviously will reduce with larger stock and or smaller end mills.

So in a real life situation where I am putting two opposite spanner flats for an 18 mm spanner on a CAT40 pull stud for my vertical mill that represents a 0.95% error - so I don't think that the spanner will mind much!

That said, once I get his working I will try and perfect it as per DJC's musings, as it would be nice to get it spot on despite the fact that using finite angular movements rather than continuous cutting will always result is scalloping errors

Andrew Mawson
East Sussex

Offline Archie Opteryx

  • Jr. Member
  • **
  • Posts: 16
Re: Maths help please: Approximating a Flat Iteratively
« Reply #17 on: June 14, 2019, 07:09:18 AM »
Here's my attempt at the problem. This uses the tangent relationship between cutter and machined face and should be exact.

In the attached Figure 1, S is the centre of the spindle and C is the centre of the cutter. The blue line shows the face being machined, with the centre of the face rotated anticlockwise by an angle alpha from the line between S and C.

The distance from the centre of the workpiece to the face (half the "across flats" distance) is d. The radius of the cutter is r.

The distance between S and C, x, is given by the equation:

x = (d + r) / cos(alpha)

Note that alpha is zero when cutting the centre of the face. To machine a face, step the spindle angle (alpha) from -30 degrees to +30 degrees or so and bring the cutter in to a distance x calculated from the above equation at each step.

If you're making fewer than six faces, you'll need to vary alpha over a slightly larger range, since the face will be a bit longer.

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #18 on: June 14, 2019, 07:15:33 AM »


As a more serious question from my position of knowing very little about the capabilities of CNC lathes could this be done with a conventional lathe tool?  I have in mind moving the tool in and out 6 times for each rotation of the work.

Russell


Russell, the Traub WAS capable of that and they had a special software package available (at enormous cost!) for the Mitsubishi control to do exactly that. I suppose it depends how quickly the X axis slide can reciprocate and maintain an accurate position, or alternatively how slowly you can rotate the work and get a decent cut. More room for future experimentation, so no chance to get bored with the lathe just yet  :lol:
Andrew Mawson
East Sussex

Offline Archie Opteryx

  • Jr. Member
  • **
  • Posts: 16
Re: Maths help please: Approximating a Flat Iteratively
« Reply #19 on: June 14, 2019, 08:52:41 AM »
Now to calculate the positions of the scallops and how deep they will be.

Fig 2 shows the same geometry as in the earlier post, but this time we are interested in the distance u between the centre of the machined face and the tangential point of contact with the cutter. This is the point where the cut is the deepest and corresponds to the bottom of the scallop.

A bit more simple trigonometry gives:

u = (d + r) tan(alpha)

It's a bit tricky to visualise the effect of the cuts in Fig 2, since the workpiece face is rotating. Fig 3 shows the situation from the point of view of the workpiece. Here a number of cuts have been made at different spindle angles alpha. I've used a small cutter and a large step in angle to show the cusps (pointy bits) between the cuts more clearly.

Due to the tan(alpha) term, the cutter positions become further apart as alpha increases, and the cusp height increases accordingly. However, as you can see from Fig 3 (which is roughly to scale), this effect is small for values of alpha likely to be used in practice.

Finally, how high will the cusps be?
 
Fig 4 is an enlarged version of part of Fig 3, showing two cutter passes spaced by w.

A bit more geometry gives the cusp height h above the bottom of the scallop as:

h = r - sqrt(r2 - (w/2)2)

It would be straightforward to put these equations into a program or spreadsheet to calculate values for conditions of interest.

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Maths help please: Approximating a Flat Iteratively
« Reply #20 on: June 14, 2019, 09:03:57 AM »
Archie, you are a handy chap to have about, welcome to the forum  :clap:
Andrew Mawson
East Sussex

Offline efrench

  • Full Member
  • ***
  • Posts: 213
Re: Maths help please: Approximating a Flat Iteratively
« Reply #21 on: June 14, 2019, 04:05:49 PM »
You all are working too hard  :D Review my posted diagram.  By using one leg of the right triangle as a line perpendicular to the midpoint of the flat, there is only one right triangle to solve for. The cutter is always tangent to the flat.

Offline Sea.dog

  • Full Member
  • ***
  • Posts: 232
  • Country: gb
  • Up Spirits!
Re: Maths help please: Approximating a Flat Iteratively
« Reply #22 on: June 14, 2019, 04:20:45 PM »
Doesn't your diagram assume the cutter is moving across the flat? It's only movement is, in fact, is along the diameter of the workpiece.

Offline chipenter

  • Hero Member
  • *****
  • Posts: 909
  • Country: gb
Re: Maths help please: Approximating a Flat Iteratively
« Reply #23 on: June 14, 2019, 04:21:44 PM »
Use a 90 degree tool holder and the scallop is on the Z axis .
Jeff

Offline efrench

  • Full Member
  • ***
  • Posts: 213
Re: Maths help please: Approximating a Flat Iteratively
« Reply #24 on: June 14, 2019, 04:38:56 PM »
Doesn't your diagram assume the cutter is moving across the flat? It's only movement is, in fact, is along the diameter of the workpiece.

No, the cutter only moves towards or away from the spindle axis.  The diagram shows the relative positions of the cutter, the flat, and the spindle axis. Rotate the diagram if you want to see the cutter at its actual position at any point along the flat.