# Thread: calculate machining time from G-Code

1. ## calculate machining time from G-Code

I want to calculate machining time for every command of a G-code
Example

N01 X10 F20 machining time = ?
N02 X20 Y20 Z20 machining time = ?
N03 X30 Y25 Z25
N04
N05

for N01:
Distance travelled= S = 10 mm
machining time = completion time = ?

for N02:
Distance travelled =sqrt ( ( 20-10)^2 + ( 20-0)^2+( 20-0)^2 ) = 22.5 mm
machining time = completion time = ?
Thanks
smar

2. This is much more difficult then it appears. You have to also take into consideration if you are using CSF as your RPM will then change and your mm/rev will change depending on the diameter of the part you are at.

It appears that by your numbers that you have rather short feed moves that you are trying to calculate out a time for. If that is the case you can be overshadowed by any rapid moves or position moves with in a given time. These should be taken in to account as well. I would suggest using the machine timers.

Can you not use the machine timers to get what you need? I have spreadsheet that I developed that you can put the rough and finish stock with the SF and feed per rev and it gives you a run time.

Stevo

3. The time it takes to travel a certain distance is the distance divided by the speed.

So for your first move on a single axis the time is 0.5 minutes, the three axis move is 1.125 minutes.

4. Tanks for the replies.
Using a machine timer may not be possible for me, as I am tying to do it offline in computer.
I am not sure if I simple can derive distance by speed to get time. As the machine accelerates/decelerates for every move and there are rounds when it change direction.
I would be thankful for father help or correction.

5. ## The perfect program.

This works well.
www.ncplot.com

6. hello
actually I want to code it in my program. Thus I am looking to write my own function doing this.
I would be thankful for further assisstance.
smar

7. Originally Posted by smar
hello
actually I want to code it in my program. Thus I am looking to write my own function doing this.
I would be thankful for further assisstance.
smar
so, you are authoring something in VB or some such or do you mean a function on the CNC?

8. One major stumbling block that everyone has not noticed

How is the part programmed ? tool comp etc. if you use tool radius comp of zero then the g-code is actual distance travelled

but

if you program to tool radius and the radius is in the comp value, then you are not calculating true tool paths

Sorry guys for thowing in this furfy

9. thanks for the useful replies,
I am doing it in Matlab. I imported a simple CNC code and I want to calculate the completion time for each command.

Should I use equations of accelerated motion to calculate completion time?
v=u+at
s=ut+1/2at^2
v^2=u^2+2as

if yes what would be the initial velocities u (zero every time or final velocity of previous step ?)

@superman
In my understanding, for a straight line cut for example

Tool path = distance travelled for a CNC command line = profile to be cur to work piece - 2 x tool radios
= actual distance travelled on work piece - 2 x tool radios

Thus distance travelled for a specific CNC command line represents the path tool moved (which I am concerned).
Please correct me if my understanding is not right.

thanks
smar

10. See if I can explain

method 1--- comp in machine = 0
the actual g-code file to run the machine is the actual toolpath, the compensation value is adjusted to compensate for cutter wear ( usually by only a small amount )

method 2--- comp in machine = tool radius
actual g-code is the part profile, if compensation is 0, then the tool will travel on this line, as the comp is increased in radius, the tool path is automatically offset by this radius. To cut the correct profile the comp. value must not be smaller than the tool radius.

eg. 100mm square block being cut with a 50mm cutter

the cutter centreline must travel on a 150mm square with 25mm corner radii to go around the 100mm square
---the g-code for method 1 is this 150mm square path ( total programmed distance=478.54mm---total traved distance=478.54mm when tool radius,R=0)
---the g-code for method 2 is the 100mm square( total programmed distance =400mm---total travel distance=478.54 when tool radius,R=25.0mm---total travel distance=478.54mm when tool radius,R=25.0mm)[ 4 x 25mm quadrants + 4 x 100mm straight sides ]

As you can see this is only 1 profile path, 78.5mm is lost out of the calculation, now add multiple cut depths, and many other toolpaths and the estimate time will be very short of actual time

Your requirements will only work with toolpaths using method 1.

11. Originally Posted by neilw20
This works well.
www.ncplot.com
I second that. NC Plot is a very useful tool.

12. Thanks superman,
I had understood that CNC commands distance is path that tool will finally travel. Tool radius compensation is done while writing CNC code or generating CNC code from CAM.

But as you corrected me that the CNC commands distance is actually the distance that would be cut on work piece. The tool travel will be equal to CNC command distance + radius compensation.

Could you please confirm the concept for me once again?

About computing time for each CNC command line, I am doing this way.
Time of completion a CNC command = (CNC commands distance + radius compensation ) x Feed rate

But I guess, this would be the case when I feed rate is constant overall. Theatrically feed rate is constant in whole CNC program. But I was just confusing one point.
When, for example, machine change direction. Does feed rate(speed) remain constant over the turn? If not, i may not be able to use (distance = feed rate x time) formula to calculate time?

I have to write my own code that software NCPlot may not help me. unfortunately, I could not find the option in this software where it calculates time of completion of each CNC command for a given CNC code and tool radius.

I would be very thankful for any further help.
Smar

Page 1 of 2 12 Last