Discussion:
best way to get a complex curve (i.e., gear tooth involute) to g-code as precisely as possible?
(too old to reply)
Cliff
2008-08-12 14:11:39 UTC
Permalink
Hello,
I run a script to create a bunch of points that define a fancy curve.
I am bringing them into solidworks, drawing a spline to them, then
exporting a drawing to dwg or dxf and using mastercam to generate the
gcode. Preferably, I dont want to keep doing the step of hand-drawing
a spline to fit each point, because I want to use a lot of points to
define the curve precisely.
Lots of points just make lots of little ripples, usually.
If you know the underlying type of geometry you are trying to
deal with you can do better much of the time.
Sadly, an involute curve does not have an exact form as a
spline (which has a polyynomial basis).


http://www.ingentaconnect.com/content/klu/366/2007/00000023/00000003/00000060?crawler=true
[
In numerous instances, accurate algorithms for approximating the original
geometry is required. One typical example is a circle involute curve which
represents the underlying geometry behind a gear tooth. The circle involute
curves are by definition transcendental and cannot be expressed by algebraic
equations, and hence it cannot be directly incorporated into commercial CAD
systems. In this paper, an approximation algorithm for circle involute curves in
terms of polynomial functions is developed. The circle involute curve is
approximated using a Chebyshev approximation formula (Press et al. in Numerical
recipes, Cambridge University Press, Cambridge, 1988), which enables us to
represent the involute in terms of polynomials, and hence as a Bézier curve. In
comparison with the current B-spline approximation algorithms for circle
involute curves, the proposed method is found to be more accurate and compact,
and induces fewer oscillations.
]

From "Numerical Recipes" (a decent enough book) a programmer
could probably help you and there was (last I looked) at least
one Web Site dedicated to this book: http://www.nr.com/forum/
The book (I have an original copy) is is/may be online too:
http://www.nr.com/
I've been told that the (original ?) C version has some errors though.
IIRC I kept the FORTRAN version.
I was thinking that if I could get the script to export to a text file
format that allows a spline to be defined, I could bring THAT file
format directly into mastercam and generate the gcode from it.
Is there such a text file format that defines splines? I was
thinking of using DWG but it isnt a text file, so I would have trouble
getting the points into it.
Is there a better way to do this?
Thanks,
-Mike
Perhaps some of the real SolidWorks experts/programmers can advise?

BTW, IF you can write fancy CNC macros AND your control supports some
"fancy" functions you can probably do no better than a CNC control macro
on this one ..... but you'll need some math <g>.
--
Cliff
Morris Dovey
2008-08-14 17:51:14 UTC
Permalink
[ at alt.machines.cnc ]
Post by Cliff
Lots of points just make lots of little ripples, usually.
If you know the underlying type of geometry you are trying to
deal with you can do better much of the time.
Sadly, an involute curve does not have an exact form as a
spline (which has a polyynomial basis).
OTOH, Archimedian, hyperbolic, and logarithmic involutes have simple
polar representations - and the involute of a circle has a relatively
simple parametric representation.

Since I don't have any gee-whiz packages to magic this stuff up for me I
either do the calculations on the fly in my part programs or (sometimes)
write a simple computer program to generate the relevant portion of the
part program that'll be doing the machining.

My favorite reference is Burington's 'Handbook of Mathematical Tables
and Formulas' (McGraw Hill).
Post by Cliff
Perhaps some of the real SolidWorks experts/programmers can advise?
BTW, IF you can write fancy CNC macros AND your control supports some
"fancy" functions you can probably do no better than a CNC control macro
on this one ..... but you'll need some math <g>.
(Almost) always, sine, cosine, log, and exponential functions are as
"fancy" as is needed. :-)

Yuppers, math is needed - but I can't imagine that geometry, algebra,
and trig aren't already a part of the normal skill set. (BICBW)
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
Cliff
2008-08-15 13:25:09 UTC
Permalink
Post by Morris Dovey
Yuppers, math is needed - but I can't imagine that geometry, algebra,
and trig aren't already a part of the normal skill set. (BICBW)
You've heard of banquer, right?
OTOH I think even simple macros are beyond him.
--
Cliff
madcadman
2008-08-16 20:37:29 UTC
Permalink
Post by Cliff
Post by Morris Dovey
Yuppers, math is needed - but I can't imagine that geometry, algebra,
and trig aren't already a part of the normal skill set. (BICBW)
You've heard of banquer, right?
OTOH I think even simple macros are beyond him.
--
Cliff
for banquer a macro would be the equivalent of writing an entire operating
system!!! That dude is so utterly clueless it makes the average machinist
look like a rocket scientist.

Cliff
2008-08-15 13:37:00 UTC
Permalink
Post by Morris Dovey
[ at alt.machines.cnc ]
Post by Cliff
Lots of points just make lots of little ripples, usually.
If you know the underlying type of geometry you are trying to
deal with you can do better much of the time.
Sadly, an involute curve does not have an exact form as a
spline (which has a polyynomial basis).
OTOH, Archimedian, hyperbolic, and logarithmic involutes have simple
polar representations - and the involute of a circle has a relatively
simple parametric representation.
But not as a polyynomial which is what's needed for splines & NURBS.
Post by Morris Dovey
Since I don't have any gee-whiz packages to magic this stuff up for me I
either do the calculations on the fly in my part programs
You have the needed functions in your control?
Post by Morris Dovey
or (sometimes)
write a simple computer program to generate the relevant portion of the
part program that'll be doing the machining.
The core problem changes too if you are machining on the curve
or tangent to it.
Post by Morris Dovey
My favorite reference is Burington's 'Handbook of Mathematical Tables
and Formulas' (McGraw Hill).
I don't have that one & have never seen it.
Post by Morris Dovey
Post by Cliff
Perhaps some of the real SolidWorks experts/programmers can advise?
BTW, IF you can write fancy CNC macros AND your control supports some
"fancy" functions you can probably do no better than a CNC control macro
on this one ..... but you'll need some math <g>.
(Almost) always, sine, cosine, log, and exponential functions are as
"fancy" as is needed. :-)
For this problem I expect.
Had one once where I had to use calculus-like "limiting" approximations
in APT.
Well, more than one but not many.
Post by Morris Dovey
Yuppers, math is needed - but I can't imagine that geometry, algebra,
and trig aren't already a part of the normal skill set. (BICBW)
For many these days they don't seem to be. AND I recall
the kids that got "sent" to shop classes. Beyond the skillsets
most of them ever got I suspect but there are lots of kinds of
"shops". Some perhaps later learned about right triangles -- banquer
clearly never did. Doubt he lasted a week in a shop class either.

Safety issues if naught else.
--
Cliff
Morris Dovey
2008-08-15 16:53:10 UTC
Permalink
Post by Cliff
Post by Morris Dovey
OTOH, Archimedian, hyperbolic, and logarithmic involutes have
simple polar representations - and the involute of a circle has a
relatively simple parametric representation.
But not as a polyynomial which is what's needed for splines & NURBS.
Ok.
Post by Cliff
Post by Morris Dovey
Since I don't have any gee-whiz packages to magic this stuff up for
me I either do the calculations on the fly in my part programs
You have the needed functions in your control?
I do - I even have square roots! :-)
Post by Cliff
Post by Morris Dovey
or (sometimes) write a simple computer program to generate the
relevant portion of the part program that'll be doing the
machining.
The core problem changes too if you are machining on the curve or
tangent to it.
That's true, offsetting the tool path from a curve just about triples
the computational requirement - but it's not really that big a hurdle.
Post by Cliff
Post by Morris Dovey
My favorite reference is Burington's 'Handbook of Mathematical
Tables and Formulas' (McGraw Hill).
I don't have that one & have never seen it.
I've found the first 50 pages provide about 99.9% of my reference needs.
The copy by my desk here was <$10 (used) from an Amazon used book
dealer. I suspect that any good analytic geometry text would be as
useful - just less compact.
Post by Cliff
Post by Morris Dovey
(Almost) always, sine, cosine, log, and exponential functions are
as "fancy" as is needed. :-)
For this problem I expect.
Yes (hoping that nothing is lost in the encoding):

Archimedian r = a·Θ
Hyperbolic r·Θ = a
Logarithmic r =exp(a·Θ) [or] a·Θ = log(r)

These formulas are polar representations, so at each point it's
necessary to convert to cartesian coordinates using

x = x0 + r·cos(Θ) and
y = y0 + r·sin(Θ)

and for the involute of a circle:

x = a·cos(Φ) + a·Φ·sin(Φ)
y = a·sin(Φ) - a·Φ·cos(Φ)

None of this is the kind of stuff that anyone likes to do in their head
or can do by counting on their fingers, but it /is/ the kind of stuff
that computers handle easily.

I'm an "owner-operator-maintainer", so I've felt free to hack both
hardware and software to meet my needs. At one point I became
sufficiently frustrated with system limitations that I backed up,
designed, and built a special purpose machine to get a job done (photos
at http://www.iedu.com/DeSoto/Projects/JBot/ ). I'm pretty sure I
wouldn't have been allowed to do anything like this if I were working in
someone else's shop. :-)
Post by Cliff
Had one once where I had to use calculus-like "limiting"
approximations in APT. Well, more than one but not many.
Sometimes ya just gotta sweat like a hog. :-)
Post by Cliff
Post by Morris Dovey
Yuppers, math is needed - but I can't imagine that geometry,
algebra, and trig aren't already a part of the normal skill set.
(BICBW)
For many these days they don't seem to be. AND I recall the kids that
got "sent" to shop classes. Beyond the skillsets most of them ever
got I suspect but there are lots of kinds of "shops". Some perhaps
later learned about right triangles -- banquer clearly never did.
Doubt he lasted a week in a shop class either.
I hear you. It seems that the first thing kids are taught is that "math
is hard" and that "you'll probably never need this, but here it is" -
not the most motivating phrases I've ever heard. OTOH, I filled in as a
substitute teacher for 7th-12th grade math at a rural school in
Minnesota and (without telling them what it was) discovered that the
eighth graders (and up) had no trouble with differential calculus - and
was surprised as all get out that they found it "fun" and "exciting".
Ever since that experience I've had some serious doubts about dumping
responsibility for educational shortcomings on the kids...
Post by Cliff
Safety issues if naught else.
Safety is always a concern.
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
Cliff
2008-08-15 17:35:53 UTC
Permalink
Post by Morris Dovey
I suspect that any good analytic geometry text would be as
useful - just less compact.
That's all in my head but that may be no more compact <G>.
--
Cliff
Cliff
2008-08-15 17:40:45 UTC
Permalink
Post by Morris Dovey
Post by Cliff
Post by Morris Dovey
Since I don't have any gee-whiz packages to magic this stuff up for
me I either do the calculations on the fly in my part programs
You have the needed functions in your control?
I do - I even have square roots! :-)
What control & what functions does it have?
Might be an interesting actual machining-related thread after all. I don't
recall any such in AMC since 1998 or so but I *migt* have missed it, if so.

Others feel free to chime in about their controls & ones they know of.

Banquers need not apply.
--
Cliff
Morris Dovey
2008-08-15 18:55:30 UTC
Permalink
Post by Cliff
What control & what functions does it have?
My ShopBot PRT-96 has a ShopBot proprietary controller and programming
language. The controller function is split between a controller box and
a dedicated PC.

Out of the box, it supports

ABS Absolute value
AND Logical AND
ARCCOS Inverse cosine
ARCCOSH Inverse hyperbolic cosine
ARCCOT Inverse cotangent
ARCCOTH Inverse hyperbolic cotangent
ARCCSC Inverse cosecant
ARCCSCH Inverse hyperbolic cosecant
ARCTANH Inverse hyperbolic tangent
ARCSEC Inverse secant
ARCSECH Inverse hyperbolic secant
ARCSIN Inverse sine
ARCSINH Inverse hyperbolic sine
ATN Inverse tangent
CLG Base 10 logarithm
COS Cosine
COT Cotangent
COTH Hyperbolic cotangent
CSC Cosecant
CSCH Hyperbolic cosecant
EXP Exponential (e^x)
LOG Natural (base e) logarithm
NOT Logical inversion
OR Logical OR
SINH Hyperbolic sine
SECH Hyperbolic secant
SEC Secant
SIN Sine
SQR Square root
TAN Tangent
TANH Hyperbolic tangent
! Factorial
^ Exponentiation
* Multiplication
/ Division
\ Integer division
+ Addition
- Subtraction
< Less than
= Equal to
Post by Cliff
Greater than
It also supports a good handful of file-related functions like OPEN,
READ, WRITE, CLOSE so that part programs can access, create, and execute
disk files - and some useful capabilities that allow part programs to
interact with the operator and control/sense things like limit switches
and current machine values.

I've hacked my system to allow me to invoke and pass parameters to PC
applications on the fly, which allows me to write conventional programs
that write part program segments that are subsequently executed as a
part of the current job. Those PC applications can do anything that any
application might do (calculate or look up customer- or job-specific
dimensions, record accounting information, and/or produce a part program
segment, for example).

One of my more recent "hacks" allows use of a simple accessory (photos
at http://www.iedu.com/DeSoto/SuperZero/ and info at the "Details" link
at the bottom of the page) to either locate a workpiece or zero the
machine to a corner of a workpiece in under a minute - and it's saved me
a heap of setup time.
Post by Cliff
Might be an interesting actual machining-related thread after all. I don't
recall any such in AMC since 1998 or so but I *migt* have missed it, if so.
Well, my machine is a "cheapie" - I just figured that the better
machines would have all this and more...
Post by Cliff
Others feel free to chime in about their controls & ones they know of.
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
j
2008-08-15 19:00:45 UTC
Permalink
But what ties it in to SOLIDWORKS> Does Solidworks have an addin that
can converse with it. QUIT CROSSPOSTING CRAP THAT HAS NOTHING TO DO WITH
SOLIDWORKS>
Post by Morris Dovey
Post by Cliff
What control & what functions does it have?
My ShopBot PRT-96 has a ShopBot proprietary controller and programming
language. The controller function is split between a controller box and
a dedicated PC.
Out of the box, it supports
ABS Absolute value
AND Logical AND
ARCCOS Inverse cosine
ARCCOSH Inverse hyperbolic cosine
ARCCOT Inverse cotangent
ARCCOTH Inverse hyperbolic cotangent
ARCCSC Inverse cosecant
ARCCSCH Inverse hyperbolic cosecant
ARCTANH Inverse hyperbolic tangent
ARCSEC Inverse secant
ARCSECH Inverse hyperbolic secant
ARCSIN Inverse sine
ARCSINH Inverse hyperbolic sine
ATN Inverse tangent
CLG Base 10 logarithm
COS Cosine
COT Cotangent
COTH Hyperbolic cotangent
CSC Cosecant
CSCH Hyperbolic cosecant
EXP Exponential (e^x)
LOG Natural (base e) logarithm
NOT Logical inversion
OR Logical OR
SINH Hyperbolic sine
SECH Hyperbolic secant
SEC Secant
SIN Sine
SQR Square root
TAN Tangent
TANH Hyperbolic tangent
! Factorial
^ Exponentiation
* Multiplication
/ Division
\ Integer division
+ Addition
- Subtraction
< Less than
= Equal to
Post by Cliff
Greater than
It also supports a good handful of file-related functions like OPEN,
READ, WRITE, CLOSE so that part programs can access, create, and execute
disk files - and some useful capabilities that allow part programs to
interact with the operator and control/sense things like limit switches
and current machine values.
I've hacked my system to allow me to invoke and pass parameters to PC
applications on the fly, which allows me to write conventional programs
that write part program segments that are subsequently executed as a
part of the current job. Those PC applications can do anything that any
application might do (calculate or look up customer- or job-specific
dimensions, record accounting information, and/or produce a part program
segment, for example).
One of my more recent "hacks" allows use of a simple accessory (photos
at http://www.iedu.com/DeSoto/SuperZero/ and info at the "Details" link
at the bottom of the page) to either locate a workpiece or zero the
machine to a corner of a workpiece in under a minute - and it's saved me
a heap of setup time.
Post by Cliff
Might be an interesting actual machining-related thread after all. I don't
recall any such in AMC since 1998 or so but I *migt* have missed it, if so.
Well, my machine is a "cheapie" - I just figured that the better
machines would have all this and more...
Post by Cliff
Others feel free to chime in about their controls & ones they know of.
----== Posted via Pronews.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.pronews.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= - Total Privacy via Encryption =---
Morris Dovey
2008-08-15 19:36:49 UTC
Permalink
Post by j
But what ties it in to SOLIDWORKS> Does Solidworks have an addin that
can converse with it. QUIT CROSSPOSTING CRAP THAT HAS NOTHING TO DO
WITH SOLIDWORKS>
What control & what functions does it have? Might be an interesting
actual machining-related thread after all. I don't recall any such in
AMC since 1998 or so but I *migt* have missed it, if so.
Others feel free to chime in about their controls & ones they know of.
Sorry - I should have trimmed the headers to drop c.c.s, and will in
future responses to Cliff.
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
Cliff
2008-08-15 17:45:22 UTC
Permalink
Post by Morris Dovey
Post by Cliff
Post by Morris Dovey
or (sometimes) write a simple computer program to generate the
relevant portion of the part program that'll be doing the
machining.
The core problem changes too if you are machining on the curve or
tangent to it.
That's true, offsetting the tool path from a curve just about triples
the computational requirement - but it's not really that big a hurdle.
There *might* be a few non-trivial classes of curve where it's easier.
Have to think about it.
After all, the locus of the offset tool's centerline has it's own
offset curve: the original curve.
Trivial: lines & arcs.
--
Cliff
Morris Dovey
2008-08-15 19:08:02 UTC
Permalink
Post by Cliff
There *might* be a few non-trivial classes of curve where it's easier.
Have to think about it.
After all, the locus of the offset tool's centerline has it's own
offset curve: the original curve.
Trivial: lines & arcs.
If you have a function for the curve, then calculate the coordinates for
the point of interest, then /close/ points on either side for a /close/
approximation to the slope of a tangent at the point of interest. That
can be used to determine the angle of a line perpendicular. All that
remains is to displace in that direction by a distance equal to the
radius of the cutting tool.

It's a slight oversimplification since checking is needed to ensure that
you don't screw up interior angles or cut into curves smaller than the
tool, and there needs to be logic to handle outside corners, but it's
fairly all fairly straight-foreward.

/close/ as used above is determined by how precise you want to be and by
the precision available in the machine. :-)
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
Cliff
2008-08-15 20:25:36 UTC
Permalink
Post by Morris Dovey
Post by Cliff
There *might* be a few non-trivial classes of curve where it's easier.
Have to think about it.
After all, the locus of the offset tool's centerline has it's own
offset curve: the original curve.
Trivial: lines & arcs.
If you have a function for the curve, then calculate the coordinates for
the point of interest, then /close/ points on either side for a /close/
approximation to the slope of a tangent at the point of interest.
As you have the function just calculate the first derivative function
directly. That's the tangent at any point.
Post by Morris Dovey
That
can be used to determine the angle of a line perpendicular. All that
remains is to displace in that direction by a distance equal to the
radius of the cutting tool.
It's a slight oversimplification since checking is needed to ensure that
you don't screw up interior angles or cut into curves smaller than the
tool, and there needs to be logic to handle outside corners, but it's
fairly all fairly straight-foreward.
But what you want is the equation of the offset curve ....
Post by Morris Dovey
/close/ as used above is determined by how precise you want to be and by
the precision available in the machine. :-)
Let's not forget that CAM systems use motion steps that
always lie within a tolernce band of the CAD curve while other
methods might be on one side or the other.
And that the control can do better than any input data in units of .0001"
IF it can calculate it's own motion based on an equation (I hope).
Hence they can nicely interpolate circles <g>.
Though an arc programmed with R may not be the same one as one
programmed with IJK.

Input data from G-code always lies on a grid with .0001"
(or similar) points. No others are allowed BUT the machine
can move other places.
--
Cliff
Cliff
2008-08-15 18:07:17 UTC
Permalink
Post by Cliff
Post by Morris Dovey
(Almost) always, sine, cosine, log, and exponential functions are
as "fancy" as is needed. :-)
For this problem I expect.
Archimedian r = a·?
Archimedean spiral: r= a* theta ?
Hyperbolic r·? = a
Hyperbolic spiral: r = a/theta ?
Logarithmic r =exp(a·?) [or] a·? = log(r)
Logarithmic spiral: r = a*e^(n) ?

(In AMC we've sort of setted on "^" for exponents but I'll buy "**" too.)
These formulas are polar representations, so at each point it's
necessary to convert to cartesian coordinates using
x = x0 + r·cos(?) and
y = y0 + r·sin(?)
x = a·cos(?) + a·?·sin(?)
y = a·sin(?) - a·?·cos(?)
I'll let you rewrite those.
What's shown in the (US) defaut charmap command output
sort of shows DOS ASCII. Start ==> Run ==> charmap
(you can copy & paste from it too). Does not show control
character strings though IIRC. <B><G>.
None of this is the kind of stuff that anyone likes to do in their head
or can do by counting on their fingers, but it /is/ the kind of stuff
that computers handle easily.
Some controls have polar modes.
Plus, those all sort of assume it's all going on about (0,0) &
not rotated in any way.
--
Cliff
Cliff
2008-08-15 18:10:15 UTC
Permalink
Post by Morris Dovey
I'm an "owner-operator-maintainer", so I've felt free to hack both
hardware and software to meet my needs. At one point I became
sufficiently frustrated with system limitations that I backed up,
designed, and built a special purpose machine to get a job done (photos
at http://www.iedu.com/DeSoto/Projects/JBot/ ). I'm pretty sure I
wouldn't have been allowed to do anything like this if I were working in
someone else's shop. :-)
GE designs & builds a lot of their own equipmet. So do a few
other large firms. But usually cheaper to buy IF what you need
is stock (or nearly so).
--
Cliff
Cliff
2008-08-15 18:15:08 UTC
Permalink
Post by Morris Dovey
I hear you. It seems that the first thing kids are taught is that "math
is hard" and that "you'll probably never need this, but here it is" -
not the most motivating phrases I've ever heard. OTOH, I filled in as a
substitute teacher for 7th-12th grade math at a rural school in
Minnesota and (without telling them what it was) discovered that the
eighth graders (and up) had no trouble with differential calculus -
Where did they get the basic concepts from?
Theory of limits, etc?
Post by Morris Dovey
and
was surprised as all get out that they found it "fun" and "exciting".
BTW, There's an engineering-oriented text by Thomas that
might be easier for some (but has less depth & rigor than
others might desire).
--
Cliff
Loading...