588,205 active members*
4,152 visitors online*
Register for free
Login
Results 1 to 10 of 10
  1. #1
    Join Date
    May 2008
    Posts
    157

    Finding Cut Length of a 2D & 3D Program

    Hi,

    Does anyone have VB code to calculate the cut length of a G code program which is both in 2D and 3D forms. I do know that Cimco gives this option by default but i was trying to develop something independant of available softwares so that we can find the cut length at shop floor level.

    thanks

  2. #2
    Join Date
    Jul 2008
    Posts
    411
    Conceptually its not hard to do, but you'd have to interpret all the movement G codes to work out the distance travelled while also deciding if the cutter is in the work or not. Or you could just ignore all the rapids and only calculate the slow feeds on the assumption they are cutting actions although this might give an overestimate. How accurate does this need to be - do you need to include Z-traverses into/out of the work?

  3. #3
    Join Date
    Jul 2003
    Posts
    1220
    Here is some code that I used in a program that will give the path length.
    It calculates the distance between the previous point and the current point.
    You could have a number of these adding up the path lengths of different feed rates.

    If F = 50 then
    numDist = Sqr((X2 - X) ^ 2 + (Y2 - Y) ^ 2)
    PathStep = Sqr(numDist ^ 2 + (Z2 - Z) ^ 2)
    PathLength = PathLength + PathStep
    End If
    X2 = X:Y2 = Y:Z2 = Z

  4. #4
    Join Date
    Apr 2006
    Posts
    3498
    If u have Mach3 then run the programm and then check in the 'Maintenance Hour' menu.

  5. #5
    Join Date
    Apr 2006
    Posts
    3498
    Here is the picture..Before dry running the G-code reset the Maintenance Hours in the dialogue by pressing the reset button.

    You not require to run the machine just calculate through the software.
    My 1000 cents
    Attached Thumbnails Attached Thumbnails Maintenance Hour.JPG  

  6. #6
    Join Date
    May 2008
    Posts
    157
    Quote Originally Posted by irving2008 View Post
    Conceptually its not hard to do, but you'd have to interpret all the movement G codes to work out the distance travelled while also deciding if the cutter is in the work or not. Or you could just ignore all the rapids and only calculate the slow feeds on the assumption they are cutting actions although this might give an overestimate. How accurate does this need to be - do you need to include Z-traverses into/out of the work?
    Yes i do need the rapid moves also taken into account as in certain 3D programs there are lots of rapid moves generated in the NC path when i generate rest milling paths.

  7. #7
    Join Date
    May 2008
    Posts
    157
    Quote Originally Posted by Kiwi View Post
    Here is some code that I used in a program that will give the path length.
    It calculates the distance between the previous point and the current point.
    You could have a number of these adding up the path lengths of different feed rates.

    If F = 50 then
    numDist = Sqr((X2 - X) ^ 2 + (Y2 - Y) ^ 2)
    PathStep = Sqr(numDist ^ 2 + (Z2 - Z) ^ 2)
    PathLength = PathLength + PathStep
    End If
    X2 = X:Y2 = Y:Z2 = Z
    Thanks a ton. I will use this and give you the feedback.

    Do you know of any ways to calculate near accurate machining time with the help of programs when i also take into account the machine acceleration and deceleration ? After finding the path length this would be my target since in large 3D programs involving high feed rates, i find there is a lot of mismatch between predicted time (path length / feed rate) and actual time on the machine due to acceleration and deceleration of machine in the corners.
    The problem is also with lots of rapid moves in rest milling routines.

  8. #8
    Join Date
    May 2008
    Posts
    157
    Quote Originally Posted by Kiwi View Post
    Here is some code that I used in a program that will give the path length.
    It calculates the distance between the previous point and the current point.
    You could have a number of these adding up the path lengths of different feed rates.

    If F = 50 then
    numDist = Sqr((X2 - X) ^ 2 + (Y2 - Y) ^ 2)
    PathStep = Sqr(numDist ^ 2 + (Z2 - Z) ^ 2)
    PathLength = PathLength + PathStep
    End If
    X2 = X:Y2 = Y:Z2 = Z
    I have encountered a problem. The code above seems to take care of only linear moves where as my program has both linear and circular moves (G03, G03). Do you have the codes for calculating length of circular moves in all three planes ? (XY, YZ and XZ planes).

  9. #9
    Join Date
    Jul 2003
    Posts
    1220
    Quote Originally Posted by yaji63 View Post
    .................Do you know of any ways to calculate near accurate machining time with the help of programs when i also take into account the machine acceleration and deceleration ..................and actual time on the machine due to acceleration and deceleration of machine in the corners........
    Unable to help any further with code.
    I think you will need to gather information from your machine as different machines performances will vary.
    Your code may need to analyse the path variations to include acceleration and deceleration of the machine in the corners.
    Sounds quite a task.

    Quote Originally Posted by yaji63 View Post
    ......Do you have the codes for calculating length of circular moves in all three planes ? (XY, YZ and XZ planes).
    Sorry...I don't have any code for the length of three axis arcs. I'll see what I can do.

  10. #10
    Join Date
    Jul 2003
    Posts
    1220
    Quote Originally Posted by yaji63 View Post
    .................... Do you have the codes for calculating length of circular moves in all three planes ? (XY, YZ and XZ planes).
    You may need to make the variables X,X2,Y,Y2,Z,Z2,I,J,K, all Abs (eg: Abs(Z)) as not sure if this code is correct when some values have minus values.
    This code should calculate the arc length.
    Pi = Atn(1) * 4

    If Left$(strGCode, 3) = "G02" Or Left$(strGCode, 3) = "G03" Then
    StepDist = Sqr((X2 - X) ^ 2 + (Y2 - Y) ^ 2)
    Radius = Sqr(I ^ 2 + J ^ 2 + K ^ 2)
    Adjacent = Sqr(Radius ^ 2 - (StepDist / 2) ^ 2)
    RadAngle = Atn((StepDist / 2) / Adjacent)
    DegAngle = RadAngle / Pi * 180
    ArcLength = Radius * 2 * Pi / 360 * (DegAngle * 2)
    PathStep = Sqr(ArcLength ^ 2 + (Z2 - Z) ^ 2)
    PathLength = PathLength + PathStep
    I = 0: J = 0: K = 0
    End If
    X2 = X:Y2 = Y:Z2 = Z

Similar Threads

  1. Tape Length???
    By ShortRunCNC in forum G-Code Programing
    Replies: 1
    Last Post: 05-12-2007, 07:12 PM
  2. cut to length
    By chathorne in forum Uncategorised MetalWorking Machines
    Replies: 0
    Last Post: 04-25-2007, 04:47 PM
  3. Replies: 11
    Last Post: 10-09-2005, 05:45 AM
  4. Max length of linear rod?
    By MrBean in forum DIY CNC Router Table Machines
    Replies: 3
    Last Post: 03-06-2005, 03:47 AM
  5. total line length program?
    By ljoe1969 in forum Uncategorised CAM Discussion
    Replies: 6
    Last Post: 01-09-2004, 05:27 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
  •