Giter Site home page Giter Site logo

0bab1 / gcodeestimator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 157 KB

[CNC G CODE] This librairy interprets G Code (FANUC) to give you a time estimation of machinning time and detailed data optimised for spreadsheet analysis.

License: MIT License

Python 70.10% G-code 20.68% GAP 9.22%
cad cam cnc estimation gcode industrial python time fanuc

gcodeestimator's Introduction

Gcode Time estimator V1.0 by Hugo.B

-> PLATFORM SUPPORT :

  • FANUC OK
  • ISO X
  • HEIDENHEIN X

image

Estimate your machinning time... Instantly !

Cost estimation on legacy CNC Code has never been easier... Woo said you need CAM software ?

Use the power of spreadsheets to make changes directly into excel and estmate the costs !

This python script interprets a gcode file and resturns a list containing the time data and relevant infos by interpreting the G Code.

This output has been designed to be converted as a CSV file. meaning each list element is a line, containing column elements.

DOCUMENTATION

First, import the estimation package :

import estimation

or if you downloaded gcodeEstimator as a package :

from gcodeEstimator import estimation

then use the run method to interpret you gcode :

timeEstimation = estimation.run("<path to your gcode>") # returns tuple : (total_time, detailled_operations_list)
print(timeEstimation[0]) #display total time estimated
print(timeEstimation[1]) #display each operation time

This (the run method) returns a tuple : (totalTime, detailledTimeData). DetailedTimeData is a list giving details on every single operation so your can identify time consuming operations or see if the cutting speeds are to your liking.

To have more details on the cutting speeds you can use the "excel mode" when using the run method :

timeEstimation = estimation.run("<path to your gcode>", excel_mode = True) # returns tuple : (total_time, detailled_operations_+cuttingSpeeds_list)
print(timeEstimation[0]) #display total time estimated
print(timeEstimation[1]) #display each detailled operation time

More details on the data structure in the sections below.

gcodeEstimator has been design with spread sheet data visualisation in mind. You can convert the output data list in csv using the makeCsv method :

timeEstimation = estimation.run("<path to your gcode>", excel_mode = True)
timeEstimation = timeEstimation[1] # keep only the list of the opration details
estimation.makeCsv("<CSV destination file>", timeEstimation)

Output structure

input : the path to your gcode file

Here is how to use is and the data structure :

from gcodeEstimator import estimation
#data output lis :
data = estimation.run(file_path) #run returns a tuple : (total time, output data list)
data = data[1] # use the data list 
# list stucture : [ [line1], [line2], [line3], ... ]
# line structure : lineX = [operation, tool, machinning time,  feedRate, line number in code]

If you want to use Excel, Librecalc or any spreadsheet softawre to lookup the data, you can use excel_mode :

from gcodeEstimator import estimation
#data output lis :
data = estimation.run(file_path, excel_mode=True)[1] #run returns a list in excel mode
estimation.makeCsv("pathToYourCsvFile", data)
# list stucture : [ [line1], [line2], [line3], ... ]
# line structure : lineX = [operation, tool, diameter (tool or part in mm) ,  cutting speed Vc (m/min), rev/min, f (mm/rev), Vf(mm/min), machinnning distance (mm), time (s), line in g code]

Ouput description

# line structure : lineX = [operation, tool, machinning time, line number in code, feedRate]
  • operation : The operation name as a string (example : G00, G01, G03, ...)
  • tool : the tool currently in use as a string (example : T1000, T5012, ...)
  • machining time : the estimated time the operation will take to execute itself in seconds as a float (example : 5, 10.12, ...)
  • feed rate : the feed rate at which the opération is executed to imediatly spot the sow machining and make optimisations as a float ( example : 40, 200, 89.54, ...)
  • line number in code : The line at which the opération is called in the gcode file in order to find it easily when editing huge files as an integer (exemple : 2, 75, ...)

IMPORTANT NOTE : if the time took is below 0.001 secs, it will not be in the output ! Thus making some G00 disapear.

and for Excel mode :

# line structure : lineX = [operation, tool, diameter (tool or part in mm) ,  cutting speed Vc (m/min), rev/min, f (mm/rev), Vf(mm/min), machinnning distance (mm), time (s), line in g code]
  • everything speaks for itself here
  • the particularity is that some fields are "calculed" using spreadsheet syntax (like "=B1*C1"). You also have more details. This is nice to make changes directly in the spreadsheet and see the results on the time imediatly.
  • Vf, rev/min and time are calculated except if cannot (example : constant rotation is used) Cf changlog V1.1 for more details
  • G71,72,74,76,etc.. (special cycles) only diplay time and time is not calculated, Cf changlog V1.1 for more details
  • Please note that parameters that doeas NOT HAVE AN EFFECT in the gcode programmation are set to 0 ! (example : if rev/min is constant, Vc is set to 0) Cf changlog V1.1 for more details

Supported languages and Opérations

Warning : This script has been developped for a Biglia mLathe using Fanuc encoder.

I made this for the needs of my compagny, meaning it might not fit yours. Designed for a lathe with Y axis, but as the Y axis was added later on, the fonctionnality might not be the best.

Feel free to read the code, understand the architecture and add you own interpreter in machines.py for your own needs and push it to this repo :)

Supported operations :

FANUC for Lathes (Biglia constructor):

  • G0, G1 (linear interpolation and positionning note taht G0 uses tha max speed of the machine, set by default at 12500m/min in machines.py)
  • G2, G3 (circular interpolations, using I,J,K or just R)
  • G71, G72 (stock removal, facing nd turning ! this is an estimation and might be wrong with complex profiles or syntax)
  • G74 (peck drilling)
  • G76 (thead cycle this is an estimation and might be wrong with complex profiles or syntax)
  • Y axis support
  • incremental support (U,V,W)
  • G28 (reset tool position to 0,0,0)
  • cutting parameters => G94, G94, G99, G98 (per revolution or per minute feed) G97, G96 (constant rotation or not) G92 (max spindle speed)

Non supported and might be added :

  • G33 (thead cutting)
  • G53, G54, .. (set origin) (not sure to add this one)

Testing the code

Go to ./tests folder and add your test file named like this : test_yourFileNameHere.py

if you need to add a gcode test file, add it in ./tests/g_test_files

to test, run : python -m pytest

to install pytests : pip install pytest

gcodeestimator's People

Contributors

0bab1 avatar hugoduncha avatar

Watchers

 avatar

Forkers

hugoduncha

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.