CAM Postprocessor Customization/es: Difference between revisions

From FreeCAD Documentation
No edit summary
(Created page with "Además, existen otros lenguajes para controlar un molino, como HPGL, DXF u otros.")
Line 28: Line 28:
* ...
* ...


Furthermore there are other languages to control a mill, such as HPGL, DXF, or others.
Además, existen otros lenguajes para controlar un molino, como HPGL, DXF u otros.


The postprocessor is a program which translates the internal codes into a complete file, that can be uploaded to your machine.
The postprocessor is a program which translates the internal codes into a complete file, that can be uploaded to your machine.

Revision as of 16:09, 15 July 2021

Tutorial
Tema
Ruta Ambiente de trabajo
Nivel
Tiempo para completar
Autores
chrisb
Versión de FreeCAD
Archivos de ejemplos
Ver también
None

Introducción

FreeCAD utiliza como representación interna para las trayectorias generadas, los llamados G-codes. Pueden describir cosas como: la velocidad y el avance, la parada del motor, etc... Pero lo más importante son los movimientos que describen. Estos movimientos son bastante simples: Pueden ser líneas rectas o arcos circulares. Curvas más sofisticadas como las B-splines ya son aproximadas por el de FreeCAD. Path Workbench/es.

Lo que el postprocesador puede hacer por ti

Muchas fresadoras utilizan también G-codes para controlar el proceso de fresado. Pueden parecerse casi a los códigos internos, pero puede haber algunas diferencias:

  • la máquina puede tener una secuencia especial de arranque
  • puede tener una secuencia de parada especial
  • los arcos pueden definirse con un centro relativo o absoluto
  • puede requerir números de línea en un formato determinado
  • puede utilizar los llamados ciclos enlatados para subprocesos predefinidos como el taladrado
  • Puede que prefiera la salida de su G-code en unidades métricas o imperiales.
  • Podría ser útil realizar un conjunto de movimientos antes de llamar a un cambio de herramienta para facilitar la acción al operario
  • Puede que desee incluir comentarios para facilitar la lectura o suprimirlos para que el programa sea pequeño.
  • Puede que desee incluir una cabecera personalizada para identificar o documentar el programa para futuras referencias.
  • ...

Además, existen otros lenguajes para controlar un molino, como HPGL, DXF u otros.

The postprocessor is a program which translates the internal codes into a complete file, that can be uploaded to your machine.

Preparación para escribir su propio postprocesador

You may start with a very simple model showing how your machine reads straight lines and arcs. Prepare it with any program suitable for your machine.

A file for such paths starting at (0,0,0) and going towards Y would be helpful. Make sure it is the tool itself moving along this path, i.e. no tool radius compensation must be applied.

The path in FreeCAD would look like this. Please note the small blue arrow, it indicates the starting direction. For a very first go you may provide only one level in the XY-plane.

You can then have a look at the file and compare it to the output of existing postprocessors such as linux_cnc_post.py or grbl_post.py and try yourself to adapt them or you upload your to the Path forum https://forum.freecadweb.org/viewforum.php?f=15 to get some help.

Convención de denominación

For a file format <filename> the postprocessor should get the name <filename>_post.py. Please note that _post.py has to be in all lower case letters.

If you are testing, place it in your macro directory. If it functions well, please consider providing it for others to benefit (post it to the FreeCAD Path forum) so that it can be included in the FreeCAD distribution going forward.

Otros postprocesadores existentes

For comparison you may look at the postprocessors which come with your FreeCAD installation. They are located under the Mod directory in Path/PathScripts/post. Widely used are the linuxcnc and the grbl postprocessors. Studying their code can give helpful insights.

  • On Linux the path is /usr/share/freecad/Mod/Path/PathScripts/post

Programming your own postprocessor

This post discusses some internals from the linuxcnc postprocessors. The same strucure is used in other postprocessors as well.

Looking at linux_cnc_post.py, you'll see the export function (as of 0.19.20514 its at line 156)

def export(objectslist, filename, argstring):
    # pylint: disable=global-statement
    ...
    gcode = ""
    ...
    ...

it collects step by step in the variable "gcode" the processed G-codes and handles the overall exporting of post-processable objects (operations, tools, jobs ,etc). Export handles the high level stuff like comments and coolant but any objects that have multiple path commands (tool changes and operations) it delegates to the parse function (as of 0.19.20514 its at line 288).

def parse(pathobj):
    ...
    out = ""
    lastcommand = None
    ...
    ...

Similarly to the "export" function collects parse the G-codes in the variable "out". In the variable "command" the commands as seen in the Path workbench's "inspect G-code" function are stored and can be investigated for further processing.

for c in pathobj.Path.Commands:

            command = c.Name

It recognizes the different G, M, F, S, and other G-codes. By remembering the last command in the variable "lastcommand" it can suppress subsequent repetitions of modal commands.

Both parse and export are just formatting strings and concatenating them together into what will be the final output.

You'll see that both functions also call the "linenumber()" function. If the user wants line numbers, the linenumber function returns the string to stick in to the appropriate spot, otherwise it returns an empty string so nothing is added.

Relacionados

Template:Tutorials navi/es Template:Path Tools navi/es