587,547 active members*
3,021 visitors online*
Register for free
Login
IndustryArena Forum > OpenSource CNC Design Center > OpenSource Software > How to Generate a CNC code from measured 3D tool path
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Posts
    12

    How to Generate a CNC code from measured 3D tool path

    Generating a CNC from measured 3D tool path
    I want to generate a CNC code from the measured tool path. The tool path is generated by taking the measure from three encoders mounted in 3-axes milling machine. Measurement is saved in a Desktop PC for an offline analysis.
    The tool path looks like this:

    Path_Matrix =

    Time X1 Y1 Z1
    0.01 0.001 0 0.001
    0.02 0.002 0 0.004
    0.03 0.003 0 0.008
    0.04 0.004 0 0.012
    0.05 0.005 0 0.018
    0.06 0.006 0 0.018
    .
    .
    .
    .
    1.2 10.00 6.00 0.018 (may be upto 100000 rows)


    Now, I want to generate the reference CNC code (originally used for the process) from this measured tool path. This generated CNC code later can be then compared with original CNC code.

    How I can do this ? (Generating a CNC from measured 3D tool path)
    Any software functions, resources, web links, literature or personal help could be really helpful to me.
    I use Matlab but functions in other languages could also be possible to use.

    Thanks
    Sma

  2. #2
    Join Date
    May 2005
    Posts
    2502
    It's not that hard to write a little program to convert those numbers to g-code that would produce the same path. However, I see a lot of problems comparing those with the original g-code.

    For example, how do you know whether the numbers were the result of a lot of short line segments in the original program or an interpolated circle?

    There are many alternate g-codes that can produce the same motion and it will be impossible to guess which one to choose from.

    I don't think your problem is solvable for that reason.

    Best,

    BW

  3. #3
    Join Date
    Feb 2009
    Posts
    12
    Thank for a very useful reply.
    I could just come up with two ideas. But I am not sure if they are right or they work.
    To make the problem simplify path can be considered consisting of only right angle turns (no circular motion)

    1…
    From the measured tool path [time X Y Z]
    If some how the “change in directions” (right angle turns) could be detected in all X, Y and Z vectors of measured tool path. Numbers at those points would be then used to generate new command lines of CNC code.
    Could it be a way to generate a reliable and comparable CNC code?


    2…
    If I do not go for comparing CNC code, rather I go for comparing two tool paths (Measures tool path and reference tool paths)
    Now reference tool path would be generated from Orignal CNC code by interpolation and splines smoothing in my computer (Matlab).
    Now both tool paths can be compared. But I see two problems here.

    Reference tool path generated should be very good approximation of the one that Machine controller (simumerik 840D in my machine) do. Any idea how?

    To compare both paths may only be possible if I could some how find the corresponding points. Any idea how?

    I would be thankful for some further assistance.
    Thanks

  4. #4
    Join Date
    Jul 2005
    Posts
    181
    Hmm... It seems as if the measured data should proceed in the same manor as the original tool path. This could make the problem easier. They should essentially be the exact same path just two different ways of measuring it. As such you might be able to load up both at once and then step through the measured path. At each measured point try to see if it would fall coincident to the line or arc prescribed by the original tool path. This is easy for linear moves but a little more complicated for arc moves. For each measured point find the nearest location on the original path and then record the error. This seems to be roughly what you want to do. This approach could be pretty quick as you wouldn't need to compare the measured point to every move in the original file. Since both data should progress the same you can always start at the point in the original that was the closest match to the measured point and scan forward looking for the next closest. There shouldn't be a closer match behind the current point or something went wrong. You'll likely find multiple matches for each input line or arc but you should never find a match behind the current position. Make sense?

  5. #5
    This sounds like a mis-match of reverse engineering and inspection, each has it's own requirements / tools & software..

    (Please answer the questions if you want any more help, I need to understand what's going on here)

    Q) Was the original toolpath generated by CAD/CAM??

    In which case it'll likely be thousands of lines of tiny linear movements, with no G02/G03 arc commands in it.

    Q) Is this part cut with a ball nosed cutter??

    Assuming your probe cancels it's own stylus tip radius, then the probed XYZ data is the surface geometry and not related to your cutter path. Imagine how a ball nose cutter would contact the geometry at different tangent angles as it passes over it. A CAM generated path for a 10mm ball nose would look very different to a path with a 20mm ball nose over the same geometry (assuming it's not simply flat!).

    With those guesses out of the way, here's your options..

    Take your XYZ data and create a surface mesh in a CAD program, and generate a toolpath on it with your CAM program. That gets the reverse engineering bit out of the way.

    *IF* your original toolpath was CAM generated for a ball nose cutter, take your surface mesh and offset it by the radius of the ball, then lower it by the radius of the ball. This will give you a tangential height mesh for the cutter. Then you'd need to examine the original cutter path, and for every X/Y compare the Z with the Z in the tangent height mesh.

    Not impossible, but certainly not trivial :/

  6. #6
    Join Date
    Feb 2009
    Posts
    12
    Thank you for very useful replies,
    some details: The final goal is to analyse the dynamic errors of a high precise milling machine(research purposes).
    The approach is to compare the measured tool path XYZ with original tool path (CNC program) XYZ.

    Original tool path = G-Code= Reference path
    Measured tool path = tool measured positions using a measurement system

    Initially, to simplify the work, a hand written simple G-Code program consist of simple right angle movements is used. Machine is started with this code (non cutting mode, no work piece).

    In next step, the original tool path generated by CAD/CAM and cutter details would be considered too. Then the surface mesh approach, I guess, might be applied…. But it would be the second step.

    @ Death Adder:
    Thanks for the idea. I have tried your approach of closest point search. Its works fine. But I am not sure it gives reliable results.
    The corresponding points in both tool paths are found by searching the closest measured tool path points for every point of original tool path.

    As an example, an original tool path consisted of 10 points (10 CNC commands lines). Machine is run. The tool path is measured which is now consist of about 10000 points. Closest point for all 10 original tool path points is search in selected portions of measured tool path. Now errors can be determined.

    But I am not sure this approach provided correct corresponding points. Because values of measured tool path points also contain the effects of machine dynamic erros. Thus, I guess, it may be possible that wrong points in neighbourhood appear to be the closest.

    I would be very thankful for further assistance and correction.

    Thanks and Regards
    Smar

Similar Threads

  1. Is there a way to generate CL code in Solidcam
    By manussim in forum SolidCAM for SolidWorks and SolidCAM for Inventor
    Replies: 6
    Last Post: 02-02-2021, 07:02 PM
  2. What tools generate G-Code
    By eskimobob in forum LinuxCNC (formerly EMC2)
    Replies: 11
    Last Post: 09-30-2008, 02:54 AM
  3. Generate G code from rhino file
    By mredican in forum Rhino 3D
    Replies: 14
    Last Post: 02-24-2008, 12:51 AM
  4. scan part and generate cad code?
    By ATV in forum Uncategorised CAM Discussion
    Replies: 4
    Last Post: 02-14-2008, 07:56 PM
  5. Best way to generate code?
    By jderou in forum BobCad-Cam
    Replies: 0
    Last Post: 09-29-2004, 02:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •